模組:Status/sandbox
外观
这是Module:Status(差异)的沙盒。 |
local p = {}
local page = mw.title.new( 'Module:Status/data.json' )
local content = page:getContent()
local data = mw.text.jsonDecode( content )
local function status (x)
for k,v in pairs(data) do
for _,s in pairs(v.status) do
if x == s then return k end
end
end
return 'unknown'
end
local function color (x)
return data[status(x)].color
end
local function text (x, arg1, arg2)
return arg2 or data[status(x)].text or arg1 or '處理中'
end
local function isKeep (x)
return data[status(x)].keep or false
end
function p._main(args)
local arg = args[1] and args[1]:lower() or '處理中'
local code = args['prefix'] or '狀態:'
local spanid = nil
local bot_archive = ''
if isKeep(arg) then
spanid = '_new_request'
bot_archive = mw.getCurrentFrame():expandTemplate{title='Bot-directive-archiver', args={'keep'}}
end
code = code .. mw.text.tag('span', {
['style'] = 'background:' .. color(arg),
['id'] = spanid or ''
}, '  ')
code = code .. ' ' .. mw.text.tag('b', {}, text(arg, args[1], args[2])) .. (args['sign'] or '')
code = mw.text.tag('div', {}, code) .. bot_archive
return code
end
--[=[
local paid = {}
if id then paid['id'] = id end
if id then paid['id'] = id end
if style then paid['style'] = style end
if title then paid['title'] = title end
]=]--
function p.main(frame)
local args = {}
for k, v in pairs( frame:getParent().args ) do
args[k] = v
end
return p._main(args)
end
return p