Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:TNT: Difference between revisions

From WikiOasis Meta
m 1 revision imported
Tags: Mobile edit Mobile web edit Advanced mobile edit
m>Pppery
m Protected "Module:TNT" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
Line 100: Line 100:
end
end


local numOnly = true
local params = {}
local params = {}
local paramOrder = {}
local paramOrder = {}
Line 113: Line 114:
end
end
if name then
if name then
if (
(type(name) ~= "number")
and (
(type(name) ~= "string")
or not string.match(name, "^%d+$")
)
) then
numOnly = false
end
params[name] = newVal
params[name] = newVal
table.insert(paramOrder, name)
table.insert(paramOrder, name)
Line 119: Line 129:


-- Work around json encoding treating {"1":{...}} as an [{...}]
-- Work around json encoding treating {"1":{...}} as an [{...}]
params['zzz123']=''
if numOnly then
params['zzz123']=''
end


local json = mw.text.jsonEncode({
local json = mw.text.jsonEncode({
params=params,
params=params,
paramOrder=paramOrder,
paramOrder=paramOrder,
description=data.description
description=data.description,
})
})


json = string.gsub(json,'"zzz123":"",?', "")
if numOnly then
json = string.gsub(json,'"zzz123":"",?', "")
end


return json
return json
Line 157: Line 171:
if not mw.ext or not mw.ext.data or not mw.ext.data.get then
if not mw.ext or not mw.ext.data or not mw.ext.data.get then
error(string.format([['''Missing JsonConfig extension, or not properly configured;
error(string.format([['''Missing JsonConfig extension, or not properly configured;
Cannot load https://commons.wikimedia.org/wiki/Data:%s. Please properly enable the JSONConfig extension at Special:ManageWiki/extensions#mw-prefsection-other
Cannot load https://commons.wikimedia.org/wiki/Data:%s.
See https://www.mediawiki.org/wiki/Extension:JsonConfig#Supporting_Wikimedia_templates''']], dataset))
See https://www.mediawiki.org/wiki/Extension:JsonConfig#Supporting_Wikimedia_templates''']], dataset))
end
end
Cookies help us deliver our services. By using our services, you agree to our use of cookies.