Module:CharTree: Difference between revisions

From Elwiki
No edit summary
No edit summary
Line 13: Line 13:
             char = args[path_iter .. 'x' .. job_iter] or 'Unreleased';
             char = args[path_iter .. 'x' .. job_iter] or 'Unreleased';
             nopath = 'no' .. path_iter .. 'path';
             nopath = 'no' .. path_iter .. 'path';
            if args[nopath] ~= nil and args[nopath] ~= 'true' then
                char = args[nopath]
            end
           
             nopathnojob = 'no' .. path_iter .. 'x' .. job_iter;
             nopathnojob = 'no' .. path_iter .. 'x' .. job_iter;
             entry = char_tree:tag('div'):addClass('char-banner-tree-image')
             entry = char_tree:tag('div'):addClass('char-banner-tree-image')


             if char ~= 'Unreleased' then
             if char ~= 'Unreleased' then
                 file_name = char:gsub(':', '');
                 file_name = 'Icon - ' .. char:gsub(':', '');
                 link = '|link=' .. char
                 link = '|link=' .. char
             end
             end
Line 31: Line 26:
             end
             end


             -- image_arg = args['image' .. path_iter .. 'x' .. job_iter]
             image_arg = args['image' .. path_iter .. 'x' .. job_iter]


             -- if image_arg ~= nil then
             if image_arg ~= nil then
            --    file_name = image_arg
                file_name = image_arg
             -- end
             end


             entry:attr('data-class-name', char):wikitext('[[File:Icon - ' .. file_name .. '.png' .. link .. ']]');
             entry:attr('data-class-name', char):wikitext('[[File:' .. file_name .. '.png' .. link .. ']]');


             if (args[nopath] ~= nil) then
             if (args[nopath] ~= nil) then

Revision as of 01:15, 28 August 2022

Documentation for this module may be created at Module:CharTree/doc

require('Module:CommonFunctions')
local getArgs = require('Module:Arguments').getArgs
local p = {}

-- Main process
function p.main(frame)
    local args = getArgs(frame);
    local char_tree = mw.html.create('div'):addClass('char-banner-tree'):attr('data-base', args[1])
    local out = {};
    local char, file_name, link, nopath, nopathnojob, entry, image_arg;
    for job_iter=1,3,1 do
        for path_iter=1,4,1 do
            char = args[path_iter .. 'x' .. job_iter] or 'Unreleased';
            nopath = 'no' .. path_iter .. 'path';
            nopathnojob = 'no' .. path_iter .. 'x' .. job_iter;
            entry = char_tree:tag('div'):addClass('char-banner-tree-image')

            if char ~= 'Unreleased' then
                file_name = 'Icon - ' .. char:gsub(':', '');
                link = '|link=' .. char
            end
            
            if (args[nopath] ~= nil or args[nopathnojob] ~= nil) then
                file_name = 'Dunno';
                link = '|link=' .. char;
            end

            image_arg = args['image' .. path_iter .. 'x' .. job_iter]

            if image_arg ~= nil then
                file_name = image_arg
            end

            entry:attr('data-class-name', char):wikitext('[[File:' .. file_name .. '.png' .. link .. ']]');

            if (args[nopath] ~= nil) then
                entry:attr('data-unreleased', 'true');
            end

            if (args[nopathnojob] ~= nil) then
                entry:addClass('disable-image-link');
                entry:attr('data-unreleased', 'true');
            end
        end
    end
    
    return tostring(char_tree);

end

return p