Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  














Module:Airport destination list






العربية
Basa Bali

Català
Dansk
ދިވެހިބަސް
Ελληνικά
فارسی
Français
Gaeilge


ि
Ilokano
Bahasa Indonesia
Kurdî
ि


مصرى



Qaraqalpaqsha
Simple English
سنڌي
Slovenščina
کوردی
Српски / srpski
ி
 
Türkçe
اردو
Tiếng Vit
Winaray


 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


Implements {{Airport destination list}}.

Usage

{{#invoke:Airport destination list|table}}

local p = {}

local function isnotempty(s)
 return s and s:match( '^%s*(.-)%s*$' ) ~= ''
end
 
function p.table(frame)
 local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
 local cols
 if isnotempty(args['4thcoltitle']) and isnotempty(args['3rdcoltitle']) then
  cols = 4
 elseif isnotempty(args['3rdcoltitle']) then cols = 3
 else cols = 2
 end

 -- compute the maximum cell index
 local cellcount = 0
 for k, v in pairs( args ) do
  if type( k ) == 'number' and isnotempty(v) then
   cellcount = math.max(cellcount, k)
  end
 end
 -- compute the number of rows
 local rows = math.ceil(cellcount / cols)

 -- create the root table
 local root = mw.html.create('table')
 root
  :addClass('wikitable')
  :addClass('sortable')

 -- add the header row
 local row = root:tag('tr')
 local cell= row:tag('th')
 cell:wikitext('Airlines')
 cell= row:tag('th')
 cell:addClass('unsortable')
 cell:wikitext('Destinations')
 if (isnotempty(args['3rdcoltitle'])) then
  cell= row:tag('th')
  cell:css('width','10%')
  if (isnotempty(args['3rdcolunsortable'])) then
   cell:addClass('unsortable')
  end
  cell:wikitext(args['3rdcoltitle'])
 end
 if (isnotempty(args['4thcoltitle'])) then
  cell= row:tag('th')
  if (isnotempty(args['4thcolunsortable'])) then
   cell:addClass('unsortable')
  end
  cell:wikitext(args['4thcoltitle'])
 end
 -- loop over rows
 for j=1,rows do
  row = root:tag('tr')
  for i=1,cols do
   cell= row:tag('td')
   if (i > 2) then cell:css('text-align','center') end
   cell:wikitext(args[cols*(j - 1) + i] or '')
  end
 end
 -- return the root table
 return tostring(root)
end

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Airport_destination_list&oldid=1165180038"

Category: 
Modules subject to page protection
Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 13 July 2023, at 14:17 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki