聖火降魔錄 Wiki
Advertisement

此模块的文档可以在Module:Common/doc创建

--[[ This module contains common objects that could be used by many other modules
     Therefore it cannot be invoked by templates ]]
-------------------------------------------------------------------------------
--[[
Functions:
+ setDefault(argument, value): Set default 'value' to argument, if 'value' is not defined, argument will be default to empty string.

+ colorLink(argument):  fix link and font color for games that have light BG.

+ isnotNil(argument): return true if not nil, else false

+ capitalize(argument): capitalize string
]]
-------------------------------------------------------------------------------
local common = {}

function common.setDefault(arg, val)
    if(arg == nil) then
        if(val == nil) then arg = ''
        else arg = val end
    end
    return arg
end

function common.colorLinks(arg)
    local class
    local games = {
        'fe6', 'fe8', 'fe9', 'fe10', 'fe12', 'fe13', 'fe14',
        'feh', 'ts2', 'tms', 'smt'
        }
    
    for i = 0, #games do
        if(arg == games[i]) then
            class = 'light'
            break
        else class = ''
        end
    end
    return class
end

function common.isnotNil(arg)
    if(arg ~= nil) then return true
    else return false end
end

function common.capitalize(arg)
    -- in progress
end

return common
--[[Category:Modules]]
Advertisement