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”类
         return string.format(
         schedule_output = frame:expandTemplate{
             '<li class="%s" style="display: flex;">' ..
             title = "ScheduleList/date",
            '{{ScheduleList/date|%s||%s|}}' ..
             args = {formatted_date, "", week, title} -- 时间为空,标题为“无”
            '</li>',
         }
             css_class, formatted_date, week
         )
     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"
         return string.format(
         schedule_output = frame:expandTemplate{
             '<li class="%s" style="display: flex;">' ..
             title = "ScheduleList/date",
            '{{ScheduleList/date|%s|%s (UTC+8)|%s|%s}}' ..
            args = {formatted_date, time .. " (UTC+8)", week, title} -- 时间和标题正常显示
            '</li>',
         }
            css_class, formatted_date, time, 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="date-title-list">' .. table.concat(result, "\n") .. '</ul>'
     return '<ul class="schedule-list">' .. table.concat(result, "\n") .. '</ul>'
end
end


return p
return p