Module:InfoboxProto: Difference between revisions

no edit summary
m (Protected "Module:InfoboxProto": Easily broken pages ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
No edit summary
Line 12: Line 12:


     local infobox = mw.html.create('div'):addClass('infobox-new');
     local infobox = mw.html.create('div'):addClass('infobox-new');
     infobox:tag('div'):addClass('infobox-new-header'):css('background-color', args.color:gsub("%#", "#")):css(
     infobox:tag('div'):addClass('infobox-new-header'):css('background-color', args.color:gsub("%#", "#")):wikitext(title);
        'color', args.textcolor):wikitext(title);
     local img = args.image;
     local img = args.image;
     if args.image == nil then
     if args.image == nil then
Line 21: Line 20:


     -- Adds a normal row
     -- Adds a normal row
     function addField(param, field_name, double)
     function addField(param, field_name, double, field_value)
         if args[param] ~= nil then
         if args[param] ~= nil or field_value ~= nil then
             local row = infobox:tag('div'):addClass('infobox-row');
             local row = infobox:tag('div'):addClass('infobox-row');
             if field_name == nil then
             if field_name == nil then
                 field_name = titleCase(param);
                 field_name = titleCase(param);
            end
            if field_value == nil then
                field_value = args[param];
             end
             end
             row:tag('div'):addClass('infobox-row-title'):tag('span'):wikitext(field_name);
             row:tag('div'):addClass('infobox-row-title'):tag('span'):wikitext(field_name);
             if (param == 'video' or param == 'tree' or param == 'stats') then
             if (param == 'video' or param == 'tree' or param == 'stats') then
                 row:tag('div'):addClass('infobox-row-content'):wikitext(args[param]);
                 row:tag('div'):addClass('infobox-row-content'):wikitext(field_value);
             else
             else
                 row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(args[param]);
                 row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(field_value);
             end
             end
         end
         end