local p = {}
local function terminus_a(num, args)
local direction = args["direction_a" .. num] or args.direction_a or ''
local label
if direction ~= '' then
label = direction .. " end:"
else
label = "Từ:"
end
local data = args["terminus_a" .. num]
return label, data
end
local function terminus_b(num, args)
local direction = args["direction_b" .. num] or args.direction_b or ''
local label
if direction ~= '' then
label = direction .. " end:"
else
label = "Đến:"
end
local data = args["terminus_b" .. num]
return label, data
end
function p._section(num, args)
local lead = --[[5 * num +]] 1
local parameters = {["label" .. (lead + 1)] = "Chiều dài:", ["label" .. (lead + 3)] = "Giao lộ<br />chính:", child = "yes", decat = "yes", labelstyle = "text-align:right"}
local data = {}
local title = args["section" .. num] or "Phần " .. num
--parameters["header" .. lead] = title
parameters.title = title
local lengthModule = require "Mô đun:Infobox road/length"
data[lead + 1] = lengthModule._length(num, args)
parameters["label" .. (lead + 2)], data[lead + 2] = terminus_a(num, args)
data[lead + 3] = args["junction" .. num]
parameters["label" .. (lead + 4)], data[lead + 4] = terminus_b(num, args)
local hasData = false
for k,v in pairs(data) do
hasData = true
break
end
if not(hasData) then
return ''
end
for k,v in pairs(data) do
parameters["data" .. k] = v
end
local infoboxModule = require 'Mô đun:Infobox'
return infoboxModule.infobox(parameters)
end
function p.section(frame)
local pframe = frame:getParent()
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
local num = config.num
return p._section(num, args)
end
local function loop(args)
local ring_road = args.ring_road or ''
if ring_road ~= '' then
return "[[Ring road]] around " .. ring_road
end
local beltway_city = args.beltway_city or ''
if beltway_city ~= '' then
return "[[Beltway]] around " .. beltway_city
end
local orbital = args.orbital or ''
if orbital ~= '' then
return "[[Orbital road|Orbital]] around " .. orbital
end
local loop = args.loop or ''
if loop ~= '' then
return "[[Loop road|Loop]] around " .. loop
end
local tloop = args.tloop or ''
if tloop == 'none' then
return "Vòng lặp du lịch"
elseif tloop ~= '' then
return "Du lịch vòng quanh " .. tloop
end
return nil
end
function p._main(args)
local lead = --[[5 * num +]] 1
local parameters = {["label" .. (lead + 3)] = " ", child = "yes", decat = "yes", labelstyle = "text-align:right"}
local data = {}
local title = args.section0 or "Giao lộ chính"
--parameters["header" .. lead] = title
parameters.title = title
data[lead + 1] = loop(args)
parameters["label" .. (lead + 2)], data[lead + 2] = terminus_a('', args)
data[lead + 3] = args.junction
parameters["label" .. (lead + 4)], data[lead + 4] = terminus_b('', args)
local hasData = false
for k,v in pairs(data) do
hasData = true
break
end
if not(hasData) then
return ''
end
for k,v in pairs(data) do
parameters["data" .. k] = v
end
local infoboxModule = require 'Mô đun:Infobox'
return infoboxModule.infobox(parameters)
end
function p.main(frame)
local pframe = frame:getParent()
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
return p._main(args)
end
return p