Jump to content

Module:NYCS SSI

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Izno (talk | contribs) at 23:03, 30 March 2022 (adj). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

local lookup_table = {
	alltimes = {
		image = 'NYCS-SSI-alltimes',
		text = 'Stops all times'
	},
	allexceptnights = {
		image = 'NYCS-SSI-allexceptnights',
		text = 'Stops all times except late nights'
	},
	allexceptweekdaynights = {
		image = 'NYCS-SSI-allexceptnights',
		text = 'Stops all times except weekday late nights'
	},
	nights = {
		image = 'NYCS-SSI-nightsonly',
		text = 'Stops late nights only'
	},
	nightsonly = lookup_table.nights,
	nightsweekdays = {
		image = 'NYCS-SSI-nightsweekdays',
		text = 'Stops late nights and weekdays'
	},
	nightsweekends = {
		image = 'NYCS-SSI-nightsweekends',
		text = 'Stops late nights and weekends'
	},
	weekdaysnights = {
		image = 'NYCS-SSI-nightsweekdays',
		text = 'Stops weekdays and weekday late nights'
	},
	weekendsnights = {
		image = 'NYCS-SSI-weekendsonly',
		text = 'Stops weekends and weekend late nights'
	},
	weekdays = {
		image = 'NYCS-SSI-weekdaysonly',
		text = 'Stops weekdays only'
	},
	weekdaysonly = lookup_table.weekdays,
	weekends = {
		image = 'NYCS-SSI-weekendsonly',
		text = 'Stops weekends only'
	},
	weekendsonly = lookup_table.weekends,
	evenings = {
		image = 'NYCS-SSI-weekdaysonly',
		text = 'Stops weekday evenings only'
	},
	eveningsonly = lookup_table.evenings,
	weekendsevenings = {
		image = 'NYCS-SSI-weekendsonly',
		text = 'Stops weekends and weekday evenings'
	},
	allexceptrush = {
		image = 'NYCS-SSI-allexceptrush',
		text = 'Stops all times except rush hours in the peak direction'
	},
	allexceptweekdays = {
		image = 'NYCS-SSI-allexceptrush',
		text = 'Stops all times except weekdays in the peak direction'
	},
	dailyexceptrush = {
		image = 'NYCS-SSI-allexceptrush',
		text = 'Stops daily except rush hours in the peak direction'
	},
	weekdaysexceptrush = {
		image = 'NYCS-SSI-allexceptrush',
		text = 'Stops weekdays except rush hours in the peak direction'
	},
	rush = {
		image = 'NYCS-SSI-rushonly',
		text = 'Stops rush hours only'
	},
	rushonly = lookup_table.rush,
	rushpeak = {
		image = 'NYCS-SSI-rushpeak',
		text = 'Stops rush hours in the peak direction only',
	},
	rushreversepeak = {
		image = NYCS-SSI-rushreversepeak'',
		text = 'Stops rush hours in the reverse-peak direction only'
	},
	limitedrushreversepeak = {
		image = 'NYCS-SSI-rushreversepeak',
		text = 'Stops rush hours in the reverse-peak direction only (limited service)'
	},
	weekdayspeak = {
		image = 'NYCS-SSI-rushpeak',
		text = 'Stops weekdays in the peak direction only'
	},
	limitedrush = {
		image = 'NYCS-SSI-rushonly',
		text = 'Stops rush hours only (limited service)'
	},
	limitedrushpeak = {
		image = 'NYCS-SSI-rushpeak',
		text = 'Stops rush hours in the peak direction only (limited service)'
	},
	closed = {
		image = 'NYCS-SSI-closed',
		text = 'Station closed'
	},
	none = {
		image = 'Transparent square',
		text = 'No service indication'
	},
	passed = {
		image_substitute = '{{abbr|||Does not stop at this station}}',
		text = 'Does not stop at this station'
	},
	default = {
		image = 'Transparent square',
		text = 'Station service unknown'
	}
}

local keyword = {
	passed = 'passed'
}

local function _main(args)
	local shorthand = args[1]
	local return_table = lookup_table[shorthand] or lookup_table['default']
	
	local noimage = args[2]
	if noimage and noimage ~= '' then return return_table[text] end
	
	if not return_table[image] then return return_table[image_substitute] end

	local text = return_table[text]
	local other_text = args['text']
	if other_text and other_text ~= '' then text = other_text end
	
	return '[[File:' .. return_table[image] ..
		'.svg|10px|link=List of New York City Subway services#Time periods|' ..
		text .. ']]'
end

function p.main(frame)
	return _main(frame:getParent().args)
end

return p