Module:Flow-timeline:修订间差异

来自有兽档案馆
([InPageEdit] 没有编辑摘要)
([InPageEdit] 没有编辑摘要)
第33行: 第33行:
mobile
mobile
:addClass("timeline-mobile-emptycell")
:addClass("timeline-mobile-emptycell")
:addClass("hidden-sm")
:addClass("visible-sm")
timeline:node(mobile)
timeline:node(mobile)
local line = mw.html.create("div")
local line = mw.html.create("div")

2023年8月1日 (二) 17:04的版本

此模块使用于{{Flow-timeline}}。

上述文档内容嵌入自Module:Flow-timeline/doc编辑 | 历史
编者可以在本模块的沙盒创建 | 镜像和测试样例创建页面进行实验。
请将模块自身所属的分类添加在文档中。本模块的子页面
local data = {}
local framework={}
local function getId(args)
    for key, value in pairs(args) do
        local prefix = string.match(key, "(%a+)%d+")
        local index = tonumber(string.match(key, "%d"))
        if index and not data[index] then
            data[index] = {}
        end
        if prefix == "text" then
            data[index][2] = value
        elseif prefix == "id" then
            data[index][1] = value
        end
    end
end
function framework.timeline(frame)
    local args = frame:getParent().args
    getId(args)
    local timeline = mw.html.create("div")
    timeline:addClass("timeline-framework")
    local trunk = mw.html.create("div")
    trunk
        :addClass("timeline-trunk")
    timeline:node(trunk)
    for index, value in ipairs(data) do
        local branch = mw.html.create("div")
        branch
            :addClass("timeline-branch")
            :attr("id","timeline-branch-" .. index)
        timeline:node(branch)
    	local mobile=mw.html.create("div")
    	mobile
    		:addClass("timeline-mobile-emptycell")
    		:addClass("visible-sm")
    	timeline:node(mobile)
        local line = mw.html.create("div")
        line
            :addClass("timeline-line")
            :attr("id","timeline-line-" .. index)
        branch:node(line)
        if value[1] then
            local id = mw.html.create("span")
            id
                :addClass("timeline-id")
                :attr("id","timeline-id-" .. index)
                :wikitext(value[1])
            line:node(id)
        end
        if value[2] then
            local text = mw.html.create("div")
            text
                :addClass("timeline-text")
                :attr("id","timeline-text-" .. index)
                :wikitext(value[2])
            branch:node(text)
        end
    end
    local empty=mw.html.create("div")
    empty:addClass("timeline-emptycell")
  	timeline:node(empty)
    return tostring(timeline)
end
return framework