模組:Status
外观
local p = {}
local data = {
['done'] = {
status = {"done", "完成", "+"},
color = '#00AF89',
text = '完成'
},
['nd'] = {
status = {"拒絕", "拒绝", "驳回", "駁回", "未完成", "-", "not done", "nd"},
color = '#D11D13',
text = '未完成'
},
['oh'] = {
status = {"on hold", "擱置", "搁置", "等待", "等待中", "oh", "hold", "*", "?"},
color = '#FFCC00',
text = '等待中'
},
['wd'] = {
status = {"撤回", "w", "wd", "withdrawn"},
color = '#000088',
text = '撤回'
},
['ad'] = {
status = {"already done", "ad", "此前已完成"},
color = '#000000',
text = '此前已完成'
},
['rd'] = {
status = {"rd", "redundant", "重複", "重复", "重複請求", "重复请求"},
color = '#FF9999',
text = '重複請求'
},
['unknown'] = {
status = {},
color = '#AAAAAA'
}
}
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 tag (tagname, text, paid)
return mw.text.tag(tagname, paid, text)
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 = 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(arg),
['id'] = spanid or ''
})
code = code .. ' ' .. tag ('b', text(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