Module:Notice

-- local p = {}

local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local setColor = require('Module:Color')._color --setColor(color, text) local mainonly = require('Module:Mainonly')

local data = require('Module:Notice/Data')

function addSup (text) return ..text.. end

function makeCenter(text) return ''..text..' ' end

function makeMSGbox (text, img, note, small, bg, bg_img, bor_c) if not text then error('no text specified') end local messagebox if bg and not bg_img then if bor_c then messagebox = mw.html.create('table') :addClass('messagebox') :css('display', 'inline-block') :css('text-align', 'left') :css('margin', '10px') :css('background-color', bg) :css('border-color', bor_c) else messagebox = mw.html.create('table') :addClass('messagebox') :css('display', 'inline-block') :css('text-align', 'left') :css('margin', '10px') :css('background-color', bg) end else if bor_c then messagebox = mw.html.create('table') :addClass('messagebox') :css('display', 'inline-block') :css('text-align', 'left') :css('margin', '10px') :css('border-color', bor_c) else messagebox = mw.html.create('table') :addClass('messagebox') :css('display', 'inline-block') :css('text-align', 'left') :css('margin', '10px') end end if img and not small then if bg and bg_img then if note then messagebox:tag('tr') :tag('td') :wikitext(img) :css('background-color', bg_img) :done :tag('td') :wikitext(text..'  Note: '..note..' ') :css('background-color', bg) :done :done else messagebox:tag('tr') :tag('td') :wikitext(img) :css('background-color', bg_img) :done :tag('td') :wikitext(text) :css('background-color', bg) :done :done end else if note then messagebox:tag('tr') :tag('td') :wikitext(img) :done :tag('td') :wikitext(text..' '..note) :done :done else messagebox:tag('tr') :tag('td') :wikitext(img) :done :tag('td') :wikitext(text) :done :done end end else if note then if bg then messagebox:tag('tr') :tag('td') :wikitext(text..'  Note: '..note..' ') :css('background-color', bg) :done else messagebox:tag('tr') :tag('td') :wikitext(text..'  Note: '..note..' ') :done end else if bg then messagebox:tag('tr') :tag('td') :wikitext(text) :css('background-color', bg) :done else messagebox:tag('tr') :tag('td') :wikitext(text) :done end end end return ''..tostring(messagebox)..' ' end

-- templates start here

function p.coming_soon (frame) local args = getArgs(frame) local small = yesno(args['small'] or args['s']) local sup = yesno(args['sup']) local addcategory = yesno(args['addcategory'] or args['ac']) return frame:preprocess(p._coming_soon (small, sup, addcategory)) end function p._coming_soon (small, sup, addcategory) if sup then return addcategory == true and addSup(data['coming_soon'].sup)..data['coming_soon'].category or addSup(data['coming_soon'].sup) end if small then return addcategory == true and data['coming_soon'].small..data['coming_soon'].category or data['coming_soon'].small end local msgbox = data['coming_soon'].MSGboxData return makeMSGbox(msgbox.text, msgbox.img)..'' end

function p.confirm return addSup(data['confirm'].sup) end

function p.ahn (frame) local args = getArgs(frame) local small = yesno(args['small'] or args['s']) local sup = yesno(args['sup']) local addcategory = yesno(args['addcategory'] or args['ac']) return frame:preprocess(p._ahn (small, sup, addcategory)) end function p._ahn (small, sup, addcategory) if sup then return addSup(data['ahn'].sup) end if small then return data['ahn'].small end local msgbox = data['ahn'].MSGboxData return makeMSGbox(msgbox.text, msgbox.img)..'' end

function p.stub (frame) local args = getArgs(frame) local variant = args['variant'] local addcategory = yesno(args['addcategory'] or args['ac']) local note = args[1] or args['note'] return frame:preprocess(p._stub(variant, note, addcategory)) end function p._stub (variant, note, addcategory) variants = { ['section'] = 'section', ['sec'] = 'section', ['tips'] = 'tips', ['tip'] = 'tips', }	local msgbox = data['stub'].MSGboxData if variants[variant] == 'section' then local msgbox_sec = data['stub'].SectionMSGbox return makeMSGbox(msgbox_sec.text, nil, ' Note: '..note..' ', true, msgbox.bg, nil, msgbox.bor_c)..'' elseif variants[variant] == 'tips' then local msgbox_tips = data['stub'].TipsMSGbox return makeMSGbox(msgbox_tips.text, nil, ' Note: '..note..' ', true, msgbox.bg, nil, msgbox.bor_c)..'' else return makeMSGbox(msgbox.text, msgbox.img, ' Note: '..note..' ', false, msgbox.bg, nil, msgbox.bor_c)..'' end end

function p.info_needed (frame) local args = getArgs(frame) local table = yesno(args['table'] or args['t']) local sup = yesno(args['sup']) local addcategory = yesno(args['addcategory'] or args['ac'], true) return frame:preprocess(p._info_needed (table, sup, addcategory)) end function p._info_needed (table, sup, addcategory) if sup then if addcategory then return addSup(data['info_needed'].sup)..'' else return addSup(data['info_needed'].sup) end end if table then if addcategory then return data['info_needed'].table..'' else return data['info_needed'].table end end if addcategory then return data['info_needed'].small..'' else return data['info_needed'].small end end

return p