模組:Status
外观
local p = {}
local function status (x)
local statuslist = {
["done"] = 'done',
["完成"] = 'done',
["+"] = 'done',
["not done"] = 'nd',
["nd"] = 'nd',
["拒絕"] = 'nd',
["拒绝"] = 'nd',
["驳回"] = 'nd',
["駁回"] = 'nd',
["未完成"] = 'nd',
["-"] = 'nd',
["on hold"] = 'oh',
["擱置"] = 'oh',
["搁置"] = 'oh',
["等待"] = 'oh',
["等待中"] = 'oh',
["oh"] = 'oh',
["hold"] = 'oh',
["*"] = 'oh',
["?"] = 'oh',
["撤回"] = 'wd',
["w"] = 'wd',
["wd"] = 'wd',
["withdrawn"] = 'wd',
["already done"] = 'ad',
["ad"] = 'ad',
["此前已完成"] = 'ad',
["rd"] = 'rd',
["redundant"] = 'rd',
["重複"] = 'rd',
["重复"] = 'rd',
["重複請求"] = 'rd',
["重复请求"] = 'rd',
}
if not statuslist[x] then
return 'unknown'
end
return statuslist[x]
end
local function color (x)
local colorlist = {
['done'] = '#00AF89',
['nd'] = '#D11D13',
['oh'] = '#FFCC00',
['unknown'] = '#AAAAAA',
['wd'] = '#000088',
['ad'] = '#000000',
['rd'] = '#FF9999',
}
return colorlist[x]
end
local function text (x, arg1, arg2)
if arg2 then return arg2 end
local textlist = {
['done'] = '完成',
['nd'] = '未完成',
['oh'] = '等待中',
['wd'] = '撤回',
['ad'] = '此前已完成',
['rd'] = '重複請求',
}
if textlist[x] == nil then
return (arg1 or '處理中')
end
return textlist[x]
end
local function tag (tagname, text, paid)
return mw.text.tag(tagname, paid, text)
end
function p._main(args)
local arg = args[1]
if not arg then
arg = '處理中'
else
arg = arg:lower()
end
local code = args['prefix'] or '狀態:'
local spanid = nil
local bot_archive = nil
if status(arg) == 'unknown' then
spanid = '_new_request'
bot_archive = tag ('span', '',{
['class'] = 'bot-directive-archiver',
['title'] = 'keep|'
})
end
code = code .. tag ('span', '  ',{
['style'] = 'background:' .. color(status(arg)),
['id'] = spanid or ''
})
code = code .. ' ' .. tag ('b', text(status(arg), args[1], args[2])) .. (args['sign'] or '')
code = tag ('div', code) .. (bot_archive or '')
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