"ഘടകം:Slippymap/sandbox" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം
ദൃശ്യരൂപം
No edit summary |
No edit summary |
||
| (ഒരേ ഉപയോക്താവ് ചെയ്ത ഇടയ്ക്കുള്ള 9 നാൾപ്പതിപ്പുകൾ പ്രദർശിപ്പിക്കുന്നില്ല) | |||
| വരി 1: | വരി 1: | ||
local | local DEFAULT_FRAME_WIDTH = "270" | ||
local DEFAULT_FRAME_HEIGHT = "200" | |||
local DEFAULT_ZOOM = 10 | |||
function | -- Trim whitespace from arguments | ||
function trimArgs(argsTable) | |||
local cleanArgs = {} | |||
for key, val in pairs(argsTable) do | |||
if type(val) == 'string' then | |||
val = val:match('^%s*(.-)%s*$') | |||
if val ~= '' then | |||
cleanArgs[key] = val | |||
end | |||
else | |||
cleanArgs[key] = val | |||
end | |||
end | |||
return cleanArgs | |||
end | |||
-- Main function to generate map | |||
local p = {} | |||
-- This will display the map based on provided coordinates | |||
local | p.main = function(frame) | ||
local parent = frame.getParent(frame) | |||
local parentArgs = parent.args | |||
local config = trimArgs(parentArgs) | |||
-- Extract coordinates (if provided) | |||
local coords = config.coordinates or config.coord | |||
if not coords then | |||
return '' -- Return an empty string if no coordinates are provided | |||
end | |||
-- Configure mapframe arguments | |||
local args = {} | |||
args.display = "inline" | |||
args.frame = "yes" | |||
args.plain = "yes" | |||
args["frame-width"] = config["frame-width"] or DEFAULT_FRAME_WIDTH | |||
args["frame-height"] = config["frame-height"] or DEFAULT_FRAME_HEIGHT | |||
args.zoom = config.zoom or DEFAULT_ZOOM | |||
args["frame-coord"] = coords | |||
] | |||
-- | -- Return the mapframe code as a string | ||
return | return frame:preprocess('{{#mapframe:' .. mw.uri.encodeArgs(args) .. '}}') | ||
end | end | ||
return p | return p | ||
18:34, 6 ജനുവരി 2025-നു നിലവിലുള്ള രൂപം
ഈ ഘടകത്തിന്റെ വിവരണം ഘടകം:Slippymap/sandbox/വിവരണം എന്ന താളിൽ നിർമ്മിക്കാവുന്നതാണ്
local DEFAULT_FRAME_WIDTH = "270"
local DEFAULT_FRAME_HEIGHT = "200"
local DEFAULT_ZOOM = 10
-- Trim whitespace from arguments
function trimArgs(argsTable)
local cleanArgs = {}
for key, val in pairs(argsTable) do
if type(val) == 'string' then
val = val:match('^%s*(.-)%s*$')
if val ~= '' then
cleanArgs[key] = val
end
else
cleanArgs[key] = val
end
end
return cleanArgs
end
-- Main function to generate map
local p = {}
-- This will display the map based on provided coordinates
p.main = function(frame)
local parent = frame.getParent(frame)
local parentArgs = parent.args
local config = trimArgs(parentArgs)
-- Extract coordinates (if provided)
local coords = config.coordinates or config.coord
if not coords then
return '' -- Return an empty string if no coordinates are provided
end
-- Configure mapframe arguments
local args = {}
args.display = "inline"
args.frame = "yes"
args.plain = "yes"
args["frame-width"] = config["frame-width"] or DEFAULT_FRAME_WIDTH
args["frame-height"] = config["frame-height"] or DEFAULT_FRAME_HEIGHT
args.zoom = config.zoom or DEFAULT_ZOOM
args["frame-coord"] = coords
-- Return the mapframe code as a string
return frame:preprocess('{{#mapframe:' .. mw.uri.encodeArgs(args) .. '}}')
end
return p