模組:Status
外观
local p = {}
local function status (x)
local statuslist = {
["done"] = true,
["完成"] = true,
["not done"] = false,
["拒絕"] = false,
["拒绝"] = false,
["驳回"] = false,
["駁回"] = false,
["未完成"] = false,
["on hold"] = 0,
["擱置"] = 0,
["搁置"] = 0,
["等待"] = 0,
["等待中"] = 0,
["oh"] = 0,
["hold"] = 0,
["*"] = 0,
["?"] = 0,
}
if not statuslist[x] then
return 'unknow'
end
return statuslist[x]
end
local function color (x)
local colorlist = {
[true] = '#00AF89',
[false] = '#D11D13',
[0] = '#FFCC00',
['unknow'] = '#AAA',
}
return colorlist[x]
end
local function text (x, text)
local textlist = {
[true] = '完成',
[false] = '未完成',
[0] = '等待中',
}
if textlist[x] == 'unknow' then
return text
end
return colorlist[x]
end
local function tag (tagname, text, id, class, style, title)
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
return mw.text.tag(tagname, paid, text)
end
function p._main(args)
local arg = args[1]:lower()
local code = args['prefix'] or '狀態:'
local spanid = nil
local bot_archive = nil
if status(arg) == nil then
spanid = '_new_request'
bot_archive = tag ('span', '', nil, 'bot-directive-archiver', nil, 'keep|')
end
code = code .. tag ('span', '  ', spanid, nil, 'background:' .. color(status(arg)), nil)
code = code .. tag ('b', text(status(arg), (args[2] or args[1]))) .. (args['sign'] or '')
code = tag ('div', code) .. (bot_archive or '')
return code
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