Module:ScheduleList:修订间差异

跳转到导航 跳转到搜索
无编辑摘要
无编辑摘要
 
(未显示同一用户的7个中间版本)
第48行: 第48行:
local function format_date_line(frame, date, time, week, title, css_class)
local function format_date_line(frame, date, time, week, title, css_class)
     local formatted_date = format_date(date)
     local formatted_date = format_date(date)
    local ruby_output = frame:expandTemplate{
        title = "ScheduleList/date",
        args = {formatted_date, time .. " (UTC+8)", week, title} -- 将 week 和 title 作为 ruby 模板的第三和第四参数
    }


     -- 如果没有标题,则自动添加 offline 类;有标题则添加 online 类
     -- 如果标题为空,设置默认值为“无”
     if not title or title == "无" then
     if not title or title == "" then
         css_class = (css_class and css_class .. " " or "") .. "offline"
        title = "无"
         title = "" -- 确保未填写标题时显示 "无"
    end
 
    local schedule_output
    if title == "无" then
         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"
         css_class = (css_class and css_class .. " " or "") .. "online" -- 标题存在时,添加“online”类
        time = time or "2:00" -- 如果未提供时间,使用默认值 "2:00"
        schedule_output = frame:expandTemplate{
            title = "ScheduleList/date",
            args = {formatted_date, time .. " (UTC+8)", week, title} -- 时间和标题正常显示
        }
     end
     end


第66行: 第75行:
         '<div class="datetime">%s</div>' ..
         '<div class="datetime">%s</div>' ..
         '</li>',
         '</li>',
         css_class, ruby_output
         css_class, schedule_output
     )
     )
end
end
第78行: 第87行:
     local week = tonumber(args.week) -- 输入的周几 (1~7)
     local week = tonumber(args.week) -- 输入的周几 (1~7)
     local leap_year = args.leap_year == "yes" -- 闰年判断
     local leap_year = args.leap_year == "yes" -- 闰年判断
    local time_default = "2:00"


     -- 如果没有输入初始日期,则报错
     -- 如果没有输入初始日期,则报错
第92行: 第100行:
     for i = 1, 7 do
     for i = 1, 7 do
         local title = args["title" .. i] -- 每行的标题
         local title = args["title" .. i] -- 每行的标题
         if title == "无" then
         local time = args["time" .. i] -- 每行的时间(可以为空)
        local time = "" -- 未提供时间+标题时默认为空
        else
        local time = args["time" .. i] or time_default -- 未提供时间时默认 "2:00"
        end
         local css_class = args["class" .. i] -- 每行的 CSS 类
         local css_class = args["class" .. i] -- 每行的 CSS 类
         local week_day = get_weekday(current_weekday) -- 计算周几
         local week_day = get_weekday(current_weekday) -- 计算周几
第109行: 第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