Module:Sandbox/ChaoticShadow/SongDataLine

From TestWiki

Documentation for this module may be created at Module:Sandbox/ChaoticShadow/SongDataLine/doc

local getArgs = require('Module:Arguments').getArgs

local p = {}
local args = {}

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

local others = ''

function p.main(frame)
	args = getArgs(frame)
	
	tbl1 = {}
	base1 = 1
	tbl2 = {}
	tbls = {
		jp = {
			pattern = "^jp[0-9]+$",
			tb = {},
			base = 1
		},
		en = {
			pattern = "^en[0-9]+$",
			tb = {},
			base = 1
		}
	}
	
	for k,v in pairs(args) do
		if string.match(k, "^jp[0-9]+$") then
			ind = tonumber(string.match(k, "[0-9]+"))
			if ind == tbls.jp.base then
				tbls.jp.base = tbls.jp.base + 1
			end
			
			tbls.jp.tb[ind] = v
		elseif string.match(k, "^en[0-9]+$") then
		else
			others = others .. k .. ',' .. v .. '\n'
		end
	end
	
	for i=1,#tbls.jp.tb,1 do
		if tbls.jp.tb[i] then
			root:tag('tr'):tag('td'):wikitext(tbls.jp.tb[i])
		else
			break
		end
	end

	return tostring(root) .. mw.dumpObject(tbls) .. others .. mw.dumpObject(args) .. #tbls.jp.tb
end

return p