FANDOM


local p = {}
local crossData = mw.loadData('Module:CrossSwitch/data')
 
function p.crossFormat(frame)
    local crossover= frame.args[1]
    local color=frame.args[2]
    local length= mw.ustring.len(crossover)
    local par={}
    if mw.ustring.find(crossover,'(',1,true)==nil
        then par=length
        else par=mw.ustring.find(crossover,'(',1,true)-2
    end
    local title=mw.ustring.sub(crossover,1,par)
 
    if crossover=="Flash vs. Arrow"
        then crossover="Flash vs. Arrow (crossover event)"
    end
    local hoverInfo={}
    if crossData[title]
        then hoverInfo="{{Hoverlink|"
            ..crossover
            .."|"
            ..title
            .."|"
            ..title
            .." ("
            ..crossData[title][1]
            ..")|color="
            ..color
            .."}}"
        else hoverInfo="{{Hoverlink|"
            ..frame.args[1]
            .."|"
            ..frame.args[1]
            .."|"
            ..frame.args[1]
            .." (Arrowverse Wiki)|color="
            ..color
            .."}}[["
            .."Category:Broken Cross link|"
            ..frame.args[1]
            .."]]"
    end
    return frame:preprocess(hoverInfo)
end
 
function p.getImage(frame)
    local crossover=frame.args[1]
    local length= mw.ustring.len(crossover)
    local par={}
    if mw.ustring.find(crossover,'(',1,true)==nil
        then par=length
        else par=mw.ustring.find(crossover,'(',1,true)-2
    end
    crossover=mw.ustring.sub(crossover,1,par)
    local image={}
    if crossData[crossover]
        then image=crossData[crossover][3]
            ..".png"
        else image="Wiki-wordmark.png"
    end
    return image
end
return p
Community content is available under CC-BY-SA unless otherwise noted.