跳转到内容

模組:Status

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

这是本页的一个历史版本,由SunAfterRain留言 | 贡献2020年2月22日 (六) 06:01编辑。这可能和当前版本存在着巨大的差异。

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 textlist[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