Module:InfoboxCharacter: Difference between revisions
From Elwiki
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
end | end | ||
local infobox = mw.html.create('div'):addClass('infobox-new'):addClass('infobox-character'); | |||
infobox:tag('div'):addClass('infobox-new-header'):css('background-color', args.color:gsub("%#", "#")):css( | |||
local infobox = mw.html.create('div'):addClass('infobox-character'); | |||
infobox:tag('div'):addClass('infobox- | |||
'color', args.textcolor):wikitext(args.class); | 'color', args.textcolor):wikitext(args.class); | ||
infobox:tag('div'):addClass('infobox- | infobox:tag('div'):addClass('infobox-new-image'):wikitext(args.image); | ||
function addField(param, field_name) | -- Adds a normal row | ||
function addField(param, field_name, double) | |||
if args[param] ~= nil then | if args[param] ~= nil then | ||
local row = infobox:tag('div'):addClass('infobox-row'); | local row = infobox:tag('div'):addClass('infobox-row'); | ||
Line 34: | Line 32: | ||
end | end | ||
end | end | ||
if double == true then addField2(param, field_name) end; | |||
end | end | ||
-- Adds a row with 2 columns | |||
function addField2(param, field_name) | function addField2(param, field_name) | ||
if args[param .. '1'] ~= nil and args[param .. '2'] ~= nil then | if args[param .. '1'] ~= nil and args[param .. '2'] ~= nil then | ||
Line 54: | Line 54: | ||
addField('class'); | addField('class'); | ||
addField2('classes', 'Classes'); | addField2('classes', 'Classes'); | ||
addField('weapon' | addField('weapon', nil, true); | ||
addField('age', nil, true); | |||
addField('age' | addField('race', nil, true); | ||
addField('Birth', 'Birthday', true); | |||
addField('race' | addField('Height', nil, true); | ||
addField('Weight', nil, true); | |||
addField('Birth', 'Birthday | addField('Blood', 'Blood Type', true); | ||
addField('Height' | |||
addField('Weight' | |||
addField('Blood', 'Blood Type | |||
addField('ESP', '[[El Search Party Collection|ESP Collection]]'); | addField('ESP', '[[El Search Party Collection|ESP Collection]]'); | ||
addField('tree', 'Class Tree'); | addField('tree', 'Class Tree'); | ||
addField('VA', 'Voice Actors | addField('VA', 'Voice Actors', true); | ||
addField('RD', 'Release Date'); | addField('RD', 'Release Date'); | ||
addField('TRD', 'Transcendence Release Date'); | addField('TRD', 'Transcendence Release Date'); |
Revision as of 22:27, 28 April 2022
Documentation for this module may be created at Module:InfoboxCharacter/doc
require('Module:CommonFunctions')
local getArgs = require('Module:Arguments').getArgs
local p = {}
-- Main process
function p.main(frame)
local args = getArgs(frame);
if args.textcolor == nil then
args.textcolor = 'white';
else
args.textcolor = 'black';
end
local infobox = mw.html.create('div'):addClass('infobox-new'):addClass('infobox-character');
infobox:tag('div'):addClass('infobox-new-header'):css('background-color', args.color:gsub("%#", "#")):css(
'color', args.textcolor):wikitext(args.class);
infobox:tag('div'):addClass('infobox-new-image'):wikitext(args.image);
-- Adds a normal row
function addField(param, field_name, double)
if args[param] ~= nil then
local row = infobox:tag('div'):addClass('infobox-row');
if field_name == nil then
field_name = titleCase(param);
end
row:tag('div'):addClass('infobox-row-title'):wikitext(field_name);
if (param == 'video' or param == 'tree' or param == 'stats') then
row:tag('div'):addClass('infobox-row-content'):wikitext(args[param]);
else
row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(args[param]);
end
end
if double == true then addField2(param, field_name) end;
end
-- Adds a row with 2 columns
function addField2(param, field_name)
if args[param .. '1'] ~= nil and args[param .. '2'] ~= nil then
local row = infobox:tag('div'):addClass('infobox-row'):addClass('infobox-double-row');
if field_name == nil then
field_name = titleCase(param):gsub("%d+", '');
end
row:tag('div'):addClass('infobox-row-title'):wikitext(field_name);
row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(args[param .. '1']);
row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(args[param .. '2']);
end
end
if (args.name1 == nil and args.name2 == nil) then
addField('name', 'Full Name');
end
addField2('name', 'Full Name');
addField('class');
addField2('classes', 'Classes');
addField('weapon', nil, true);
addField('age', nil, true);
addField('race', nil, true);
addField('Birth', 'Birthday', true);
addField('Height', nil, true);
addField('Weight', nil, true);
addField('Blood', 'Blood Type', true);
addField('ESP', '[[El Search Party Collection|ESP Collection]]');
addField('tree', 'Class Tree');
addField('VA', 'Voice Actors', true);
addField('RD', 'Release Date');
addField('TRD', 'Transcendence Release Date');
addField('MRD', 'Master Class Release Date');
addField('theme');
addField('video', 'Job Path Story Movie');
addField('stat', 'Statistics');
return tostring(infobox);
end
return p