Module:ScheduleList:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
无编辑摘要 |
||
(未显示同一用户的2个中间版本) | |||
第49行: | 第49行: | ||
local formatted_date = format_date(date) | local formatted_date = format_date(date) | ||
-- | -- 如果标题为空,设置默认值为“无” | ||
if not title or title == "无" then | if not title or title == "" then | ||
title = "无" | |||
end | |||
local schedule_output | |||
if title == "无" then | |||
css_class = (css_class and css_class .. " " or "") .. "offline" -- 标题为空时,添加“offline”类 | css_class = (css_class and css_class .. " " or "") .. "offline" -- 标题为空时,添加“offline”类 | ||
schedule_output = frame:expandTemplate{ | |||
title = "ScheduleList/date", | |||
args = {formatted_date, "", week, title} -- 时间为空,标题为“无” | |||
} | |||
else | else | ||
css_class = (css_class and css_class .. " " or "") .. "online" -- 标题存在时,添加“online”类 | css_class = (css_class and css_class .. " " or "") .. "online" -- 标题存在时,添加“online”类 | ||
time = time or "2:00" -- 如果未提供时间,使用默认值 "2:00" | time = time or "2:00" -- 如果未提供时间,使用默认值 "2:00" | ||
schedule_output = frame:expandTemplate{ | |||
title = "ScheduleList/date", | |||
args = {formatted_date, time .. " (UTC+8)", week, title} -- 时间和标题正常显示 | |||
} | |||
end | end | ||
-- 构建 HTML 输出 | |||
return string.format( | |||
'<li class="%s" style="display: flex;">' .. | |||
'<div class="datetime">%s</div>' .. | |||
'</li>', | |||
css_class, schedule_output | |||
) | |||
end | end | ||
第104行: | 第113行: | ||
-- 包装在 <ul> 中,作为返回结果 | -- 包装在 <ul> 中,作为返回结果 | ||
return '<ul class=" | return '<ul class="schedule-list">' .. table.concat(result, "\n") .. '</ul>' | ||
end | end | ||
return p | return p |