WIKI公告栏
欢迎各位引航者访问卡拉彼丘WIKI,由于游客访问页面会有一定的页面旧版缓存,建议你登陆B站账号进行浏览,如果您觉得本WIKI有帮助到你,欢迎推荐给身边的引航者。
全站通知:

模块:路线图

来自卡拉彼丘WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

--原模块链接:https://mzh.moegirl.org.cn/模块:Tree_chart
local p = {}
 
local cells = mw.loadData('Module:路线图/Data')
 
function p._main(cell_args)
	local ret = mw.html.create()
	local top = ret:tag('tr')
						:css{ height = '1px',
								['text-align'] = 'center' }
	local bottom = ret:tag('tr')
						:css{ height = '1px',
								['text-align'] = 'center' }
	for _, v in ipairs(cell_args) do
		if type(v) == 'string' then
			top:wikitext(cells[v].t)
			bottom:wikitext(cells[v].b)
		else
			top:tag('td')
				:attr{ colspan = v.colspan or cell_args.colspan or 6,
						rowspan = v.rowspan or cell_args.rowspan or 2 }
				:css{ padding = '0.2em',
						['border-radius']  = '5px',
						['-webkit-box-shadow'] = '2px 2px 8px #ddd',
						['-moz-box-shadow'] = '2px 2px 8px #ddd',
						['box-shadow'] = '2px 2px 8px #ddd',
						['background-color'] = 'rgba(232,232,232,1)' ,
						border = (v.border or cell_args.border or '2') .. 'px solid rgba(220,186,114,.8)' }
				:cssText(v.boxstyle or cell_args.boxstyle)
				:wikitext(v.text)
		end
	end
	return tostring(ret)
end
 
function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:路线图', trim = false, removeBlanks = false})
	local cell_args = {
		colspan = args.colspan,
		rowspan = args.rowspan,
		border = args.border,
		boxstyle = args.boxstyle
	}
	for _, val in ipairs(args) do
		local trimmedVal = val:match('^%s*(.-)%s*$')
		if trimmedVal == '' then
			trimmedVal = '$'
		end
		if cells[trimmedVal] then
			table.insert(cell_args, trimmedVal)
		else
			-- Unnamed params behave weirdly
			-- white space at the front counts for param_{{{1}}}, but not whitespace at the end, so remove it
			local rightTrimmedVal = val:gsub('%s+$','')
			table.insert(cell_args, {
				text = args[trimmedVal] or ('{{{'..trimmedVal..'}}}'),
				colspan = args['colspan_'..rightTrimmedVal],
				rowspan = args['rowspan_'..rightTrimmedVal],
				border = args['border_'..rightTrimmedVal],
				boxstyle = args['boxstyle_'..rightTrimmedVal]
			})
		end
	end
	
	return p._main(cell_args)
end
 
return p