This is the current revision of this page, as edited by JohnFromPinckney(talk | contribs) at 13:10, 3 May 2023(Restored revision 794628147 by JJMC89 (talk): Rv clueless trail-and-error poking; sorry for any disruption.). The present address (URL) is a permanent link to this version.Revision as of 13:10, 3 May 2023 by JohnFromPinckney(talk | contribs)(Restored revision 794628147 by JJMC89 (talk): Rv clueless trail-and-error poking; sorry for any disruption.)
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.
localp={}localfunctionisnotempty(s)returnsands:match('^%s*(.-)%s*$')~=''endfunctionp.table(frame)localargs=(frame.args[1]~=nil)andframe.argsorframe:getParent().argslocalcolsifisnotempty(args['4thcoltitle'])andisnotempty(args['3rdcoltitle'])thencols=4elseifisnotempty(args['3rdcoltitle'])thencols=3elsecols=2end-- compute the maximum cell indexlocalcellcount=0fork,vinpairs(args)doiftype(k)=='number'andisnotempty(v)thencellcount=math.max(cellcount,k)endend-- compute the number of rowslocalrows=math.ceil(cellcount/cols)-- create the root tablelocalroot=mw.html.create('table')root:addClass('wikitable'):addClass('sortable'):css('font-size','95%')-- add the header rowlocalrow=root:tag('tr')localcell=row:tag('th')cell:wikitext('Airlines')cell=row:tag('th')cell:addClass('unsortable')cell:wikitext('Destinations')if(isnotempty(args['3rdcoltitle']))thencell=row:tag('th')cell:css('width','10%')if(isnotempty(args['3rdcolunsortable']))thencell:addClass('unsortable')endcell:wikitext(args['3rdcoltitle'])endif(isnotempty(args['4thcoltitle']))thencell=row:tag('th')if(isnotempty(args['4thcolunsortable']))thencell:addClass('unsortable')endcell:wikitext(args['4thcoltitle'])end-- loop over rowsforj=1,rowsdorow=root:tag('tr')fori=1,colsdocell=row:tag('td')if(i>2)thencell:css('text-align','center')endcell:wikitext(args[cols*(j-1)+i]or'')endend-- return the root tablereturntostring(root)endreturnp