跳转到内容

模組:Status

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由Sanmosa留言 | 贡献2021年2月25日 (四) 03:56 (// Edit via Wikiplus)编辑。这可能和当前版本存在着巨大的差异。

local p = {}

local function status (x)
	local statuslist = {
		["done"] = 'true',
		["完成"] = 'true',
		["+"] = 'true',
		["not done"] = 'false',
		["拒絕"] = 'false',
		["拒绝"] = 'false',
		["驳回"] = 'false',
		["駁回"] = 'false',
		["未完成"] = 'false',
		["-"] = 'false',
		["on hold"] = 'oh',
		["擱置"] = 'oh',
		["搁置"] = 'oh',
		["等待"] = 'oh',
		["等待中"] = 'oh',
		["oh"] = 'oh',
		["hold"] = 'oh',
		["*"] = 'oh',
		["?"] = 'oh',
		["撤回"] = 'withdrawn',
		["w"] = 'withdrawn',
		["withdrawn"] = 'withdrawn',
		["wd"] = 'withdrawn',
		["already done"] = 'ad',
		["ad"] = 'ad',
		["此前已完成"] = 'ad',
		["redundant"] = 'redundant',
		["rd"] = 'redundant',
		["重複"] = 'redundant',
		["重复"] = 'redundant',
		["重複請求"] = 'redundant',
		["重复请求"] = 'redundant',
	}
	if not statuslist[x] then
		return 'unknown'
	end
	return statuslist[x]
end

local function color (x)
	local colorlist = {
		['true'] = '#00AF89',
		['false'] = '#D11D13',
		['oh'] = '#FFCC00',
		['unknown'] = '#AAA',
		['withdrawn'] = '#000088',
		['ad'] = '#000',
		['redundant'] = '#F99',
	}
	return colorlist[x]
end

local function text (x, arg1, arg2)
	if arg2 then return arg2 end
	local textlist = {
		['true'] = '完成',
		['false'] = '未完成',
		['oh'] = '等待中',
		['withdrawn'] = '撤回',
		['ad'] = '此前已完成',
		['redundant'] = '重複請求',
	}
	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