Module documentation
This module has various functions described below and should only be utilized on templates. To call a module in a template, insert {{#invoke:CrossSwitch|function name|various parameters}} onto the template.[ Data ]
Functions | ||||
---|---|---|---|---|
Function name | Input value(s) | Output value | ||
crossFormat | Crossover Title, Optional Color | Format for Template:Cross | ||
getImage | Crossover Title | Produces image for a crossover |
- For help on this module, please contact an administrator.
Visit Module:CrossSwitch/doc to edit this text! (How does this work?)
--[[Category:Lua modules]]
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][3]
then image=crossData[crossover][3]
..".png"
else image="Wiki-wordmark.png"
end
return image
end
return p