Module:Cbox/process

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) ..' '..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 = ""..tp.."理由: "..data.." このページが最後に編集されたのは"..timestamp.."です. " if towhere and towhere~='' then realdata = ""..tp.."先: "..data.." "..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,styles,css) colorfix('image',styles) local cell = quickcreate('td','image',styles,css) cell:wikitext('['..'[File:'..image) if tonumber(size)>1 then cell:wikitext('|'..size..'x'..size..'px') end cell:wikitext('|link=]'..']') if tonumber(rowspan)>1 then cell:attr('rowspan',rowspan) end return cell end return p