Module:Test
More actions
This documentation is transcluded from Module:Test/doc. Changes can be proposed in the talk page.
This module is unused.
This module is neither invoked by a template nor required/loaded by another module. If this is in error, make sure to add
{{Documentation}}
/{{No documentation}}
to the calling template's or parent's module documentation.Function list |
---|
L 8 — p.hello L 29 — p.get_table L 39 — p._format_date L 50 — p._unknown |
require("strict");
local tables = require('Module:Tables')
local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo
local p = {}
function p.hello( frame )
local antable = mw.html.create('table'):addClass('wikitable sortable')
local amusementdata = p.get_table()
local data = {{{text = 'Name', tag = 'th'}, {text = 'Location', tag = 'th'}, {text = 'Opened', tag = 'th'}}}
for i=1,#amusementdata do
data[i+1] = {}
data[i+1][1] = {text = '[[' .. amusementdata[i]._pageTitle .. '|' .. amusementdata[i].Name .. ']]'}
data[i+1][2] = {text = amusementdata[i].Location}
if (amusementdata[i].Opened == nil) then
data[i+1][3] = p._unknown()
else
data[i+1][3] = {
attr = { ["data-sort-value"] = amusementdata[i].Opened },
text = p._format_date(amusementdata[i].Opened, amusementdata[i].Opened__precision, frame)
}
end
end
tables._table(antable, data)
return tostring(antable)
end
function p.get_table()
local tables = 'Amusement_Parks,'
local fields = '_pageTitle,Name,Location,Opened,Opened__precision'
local args = {
limit = 100
}
local results = cargo.query( tables, fields, args )
return results
end
function p._format_date(datevalue, precision, frame)
local lang = mw.language.getContentLanguage()
if (precision == '1') then
return frame:callParserFunction('#dateformat', lang:formatDate('F j, Y', datevalue))
elseif (precision == '2') then
return lang:formatDate('F Y', datevalue)
elseif (precision == '3') then
return lang:formatDate('Y', datevalue)
end
end
function p._unknown()
return {
text = 'Unknown',
attr = { ["data-sort-value"] = 'zzzzzzz' },
css = {
["background"] = '#ececec',
["vertical-align"] = 'middle',
["text-align"] = 'center'
},
class = "unknown table-unknown"
}
end
return p