پودمان:Road data/browse/تمرین
ظاهر
< پودمان:Road data | browse
اینجا صفحهٔ تمرین پودمان برای پودمان:Road data/browse (تفاوت) است. |
local p = {}
local format = mw.ustring.format
local roadDataModule = require("Module:Road data")
local function routeText(route)
local shieldText = roadDataModule.shield(route, nil, nil, nil, true)
local linkText = roadDataModule.link(route)
local result = mw.html.create("span"):css({display = "inline-block"})
result:wikitext(shieldText .. ' ' .. linkText)
return tostring(result)
end
local function previousRoute(route)
local cell = mw.html.create('td'):css({
padding = "0",
["text-align"] = "right",
["vertical-align"] = "middle"
})
if not route.type or route.type == '' then
cell:wikitext(" ")
else
cell:wikitext(" →" .. routeText(route))
end
return cell
end
local function nextRoute(route)
local cell = mw.html.create('td'):css({
direction = "ltr",
padding = "0",
["text-align"] = "left",
["vertical-align"] = "middle"
})
if not route.type or route.type == '' then
cell:wikitext(" ")
else
cell:wikitext("← " .. routeText(route))
end
return cell
end
function p._browse(route)
local country = route.country or route['کشور']
local state = route.state or route['ایالت'] or route.province or route['استان']
local county = route.county or route['کشور']
local previousData = {
country = country, state = state, county = county,
type = route.previous_type or route['مسیر پیشین'] or route['نوع قبلی'], route = route.previous_route or route['مسیر پیشین'] or route['مسیر قبلی'],
dab = route.previous_dab or route['ابهامزدایی پیشین'] or route['ابهامزدایی قبلی']
}
local nextData = {
country = country, state = state, county = county,
type = route.next_type or route['نوع پسین'] or route['نوع بعدی'], route = route.next_route or route['مسیر پسین'] or route['مسیر بعدی'],
dab = route.next_dab or route['ابهامزدایی پسین'] or route['ابهامزدایی بعدی']
}
local previousRoute = previousRoute(previousData)
local nextRoute = nextRoute(nextData)
if previousData.typeerror or nextData.typeerror then
route.typeerror = true
end
local centerRoute = mw.html.create('td'):css({
["text-align"] = "center",
["white-space"] = "nowrap",
padding = "0 3px",
["vertical-align"] = "middle"
})
local route = route.browse_route
if route then
centerRoute:css("padding", "0 6px")
centerRoute:wikitext(format("'''%s'''", route))
end
local browseRow = mw.html.create('tr')
browseRow:node(previousRoute):node(centerRoute):node(nextRoute)
return tostring(browseRow)
end
function p.browse(frame)
-- Import module function to work with passed arguments
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame)
args.browse_route = args.route or args['مسیر']
return p._browse(args)
end
return p