1,132
个编辑
小 (img) |
小 (try?) |
||
第1行: | 第1行: | ||
-- text.jsonEncode({sp=W.site.namespaces},W.text.JSON_PRETTY) | -- text.jsonEncode({sp=W.site.namespaces},W.text.JSON_PRETTY) | ||
local p={} | local p={} | ||
p.filter={text=mw.text.encode,json=mw.text.jsonEncode,no=function (x)return x end} | p.filter={text=mw.text.encode,json=mw.text.jsonEncode,no=function(x)return x end} | ||
function p.label_text(text) | function p.label_text(text) | ||
return tostring(mw.html.create('span'):addClass('label-text'):wikitext(text)) | return tostring(mw.html.create('span'):addClass('label-text'):wikitext(text)) | ||
end | |||
function p.song_cell(frame) | |||
return mw.text.jsonEncode({ | |||
class=frame.args['色彩'], | |||
tab=frame.args['标签'], | |||
content=string.format('[[文件:Songs %%s%s.jpg|256px|none]]%s%s',frame.args['后缀']or'',p.label_text('画师'),frame.args['画师']), | |||
active=frame.args['后缀']==nil | |||
},mw.text.JSON_PRESERVE_KEYS) | |||
end | end | ||
function p.tab_img(id, config) | function p.tab_img(id, config) | ||
local container = mw.html.create('div'):addClass('container') | |||
if #config==1 then | |||
container:wikitext(config[1].content) | |||
else | |||
local img_tab=container:tag('div'):addClass('img-tab'):attr('id', 'tab-a') | |||
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('tab-text-a'):wikitext(tab.content) | |||
if _==id then figure:addClass('active') end | |||
end | end | ||
end | end | ||
return tostring(container) | |||
-- return '[[文件:Songs '..tostring(id) .. '.jpg|点此上传图片]]' | -- return '[[文件:Songs '..tostring(id) .. '.jpg|点此上传图片]]' | ||
end | |||
function p.song(frame) | |||
local config,main={},1 | |||
for i, v in ipairs(frame) do | |||
local item=mw.text.jsonDecode(v) | |||
item.content=item.content:format(frame.args['id']) | |||
config:insert(item) | |||
if item.active then main=i end | |||
end | |||
return p.tab_img(main,config) | |||
end | end | ||
function p.direct(frame) | function p.direct(frame) |
个编辑