Module:StoreTableHead: Difference between revisions

From 2006Scape Wiki
Jump to navigation Jump to search
(Replaced content with "{{Delete}}")
Tag: Replaced
(Undo revision 71 by Halogod35 (talk))
Tag: Undo
 
Line 1: Line 1:
{{Delete}}
local p = {}
 
local params = require('Module:Paramtest')
local yesno = require('Module:Yesno')
local var = mw.ext.VariablesLua
 
function p.main(frame)
    local args = frame:getParent().args
    local currency,namenotes,delta,smw,hideimage,hidege,hidebuy,hidesell,hidestock,hiderestock,hidecaption = params.defaults{
                    {args.currency,'Coins'},
                    {args.namenotes,''},
                    {args.delta,10},
                    {args.smw,'yes'},
                    {args.hideimage,'no'},
                    {args.hidege,'no'},
                    {args.hidebuy,'no'},
                    {args.hidesell,'no'},
                    {args.hidestock,'no'},
                    {args.hiderestock,'no'},
                    {args.hidecaption,'no'}
                }
    var.vardefine('Currency', currency)
    var.vardefine('NameNotes', namenotes)
    var.vardefine('Delta', delta)
    var.vardefine('smw', smw)
    var.vardefine('hideImage', hideimage)
    var.vardefine('hideGE', hidege)
    var.vardefine('hideBuy', hidebuy)
    var.vardefine('hideSell', hidesell)
    var.vardefine('hideStock', hidestock)
    var.vardefine('hideRestock', hiderestock)
   
    ret:tag('tr')
    local colspan = yesno(hideimage) and 1 or 2
    ret:tag('th'):attr('colspan', colspan):wikitext('Item'):done()
    if not(yesno(hidestock)) then
        ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Number<br>in stock'):done()
    end
    if not(yesno(hiderestock)) then
        ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Restock<br/>time'):done()
    end
    if not(yesno(hidesell)) then
        ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Price<br>sold at'):done()
    end
    if not(yesno(hidebuy)) then
        ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Price<br>bought at'):done()
    end
    if not(yesno(hidege)) then
        ret:tag('th'):attr('data-sort-type', 'number'):wikitext('[[Grand Exchange|GE <br>price]]'):done()
    end
    local i = 1
    while args['column' .. i] do
        ret:tag('th'):attr('data-sort-type', 'number'):wikitext(args['column' .. i]):done()
        i = i+1
    end
    ret:done()
    return '<table class="wikitable sortable" style="text-align:center;">' .. tostring(ret)
end
   
return p

Latest revision as of 05:07, 2 February 2023

local p = {}

local params = require('Module:Paramtest') local yesno = require('Module:Yesno') local var = mw.ext.VariablesLua

function p.main(frame)

   local args = frame:getParent().args
   local currency,namenotes,delta,smw,hideimage,hidege,hidebuy,hidesell,hidestock,hiderestock,hidecaption = params.defaults{
                   {args.currency,'Coins'},
                   {args.namenotes,},
                   {args.delta,10},
                   {args.smw,'yes'},
                   {args.hideimage,'no'},
                   {args.hidege,'no'},
                   {args.hidebuy,'no'},
                   {args.hidesell,'no'},
                   {args.hidestock,'no'},
                   {args.hiderestock,'no'},
                   {args.hidecaption,'no'}
               }
   var.vardefine('Currency', currency)
   var.vardefine('NameNotes', namenotes)
   var.vardefine('Delta', delta)
   var.vardefine('smw', smw)
   var.vardefine('hideImage', hideimage)
   var.vardefine('hideGE', hidege)
   var.vardefine('hideBuy', hidebuy)
   var.vardefine('hideSell', hidesell)
   var.vardefine('hideStock', hidestock)
   var.vardefine('hideRestock', hiderestock)
   
   ret:tag('tr')
   local colspan = yesno(hideimage) and 1 or 2
   ret:tag('th'):attr('colspan', colspan):wikitext('Item'):done()
   if not(yesno(hidestock)) then
       ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Number
in stock'):done() end if not(yesno(hiderestock)) then ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Restock
time'):done() end if not(yesno(hidesell)) then ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Price
sold at'):done() end if not(yesno(hidebuy)) then ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Price
bought at'):done() end if not(yesno(hidege)) then ret:tag('th'):attr('data-sort-type', 'number'):wikitext('GE
price
'):done() end local i = 1 while args['column' .. i] do ret:tag('th'):attr('data-sort-type', 'number'):wikitext(args['column' .. i]):done() i = i+1 end ret:done()

return '

' .. tostring(ret) end return p