跳转到内容

模組:沙盒/Carrotkit/lengthicon

维基百科,自由的百科全书
local p = {}
--p.main 修改自自module:Template:Weighted_page_size
function p.Weighted_page_size( titleText )
    if not titleText then
        return 0
    end
    local title = mw.title.new( titleText )
    if not title then
        return 0
    end
    local content = title:getContent()
    if not content then
        return 0
    end
    local chars = mw.ustring.len( content )
    return math.floor( chars * 3.7 + 0.5 )
end

function p.main( frame )
    local titleText = frame.args[1]
    local size
    local icontext
    size = p.Weighted_page_size(titleText)

    if size<3000 then
        icontext='<span style="color:black">●</span>'
    elseif size<10000 then   
        icontext='<span style="color:red">●</span>'
    elseif size<30000 then  
        icontext='<span style="color:orange;">●</span>'
    else    
        icontext='<span style="color:green">●</span>'
    end
    return icontext
end
return p