Module:Jcon
Appearance
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This module depends on the following other modules: |
This module implements Template:Jcon and Template:Shieldlist.
local p = {}
local insert = table.insert
local jctTypeData = {["Hwy"] = "Hwy", ["Highway"] = "Hwy", ["Sudbury"] = "MR",
["SB"] = "MR", ["Greater Sudbury"] = "MR", ["GS"] = "MR",
["Muskoka"] = "DR", ["Durham"] = "RR", ["Hamilton"] = "RR",
["Halton"] = "RR", ["Niagara"] = "RR", ["Peel"] = "RR",
["Ottawa"] = "RR", ["Waterloo"] = "RR", ["York"] = "RR",
["KL"] = "KLR", ["Kawartha Lakes"] = "KLR", ["Durham Regional Highway"] = "RR",
["DRH"] = "RR"}
local regionData = {Hwy = '', Highway = ''}
function p.jcon(frame)
local args = frame:getParent().args
local type = args[1] or ''
if type == '' then return end
local route1 = args[2] or ''
if route1 == '' then return end
local route2 = args.con or ''
local route3 = args.con2 or ''
local jctType = jctTypeData[type] or 'CR'
local region = regionData[type] or type
local jctCall = {"{{jct", "province=ON", jctType, route1}
if region ~= '' then
insert(jctCall, "county=" .. region)
end
if route2 ~= '' then
insert(jctCall, jctType)
insert(jctCall, route2)
end
if route3 ~= '' then
insert(jctCall, jctType)
insert(jctCall, route3)
end
-- Add direction and location stuff
return table.concat(jctCall, "|") .. "}}"
end
return p