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 18:16, 31 March 2022 (add copies). 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 = { -- same as nightsonly
		image = 'NYCS-SSI-nightsonly',
		text = 'Stops late nights only'
	}, -- same as nightsonly
	nightsonly = { -- same as nights
		image = 'NYCS-SSI-nightsonly',
		text = 'Stops late nights only'
	}, -- same as 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 = { -- same as weekdaysonly
		image = 'NYCS-SSI-weekdaysonly',
		text = 'Stops weekdays only'
	}, -- same as weekdaysonly
	weekdaysonly = { -- same as weekdays
		image = 'NYCS-SSI-weekdaysonly',
		text = 'Stops weekdays only'
	}, -- same as weekdays
	weekends = { -- same as weekendsonly
		image = 'NYCS-SSI-weekendsonly',
		text = 'Stops weekends only'
	}, -- same as weekendsonly
	weekendsonly = { -- same as weekends
		image = 'NYCS-SSI-weekendsonly',
		text = 'Stops weekends only'
	}, -- same as weekends
	evenings = { -- same as eveningsonly
		image = 'NYCS-SSI-weekdaysonly',
		text = 'Stops weekday evenings only'
	}, -- same as eveningsonly
	eveningsonly = { -- same as evenings
		image = 'NYCS-SSI-weekdaysonly',
		text = 'Stops weekday evenings only'
	}, -- same as 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 = { -- same as rushonly
		image = 'NYCS-SSI-rushonly',
		text = 'Stops rush hours only'
	}, -- same as rushonly
	rushonly = { -- same as rush
		image = 'NYCS-SSI-rushonly',
		text = 'Stops rush hours only'
	}, -- same as 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 title="Does not stop at this station">&#124;</abbr>',
		text = 'Does not stop at this station'
	},
	default = {
		image = 'Transparent square',
		text = 'Station service unknown'
	}
}

function p._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 p._main(frame:getParent().args)
end

return p