Arrowverse Wiki
Register
Advertisement
Arrowverse Wiki
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:IdentifySeries|function name|various parameters}} onto the template.[ Data ]

For help on this module, please contact an administrator.
Visit Module:IdentifySeries/doc to edit this text! (How does this work?)

--[[Category:Lua modules]]
local p = {}
local seriesData = mw.loadData('Module:IdentifySeries/data')
local numData = mw.loadData('Module:Number/data')

function removeParen(fullTitle)
    local title={}
    local length= mw.ustring.len(fullTitle)
    local par={}
    if mw.ustring.find(fullTitle,'(',1,true)==nil
        then par=length
        else par=mw.ustring.find(fullTitle,'(',1,true)-2
    end
    local title=mw.ustring.sub(fullTitle,1,par)
    return title
end

function p.getSeries(frame)
    local episode= frame.args[1]
    local seriesName={}
    if seriesData[episode]
        then seriesName=seriesData[episode][1]
        else seriesName="Arrowverse Wiki"
    end
    return seriesName
end

function p.EpisodeHover(frame)
    local episode=frame.args[1]
    local color=frame.args[2]
    local hoverInfo={}
    if seriesData[episode]
        then local number=seriesData[episode][3]
        	local show=seriesData[episode][1]
        	local extra=")"
        	if seriesData[episode][4] > numData[show][1]
        		then if episode=="Final Girl"
        			then extra="; unproduced)"
        			else extra="; upcoming)"
        		end
        	end
            if number < 10
                then number="0"
                    ..seriesData[episode][3]
            end
            if seriesData[episode][5]=="?"
            	then number="??"
            end
            hoverInfo="("
            ..seriesData[episode][1]
            .." "
            ..seriesData[episode][2]
            .."x"
            ..number
            ..extra
        else hoverInfo="(Arrowverse Wiki)"
    end 
    local title=removeParen(episode)
    
    if episode =="Rule #1"
    	then episode="Rule"
	end
	
	if episode =="wvrdr_error_100 not found"
		then episode="wvrdr error 100 not found"
	end
    
    local fullForm="{{Hoverlink|"
        ..episode
        .."|"
        ..title
        .."|"
    
    if episode=="wvrdr error 100 not found"
    	then fullForm=fullForm
    		.."wvrdr_error_100 not found"
    	else fullForm=fullForm
    		..title
    end
        
    fullForm=fullForm
        .." "
        ..hoverInfo
    
    if mw.ustring.len(color)>0
        then fullForm=fullForm
            .."|color="
            ..color
    end
    fullForm=fullForm
        .."}}"
    if hoverInfo == "(Arrowverse Wiki)"
        then if episode=="TBA"
        	then fullForm=fullForm
        	else fullForm=fullForm
            	.."[["
            	.."Category:Broken Ep link|"
            	..episode
            	.."]]"
            end
    end
    return frame:preprocess(fullForm)
end

function p.Disambig(frame)
	local episode = frame.args[1]
	local show={}
	local season={}
	local number={}
	local bignumber={}
	if seriesData[episode]
		then show=seriesData[episode][1]
			season=seriesData[episode][2]
			number=seriesData[episode][3]
			bignumber=seriesData[episode][4]
	end
	local fullForm="{{Ep|"
		..episode
		.."}}, the "
	if bignumber > numData[show][1]
		then fullForm=fullForm
			.."upcoming "
	end
	fullForm=fullForm
		.."{{Convert:NumtoText|"
		..number
		.."}} episode of "
	local flip = false
	if show == "The Flash (CBS)"
		then flip = true
	end
	if show == "Birds of Prey"
		then flip = true
	end
	if show == "Constantine"
		then flip = true
	end
	if flip == true
		then fullForm = fullForm
			.." {{S|"
			..show
			.."}}."
		else fullForm = fullForm
		.."the [[Season "
		..season
		.." ("
		..removeParen(show)
		..")|{{Convert:NumtoText|"
		..season
		.."}} season]] of {{S|"
		..show
		.."}}, and the {{Convert:NumtoText|"
		..bignumber
		.."}} episode overall."
	end
	return frame:preprocess(fullForm)
end
return p
Advertisement