Módulo:Estação SuperVia

Origem: Wikipédia, a enciclopédia livre.
Documentação do módulo[ver] [editar] [histórico] [purgar]


Descrição[editar código-fonte]

Este modulo, é um complemento da Predefinição:Info/Estação SuperVia.

Função background_color_title[editar código-fonte]

Seu funcionamento é simples, a função background_color_title do modulo detectar numa expressão, as palavras: Deodoro, Japeri, Santa Cruz, Belford Roxo, Saracuruna, Paracambi, Vila Inhomirim, Guapimirim e Teleférico A.
Sua resposta é um código HTML (Que são as cores do titulo e da fonte) que será usado na Predefinição:Info/Estação SuperVia.

Exemplo[editar código-fonte]

{{#invoke:Estação_SuperVia|background_color_title|"O trem veio de Japeri"}}

A resposta é background-color:#0096c5;color:#FFFFFF; que representa

WK

Tabela de cores.[editar código-fonte]

Tabela abaixo mostra a lista de palavras que serão detectadas, e o resultado do modulo.

Deodoro X X X X
Santa Cruz X X X X X
Japeri X X X X X
Belford Roxo X X X
Saracuruna X X X X X
Paracambi X X
Vila Inhomirim X X
Guapimirim X X
Teleférico A X X
Resultado WK WK WK WK WK WK WK WK WK WK WK WK WK WK WK WK WK WK


Função convertlink[editar código-fonte]

Seu funcionamento é converter a expressão uma lista de links coloridos.

{{#invoke:Estação_SuperVia|convertlink|"Deodoro - Japeri - Santa Cruz - Mangaratiba"}}

A resposta é:
Linha Deodoro
Linha Santa Cruz
Linha Japeri

Note: Mangaratiba não foi incluída, já que não esta incluído na lista do Módulo.

local estacaosv ={}

function estacaosv.cor( linhanome )

	local source_str = linhanome

 	local source_str_lower = mw.ustring.lower(source_str)
 
	local deodoro_str = mw.ustring.find( source_str_lower, 'deodoro', 1, true )
	local santa_cruz_str = mw.ustring.find( source_str_lower, 'santa cruz', 1, true )
	local japeri_str = mw.ustring.find( source_str_lower, 'japeri', 1, true )
	local paracambi_str = mw.ustring.find( source_str_lower, 'paracambi', 1, true )
	local belford_roxo_str = mw.ustring.find( source_str_lower, 'belford roxo', 1, true )
	local saracuruna_str = mw.ustring.find( source_str_lower, 'saracuruna', 1, true )
    local vila_inhomirim_str = mw.ustring.find( source_str_lower, 'vila inhomirim', 1, true )
   	local guapimirim_str = mw.ustring.find( source_str_lower, 'guapimirim', 1, true ) 
	local teleferico_a_str = mw.ustring.find( source_str_lower, 'teleférico a', 1, true )   
    
    local color = {}
    
    -- Parada Deodoro - Santa Cruz - Japeri - Belford Roxo - Saracuruna
    if deodoro_str ~= nil and santa_cruz_str ~= nil and japeri_str ~= nil and paracambi_str == nil and belford_roxo_str ~= nil and saracuruna_str ~= nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
    color[0] = '#666666' -- background
    color[1] = '#FFFFFF' -- font
    
    -- Parada Deodoro - Santa Cruz - Japeri	
	elseif deodoro_str ~= nil and santa_cruz_str ~= nil and japeri_str ~= nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#666666' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Deodoro - Santa Cruz
	elseif deodoro_str ~= nil and santa_cruz_str ~= nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#666666' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Santa Cruz - Japeri
	elseif deodoro_str == nil and santa_cruz_str ~= nil and japeri_str ~= nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#666666' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Deodoro
	elseif deodoro_str ~= nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#e91233' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Santa Cruz
	elseif deodoro_str == nil and santa_cruz_str ~= nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#369f3a' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Japeri
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str ~= nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#0096c5' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Japeri - Paracambi
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str ~= nil and paracambi_str ~= nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#666666' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Paracambi
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str ~= nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#8acdd5' -- background
    color[1] = '#FFFFFF' -- font
	-- Parada Belford Roxo - Saracuruna
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str ~= nil and saracuruna_str ~= nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#666666' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Belford Roxo
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str ~= nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#9b4fa7' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Saracuruna
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str ~= nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] = '#fc892c' -- background
    color[1] = '#FFFFFF' -- font
    
	-- Parada Saracuruna - Teleférico A
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str ~= nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str ~= nil then
	color[0] ='#fc892c' -- background
    color[1] ='#FFFFFF' -- font
    
	-- Parada Teleférico A
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str == nil and teleferico_a_str ~= nil then
	color[0] ='#818286' -- background
    color[1] ='#FFFFFF' -- font
    
	-- Parada Saracuruna - vila_inhomirim - guapimirim
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str ~= nil and vila_inhomirim_str ~= nil and guapimirim_str ~= nil and teleferico_a_str == nil then
	color[0] ='#666666' -- background
    color[1] ='#FFFFFF' -- font
    
	-- Parada Vila Inhomirim
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str ~= nil and guapimirim_str == nil and teleferico_a_str == nil then
	color[0] ='#f3a800' -- background
    color[1] ='#FFFFFF' -- font
    
	-- Parada Guapimirim
	elseif deodoro_str == nil and santa_cruz_str == nil and japeri_str == nil and paracambi_str == nil and belford_roxo_str == nil and saracuruna_str == nil and vila_inhomirim_str == nil and guapimirim_str ~= nil and teleferico_a_str == nil then
	color[0] ='#fbca01' -- background
    color[1] ='#696969' -- font
    
	else
	color[0]= '#666666' -- background
    color[1] ='#FFFFFF' -- font
    
	end
 
 
    return color
end

function estacaosv.background_color_title(linhanome)
	local colorbackground = estacaosv.cor( linhanome.args[1] )
	return 'background-color:' .. colorbackground[0] .. ';color:'.. colorbackground[1] .. ';'
	end


function estacaosv.convertlink(linhanome)
	local linhanomestring = linhanome.args[1]
	local linhanomelow = mw.ustring.lower( linhanomestring )
	
	local linhanometable = {'deodoro'; 'santa cruz'; 'japeri'; 'paracambi'; 'belford roxo'; 'saracuruna'; 'vila inhomirim'; 'guapimirim' ;'teleférico a'}
	local linhanometableurl = {'Deodoro'; 'Santa Cruz'; 'Japeri'; 'Paracambi'; 'Belford Roxo'; 'Saracuruna'; 'Vila Inhomirim'; 'Guapimirim' ;'Teleférico A'}
		
	retornaurl = '';
	local cormatriz 
	local detect
	
	for numerorep = 1, 15, 1 do
		if linhanometable[numerorep] ~= nil then
			detect = mw.ustring.find(linhanomelow, linhanometable[numerorep], 1, true )
			if detect ~= nil then
				cormatriz = estacaosv.cor( linhanometableurl[numerorep] )
				if detect == mw.ustring.find(linhanomelow,'teleférico', 1, true ) then
					retornaurl = retornaurl .."[[".. linhanometableurl[numerorep] .." da SuperVia|<span style=\"color:".. cormatriz[0] .."\">Linha " .. linhanometableurl[numerorep] .."</span>]]<br />"
				else
					retornaurl = retornaurl .."[[Linha ".. linhanometableurl[numerorep] .." da SuperVia|<span style=\"color:".. cormatriz[0] .."\">Linha " .. linhanometableurl[numerorep] .."</span>]]<br />"
				end
			end
		end
	end

	local retornolen = mw.ustring.len(retornaurl) - 6
	
	retornaurl = mw.ustring.sub( retornaurl, 0, retornolen )
	
	return retornaurl
	end

return estacaosv