Module:沙盒/盐棋/Sandbox1:修订间差异

来自Arcaea中文维基
(无)
(try)
第1行: 第1行:
-- text.jsonEncode({sp=W.site.namespaces},W.text.JSON_PRETTY)
local p={}
local p={}
local W=mw
function p.label_text(text)
 
   return tostring(mw.html.create('span'):addClass('label-text'):wikitext(text))
function p.main(frame)
end
return W.text.jsonDecode(frame.args[1])[2]["suffix"]-- text.jsonEncode({sp=W.site.namespaces},W.text.JSON_PRETTY)
function p.tab_img(id, config)
if id then
local container = mw.html.create('div'):addClass('container')
if type(config)=="string" then
container:wikitext('[[文件:Songs '..id..'.jpg|256px|none]]',p.label_text('画师'),config)
elseif type(config)=="table" then
local img_tab=container:tag('div'):addClass('img-tab')
for _, tab in ipairs(config) do
img_tab:tag('div'):addClass('img-tab-part'):addClass(tab.class):wikitext(tab.tab)
local figure=container:tag('div'):addClass('nodesktop'):wikitext('[[文件:Songs '..id..' '..tab.suffix..'.jpg|256px|none]]',p.label_text('画师'),tab.illust)
if tab.suffix=="" then figure:addClass('active') end
end
end
return tostring(container)
end
-- return '[[文件:Songs '..tostring(id) .. '.jpg|点此上传图片]]'
end
function p.direct(frame)
return mw.text.encode(p.tab_img(frame.arg[1],frame.arg[2]))
end
function p.jsonmode(frame)
return mw.text.encode(p.tab_img(frame.arg[1],mw.text.jsonDecode(frame.arg[2])))
end
end
return p
return p

2022年7月27日 (三) 17:51的版本

可在Module:沙盒/盐棋/Sandbox1/doc创建此模块的帮助文档

-- text.jsonEncode({sp=W.site.namespaces},W.text.JSON_PRETTY)
local p={}
function p.label_text(text)
    return tostring(mw.html.create('span'):addClass('label-text'):wikitext(text))
end
function p.tab_img(id, config)
	if id then
		local container = mw.html.create('div'):addClass('container')
		if type(config)=="string" then
			container:wikitext('[[文件:Songs '..id..'.jpg|256px|none]]',p.label_text('画师'),config)
		elseif type(config)=="table" then
			local img_tab=container:tag('div'):addClass('img-tab')
			for _, tab in ipairs(config) do
				img_tab:tag('div'):addClass('img-tab-part'):addClass(tab.class):wikitext(tab.tab)
				local figure=container:tag('div'):addClass('nodesktop'):wikitext('[[文件:Songs '..id..' '..tab.suffix..'.jpg|256px|none]]',p.label_text('画师'),tab.illust)
				if tab.suffix=="" then figure:addClass('active') end
			end
		end
		return tostring(container)
	end
	-- return '[[文件:Songs '..tostring(id) .. '.jpg|点此上传图片]]'
end
function p.direct(frame)
	return mw.text.encode(p.tab_img(frame.arg[1],frame.arg[2]))
end
function p.jsonmode(frame)
	return mw.text.encode(p.tab_img(frame.arg[1],mw.text.jsonDecode(frame.arg[2])))
end
return p