查看“模块:Timeline”的源代码
←
模块:Timeline
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
-- Module:Timeline -- Made with ♥ by User:Leranjun -- This module implements {{tl|Timeline}}. -- Please refrain from invoking this module directly. local p = {} local getArgs = require("Module:Arguments").getArgs local function notempty(s) return (s and s ~= "") end function p.main(frame) return p._main(getArgs(frame)) end function p._main(args) local anchor = (mw.ustring.lower((args.anchor or "yes")) ~= "no") local r = mw.html.create("table"):addClass("timeline"):addClass(args.class):cssText(args.style) local data = p.parse(args) for _, period in ipairs(data[1]) do local timelist = data[period] if (notempty(period)) then local row = mw.html.create("tr") local header = mw.html.create("th"):attr("colspan", 3):cssText(args.periodstyle):cssText(args[period .. "style"]) if (anchor) then local heading = mw.html.create("h5"):cssText("display:inline;font-weight:inherit;color:inherit"):wikitext(period) header:node(tostring(heading)) else header:wikitext(period) end row:node(tostring(header)) r:node(tostring(row)) end for _, time in ipairs(timelist[1]) do local events = timelist[time] local long = events.l local cnt = #events local full = period .. time for cur, event in ipairs(events) do local row = mw.html.create("tr") local cell = mw.html.create("td"):cssText(args.textstyle):cssText(args[full .. "textstyle"]) if (not long) then cell:attr("colspan", 2) end -- Add line breaks to fix compatibility issues with unordered lists cell:wikitext(event .. "\n") if (cur == 1) then local header = mw.html.create("th"):css("font-weight", args.timeweight):cssText(args.timestyle):cssText( args[full .. "style"] ) if (long) then header:attr("colspan", 2) end if (cnt > 1) then header:attr("rowspan", cnt) end if (args.period == "on") then header:wikitext(period) end header:wikitext(time) header:wikitext(args.sepr or "") row:node(tostring(header)) end row:node(tostring(cell)) r:node(tostring(row)) end end end return r end function p.parse(args) local raw = args.list local data = {[1] = {}} -- index for v in mw.text.gsplit(raw, ";") do if (not notempty(v)) then break end local timelist = mw.text.split(v, ":") local period = timelist[1] timelist = timelist[2] data[period] = {[1] = {}} table.insert(data[1], period) for time in mw.text.gsplit(timelist, ",") do if (not notempty(time)) then break end local value = args["in" .. period .. time] time = mw.text.split(time, "#") local needSort = false if (#time == 1) then needSort = true end time = time[1] time = mw.text.split(time, "in") if (#time > 1) then time = time[2] data[period][time] = data[period][time] or {l = true} else time = time[1] data[period][time] = data[period][time] or {} end if (needSort) then table.insert(data[period][1], time) end table.insert(data[period][time], value) end end return data end return p
该页面使用的模板:
模板:FromOther/CN
(
查看源代码
)
模板:Namespace detect
(
查看源代码
)
模板:Tl
(
查看源代码
)
模块:Timeline/doc
(
查看源代码
)
返回至
模块:Timeline
。
导航菜单
个人工具
登录
名字空间
模块
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
随机页面
最近更改
最新文件
常用
上传多个文件
工具
链入页面
相关更改
特殊页面
页面信息