查看“模块:Infobox”的源代码
←
模块:Infobox
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
local module = { } local inner_args = { ["wrapper"] = true, ["m-style"] = true, ["font-size"] = true, ["text-align"] = true, ["width"] = true, ["max-width"] = true, ["float"] = true, ["bg-color"] = true, ["m-bcolor"] = true, ["m-color"] = true, ["notitle"] = true, ["title-main"] = true, ["top-style"] = true, ["top-bcolor"] = true, ["标题背景色"] = true, ["標題背景色"] = true, ["top-color"] = true, ["标题文字色"] = true, ["標題文字色"] = true, ["Title"] = true, ["标题"] = true, ["tabs"] = true, ["image-style"] = true, ["image"] = true, ["size"] = true, ["图片大小"] = true, ["圖片大小"] = true, ["caption"] = true, ["图片说明"] = true, ["圖片說明"] = true, ["图片信息"] = true, ["圖片信息"] = true, ["image-lostmessage"] = true, ["l-style"] = true, ["l-width"] = true, ["l-bcolor"] = true, ["左栏背景色"] = true, ["左欄背景色"] = true, ["l-color"] = true, ["左栏文字色"] = true, ["左欄文字色"] = true, ["r-style"] = true, ["t-style"] = true, ["t-bcolor"] = true, ["底栏背景色"] = true, ["底欄背景色"] = true, ["t-color"] = true, ["底栏文字色"] = true, ["底欄文字色"] = true, ["i-style"] = true } function module.Modern(frame) local frame_self = frame local parent = frame:getParent() local title = parent:getTitle() local _chk_arg_self = function(...) local ret = nil for _, arg_name in ipairs{...} do ret = frame_self.args[arg_name] if ret then ret = mw.text.trim(ret) if ret ~= "" then return ret end end end return nil end local _chk_arg, _chk_arg_caller = _chk_arg_self, _chk_arg_self if parent and ((title == "Template:InfoboxModern") or (frame.args["wrapper"]=="1" and mw.title.new(title).namespace == 10)) then frame = parent _chk_arg_caller = function(...) local ret = nil for _, arg_name in ipairs{...} do ret = parent.args[arg_name] if ret then ret = mw.text.trim(ret) if ret ~= "" then return ret end end end return nil end _chk_arg = function(...) return _chk_arg_caller(...) or _chk_arg_self(...) end end local html = mw.html.create() local box = html:tag("table") :addClass("infotemplatebox") :attr("align", "right") local style_main = _chk_arg("m-style") if style_main then box:cssText(style_main) else box:css("font-size", _chk_arg("font-size") or "90%") :css("text-align", _chk_arg("text-align") or "center") :css("width", _chk_arg("width") or "280px") :css("max-width", _chk_arg("max-width") or "100%") :css("float", _chk_arg("float") or "right") :css("background-color", _chk_arg("bg-color", "m-bcolor") or "#FFF") :css("color", _chk_arg("m-color") or "#000") end if not _chk_arg("notitle") then local title_main = _chk_arg_caller("title-main") if title_main then box:wikitext(title_main) else local td_title = box:tag("tr"):tag("td"):attr("colspan", "2") local style_top = _chk_arg("top-style") if style_top then td_title:cssText(style_top) else td_title:css("background-color", _chk_arg("top-bcolor", "标题背景色", "標題背景色") or"#26ca9b") :css("color", _chk_arg("m-color", "top-color", "标题文字色", "標題文字色") or"#FFF") :css("font-size", "100%") :css("padding", "1em") :wikitext(_chk_arg("Title", "title", "标题") or mw.title.getCurrentTitle().fullText) end end end local arg_tabs = _chk_arg_caller("tabs") local arg_image = _chk_arg_caller("image") local arg_image_lostmessage = _chk_arg("image-lostmessage") if arg_tabs or arg_image or arg_image_lostmessage then local td_top = box:tag("tr"):tag("td"):attr("colspan", "2") if arg_tabs then td_top:wikitext(arg_tabs) else local style_image = _chk_arg("image-style") if style_image then td_top:cssText(style_image) end if arg_image then td_top:wikitext("[[Image:" .. arg_image .. "|" .. (_chk_arg("size", "图片大小", "圖片大小") or "280px") .. "]]") local arg_caption = _chk_arg_caller("caption", "图片说明", "圖片說明", "图片信息", "圖片信息") if arg_caption then td_top:tag("br"):done() :wikitext(arg_caption) end else td_top:wikitext(arg_image_lostmessage) end end end local num_names, item_type, num_insert = 1, 0, nil local arg_queue, arg_names = { }, { } for idx, value in ipairs(frame_self.args) do local arg_trim = mw.text.trim(value) if num_insert == nil and arg_trim == "<customs>" then num_insert = idx else local arg_split = mw.text.split(arg_trim, ",", true) if mw.ustring.sub(arg_split[1], 1, 1) == "-" then arg_split[1] = mw.ustring.sub(arg_split[1], 2) item_type = 1 else item_type = 0 end arg_names[arg_split[1]] = arg_split[1] table.insert(arg_queue, { ["name"] = arg_split[1], ["type"] = item_type } ) for index = 2, #arg_split do local alias = arg_split[index] arg_names[alias] = arg_split[1] table.insert(arg_queue, { ["name"] = alias, ["alias"] = num_names } ) end num_names = num_names + #arg_split end end local arg_exclude = frame_self.args["exclude"] if arg_exclude then arg_exclude = mw.text.trim(arg_exclude) end if arg_exclude and arg_exclude ~= "" then local arg_split = mw.text.split(arg_exclude, ";", true) for _, value in ipairs(arg_split) do inner_args[value] = true end end -- Todo: CustomArgs by {{{order}}} local arg_order = frame_self.args["order"] if arg_order then arg_order = mw.text.trim(arg_order) end if arg_order and arg_order ~= "" then local arg_split = mw.text.split(arg_order, ";", true) for _, value in ipairs(arg_split) do if not (inner_args[value] or arg_names[value] or value == "") then if num_insert ~= nil then table.insert(arg_queue, num_insert, { ["name"] = value } ) else table.insert(arg_queue, { ["name"] = value } ) end arg_names[value] = value end end end local args_input = { } for key, value in pairs(frame.args) do value = mw.text.trim(value) if (not (tonumber(key) or inner_args[key])) and (value ~= "") then args_input[key] = value end end for key, value in pairs(args_input) do if not arg_names[key] then if num_insert ~= nil then table.insert(arg_queue, num_insert, { ["name"] = value } ) else table.insert(arg_queue, { ["name"] = value } ) end end end local style_left = _chk_arg("l-style") local width_left = _chk_arg("l-width") local bcolor_left = _chk_arg("l-bcolor", "左栏背景色", "左欄背景色") local color_left = _chk_arg("l-color", "左栏文字色", "左欄文字色") local style_right = _chk_arg("r-style") local style_rebar = _chk_arg("t-style") local bcolor_rebar = _chk_arg("t-bcolor", "底栏背景色", "底欄背景色") local color_rebar = _chk_arg("t-color", "底栏文字色", "底欄文字色") local style_text = _chk_arg("i-style") local InsertItem = function(key, value) local tr_item = box:tag("tr") local td_item = tr_item:tag("td") if style_left then td_item:cssText(style_left) else td_item:css("width", width_left or "80px") :css("background-color", bcolor_left or "#E0FFFF") :css("color", color_left or "#000") end td_item:wikitext(key) td_item = tr_item:tag("td") if style_right then td_item:cssText(style_right) end td_item:wikitext(value) end local InsertRebar = function(value) local td_item = box:tag("tr"):tag("td"):attr("colspan", "2") if style_rebar then td_item:cssText(style_rebar) else td_item:css("background-color", bcolor_rebar or "#62BCA9") :css("color", color_rebar or "#FFF") end td_item:wikitext(value) end local InsertText = function(value) local td_item = box:tag("tr"):tag("td"):attr("colspan", "2") if style_text then td_item:cssText(style_text) else td_item:css("text-align", "left") end td_item:wikitext(value) end mw.logObject(arg_queue) local temp_name, temp_type = nil, nil for _, arg_item in ipairs(arg_queue) do if args_input[arg_item.name] then if arg_item.alias then temp_name = arg_queue[arg_item.alias].name temp_type = arg_queue[arg_item.alias].type else temp_name = arg_item.name temp_type = arg_item.type end if temp_name then if temp_type == 1 then InsertRebar(temp_name) InsertText(args_input[arg_item.name]) else InsertItem(temp_name, args_input[arg_item.name]) end if arg_item.alias then arg_queue[arg_item.alias].name = nil end end args_input[arg_item.name] = nil arg_item.name = nil end end return html end return module
该页面使用的模板:
模块:Infobox/doc
(
查看源代码
)
返回至
模块:Infobox
。
导航菜单
个人工具
登录
名字空间
模块
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
随机页面
最近更改
最新文件
常用
上传多个文件
工具
链入页面
相关更改
特殊页面
页面信息