Module:Cbox/layout

local lo = {} local process = require('Module:Cbox/process') function lo.layout1(cbox,styles,css,args) local headrow = mw.html.create('tr') local descrow = mw.html.create('tr') local headcell = process.Header('2',args.header,styles,css) local desccell = process.Description(args.text,args.quote,args.name,styles,css) headrow:node( headcell ) mw.log(tostring(headrow)) descrow:node( desccell ) if args.image then local imgcell=process.Image('1',args.image,args.imagesize,styles,css) descrow:node( imgcell ) end mw.log(tostring(descrow)) cbox:node( headrow ):node( descrow ) if (args.reason and args.timestamp) or args.data then local reasonrow = mw.html.create('tr') if args.reason then local reasoncell = process.Reason('2',args.reason,args.reasontext or "不明",args.timestamp,args.towhere,styles,css) reasonrow:node( reasoncell ) elseif args.data then local datacell = process.Data('2',args.data,styles,css) reasonrow:node( datacell ) end mw.log(tostring(reasonrow)) cbox:node( reasonrow ) end return cbox end function lo.layout2(cbox,styles,css,args) local headrow = mw.html.create('tr') local descrow = mw.html.create('tr') local headcell = process.Header('2',args.header,styles,css) local desccell = process.Description(args.text,args.quote,args.name,styles,css) headrow:node( headcell ) mw.log(tostring(headrow)) if args.image then local imgcell=process.Image('1',args.image,args.imagesize,styles,css) descrow:node( imgcell ) end descrow:node( desccell ) mw.log(tostring(descrow)) cbox:node( headrow ):node( descrow ) if (args.reason and args.timestamp) or args.data then local reasonrow = mw.html.create('tr') if args.reason then local reasoncell = process.Reason('2',args.reason,args.reasontext or "不明",args.timestamp,args.towhere,styles,css) reasonrow:node( reasoncell ) elseif args.data then local datacell = process.Data('2',args.data,styles,css) reasonrow:node( datacell ) end mw.log(tostring(reasonrow)) cbox:node( reasonrow ) end return cbox end function lo.layout3(cbox,styles,css,args) local headrow = mw.html.create('tr') local descrow = mw.html.create('tr') local headcell = process.Header('1',args.header,styles,css) local desccell = process.Description(args.text,args.quote,args.name,styles,css) headrow:node( headcell ) if args.image then local imgcell=process.Image('2',args.image,args.imagesize,styles,css) headrow:node( imgcell ) end mw.log(tostring(headrow)) descrow:node( desccell ) mw.log(tostring(descrow)) cbox:node( headrow ):node( descrow ) if (args.reason and args.timestamp) or args.data then local reasonrow = mw.html.create('tr') if args.reason then local reasoncell = process.Reason('2',args.reason,args.reasontext or "不明",args.timestamp,args.towhere,styles,css) reasonrow:node( reasoncell ) elseif args.data then local datacell = process.Data('2',args.data,styles,css) reasonrow:node( datacell ) end mw.log(tostring(reasonrow)) cbox:node( reasonrow ) end return cbox end function lo.layout4(cbox,styles,css,args) local headrow = mw.html.create('tr') local descrow = mw.html.create('tr') local headcell = process.Header('1',args.header,styles,css) local desccell = process.Description(args.text,args.quote,args.name,styles,css) if args.image then local imgcell=process.Image('2',args.image,args.imagesize,styles,css) headrow:node( imgcell ) end headrow:node( headcell ) mw.log(tostring(headrow)) descrow:node( desccell ) mw.log(tostring(descrow)) cbox:node( headrow ):node( descrow ) if (args.reason and args.timestamp) or args.data then local reasonrow = mw.html.create('tr') if args.reason then local reasoncell = process.Reason('2',args.reason,args.reasontext or "不明",args.timestamp,args.towhere,styles,css) reasonrow:node( reasoncell ) elseif args.data then local datacell = process.Data('2',args.data,styles,css) reasonrow:node( datacell ) end mw.log(tostring(reasonrow)) cbox:node( reasonrow ) end return cbox end function lo.layout5(cbox,styles,css,args) local aboverow = mw.html.create('tr') local descrow = mw.html.create('tr') local belowrow = mw.html.create('tr') local abovecell = process.Above('1',args.above,args.header,styles,css) local belowcell = process.Below('1',args.below,styles,css) local desccell = process.Description(args.text,args.quote,args.name,styles,css) aboverow:node( abovecell ) if args.image then local cs=3 if (args.reason and args.timestamp) or args.data then cs=4 end local imgcell=process.Image(tostring(cs),args.image,args.imagesize,styles,css) aboverow:node( imgcell ) end belowrow:node( belowcell ) descrow:node( desccell ) mw.log(tostring(descrow)) cbox:node( aboverow ):node( descrow ) if (args.reason and args.timestamp) or args.data then local reasonrow = mw.html.create('tr') if args.reason then local reasoncell = process.Reason('1',args.reason,args.reasontext or "不明",args.timestamp,args.towhere,styles,css) reasonrow:node( reasoncell ) elseif args.data then local datacell = process.Data('1',args.data,styles,css) reasonrow:node( datacell ) end mw.log(tostring(reasonrow)) cbox:node( reasonrow ) end cbox:node( belowrow ) return cbox end function lo.layout6(cbox,styles,css,args) local aboverow = mw.html.create('tr') local descrow = mw.html.create('tr') local belowrow = mw.html.create('tr') local abovecell = process.Above('1',args.above,args.header,styles,css) local belowcell = process.Below('1',args.below,styles,css) local desccell = process.Description(args.text,args.quote,args.name,styles,css) aboverow:node( abovecell ) if args.image then local cs=3 if (args.reason and args.timestamp) or args.data then cs=4 end local imgcell=process.Image(tostring(cs),args.image,args.imagesize,styles,css) aboverow:node( imgcell ) end belowrow:node( belowcell ) descrow:node( desccell ) mw.log(tostring(descrow)) cbox:node( aboverow ):node( descrow ) if (args.reason and args.timestamp) or args.data then local reasonrow = mw.html.create('tr') if args.reason then local reasoncell = process.Reason('1',args.reason,args.reasontext or "不明",args.timestamp,args.towhere,styles,css) reasonrow:node( reasoncell ) elseif args.data then local datacell = process.Data('1',args.data,styles,css) reasonrow:node( datacell ) end mw.log(tostring(reasonrow)) cbox:node( reasonrow ) end cbox:node( belowrow ) return cbox end return lo -- process.Header(colspan,header,styles,css) -- process.Above(colspan,above,header,styles,css) -- process.Below(colspan,below,styles,css) -- process.Description(description,quote,name,styles,css) -- process.Data(colspan,data,styles,css) -- process.Reason(colspan,tp,data,timestamp,towhere,styles,css) -- process.Image(rowspan,image,size,styles,css)