;
×
创建新页面
在此填写您的页面标题:
我们当前在Undertale社区维基上拥有210个页面。请在上方输入您的页面名称或点击以下任意标题来开始编写页面!



Undertale社区维基

模块:条目创建状态

欢迎来到Undertale社区维基(*`∀´*)ノ亻,如果想要参与条目创建或编辑,请先登录

可在模块:条目创建状态/doc创建此模块的帮助文档

local p = {}
local b = require("Module:Basic")
function p.checkExists(frame)
    local titles = mw.text.split(frame.args[1], ",")
    local existCount = 0
    local totalCount = #titles
    local width = b.empty(frame.args.width)
    local height = b.empty(frame.args.height)
    local left_text = b.empty(frame.args.left_text)
    local right_text = b.empty(frame.args.right_text)
    mw.logObject(frame.args)

    for i, title in ipairs(titles) do
        local page = mw.title.new(title)
        if page.exists then
            existCount = existCount + 1
        end
    end

    local progress = existCount / totalCount

    return p.renderProgressBar(progress,width,height,existCount ,totalCount,left_text,right_text)
end

function p.renderProgressBar(progress,width,height,existCount ,totalCount, left_text, right_text)
    local bigBar = mw.html.create('div')
        :css('display', "flex")

    local progressBar = mw.html.create('div')
        :css('width', width or totalCount .. "px")
        :css('height', height or '20px')
        :css('background-color', '#ff0000')
        :css('display', 'inline-block')
        :css('margin-left', '10px')
        :css('margin-right', '10px')

    local bar = mw.html.create('div')
        :css('width', progress * 100 .. '%')
        :css('height', height or '20px')
        :css('background-color', '#ffff00')
        :css('display', 'inline-block')

    local left_html = mw.html.create('span')
        :wikitext(right_text or "")

    local right_html = mw.html.create('span')
        :css("font-family", "\"ut-hp-font\",\"Determination Mono\"")
        :css("font-size", "18px")
        :wikitext(left_text or (existCount .. " / " .. totalCount))
    
    progressBar:node(bar)
    bigBar:node(left_html)
    bigBar:node(progressBar)
    bigBar:node(right_html)

    return tostring(bigBar)
end

return p