跳转到内容

模組:Bulletin

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

这是本页的一个历史版本,由Xiplus留言 | 贡献2018年2月13日 (二) 09:37编辑。这可能和当前版本存在着巨大的差异。

local p = {}

function p._getcolor( color )
	local colorlist = {
		["公告"] = "Pink",
		["人事"] = "LightGreen",
		["投票"] = "LightGreen",
		["编辑"] = "LightGreen",
		["讨论"] = "LightBlue",
		["討論"] = "LightBlue",
		["請求"] = "Orange",
		["请求"] = "Orange",
		["通知"] = "Skyblue",
		["调查"] = "Yellow",
		["調查"] = "Yellow",
		["聚會"] = "PaleGoldenrod",
		["聚会"] = "PaleGoldenrod",
		["獎勵"] = "PaleGoldenrod",
		["奖励"] = "PaleGoldenrod",
		["解任"] = "#99FF4D",
		["離任"] = "#99FF4D",
		["离任"] = "#99FF4D"
	}
	if colorlist[color] == nil then
		return "transparent"
	end
	return colorlist[color]
end

function p.item( frame )
	local args = frame:getParent().args
	prefix = args["prefix"]
	if prefix == nil then
		prefix = ""
	end
		
	suffix = args["suffix"]
	if suffix == nil then
		suffix = ""
	end
		
	separator = args["separator"]
	if separator == nil then
		separator = "、"
	end
	
	conjunction = args["conjunction"]
	if conjunction == nil then
		conjunction = "及"
	end
	
	type = args[1]
	if type == nil then
		type = "公告"
	end
	
	local items = {}
	local i = 2
	while args[i] ~= nil do
		local value = mw.text.trim( args[i] )
		if value ~= "" then
			table.insert( items, value )
			i = i + 1
		end
	end
	return '<li><span style="font-weight: bold; background-color:' .. 
		p._getcolor(type) .. ';">[' .. type .. ']</span> ' ..
		prefix .. mw.text.listToText( items, separator, conjunction ) .. suffix .. '</li>'
end

return p