Module:Sandbox/ChaoticShadow/SongDataLine: Difference between revisions

From TestWiki
Content added Content deleted
No edit summary
No edit summary
Line 44: Line 44:
addCell(args.id or args[1], '-1')
addCell(args.id or args[1], '-1')
addCell(args[2] or args.song, '')
addCell(args.song or args[2] , '')
addCell(args[3] or args.producer, '')
addCell(args[3] or args.producer, '')
addCell(args[4] or units[args.unit], '', {
addCell(args[4] or units[args.unit], '', {

Revision as of 22:43, 14 May 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

local units = {
	vs       = 'VIRTUAL SINGER',
	ln       = 'Leo/need',
	mmj      = 'MORE MORE JUMP!',
	vbs      = 'Vvid BAD SQUAD',
	wxs      = 'Wonderlands × Showtime',
	['25ji'] = '25-ji, Night Code de.',
	mix      = 'Mixed'
}
local colors = {
	vs       = { bg = '#00CDBA', text = '#FFFFFF' },
	ln       = { bg = '#4455DD', text = '#FFFFFF' },
	mmj      = { bg = '#6CCB20', text = '#FFFFFF' },
	vbs      = { bg = '#EE1166', text = '#FFFFFF' },
	wxs      = { bg = '#FF9900', text = '#FFFFFF' },
	['25ji'] = { bg = '#884499', text = '#FFFFFF' },
	mix      = { bg = '#81ebee', text = '#000000' }
}
local palette = { bg = 'none', text = '#000000' }

local function addCell(value, default, css)
	local content = value or default
	
	root:tag('td')
		:css(css or {})
		:wikitext(content)
end

function p.main(frame)
	args = getArgs(frame)
	
	if args.unit and colors[args.unit] then
		palette = colors[args.unit]
	end
	
	root = mw.html.create('tr')
	
	addCell(args.id or args[1], '-1')
	addCell(args.song or args[2] , '')
	addCell(args[3] or args.producer, '')
	addCell(args[4] or units[args.unit], '', {
		['background-color']= palette.bg,
		['color']= palette.text
	})
	addCell(args[5] or args.mv, '✕')
	addCell(args[6] or args.date, '')
	addCell(args[7] or args.bpm, '')
	addCell(args[8] or args.duration, '')
	
	local diffs = mw.text.split(args.difficulties or '', ',')
	for i=1,5,1 do
		addCell(diffs[i], '')
	end
	
	local notes = mw.text.split(args.notes or '', ',')
	for i=1,5,1 do
		addCell(notes[i], '')
	end
	
	return tostring(root)
end

return p