FANDOM


 
-- <pre>
local p = {}
local titleParts = require("Module:TitleParts")
 
-- See https://springrts.com/wiki/Lua_Performance
local uslower = mw.ustring.lower
local usmatch = mw.ustring.match
local usfind = mw.ustring.find
local usgsub = mw.ustring.gsub
local usrep = mw.ustring.rep
local uslen = mw.ustring.len
 
local txttrim = mw.text.trim
local txtsplit = mw.text.split
 
local tableconcat = table.concat
local tableinsert = table.insert
 
function toLower(str)
    if str == nil then
        return nil
    end
 
    return uslower(tostring(str))
end
 
function toNum(str, def)
	if type(str) == "number" then
		return str
	elseif str == '' then
		return nil
	elseif type(str) == "boolean" then
		return (str == true and 1 or 0)
	end
 
	local isNum = (type(str) == "string" and (txttrim(tostring(str)):match('^([%d]+%.?[%d]*)$')) or nil)
 
	if isNum ~= nil then
		return tonumber(isNum)
	end
 
	if def == true and str ~= nil then
		return tonumber(str)
	end
 
	if type(def) == "number" or type(def) == "string" then
		return tonumber(def)
	end
 
	return str
end
 
local testFrame = {
    -- Child frame's arguments (change as needed)
    args = {
		link = 'Wookieepedia:Star_Wars:_Uprising_Super_Walkthrough/Ndaya', forceLegends = '1'
	},
 
    getParent = function()
        -- Parent frame's arguments (change as needed)
        local pArgs = {}
 
        return { args = pArgs }
    end
}
 
 
local selectedBGColor = '002e54'
local notSelectedBGColor = 'd8e9fc'
local redLinkTabBGColor = 'be003c'
 
 
local tabTata = {
    canon = {
        id = 'canontab-canon',
        selected = {
            image = 'Tab-canon-white.png',
            alt = 'This article covers the Canon version of this subject.'
        },
        notSelected = {
            image = 'Tab-canon-black.png',
            alt = 'Click here for Wookieepedia\'s article on the Canon version of this subject.'
        }
    },
    legends = {
        id = 'canontab-legends',
        selected = {
            image = 'Tab-legends-white.png',
            alt = 'This article covers the Legends version of this subject.'
        },
        notSelected = {
            image = 'Tab-legends-black.png',
            alt = 'Click here for Wookieepedia\'s article on the Legends version of this subject.'
        }
    },
    uprising = {
        id = 'canontab-uprising',
        selected = {
            image = 'StarWarsUprisingLogoTransparent.png',
            alt = 'This article covers the Star Wars: Uprising game information for this subject.'
        },
        notSelected = {
            image = 'StarWarsUprisingLogoTransparent_Invert.png',
            alt = 'Click here for Wookieepedia\'s article on the Star Wars: Uprising version of this subject.'
        }
    },
}
 
function p.genSelectedTab(options)
    local backgroundColor = (options.redLink and redLinkTabBGColor) or (options.selected and selectedBGColor or notSelectedBGColor)
 
    local thisTab = options.type and tabTata[options.type] or {}
 
    local id = options.id or thisTab.id or ''
    local imageFileName = (options.selected ~= true and not options.redLink and thisTab.notSelected.image or thisTab.selected.image)
    local alt = (options.selected ~= true and thisTab.notSelected.alt or thisTab.selected.alt or thisTab.alt or '') .. (options.redLink and ' (page does not exist)' or '')
 
    local tdStyle = 'padding:0 0 5px 0;background-color:#' .. backgroundColor .. ';line-height:0.95em;font-size:150%;font-weight:bold;width:20px;vertical-align:top;'
 
    local rClass = 'display-block std-background-', backgroundColor, ' padding-0 margin-top-0px margin-bottom-0px'
 
 
    local image = ''
 
 
 
    if options.type == 'uprising' then
        image = tableconcat({
			'<div class="class-style display-inline-block width-76-px height-35-px margin-left-auto margin-right-auto margin-top-0 margin-bottom-0 thumb-no-margin" style="display:block;width:76px;height:35px;margin:0 auto;">',
                '[[File:', imageFileName, '|frameless|link=', options.link, '|alt=', alt, '|', alt, '|x35px]]',
            '</div>'})
    else
        image = tableconcat({'[[File:', imageFileName, '|frameless|link=', options.link, '|alt=', alt, '|', alt, '|170x35px]]'})
    end
 
    return tableconcat({
        '<td id="canontab-uprising" style="', tdStyle, '" class="class-style std-background-', backgroundColor, ' vertical-align-top padding-0 width-170-px padding-bottom-5px">',
            '<span class="content-bg rtop class-style std-background-white display-block padding-0 margin-0" style="background:#ffffff;">',
                '<span class="r1 ', rClass,' height-1-px margin-left-5px margin-right-5px" style="background:#', backgroundColor, ';"></span>',
                '<span class="r2 ', rClass,' height-1-px margin-left-3px margin-right-3px" style="background:#', backgroundColor, ';"></span>',
                '<span class="r3 ', rClass,' height-1-px margin-left-2px margin-right-2px" style="background:#', backgroundColor, ';"></span>',
                '<span class="r4 ', rClass,' height-2-px margin-left-1px margin-right-1px" style="background:#', backgroundColor, ';"></span>',
            '</span>',
            '<div class="class-style display-block width-170-px height-30-px" style="display:block;width:170px;height:30px;">',
                image,
            '</div>',
        '</td>'
    })
end
 selected = 'lfwd'
	if selected == 'canon' and canonAdded then
		if linkTitleParts and linkTitleParts.exists() then
			addCat('Canon articles with Star Wars: Uprising counterparts')
		end
		if legendsAdded and legendsTitleParts and legendsTitleParts.exists() then
			addCat('Canon articles with Legends counterparts')
		end
	end
 
	if selected == 'legends' and legendsAdded then
		if linkTitleParts and linkTitleParts.exists() then
			addCat('Legends articles with Star Wars: Uprising counterparts')
		end
		if canonAdded and canonTitleParts and canonTitleParts.exists() then
			addCat('Legends articles with canon counterparts')
		end
	end
 
	if selected == 'lfwd' then
		if canonAdded and canonTitleParts and canonTitleParts.exists() then
			addCat('LFwD articles with canon counterparts')
		end
		if legendsAdded and legendsTitleParts and legendsTitleParts.exists() then
			addCat('LFwD articles with legends counterparts')
		end
	end
 
	tableinsert(out, tableconcat(cats))
 
 
    return tableconcat(out)
 
function getParentFrame(frame)
    return frame:getParent()
end
function Try_getParentFrame(frame)
    local success,result = pcall(getParentFrame, frame)
 
    if success == false or result == nil or result.args == nil then
        return nil
    end
 
    return result
end
 
 
function _getArgs(frame)
    local args = {}
    local argNames = {}
    local parentFrame = nil
    local parentFrame2 = nil
 
    frame = frame or mw.getCurrentFrame()
 
    local processArgList = function(_args)
        for k,v in pairs(_args) do
            local lKey = toLower(k)
            argNames[lKey] = k
 
            if v ~= nil and txttrim(tostring(v)) ~= '' then
                local isNum = txttrim(tostring(v)):match('^(%d+)$')
                if isNum ~= nil then
                    args[lKey] = tonumber(isNum)
                elseif type(v) == 'string' then
                    args[lKey] = txttrim(v)
                else
                    args[lKey] = v
                end
            end
        end
    end
 
    if frame then
        if frame.args ~= nil then
            processArgList(frame.args)
        end
        parentFrame = Try_getParentFrame(frame)
        if parentFrame == nil and frame.args == nil then
            processArgList(frame)
        end
    end
 
    if parentFrame and parentFrame.args ~= nil then
        processArgList(parentFrame.args)
    end
 
    local getValue = function(name, def)
        local key = toLower(name)
 
        if not args[key] then
            return def
        end
 
        return args[key]
    end
 
	local setValue = function(name, val)
		local key = toLower(name)
		if key ~= nil then
			args[key] = val
			if argNames[key] == nil and argNames[name] == nil then
				argNames[key] = name
			end
		end
		return val
	end
 
    return getValue, setValue, args, argNames
end
 
function p.main(frame)
	local getValue, setValue, args, argNames = _getArgs(frame)
	return p.getTabs(getValue, setValue, args, argNames)
end
 
function p._debug(frame)
    local result = p.main(testFrame)
    mw.log(result)
    return result
end
 
return p
-- </pre>
-- <noinclude>[[Category:Templates for Star Wars: Uprising]]</noinclude>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.