This is an old revision of this page, as edited by Zackmann08(talk | contribs) at 19:57, 17 September 2018(←Created page with 'require('Module:No globals') local getArgs = require('Module:Arguments').getArgs local navbar = require('Module:Navbar')._navbar local p = {} function p.createT...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.Revision as of 19:57, 17 September 2018 by Zackmann08(talk | contribs)(←Created page with 'require('Module:No globals') local getArgs = require('Module:Arguments').getArgs local navbar = require('Module:Navbar')._navbar local p = {} function p.createT...')
This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing.
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
require('Module:No globals')localgetArgs=require('Module:Arguments').getArgslocalnavbar=require('Module:Navbar')._navbarlocalp={}functionp.createTable(frame,args)ifnotargsthenargs=getArgs(frame)endlocalroot=mw.html.create()root=root:tag('table'):addClass('wikitable'):addClass('sortable'):addClass('plainrowheaders'):addClass('jquery-tablesorter'):css('text-align','center')-- add the header rowroot:tag('tr'):tag('th'):wikitext('Rank'):tag('th'):wikitext('Nation'):tag('th'):addClass('headerSort'):css('width','6em'):css('background','gold'):wikitext('Gold'):tag('th'):addClass('headerSort'):css('background','silver'):wikitext('Silver'):tag('th'):addClass('headerSort'):css('background','#c96'):wikitext('Bronze'):tag('th'):wikitext('Total')-- enumerate the rowslocalrowNums={}fork,vinpairs(args)dok=''..klocalnum=k:match('^nation(%d+)$')ifnumthentable.insert(rowNums,tonumber(num))endendtable.sort(rowNums)-- for k,v in pairs(args) do-- k = ''..k-- local num = k:match('^nation(%d+)$') -- if num then -- root:tag('tr')-- :tag('td')-- :tag('td')-- :wikitext(v)-- end-- end-- For finding the matching args...-- make num equal to the current number (i.e. 1 for nation 1)-- then merge it and find the corresponding argument: mw.logObject(rowNums)fori,numinipairs(rowNums)dolocalnation=args['nation'..num]localgold=args['gold'..num]localsilver=args['silver'..num]localbronze=args['bronze'..num]root:tag('tr'):tag('td'):wikitext('-'):tag('td'):wikitext(nation):tag('td'):wikitext(gold):tag('td'):wikitext(silver):tag('td'):wikitext(bronze):tag('td'):wikitext(tonumber(gold)+tonumber(silver)+tonumber(bronze))endreturntostring(root)endreturnp