[create]
The documentation for this module is missing. Click here to create it.
local p = {}
local function colorfix(header,styles)
if styles[header] then
local c,bc = styles[header]['color'],styles[header]['background-color']
if c and not bc then
local ddc = {['args']={c}}
styles[header]['background-color'] = chrome.text(ddc)
elseif bc and not c then
local ddc = {['args']={bc}}
styles[header]['color']=chrome.text(ddc)
end
end
end
local function quickcreate(element,class,styles,css)
local cell = mw.html.create(element)
cell:addClass(class)
if styles[class] then
cell:css(styles[class])
end
if css[class] then
cell:cssText(css[class])
end
return cell
end
function p.Header(colspan,header,styles,css)
local cell = quickcreate('th','header',styles,css)
cell:wikitext(header or "???")
if tonumber(colspan)>1 then
cell:attr('colspan',colspan)
end
return cell
end
function p.Above(colspan,above,header,styles,css)
local cell = quickcreate('th','header',styles,css)
cell:wikitext(above or header or "???")
if tonumber(colspan)>1 then
cell:attr('colspan',colspan)
end
return cell
end
function p.Below(colspan,below,styles,css)
local cell = quickcreate('th','header',styles,css)
cell:wikitext(below or "???")
if tonumber(colspan)>1 then
cell:attr('colspan',colspan)
end
return cell
end
local function processQuote(letter,name)
return "'''''" .. '"' .. letter .. '"'.."''''' - ["..'['..name..']'.."]"
end
function p.Description(description,quote,name,styles,css)
local data = description or "???"
if quote and quote~='' and name and name~='' then
data = processQuote(quote,name) ..'<br/>'..data
end
colorfix('description',styles)
local cell = quickcreate('td','description',styles,css)
cell:wikitext(data)
return cell
end
function p.Data(colspan,data,styles,css)
local cell = quickcreate('td','reason',styles,css)
cell:wikitext(data)
if tonumber(colspan)>1 then
cell:attr('colspan',colspan)
end
return cell
end
function p.Reason(colspan,tp,data,timestamp,towhere,styles,css)
local realdata = "'''Reason of "..tp.."''': "..data.."<br />This page was last edited on "..timestamp.."."
if towhere and towhere~='' then
realdata = "'''"..tp.." to''': "..data.."<br />"..realdata
end
local cell = quickcreate('td','reason',styles,css)
cell:wikitext(realdata)
if tonumber(colspan)>1 then
cell:attr('colspan',colspan)
end
return cell
end
function p.Image(rowspan,image,size,link,styles,css)
colorfix('image',styles)
local cell = quickcreate('td','image',styles,css)
cell:wikitext('['..'[File:'..image)
if size then
if string.find(size,'%%') or string.find(size,'px') then
cell:wikitext('|'..size)
elseif tonumber(size)>1 then
cell:wikitext('|'..size..'x'..size..'px')
end
end
cell:wikitext('|link='..(link or '')..']'..']')
if tonumber(rowspan)>1 then
cell:attr('rowspan',rowspan)
end
return cell
end
return p