Module:Sandbox/ChaoticShadow/Song

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

local p = {} local args = {}

local width = '330px'

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' }, niigo = { bg = '#884499', text = '#FFFFFF' } } local palette = { bg = '#FFAFA8', text = '#FFFFFF' }

local default_jacket = 'Dummyalbumart.png'

local units = { vs   = { image = 'Virtualsingerlogo.png', link = 'VIRTUAL SINGERS' }, ln   = { image = 'Leoneedlogo.png', link = 'Leo/need' }, mmj  = { image = 'MMJ_logo.png', link = 'MORE MORE JUMP!'}, vbs  = { image = 'Vivid_logo.png', link = 'Vivid BAD SQUAD'}, wxs  = { image = 'Wonderlandsxswowtimelogo.png', link = 'Wonderlands×Showtime' }, niigo = { image = '25ji-logo.png', link = '25-ji, Night Code de.' } }

local difficulties = { 'EASY', 'NORMAL', 'HARD', 'EXPERT', 'MASTER' } local diff_colors = { EASY  = '#6BD81B', NORMAL = '#5FB8E9', HARD  = '#FFA900', EXPERT = '#E23F6A', MASTER = '#BE3EE9' }

function p.info_box local song_info local function addRow(label, data) if data then local row = song_info:tag('tr') row:attr('id', label) row:tag('th') :css('colspan', 10) :wikitext(label) row:tag('td') :css('colspan', 20) :wikitext(data) end end local function addHeader(label) local row = song_info:tag('tr') row:tag('th') :attr('colspan', 30) :css({				['text-align'] = 'center',				['background-color'] = palette.bg,				color = palette.text			}) :wikitext(label) end local function addSongJacket(file) local image if file then image = file else image = default_jacket end local row = song_info:tag('tr') row:tag('td') :attr('colspan', 30) :css('text-align', 'center') :wikitext(				string.format( "",					image )			)	end local function addUnitRow(unit) if unit and units[unit] then local unit_info = units[unit] addRow(				'Unit',				string.format( "",					unit_info.image, unit_info.link )			)		end end song_info = mw.html.create('table') song_info :addClass('infobox') :css('width', width) addHeader(args.songtitle) addSongJacket(args.image) addRow('Original Song Title', args.kanji) addRow('Romaji', args.romaji) addRow('English', args.english) addHeader('Information') addRow('Original Singer(s)', args.singer) addRow('Producer(s)', args.producer) addRow('Composer', args.composer) addRow('Lyricist', args.lyricist) addUnitRow(args.unit) addRow('BPM', args.bpm) addRow('Duration', args.duration) addRow('MV', args.mv) return tostring(song_info) end

function p.data_box local song_data local function addHeader(label) song_data:tag('tr') :tag('th') :attr('colspan', 5) :css({					['text-align'] = 'center',					['background-color'] = palette.bg,					color = palette.text				}) :wikitext(label) end local function addDifficulties local row = song_data:tag('tr') for _, v in ipairs(difficulties) do			row:tag('th') :css({					['text-align'] = 'center',					['background-color'] = diff_colors[v],					color = '#FFFFFF',					width = '20%',					['border-radius'] = '5px'				}) :wikitext(v) end end local function addInformation(easy, normal, hard, expert, master) local arr = { easy, normal, hard, expert, master } local row = song_data:tag('tr') for i = 1,5,1 do			local text = 'N/A' if arr[i] then text = arr[i] end row:tag('td') :css('text-align', 'center') :wikitext(text) end end song_data = mw.html.create('table') song_data :addClass('infobox') :css('width', width) addHeader('Difficulty') addDifficulties addInformation(args.easy_difficulty, args.normal_difficulty, args.hard_difficulty, args.expert_difficulty, args.master_difficulty) addHeader('Notes') addDifficulties addInformation(args.easy_notes, args.normal_notes, args.hard_notes, args.expert_notes, args.master_notes) return tostring(song_data) end

function p.main(frame) args = getArgs(frame) if args.bg_color or args.text_color then if args.bg_color then palette.bg = args.bg_color end if args.text_color then palette.text = args.text_color end elseif args.unit and colors[args.unit] then palette = colors[args.unit] end return p.info_box .. p.data_box end

return p