Module:Road data/browse
Documentation for this module may be created at Module:Road data/browse/doc
Documentation for this module may be created at Module:Road data/browse/doc
local p = {}
local getArgs = require('Module:Arguments').getArgs -- Import module function to work with passed arguments
local parserModule = require "Module:Road data/parser"
local parser = parserModule.parser
local function size(args)
local country = args.country
local state = args.state or args.province
local type = args.type
if country == 'MEX' then
return "20x30"
elseif country == 'CAN' then
if state == 'AB' or state == 'QC' or state == 'SK' then
return "20x30"
elseif state == 'NS' then
if (type == 'NS' or type == 'Hwy') then
return "18"
else
return "x20"
end
elseif state == 'ON' then
if type == 'ON' or type == 'Hwy' or type == 'Fwy' then
return "20x30"
elseif type == 'CR' or type == 'RR' then
return "30x32"
end
end
return "25x20"
elseif country == 'USA' then
if state == 'NY' and (type == 'NY 1927' or type == 'NY 1948') then
return '20'
end
end
return 'x20'
end
local function shield(args)
local size = size(args)
local shield = parser(args, 'shield')
if not shield or shield == '' then return '' end
return string.format("[[File:%s|%spx|link=|alt=]]", shield, size)
end
local function link(args)
local abbr = parser(args, 'abbr')
if not abbr then
local page = mw.title.getCurrentTitle().prefixedText -- Get transcluding page's title
return string.format("<span class=\"error\">Invalid type: %s</span>[[Category:Infobox road transclusion errors|& %s]]", args.type, page)
end
local link = parser(args, 'link')
if not link or link == '' then
return string.format("<span class=\"nowrap\">%s</span>", abbr)
else
return string.format("<span class=\"nowrap\">[[%s|%s]]</span>", link, abbr)
end
end
local function previousRoute(args)
local shieldText = shield(args)
local linkText = link(args)
local cell = mw.html.create('td'):css( {width = "45%", ["vertical-align"] = "middle", padding = "0", ["text-align"] = "left"} )
cell:wikitext("← " .. shieldText .. ' ' .. linkText)
return cell
end
local function nextRoute(args)
local shieldText = shield(args)
local linkText = link(args)
local cell = mw.html.create('td'):css( {width = "45%", ["vertical-align"] = "middle", padding = "0", ["text-align"] = "right"} )
cell:wikitext(linkText .. ' ' .. shieldText .. " →")
return cell
end
function p._browse(args)
local browseRow = mw.html.create('tr')
local country = args.country
local state = args.state or args.province
local county = args.county
local previousData = {country = country, state = state, county = county,
type = args.previous_type, route = args.previous_route,
dab = args.previous_dab}
local nextData = {country = country, state = state, county = county,
type = args.next_type, route = args.next_route,
dab = args.next_dab}
local previousRoute = previousRoute(previousData)
local nextRoute = nextRoute(nextData)
local centerRoute = mw.html.create('td'):css( {["text-align"] = "center", ["white-space"] = "nowrap", width = "10%", ["vertical-align"] = "middle", padding = "0"} )
local route = args.browse_route
if route then
centerRoute:wikitext("'''" .. route .. "'''")
end
browseRow:node(previousRoute):node(centerRoute):node(nextRoute)
return tostring(browseRow)
end
function p.browse(frame)
local args = getArgs(frame)
args.browse_route = args.route
return p._browse(args)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.