Module:SkillNav: Difference between revisions

Undo revision 914017 by Ritsu (talk)
No edit summary
(Undo revision 914017 by Ritsu (talk))
Tag: Undo
 
(38 intermediate revisions by 2 users not shown)
Line 13: Line 13:
         end
         end
     end
     end
    local isForceNav = args.forcenav ~= nil;


     -- Prepare a table of skill types to display in the navigation.
     -- Prepare a table of skill types to display in the navigation.
     local skill_types;
     local skill_types;
     if (args.forcenav == nil) then
     if (not isForceNav) then
         skill_types = {
         skill_types = {{
             [1] = {
             ['name'] = args.l_hyper, -- 'Hyper Active',
                ['name'] = args.l_hyper, -- 'Hyper Active',
            ['abbr'] = 'HA'
                ['abbr'] = 'HA'
        }, {
            },
             ['name'] = args.l_secret, -- 'Secret Art',
             [2] = {
            ['abbr'] = 'SeA'
                ['name'] = args.l_secret, -- 'Secret Art',
        }, {
                ['abbr'] = 'SeA'
             ['name'] = args.l_special, -- 'Special Active',
            },
            ['abbr'] = 'SA'
             [3] = {
        }, {
                ['name'] = args.l_special, -- 'Special Active',
             ['name'] = args.l_active, -- 'Active',
                ['abbr'] = 'SA'
            ['abbr'] = 'A'
            },
        }, {
             [4] = {
             ['name'] = args.l_mod, -- 'Force Mod',
                ['name'] = args.l_active, -- 'Active',
            ['abbr'] = 'FC'
                ['abbr'] = 'A'
        }, {
            },
             ['name'] = args.l_buff, -- 'Buff',
             [5] = {
            ['abbr'] = 'B'
                ['name'] = args.l_mod, -- 'Force Mod',
        }, {
                ['abbr'] = 'FC'
             ['name'] = args.l_passive, -- 'Passive',
            },
            ['abbr'] = 'P'
             [6] = {
        }, {
                ['name'] = args.l_buff, -- 'Buff',
             ['name'] = args.l_demon, -- 'Manic Demon',
                ['abbr'] = 'B'
            ['abbr'] = 'MD'
            },
        }, {
             [7] = {
             ['name'] = '[[File:ForceIcon.png|16px]] ' .. args.l_demon, -- 'Manic Demon',
                ['name'] = args.l_passive, -- 'Passive',
            ['abbr'] = 'MDF'
                ['abbr'] = 'P'
        }, {
            },
             ['name'] = args.l_master, -- 'Master Skill',
             [8] = {
             ['abbr'] = 'MS'
                ['name'] = args.l_demon, -- 'Manic Demon',
        }, {
                ['abbr'] = 'MD'
            ['name'] = args.l_couple, -- 'Couple Skill',
            },
            ['abbr'] = 'Wed'
             [9] = {
        }, {
                ['name'] = '[[File:ForceIcon.png|16px]] ' .. args.l_demon, -- 'Manic Demon',
            ['name'] = args.l_row1, -- 'Row 1',
                ['abbr'] = 'MDF'
             ['abbr'] = 'row1'
             },
        }, {
             [10] = {
            ['name'] = args.l_row2, -- 'Row 2',
                ['name'] = args.l_master, -- 'Master Skill',
             ['abbr'] = 'row2'
                ['abbr'] = 'MS'
        }, {
             },
            ['name'] = args.l_row3, -- 'Row 3',
             [11] = {
            ['abbr'] = 'row3'
                ['name'] = args.l_couple, -- 'Couple Skill',
        }, {
                ['abbr'] = 'Wed'
            ['name'] = args.l_row4, -- 'Row 4',
             }
             ['abbr'] = 'row4'
         }
         }}
     else
     else
         -- Force Nav called, change skill types
         -- Force Nav called, change skill types
         skill_types = {
         skill_types = {{
             [1] = {
             ['name'] = args.l_force_active, -- 'Force Active',
                ['name'] = args.l_force_active, -- 'Force Active',
            ['abbr'] = 'FA3',
                ['abbr'] = 'FA3',
            ['type'] = 'third'
                ['type'] = 'third'
        }, {
            },
             ['name'] = args.l_force_passive, -- 'Force Passive',
             [2] = {
            ['abbr'] = 'FP3',
                ['name'] = args.l_force_passive, -- 'Force Passive',
            ['type'] = 'third'
                ['abbr'] = 'FP3',
        }, {
                ['type'] = 'third'
             ['name'] = args.l_force_active, -- 'Force Active',
            },
            ['abbr'] = 'FAM',
             [3] = {
            ['type'] = 'master'
                ['name'] = args.l_force_active, -- 'Force Active',
        }, {
                ['abbr'] = 'FAM',
             ['name'] = args.l_force_passive, -- 'Force Passive',
                ['type'] = 'master'
            ['abbr'] = 'FPM',
            },
            ['type'] = 'master'
             [4] = {
        }}
                ['name'] = args.l_force_passive, -- 'Force Passive',
                ['abbr'] = 'FPM',
                ['type'] = 'master'
            }
        }
     end
     end
   


     -- For backward compatibility. Do not remove until all pages are changed.
     -- For backward compatibility. Do not remove until all pages are changed.
Line 96: Line 92:


     -- Needed this to make a custom toggle.
     -- Needed this to make a custom toggle.
    local char_name_sanitized = '';
     local char_name = args.name;
     local char_name = args.name;
    local char_name_sanitized = '';
     if (isForceNav and args.parent_name ~= nil) then
     if (args.forcenav ~= nil and args.char ~= nil) then
         char_name = args.parent_name;
         char_name = 'ForceSkills-' .. args.char;
     end
     end
     for w in char_name:gmatch("%w+") do
     for w in char_name:gmatch("%w+") do
         char_name_sanitized = char_name_sanitized .. w;
         char_name_sanitized = char_name_sanitized .. w;
    end
    if (isForceNav and args.parent_name ~= nil) then
        char_name_sanitized = 'ForceSkills-' .. char_name_sanitized;
     end
     end


     -- Main block
     -- Main block
     local skill_nav = mw.html.create('div'):addClass('skill-nav');
     local skill_nav = mw.html.create('div'):addClass('skill-nav');
     if (args.forcenav ~= nil) then
     if (isForceNav) then
         skill_nav:addClass('force-nav');
         skill_nav:addClass('force-nav');
     end
     end
Line 113: Line 112:
     -- Header
     -- Header
     local header = skill_nav:tag('div'):addClass('skill-nav-header');
     local header = skill_nav:tag('div'):addClass('skill-nav-header');
     local colors = frame:expandTemplate{
     local colors;
        title = 'ColorSel',
        args = {'Character', args.char}
    };
     if (args.color ~= nil) then
     if (args.color ~= nil) then
         colors = args.color;
         colors = args.color;
    else
        colors = frame:expandTemplate{
            title = 'ColorSel',
            args = {'Character', args.char}
        };
     end
     end


Line 128: Line 129:
     end
     end


     header:attr('style', 'background-color:' .. colors)
     colors = colors:gsub('#', '#')
     if (args.forcenav == nil) then
   
    header:css('background-color', colors);
 
     if (args.is_guild ~= nil) then
        header:css({
            ['justify-content'] = 'center',
            ['background-color'] = colors
        });
    end
   
    if (not isForceNav and not args.is_guild) then
         header:wikitext(frame:expandTemplate{
         header:wikitext(frame:expandTemplate{
             title = 'Face',
             title = 'Face',
Line 135: Line 146:
                 args.char,
                 args.char,
                 args.pic,
                 args.pic,
                 link = args.name .. lang_suffix,
                 link = args.name,
                 scale = '0.75'
                lang = lang_suffix,
                 scale = '0.85'
             }
             }
         })
         })
Line 144: Line 156:
         args.l_name = args.name;
         args.l_name = args.name;
     end
     end
     if (args.forcenav == nil) then
     local headerText = header:tag('span'):addClass('skill-nav-title');
        header:tag('span'):wikitext('[[' .. args.name .. lang_suffix .. '|' .. args.l_name .. ']] - ' .. args.l_skills);
    if (not isForceNav) then
        headerText:wikitext('[[' .. args.name .. lang_suffix .. '|' .. args.l_name .. ']] - ' .. args.l_skills);
     else
     else
         header:tag('span'):wikitext(args.name);
         headerText:wikitext(args.name);
     end
     end


Line 156: Line 169:
     end
     end
     -- Make it collapsible if needed.
     -- Make it collapsible if needed.
     if (args.type ~= nil and string.find(args.type, 'mw%-collapsible') ~= nil) then
     if ((args.type ~= nil and string.find(args.type, 'mw%-collapsible') ~= nil) or args.collapsible ~= nil) then
         skill_nav_wrap:attr('id', 'mw-customcollapsible-' .. char_name_sanitized);
         skill_nav_wrap:attr('id', 'mw-customcollapsible-' .. char_name_sanitized);
         header:tag('div'):addClass('mw-customtoggle-' .. char_name_sanitized);
         header:tag('div'):addClass('mw-customtoggle-' .. char_name_sanitized);
    end
    if (args.collapsible ~= nil) then
        skill_nav_wrap:addClass('mw-collapsible');
    end
    if (args.collapsed ~= nil) then
        skill_nav_wrap:addClass('mw-collapsed');
     end
     end


Line 170: Line 189:
             local skills = split(args[abbr], ';');
             local skills = split(args[abbr], ';');
             if (abbr == 'Wed') then
             if (abbr == 'Wed') then
                 skills = {'CSZE.png', 'Extreme Heavenly Love' .. lang_suffix .. '|' .. args.l_couple_skill_name}
                 skills = {
                    'RelationSkill1.png', 'Extreme Heavenly Love' .. lang_suffix .. '|' .. args.l_couple_skill_name,
                    'RelationSkill2.png', 'Extreme Heavenly Bond' .. lang_suffix .. '|' .. args.l_soulmate_skill_name
                }
             end
             end
             -- Separate syntax for Master Skills: [Stage 1 image]; [Stage 2 image]; [Stage 3 image]; [Stage 4 image]; [skill name];
             -- Separate syntax for Master Skills: [Stage 1 image]; [Stage 2 image]; [Stage 3 image]; [Stage 4 image]; [skill name];
Line 177: Line 199:
             if (abbr == 'MS') then
             if (abbr == 'MS') then
                 mc_skill_name = skills[5];
                 mc_skill_name = skills[5];
                mc_skill_name = mc_skill_name:gsub('ä', 'a');
                 local l_mc_skill_name = skills[5];
                 local l_mc_skill_name = skills[5];
                 if (args.l_mc_skill_name ~= nil and is_localized) then
                 if (args.l_mc_skill_name ~= nil and is_localized) then
Line 204: Line 227:


             -- Append header fields on the left.
             -- Append header fields on the left.
             skill_nav_wrap:tag('div'):addClass('skill-nav-sub-head border-color tone-4'):wikitext(name .. mc_skill_name_head);
             skill_nav_wrap:tag('div'):addClass('skill-nav-sub-head border-color tone-4'):wikitext(name ..
                                                                                                      mc_skill_name_head);


             -- Get localized names
             -- Get localized names
Line 226: Line 250:
                     end
                     end
                     -- Remove stuff like (Elesis) or (Elsword) in skill display name
                     -- Remove stuff like (Elesis) or (Elsword) in skill display name
                     v_display_name = v_display_name:gsub("%s%(%w+%)", "");
                     v_display_name = v_display_name:gsub("%s%([%w%s%/]+%)", "");


                     -- Append the actual skills.
                     -- Append the actual skills.
Line 270: Line 294:
                 type = 'mw-collapsible mw-collapsed',
                 type = 'mw-collapsible mw-collapsed',
                 char = colors,
                 char = colors,
                 Color = args.color
                 Color = args.color,
                parent_name = args.name
             }
             }
         }
         }