Module:Sandbox/ChaoticShadow/SongDataLine: Difference between revisions

From TestWiki
Content deleted Content added
No edit summary
No edit summary
Line 41: Line 41:
end
end
for i=1,tbls.jp.base,1 do
-- for i=1,tbls.jp.base,1 do
root:tag('tr'):tag('td'):wikitext(tbls.jp.tb[i])
-- root:tag('tr'):tag('td'):wikitext(tbls.jp.tb[i])
end
-- end


return tostring(root) .. mw.dumpObject(tbls) .. others .. mw.dumpObject(args)
return tostring(root) .. mw.dumpObject(tbls) .. others .. mw.dumpObject(args)

Revision as of 02:01, 24 June 2021

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'):class('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 == base1 then
				base1 = base1 + 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.base,1 do
	-- 	root:tag('tr'):tag('td'):wikitext(tbls.jp.tb[i])
	-- end

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

return p