模組:沙盒/Carrotkit/lengthicon
模块文档[创建]
您可能想要创建本Scribunto模块的文档。 编者可以在本模块的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 请在/doc子页面中添加分类。本模块的子页面。 |
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