跳转到内容

模組:Status/sandbox

维基百科,自由的百科全书

这是本页的一个历史版本,由Yining Chen留言 | 贡献2021年2月24日 (三) 15:45 (建立Module:Status的沙盒版本)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
local p = {}

local function status (x)
    local statuslist = {
        ["done"] = true,
        ["完成"] = true,
        ["+"] = true,
        ["not done"] = 'false',
        ["拒絕"] = 'false',
        ["拒绝"] = 'false',
        ["驳回"] = 'false',
        ["駁回"] = 'false',
        ["未完成"] = 'false',
        ["-"] = 'false',
        ["on hold"] = 0,
        ["擱置"] = 0,
        ["搁置"] = 0,
        ["等待"] = 0,
        ["等待中"] = 0,
        ["oh"] = 0,
        ["hold"] = 0,
        ["*"] = 0,
        ["?"] = 0,
        ["撤回"] = 'test',
    }
    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',
        ['test'] = '#000088',
    }
    return colorlist[x]
end

local function text (x, arg1, arg2)
    if arg2 then return arg2 end
    local textlist = {
        [true] = '完成',
        ['false'] = '未完成',
        [0] = '等待中',
        ['test'] = '撤回',
    }
    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) == 'unknow' 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