Module:Schedule
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Schedule/doc
local p = {}
local lib = require('Module:Feature')
local Tabber = require('Module:Tabber')._main
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = { 'Template:Schedule' }
})
args.character = args.character or mw.title.getCurrentTitle().rootText
return p._main(args)
end
function p._main(args)
local out = mw.html.create()
local tabs = {}
local i = '1'
while lib.isNotEmpty(args[i .. '_name']) and lib.isNotEmpty(args[i .. '_1_time']) and lib.isNotEmpty(args[i .. '_1_info']) do
local _table = mw.html.create('table'):addClass('fandom-table article-table tdc1 tdbg1')
if i == '1' and lib.isEmpty(args['2_name']) then _table:tag('caption'):wikitext(args[i .. '_name']) end
--header
local tr = _table:tag('tr')
tr:tag('th'):wikitext('Time')
tr:tag('th'):wikitext('Activity')
local y = '1'
while lib.isNotEmpty(args[i .. '_' .. y .. '_time']) and lib.isNotEmpty(args[i .. '_' .. y .. '_info']) do
local tr = _table:tag('tr')
local _time = lib.split(args[i .. '_' .. y .. '_time'], ':')
tr:tag('td'):wikitext(string.format('%02d', _time[1]),':', string.format('%02d', (_time[2] or '00')))
tr:tag('td'):wikitext(args[i .. '_' .. y .. '_info'])
y = tostring(tonumber(y)+1)
end
tabs['content' .. i] = _table
tabs['label' .. i] = args[i .. '_name']
i = tostring(tonumber(i)+1)
end
if not tabs['content1'] then
return 'No information about ' .. args.character .. '\'s schedule.'
else
return Tabber(tabs)
end
end
return p