维护提醒

BWIKI 全站将于 9 月 3 日(全天)进行维护,期间无法编辑任何页面或发布新的评论。

全站通知:

模块:Schedule

来自星露谷物语维基
跳到导航 跳到搜索
[ 创建 | 刷新 ]文档页面
当前模块文档缺失,需要扩充。
local p = {}

function p.main(frame)
	local parent_args = frame:getParent().args
	local args = {}
	local max_key = 0

	for k, v in pairs(parent_args) do
		local num_key = tonumber(k)
		if num_key and num_key > 0 and math.floor(num_key) == num_key then
			args[num_key] = v
			if num_key > max_key then
				max_key = num_key
			end
		end
	end

	local result = {}
	table.insert(result, '<table class="wikitable scheduleheader">')
	table.insert(result, '<tr><th style="width: 15%;">时间</th><th style="width: 85%;">地点</th></tr>')

	for i = 1, max_key, 2 do
		local time = args[i] or ''
		local location = args[i + 1] or ''

		if time ~= '' then
			local row = string.format('<tr><td>%s</td><td>%s</td></tr>', time, location)
			table.insert(result, row)
		end
	end

	table.insert(result, '</table>')

	return table.concat(result, '\n')
end

return p