Line 2: |
Line 2: |
| -- by DennouNeko | | -- by DennouNeko |
| | | |
− | local common = require("Module:Common") | + | local U = require("Module:Core") |
− | local style = require("Module:Styles")
| |
− | | |
− | local colors = style.main_colors
| |
| | | |
| + | local colors = U.main_colors |
| | | |
| -- == Helper functions == | | -- == Helper functions == |
Line 54: |
Line 52: |
| end | | end |
| | | |
− | common.trunkTable(idx) | + | U.trunkTable(idx) |
| | | |
| for k,v in pairs(idx) do | | for k,v in pairs(idx) do |
| local tmp = {} | | local tmp = {} |
| tmp['index'] = v | | tmp['index'] = v |
− | if common.isset(header[v]) then tmp['header'] = header[v] end | + | if U.isset(header[v]) then tmp['header'] = header[v] end |
− | if common.isset(label[v]) then tmp['label'] = label[v] end | + | if U.isset(label[v]) then tmp['label'] = label[v] end |
− | if common.isset(data[v]) then tmp['data'] = data[v] end | + | if U.isset(data[v]) then tmp['data'] = data[v] end |
− | if common.isset(class[v]) then tmp['class'] = class[v] end | + | if U.isset(class[v]) then tmp['class'] = class[v] end |
− | if common.isset(rclass[v]) then tmp['rclass'] = rclass[v] end | + | if U.isset(rclass[v]) then tmp['rclass'] = rclass[v] end |
| ret[#ret+1] = tmp | | ret[#ret+1] = tmp |
| end | | end |
Line 74: |
Line 72: |
| local ret = {''} | | local ret = {''} |
| | | |
− | if common.isset(header) then | + | if U.isset(header) then |
− | if common.isset(colors[ttype]) then | + | if U.isset(colors[ttype]) then |
− | hstyle = 'background-color:' .. colors[ttype]['title'] .. ';' .. common.cv(common.isset(hstyle), hstyle, '') | + | hstyle = 'background-color:' .. colors[ttype]['title'] .. ';' .. U.cv(U.isset(hstyle), hstyle, '') |
| end | | end |
| | | |
| ret[#ret+1] = '<tr><th colspan="2"' | | ret[#ret+1] = '<tr><th colspan="2"' |
| | | |
− | if common.isset(class) then ret[#ret+1] = ' class="' .. class .. '"' end | + | if U.isset(class) then ret[#ret+1] = ' class="' .. class .. '"' end |
| | | |
| ret[#ret+1] = ' style="text-align:center;' | | ret[#ret+1] = ' style="text-align:center;' |
− | style.add(ret, hstyle) | + | U.addStyle(ret, hstyle) |
| ret[#ret+1] = '">' | | ret[#ret+1] = '">' |
| | | |
Line 99: |
Line 97: |
| local ret = {''} | | local ret = {''} |
| | | |
− | if common.isset(data) then | + | if U.isset(data) then |
| ret[#ret+1] = '<tr' | | ret[#ret+1] = '<tr' |
− | if common.isset(rclass) then ret[#ret+1] = ' class="' .. rclass .. '"' end | + | if U.isset(rclass) then ret[#ret+1] = ' class="' .. rclass .. '"' end |
| ret[#ret+1] = '>' | | ret[#ret+1] = '>' |
| | | |
− | if common.isset(label) then | + | if U.isset(label) then |
| | | |
| ret[#ret+1] = '<th scope="row"' | | ret[#ret+1] = '<th scope="row"' |
| | | |
− | if common.isset(class) then ret[#ret+1] = ' class="' .. class .. '"' end | + | if U.isset(class) then ret[#ret+1] = ' class="' .. class .. '"' end |
| | | |
| ret[#ret+1] = ' style="text-align:left;' | | ret[#ret+1] = ' style="text-align:left;' |
− | style.add(ret, lstyle) | + | U.addStyle(ret, lstyle) |
| ret[#ret+1] = '">' | | ret[#ret+1] = '">' |
| | | |
Line 120: |
Line 118: |
| ret[#ret+1] = '<td colspan="2"' | | ret[#ret+1] = '<td colspan="2"' |
| | | |
− | dstyle = 'text-align:center;' .. common.cv(common.isset(dstyle), dstyle, '') | + | dstyle = 'text-align:center;' .. U.cv(U.isset(dstyle), dstyle, '') |
| end | | end |
| | | |
− | if common.isset(class) then ret[#ret+1] = ' class="' .. class .. '"' end | + | if U.isset(class) then ret[#ret+1] = ' class="' .. class .. '"' end |
− | if common.isset(dstyle) then ret[#ret+1] = ' style="' .. dstyle .. '"' end | + | if U.isset(dstyle) then ret[#ret+1] = ' style="' .. dstyle .. '"' end |
| | | |
| ret[#ret+1] = '>' | | ret[#ret+1] = '>' |
Line 149: |
Line 147: |
| | | |
| ret[#ret+1] = ' class="infobox' | | ret[#ret+1] = ' class="infobox' |
− | if common.isset(frame.args['bodyclass']) then ret[#ret+1] = ' ' .. frame.args['bodyclass'] end | + | if U.isset(frame.args['bodyclass']) then ret[#ret+1] = ' ' .. frame.args['bodyclass'] end |
| ret[#ret+1] = '"' | | ret[#ret+1] = '"' |
| | | |
Line 155: |
Line 153: |
| | | |
| ret[#ret+1] = ' style="width:22em; text-align:left; font-size:88%; line-height:1.5em;' | | ret[#ret+1] = ' style="width:22em; text-align:left; font-size:88%; line-height:1.5em;' |
− | if common.isset(colors[ttype]) then | + | if U.isset(colors[ttype]) then |
| ret[#ret+1] = 'border-color:' .. colors[ttype]['border'] .. ';' | | ret[#ret+1] = 'border-color:' .. colors[ttype]['border'] .. ';' |
| ret[#ret+1] = 'background-color:' .. colors[ttype]['background'] .. ';' | | ret[#ret+1] = 'background-color:' .. colors[ttype]['background'] .. ';' |
| end | | end |
− | style.add(ret, frame.args['bodystyle']) | + | U.addStyle(ret, frame.args['bodystyle']) |
| ret[#ret+1] = '"' | | ret[#ret+1] = '"' |
| | | |
Line 165: |
Line 163: |
| | | |
| -- Caption | | -- Caption |
− | if common.isset(frame.args['title']) then | + | if U.isset(frame.args['title']) then |
| ret[#ret+1] = '<caption' | | ret[#ret+1] = '<caption' |
− | if common.isset(frame.args['titleclass']) then ret[#ret+1] = ' class="' .. frame.args['titleclass'] .. '"' end | + | if U.isset(frame.args['titleclass']) then ret[#ret+1] = ' class="' .. frame.args['titleclass'] .. '"' end |
| | | |
| ret[#ret+1] = ' style="font-size:125%; font-weight:bold;' | | ret[#ret+1] = ' style="font-size:125%; font-weight:bold;' |
− | style.add(ret, frame.args['titlestyle']) | + | U.addStyle(ret, frame.args['titlestyle']) |
| ret[#ret+1] = '"' | | ret[#ret+1] = '"' |
| | | |
Line 181: |
Line 179: |
| | | |
| -- Header | | -- Header |
− | if common.isset(frame.args['above']) then | + | if U.isset(frame.args['above']) then |
| local class = frame.args['aboveclass'] | | local class = frame.args['aboveclass'] |
| local rclass = frame.args['aboverowclass'] | | local rclass = frame.args['aboverowclass'] |
| local text = frame.args['above'] | | local text = frame.args['above'] |
| local style = 'text-align:center; font-size:125%; font-weight:bold;' | | local style = 'text-align:center; font-size:125%; font-weight:bold;' |
− | if common.isset(frame.args['abovestyle']) then style = style .. ' ' .. frame.args['abovestyle'] end | + | if U.isset(frame.args['abovestyle']) then style = style .. ' ' .. frame.args['abovestyle'] end |
| | | |
| ret[#ret+1] = build_header_row(ttype, class, rclass, text, style) | | ret[#ret+1] = build_header_row(ttype, class, rclass, text, style) |
Line 193: |
Line 191: |
| else | | else |
| -- for child infobox add simple header | | -- for child infobox add simple header |
− | if common.isset(frame.args['title']) then | + | if U.isset(frame.args['title']) then |
| ret[#ret+1] = "'''" .. frame.args['title'] .. "'''" | | ret[#ret+1] = "'''" .. frame.args['title'] .. "'''" |
| end | | end |
Line 206: |
Line 204: |
| | | |
| -- Subheader1 | | -- Subheader1 |
− | if common.isset(frame.args['subheader']) or common.isset(frame.args['subheader1']) then | + | if U.isset(frame.args['subheader']) or U.isset(frame.args['subheader1']) then |
− | local text = common.cv(common.isset(frame.args['subheader']), frame.args['subheader'], frame.args['subheader1']) | + | local text = U.cv(U.isset(frame.args['subheader']), frame.args['subheader'], frame.args['subheader1']) |
| local style = frame.args['subheaderstyle'] | | local style = frame.args['subheaderstyle'] |
| local class = frame.args['subheaderclass'] | | local class = frame.args['subheaderclass'] |
− | local rclass = common.cv(common.isset(frame.args['subheaderrowclass']), frame.args['subheaderrowclass'], frame.args['subheaderrowclass1']) | + | local rclass = U.cv(U.isset(frame.args['subheaderrowclass']), frame.args['subheaderrowclass'], frame.args['subheaderrowclass1']) |
| | | |
| ret[#ret+1] = build_row(ttype, class, rclass, '', '', text, style) | | ret[#ret+1] = build_row(ttype, class, rclass, '', '', text, style) |
Line 216: |
Line 214: |
| | | |
| -- Subheader2 | | -- Subheader2 |
− | if common.isset(frame.args['subheader2']) then | + | if U.isset(frame.args['subheader2']) then |
| local text = frame.args['subheader2'] | | local text = frame.args['subheader2'] |
| local style = frame.args['subheaderstyle'] | | local style = frame.args['subheaderstyle'] |
Line 226: |
Line 224: |
| | | |
| -- Image1 | | -- Image1 |
− | if common.isset(frame.args['image']) or common.isset(frame.args['image1']) then | + | if U.isset(frame.args['image']) or U.isset(frame.args['image1']) then |
| local text = {} | | local text = {} |
− | text[#text+1] = common.cv(common.isset(frame.args['image']), frame.args['image'], frame.args['image1']) | + | text[#text+1] = U.cv(U.isset(frame.args['image']), frame.args['image'], frame.args['image1']) |
| | | |
− | if common.isset(frame.args['caption']) or common.isset(frame.args['caption1']) then | + | if U.isset(frame.args['caption']) or U.isset(frame.args['caption1']) then |
| text[#text+1] = '<br/><span' | | text[#text+1] = '<br/><span' |
− | if common.isset(frame.args['captionstyle']) then text[#text+1] = ' style="' .. frame.args['captionstyle'] .. '"' end | + | if U.isset(frame.args['captionstyle']) then text[#text+1] = ' style="' .. frame.args['captionstyle'] .. '"' end |
| text[#text+1] = '>' | | text[#text+1] = '>' |
− | text[#text+1] = common.cv(common.isset(frame.args['caption']), frame.args['caption'], frame.args['caption1']) | + | text[#text+1] = U.cv(U.isset(frame.args['caption']), frame.args['caption'], frame.args['caption1']) |
| text[#text+1] = '</span>' | | text[#text+1] = '</span>' |
| end | | end |
Line 248: |
Line 246: |
| | | |
| -- Image2 | | -- Image2 |
− | if common.isset(frame.args['image2']) then | + | if U.isset(frame.args['image2']) then |
| local text = {} | | local text = {} |
| text[#text+1] = frame.args['image2'] | | text[#text+1] = frame.args['image2'] |
| | | |
− | if common.isset(frame.args['caption2']) then | + | if U.isset(frame.args['caption2']) then |
| text[#text+1] = '<br/><span' | | text[#text+1] = '<br/><span' |
− | if common.isset(frame.args['captionstyle']) then text[#text+1] = ' style="' .. frame.args['captionstyle'] .. '"' end | + | if U.isset(frame.args['captionstyle']) then text[#text+1] = ' style="' .. frame.args['captionstyle'] .. '"' end |
| text[#text+1] = '>' | | text[#text+1] = '>' |
| text[#text+1] = frame.args['caption2'] | | text[#text+1] = frame.args['caption2'] |
Line 281: |
Line 279: |
| | | |
| for k,v in pairs(tbl) do | | for k,v in pairs(tbl) do |
− | -- not using common.cv, because both functions would be called | + | -- not using U.cv, because both functions would be called |
− | if common.isset(v['header']) then | + | if U.isset(v['header']) then |
| ret[#ret+1] = build_header_row(ttype, v['class'], v['rclass'], v['header'], hstyle) | | ret[#ret+1] = build_header_row(ttype, v['class'], v['rclass'], v['header'], hstyle) |
| else | | else |