Module:StoreTableHeader: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Swap hidebuy and hidesell) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
-------------------------- | |||
-- Module for [[Template:StoreTableHeader]] | |||
-- | |||
-- | |||
------------------------ | |||
local p = {} | local p = {} | ||
Line 7: | Line 13: | ||
function p.main(frame) | function p.main(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local currency,namenotes,smw,hideimage,hidebuy,hidesell = params.defaults{ | local currency,namenotes,smw,hideimage,hidebuy,hidesell, hidemembers = params.defaults{ | ||
{args.currency,'Gold'}, | {args.currency,'Gold'}, | ||
{args.namenotes,''}, | {args.namenotes,''}, | ||
Line 14: | Line 20: | ||
{args.hidebuy,'no'}, | {args.hidebuy,'no'}, | ||
{args.hidesell,'no'}, | {args.hidesell,'no'}, | ||
{args.hidelevel, 'no'}, | |||
{args.hidemembers, 'no'}, | |||
} | } | ||
var.vardefine('Currency', currency) | var.vardefine('Currency', currency) | ||
Line 21: | Line 29: | ||
var.vardefine('hideBuy', hidebuy) | var.vardefine('hideBuy', hidebuy) | ||
var.vardefine('hideSell', hidesell) | var.vardefine('hideSell', hidesell) | ||
var.vardefine('hideLevel', hidelevel) | |||
var.vardefine('hideMembers', hidemembers) | |||
local ret = mw.html.create('') | local ret = mw.html.create('') | ||
Line 27: | Line 37: | ||
local colspan = yesno(hideimage) and 1 or 2 | local colspan = yesno(hideimage) and 1 or 2 | ||
ret:tag('th'):attr('colspan', colspan):wikitext('Item'):done() | ret:tag('th'):attr('colspan', colspan):wikitext('Item'):done() | ||
if not(yesno(hidebuy)) then | |||
ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Buyable for'):done() | |||
end | |||
if not(yesno(hidesell)) then | if not(yesno(hidesell)) then | ||
ret:tag('th'):attr('data-sort-type', 'number'):wikitext(' | ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Sellable for'):done() | ||
end | end | ||
if not(yesno( | if not(yesno(hidelevel)) then | ||
ret:tag('th'):attr('data-sort-type', ' | ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Level'):done() | ||
end | |||
if not(yesno(hidemembers)) then | |||
ret:tag('th'):attr('data-sort-type', 'string'):wikitext('Members only'):done() | |||
end | end | ||
local i = 1 | local i = 1 |
Latest revision as of 11:17, 4 April 2022
Documentation for this module may be created at Module:StoreTableHeader/doc
-------------------------- -- Module for [[Template:StoreTableHeader]] -- -- ------------------------ 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,smw,hideimage,hidebuy,hidesell, hidemembers = params.defaults{ {args.currency,'Gold'}, {args.namenotes,''}, {args.smw,'yes'}, {args.hideimage,'no'}, {args.hidebuy,'no'}, {args.hidesell,'no'}, {args.hidelevel, 'no'}, {args.hidemembers, 'no'}, } var.vardefine('Currency', currency) var.vardefine('NameNotes', namenotes) var.vardefine('smw', smw) var.vardefine('hideImage', hideimage) var.vardefine('hideBuy', hidebuy) var.vardefine('hideSell', hidesell) var.vardefine('hideLevel', hidelevel) var.vardefine('hideMembers', hidemembers) local ret = mw.html.create('') ret:tag('tr') local colspan = yesno(hideimage) and 1 or 2 ret:tag('th'):attr('colspan', colspan):wikitext('Item'):done() if not(yesno(hidebuy)) then ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Buyable for'):done() end if not(yesno(hidesell)) then ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Sellable for'):done() end if not(yesno(hidelevel)) then ret:tag('th'):attr('data-sort-type', 'number'):wikitext('Level'):done() end if not(yesno(hidemembers)) then ret:tag('th'):attr('data-sort-type', 'string'):wikitext('Members only'):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; margin:0;" cellpadding="2" cellspacing="0">' .. tostring(ret) end return p