local mapframe = require('Module:Mapframe')local getArgs = require('Module:Arguments').getArgs
local DEFAULT_WIDTH = "300"
local p =
-- Get the number of key-value pairs in a table, which might not be a sequence.function tableCount(t) local count = 0 for k, v in pairs(t) do count = count + 1 end return countend
-- For a table where the values are all tables, returns either the tableCount of-- the subtables if they are all the same, or nil if they are not all the same.function subTablesCount(t) local count = nil for k, v in pairs(t) do if count
function tableFromList(listString) if type(listString) ~= "string" or listString
1 then -- debugging -- error(string.format("Found 1 value in '%s' using separator '%s'", listString or "", separator)) -- end return tend
--Makes the HTML required for the swicther to work, including the templatestyles tag
@param params table sequence of tables @param params.map Wikitext for mapframe map @param params.label Label text for swicther option@param options @param options.alignment "left" or "center" or "right" @param options.isThumbnail Display in a thumbnail @param options.width Width of frame, e.g. "200" @param [options.caption] Caption wikitext for thumnail@retruns swicther HTML
--function makeSwitcherHtml(params, options) if not options then option = end local frame = mw.getCurrentFrame local styles = frame:extensionTag local container = mw.html.create("div") :addClass("switcher-container") :addClass("mapframe-multi-container") if options.alignment"right" then container:addClass("float"..options.alignment) else -- alignment is "center" container:addClass("center") end for i = 1, #params do container :tag("div") :wikitext(params[i].map) :tag("span") :addClass("switcher-label") :css("display", "none") :wikitext(mw.text.trim(params[i].label)) end if not options.isThumbnail then return styles .. tostring(container) end local classlist = container:getAttr("class") classlist = mw.ustring.gsub(classlist, "%a*"..options.alignment, "") container:attr("class", classlist) local outerCountainer = mw.html.create("div") :addClass("mapframe-multi-outer-container") :addClass("mw-kartographer-container") :addClass("thumb") if options.alignment
"right" then outerCountainer:addClass("t"..options.alignment) else -- alignment is "center" outerCountainer :addClass("tnone") :addClass("center") end outerCountainer :tag("div") :addClass("thumbinner") :css("width", options.width.."px") :node(container) :node(options.caption and mw.html.create("div") :addClass("thumbcaption") :wikitext(options.caption) ) return styles .. tostring(outerCountainer)end
-- Entry points for templatesp.main = function(frame) local args = getArgs(frame,) local output = p._main(args) return frame:preprocess(output)end
p._main = function(args) if not args.switch then error("Mapframe multi: Paramater switch= is required", 0) end local switchLabels = tableFromList(args.switch) if #switchLabels
1 then error(string.format("Mapframe multi: Found only one switch value in paramater %s=", name), 0) end switchParams[name] = values end end if tableCount(switchParams)
1 and "" or "s", #switchLabels, #switchLabels
return p