模块: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=…” 标签:已重建 |
无编辑摘要 |
||
| (未显示同一用户的4个中间版本) | |||
| 第2行: | 第2行: | ||
function p.main(frame) |
function p.main(frame) |
||
local args = frame:getParent().args |
|||
local args = {} |
|||
-- 使用原生 wikitable 类,确保暗色模式下背景色和文字颜色自动适配 |
|||
local max_key = 0 |
|||
local tbl = mw.html.create('table') |
|||
:addClass('wikitable') |
|||
:css('width', '100%') |
|||
:css('max-width', '600px') |
|||
:css('margin', '10px 0 10px 15px') -- 左侧缩进,增强层级感 |
|||
:css('border-collapse', 'collapse') |
|||
local tr_head = tbl:tag('tr') |
|||
for k, v in pairs(parent_args) do |
|||
tr_head:tag('th'):css('width', '85px'):wikitext('时间') |
|||
local num_key = tonumber(k) |
|||
tr_head:tag('th'):wikitext('地点') |
|||
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 |
|||
local i = 1 |
|||
while args[i] do |
|||
table.insert(result, '<table class="wikitable scheduleheader">') |
|||
local tr = tbl:tag('tr') |
|||
table.insert(result, '<tr><th style="width: 15%;">时间</th><th style="width: 85%;">地点</th></tr>') |
|||
tr:tag('td'):wikitext(mw.text.trim(args[i])) |
|||
tr:tag('td'):wikitext(args[i+1] and mw.text.trim(args[i+1]) or '') |
|||
i = i + 2 |
|||
| ⚫ | |||
return tostring(tbl) |
|||
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 |
end |
||
2026年4月20日 (一) 23:37的最新版本
local p = {}
function p.main(frame)
local args = frame:getParent().args
-- 使用原生 wikitable 类,确保暗色模式下背景色和文字颜色自动适配
local tbl = mw.html.create('table')
:addClass('wikitable')
:css('width', '100%')
:css('max-width', '600px')
:css('margin', '10px 0 10px 15px') -- 左侧缩进,增强层级感
:css('border-collapse', 'collapse')
local tr_head = tbl:tag('tr')
tr_head:tag('th'):css('width', '85px'):wikitext('时间')
tr_head:tag('th'):wikitext('地点')
local i = 1
while args[i] do
local tr = tbl:tag('tr')
tr:tag('td'):wikitext(mw.text.trim(args[i]))
tr:tag('td'):wikitext(args[i+1] and mw.text.trim(args[i+1]) or '')
i = i + 2
end
return tostring(tbl)
end
return p