|
||||||
|
|
|
||||||||||||||||||||||||
MediaWiki:Common.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
| (601 revisões intermediárias por 15 usuários não estão sendo mostradas) | |||
| Linha 1: | Linha 1: | ||
/* | /* Abrir Spoilers */ | ||
$(document).ready(function(){ | |||
$('.showspoiler').click(function(){ | |||
var a = $('.spoiler').css('display'); | |||
if (a == "none"){ | |||
$('.showspoiler').text("Clique para fechar todos os spoilers"); | |||
$('div.spoiler').css({'display': 'block'}); | |||
} else { | |||
$('.showspoiler').text("Clique para abrir todos os spoilers"); | |||
$('div.spoiler').css({'display': 'none'}); | |||
} | |||
}); | |||
}); | |||
/* Sempre mostra Spoilers */ | |||
$(document).ready(function(){ | |||
$('[data-sempre-mostrar]').click(function(){ | |||
if($.cookie('sempre-mostrar-spoilers') === "true") { | |||
$.cookie('sempre-mostrar-spoilers', "false", { expires: 360, path: '/' }); | |||
} else { | |||
$.cookie('sempre-mostrar-spoilers', "true", { expires: 360, path: '/' }); | |||
} | |||
$('#spoil').toggle(); | |||
$('.showhide').toggle(); | |||
}); | |||
}); | |||
/* anuncio */ | |||
$(document).ready(function() { | |||
if (typeof googletag !== 'undefined') { | |||
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1540046116529-0'); }); | |||
} | |||
}); | |||
/* Quest Spoils */ | |||
$(document).ready(function(){ | |||
var url = location.hash; | |||
if (url.length > 0 || $.cookie('sempre-mostrar-spoilers') === "true"){ | |||
$('.showhide').click(function(){ | |||
$('#spoil').toggle(); | |||
$('.showhide').toggle(); | |||
}); | |||
} else { | |||
$('#spoil').toggle(); | |||
$('.showhide').toggle(); | |||
$('.showhide').click(function(){ | |||
$('#spoil').toggle(); | |||
$('.showhide').toggle(); | |||
}); | |||
} | |||
}); | |||
/* Tirar ícone de links externos */ | |||
$('.mapa > a').removeClass('external text'); | |||
$('#siteNotice a').removeClass('external text'); | |||
/* Tirar atributo title de links */ | |||
$('.tooltip > a').removeAttr('title'); | |||
/* Transcrições NPCs */ | |||
$(document).ready(function() { | $(document).ready(function() { | ||
$(". | $('#show2, #show3').click(function() { | ||
$('.hide').toggle(); | |||
}); | |||
}, function() { | }); | ||
}). | /* Criaturas */ | ||
var | $(document).ready(function () { | ||
var | var height = $('#hab').height(); | ||
if (height >= 50) { | |||
$('#hab').addClass('hide'); | |||
$('#show').removeClass('hide'); | |||
} | |||
$('#show').click(function () { | |||
$('.hide').toggle(); | |||
$('.showhab').toggle(); | |||
$('#NPC').addClass('hide'); | |||
}); | |||
}); | |||
/* Simulador de Charms - Charm Simulator */ | |||
if (mw.config.values.wgPageName === 'Simulador_de_Charms' || mw.config.values.wgPageName === 'Simulador_de_Charms' || mw.config.values.wgPageName === 'Calculadoras') { | |||
$(document).ready(function(){ | |||
if ($('.charm_simulator_html') !== null) { | |||
$.ajax({ url: '/index.php?title=Tibia_Wiki:Charm_Simulator/codigo&action=raw',success: function(codigo) { | |||
var codigo_html = codigo.slice(codigo.search('<pre id="charm_html">') + 21, codigo.search('</pre>')); | |||
$('.charm_simulator_html').html(codigo_html); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_css = codigo.slice(codigo.search('<pre id="charm_css">') + 20, codigo.search('</pre>')); | |||
$('head').append('<style type="text/css">'+codigo_css+'</style>'); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_js = codigo.slice(codigo.search('<pre id="charm_js">') + 19, codigo.search('</pre>')); | |||
$('.charm_simulator_js').html('<script type="text/javascript">'+codigo_js+'</script>'); | |||
}}); | |||
} | |||
}); | |||
} | |||
/* Hot Cuisine Calculator System */ | |||
if (mw.config.values.wgPageName === 'Hot_Cuisine_Calculator_System' || mw.config.values.wgPageName === 'Hot_Cuisine_Quest' || mw.config.values.wgPageName === 'Calculadoras') { | |||
$(document).ready(function(){ | |||
if ($('.hot_cuisine_calc_system') !== null) { | |||
$.ajax({ url: '/index.php?title=Tibia_Wiki:Hot_Cuisine_Calculator_System/Codigo&action=raw',success: function(codigo) { | |||
var codigo_html = codigo.slice(codigo.search('<pre id="hot_cuisine_system_html">') + 34, codigo.search('</pre>')); | |||
$('.hot_cuisine_calc_system').html(codigo_html); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_css = codigo.slice(codigo.search('<pre id="hot_cuisine_system_css">') + 33, codigo.search('</pre>')); | |||
$('head').append('<style type="text/css">'+codigo_css+'</style>'); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_js = codigo.slice(codigo.search('<pre id="hot_cuisine_system_js">') + 32, codigo.search('</pre>')); | |||
$('.hot_cuisine_calc_system_js').html('<script type="text/javascript">'+codigo_js+'</script>'); | |||
}}); | |||
} | |||
}); | |||
} | |||
/* Exercise Weapons Calculator */ | |||
if (mw.config.values.wgPageName === 'Exercise_Weapons_Calculator' || mw.config.values.wgPageName === 'Calculadoras') { | |||
$(document).ready(function(){ | |||
if ($('.exercise_weapon_calc') !== null) { | |||
$.ajax({ url: '/index.php?title=Tibia_Wiki:Exercise_Weapons_Calculator/Codigo&action=raw',success: function(codigo) { | |||
var codigo_html = codigo.slice(codigo.search('<pre id="exercise_weapons_html">') + 32, codigo.search('</pre>')); | |||
$('.exercise_weapon_calc').html(codigo_html); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_css = codigo.slice(codigo.search('<pre id="exercise_weapons_css">') + 31, codigo.search('</pre>')); | |||
$('head').append('<style type="text/css">'+codigo_css+'</style>'); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_js = codigo.slice(codigo.search('<pre id="exercise_weapons_js">') + 30, codigo.search('</pre>')); | |||
$('.exercise_weapon_calc_js').html('<script type="text/javascript">'+codigo_js+'</script>'); | |||
}}); | |||
} | |||
}); | |||
} | |||
/* Skills Calculator */ | |||
if (mw.config.values.wgPageName === 'Calculadora_de_Skills' || mw.config.values.wgPageName === 'Calculadoras') { | |||
$(document).ready(function(){ | |||
if ($('.skills_calc_system') !== null) { | |||
$.ajax({ url: '/index.php?title=Tibia_Wiki:Skills_Calculator/Codigo&action=raw',success: function(codigo) { | |||
var codigo_html = codigo.slice(codigo.search('<pre id="skills_calculator_html">') + 33, codigo.search('</pre>')); | |||
$('.skills_calc_system').html(codigo_html); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_css = codigo.slice(codigo.search('<pre id="skills_calculator_css">') + 32, codigo.search('</pre>')); | |||
$('head').append('<style type="text/css">'+codigo_css+'</style>'); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_js = codigo.slice(codigo.search('<pre id="skills_calculator_js">') + 31, codigo.search('</pre>')); | |||
$('.skills_calc_system_js').html('<script type="text/javascript">'+codigo_js+'</script>'); | |||
}}); | |||
} | |||
}); | |||
} | |||
/* Mapa */ | |||
if (mw.config.values.wgPageName === 'Mapa') { | |||
$(document).ready(function(){ | |||
var url = location.hash; | |||
$(".map_wiki").append('<div id="map" style="width: 100%; height: 100%;"></div>'); | |||
loadMapScripts(); | |||
}); | |||
} | |||
/* Mapa Popup */ | |||
/** Abre o popup de mapa de Monstros e NPCs */ | |||
$('.map_show').click(function() { | |||
var display = $('.map_frame',this).css('display'); | |||
if (display == 'none') { showMap(this); } | |||
return false; | |||
}); | |||
/** Fecha o mapa ao clicar na parte Preta (Overlay) */ | |||
$('.map_overlay').click(function() { | |||
$('.map_show').each(function( index ) { | |||
hideMap($('.map_show')[index]); | |||
}); | |||
return false; | |||
}); | |||
$('.map_logobox').click(function(event){ | |||
event.stopPropagation(); | |||
}); | |||
/* Mapa Infobox Hunt */ | |||
$('.map_hunt').ready(function(){ | |||
var coord = $('.map_hunt_coord',this).text(); | |||
/** Transforma a logo do TibiaWiki em um link para a página do Mapa com as coordenadas da localiação */ | |||
$(".map_logobox",this).append('<a href="https://www.tibiawiki.com.br/wiki/mapa#'+coord+':1" class="map_logo" target="_blank" title="Ver no mapa do Tibia Wiki"></a>'); | |||
/** Box do Map */ | |||
var mapBox = $(".map_hunt_box",this); | |||
mapBox.html(""); | |||
/** Cria o iFrame que conterá o Mapa */ | |||
mapBox.append('<iframe id="mapa_frame" scrolling="no" frameborder="0" width="100%" height="310" style="border-radius:8px"></iframe>'); | |||
/** Pega o Map iFrame */ | |||
var mapFrame = $("#mapa_frame",mapBox); | |||
/** Seta as Coordenadas do Mapa */ | |||
// mapFrame.attr("src", mapFrame.contents().get(0).URL + "#" + coord + ":1"); | |||
mapFrame.ready(function() { | |||
//let iframeMap = mapFrame[0]; | |||
//if (iframeMap !== null) { | |||
// loadMapOnIFrame(coord, mapFrame[0]); | |||
//} | |||
loadMapOnIFrame(coord, mapFrame[0]); | |||
}); | |||
}); | |||
/* Mapa Infobox Geo */ | |||
$('.map_hunt_geo').ready(function(){ | |||
var coord = $('.map_hunt_coord_geo',this).text(); | |||
/** Transforma a logo do TibiaWiki em um link para a página do Mapa com as coordenadas da localiação */ | |||
$(".map_logobox",this).append('<a href="https://www.tibiawiki.com.br/wiki/mapa#'+coord+':1" class="map_logo" target="_blank" title="Ver no mapa do Tibia Wiki"></a>'); | |||
/** Box do Map */ | |||
var mapBox = $(".map_hunt_box_geo",this); | |||
mapBox.html(""); | |||
/** Cria o iFrame que conterá o Mapa */ | |||
mapBox.append('<iframe id="mapa_frame" scrolling="no" frameborder="0" width="100%" height="430" style="border-radius:8px"></iframe>'); | |||
/** Pega o Map iFrame */ | |||
var mapFrame = $("#mapa_frame",mapBox); | |||
/** Seta as Coordenadas do Mapa */ | |||
// mapFrame.attr("src", mapFrame.contents().get(0).URL + "#" + coord + ":1"); | |||
mapFrame.ready(function() { | |||
//let iframeMap = mapFrame[0]; | |||
//if (iframeMap !== null) { | |||
// loadMapOnIFrame(coord, mapFrame[0]); | |||
//} | |||
loadMapOnIFrame(coord, mapFrame[0]); | |||
}); | |||
}); | |||
/** Mapa internalizado ao Wiki - Teste */ | |||
if (mw.config.values.wgPageName === 'Mapa/Teste') { | |||
$(document).ready( function () { | |||
$(".map_wiki").append('<div id="map" style="width: 100%; height: 100%;"></div>'); | |||
loadMapScripts(); | |||
}); | |||
} | |||
/** Função que faz o popup em lightbox do Mapa apareça. */ | |||
function showMap(container) { | |||
$('.map_frame',container).css('display', 'inline'); | |||
$('.map_overlay',container).css('display', 'inline'); | |||
configPopupMap(container); | |||
} | |||
/** Função que faz o popup em lightbox do Mapa desaparecer. */ | |||
function hideMap(container) { | |||
$('.map_frame',container).css('display', 'none'); | |||
$('.map_overlay',container).css('display', 'none'); | |||
} | |||
/** Configura o Popup (LightBox) de Mapa */ | |||
function configPopupMap(container) { | |||
/** Configura o Mapa. */ | |||
$('.map_box').each(function( index ) { | |||
$(this).html("") | |||
}); | |||
var coord = $('.map_frame_coord',container).text(); | |||
window.history.replaceState("map", null, "#" + coord + ":1"); | |||
$(".map_box", container).css("width", "100%").css("height", "100%") | |||
$(".map_box", container).append('<div id="map" style="width: 100%; height: 100%;"></div>'); | |||
/** Transforma a logo do TibiaWiki em um link para a página do Mapa com as coordenadas da localiação */ | |||
$(".map_logobox",container).append('<a href="https://www.tibiawiki.com.br/wiki/mapa#'+coord+':1" class="map_logo" target="_blank" title="Ver no mapa do Tibia Wiki"></a>'); | |||
loadMapScripts(); | |||
} | |||
/** Função que realiza o load dos scripts de Map. */ | |||
function loadMapScripts() { | |||
$('link[href="https://tibiamaps.io/_css/map.css"]').remove(); | |||
$('head').append('<link rel="stylesheet" href="https://tibiamaps.io/_css/map.css">'); | |||
$('script[src="https://tibiamaps.io/_js/map.js"]').remove(); | |||
$('<script>').attr('src', "https://tibiamaps.io/_js/map.js").appendTo('head'); | |||
} | |||
/** Carrega o Mapa no iframe. */ | |||
function loadMapOnIFrame(coord, iframe) { | |||
if (iframe === null || iframe === undefined) { return; } | |||
createCss(iframe.contentDocument, iframe.contentDocument.getElementsByTagName('head').item(0), 'https://tibiamaps.io/_css/map.css'); | |||
createStyle(iframe.contentDocument, iframe.contentDocument.getElementsByTagName('head').item(0), {"body": {"margin": "0px"}}); | |||
createComponent("map", {"width": "100%", "height": "100%"} ,iframe.contentDocument, iframe.contentDocument.getElementsByTagName('body').item(0)); | |||
$.ajax({ url: '/index.php?title=Tibia_Wiki:Mapa/Codigo&action=raw',success: function(codigo) { | |||
var codigo_js = codigo.slice(codigo.search('<pre id="mapa_js">') + 18, codigo.search('</pre>')); | |||
var bodyFrame = $(iframe).contents().find('body'); | |||
bodyFrame.append('<script type="text/javascript">var mapLocation = "#' + coord + ':1";\n'+codigo_js+'</script>'); | |||
}}); | |||
} | |||
/** Cria component DIV. */ | |||
function createComponent(id, css, doc, target, callback) { | |||
var params = { | |||
"name": "div", | |||
"id": id, | |||
"css": css | |||
}; | |||
iframeInsertComponents(params, doc, target, callback); | |||
} | |||
/** Cria component LINK que carrega CSS. */ | |||
function createCss(doc, target, href, callback) { | |||
var params = { | |||
"name": "link", | |||
"rel": "stylesheet", | |||
"href": href | |||
}; | |||
iframeInsertComponents(params, doc, target, callback); | |||
} | |||
/** Cria component Script que carrega JavaScript. */ | |||
function createScript(doc, target, code, callback) { | |||
var params = { | |||
"name": "script", | |||
"type": "text/javascript", | |||
"code": code | |||
}; | |||
iframeInsertComponents(params, doc, target, callback); | |||
} | |||
/** Cria component STYLE que carrega CSS na HEAD. */ | |||
function createStyle(doc, target, css, callback) { | |||
var params = { | |||
"name": "style", | |||
"css": css | |||
}; | |||
iframeInsertComponents(params, doc, target, callback); | |||
} | |||
/** Checa se a Variavel existe */ | |||
function isDefined(variable) { | |||
return typeof variable !== 'undefined'; | |||
} | |||
/** Algumas telas utiliza iFrames e precisa injetar JavaScripts para funcionar corretamente */ | |||
function iframeInsertComponents(params, doc, target, callback) { | |||
//doc, target, src, callback | |||
var s = doc.createElement(params.name); | |||
if (params.name == "script") { | |||
s.type = params.type; | |||
} | |||
if (params.name == "link") { | |||
s.rel = params.rel; | |||
} | |||
if (params.name == "div") { | |||
s.id = params.id; | |||
if (params.css != null) { | |||
Object.entries(params.css).forEach(function(arr, i) { | |||
$(s).css(arr[0], arr[1]); | |||
}); | |||
} | |||
} | |||
if(callback) { | |||
if (s.readyState){ //IE | |||
s.onreadystatechange = function(){ | |||
if (s.readyState == "loaded" || | |||
s.readyState == "complete"){ | |||
s.onreadystatechange = null; | |||
callback(); | |||
} | |||
}; | |||
} else { //Others | |||
s.onload = function(){ | |||
callback(); | |||
}; | |||
} | |||
} | |||
if (params.name == "style") { | |||
Object.entries(params.css).forEach(function(arr, i) { | |||
var attrs = ""; | |||
Object.entries(arr[1]).forEach(function(attr, i) { | |||
attrs += '\n' + attr[0] + ': ' + attr[1]; | |||
}); | |||
if (i === 0) { | |||
s.innerText = arr[0] + ' {' + attrs + '\n}'; | |||
} | |||
}); | |||
} | |||
if (params.name == "script") { | |||
if (params.code.src != null && params.code.src != "") { | |||
s.src = params.src; | |||
} | |||
if (params.code.code != null) { | |||
console.log(params.code.code); | |||
var re = new RegExp('\n', 'g'); | |||
s.innerText = params.code.code.replace(re, '');//.split('<br>').join('\n'); | |||
} | |||
} | |||
if (params.name == "link") { | |||
s.href = params.href; | |||
} | |||
target.appendChild(s); | |||
} | |||
/* Calculadoras - Shards */ | |||
if (mw.config.values.wgPageName === 'Calculadoras') { | |||
$(document).ready(function(){ | |||
if ($('.calc_exp_events') !== null) { | |||
$.ajax({ url: '/index.php?title=Tibia_Wiki:Experience_Events_Calculator/Codigo&action=raw',success: function(codigo) { | |||
/* Get HTML Code */ | |||
var codigo_html = codigo.slice(codigo.search('<pre id="calc_exp_events_code_html">') + 36, codigo.search('</pre>')); | |||
$('.calc_exp_events').html(codigo_html); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
/* Get JavaScript Code */ | |||
var codigo_js = codigo.slice(codigo.search('<pre id="calc_exp_events_code_js">') + 34, codigo.search('</pre>')); | |||
$('.calc_exp_events_js').html('<script type="text/javascript">'+codigo_js+'</script>'); | |||
}}); | |||
} | |||
}); | |||
} | |||
/* Calculadoras - Party */ | |||
if (mw.config.values.wgPageName === 'Calculadoras') { | |||
$(document).ready(function(){ | |||
if ($('.calc_exp_events') !== null) { | |||
$.ajax({ url: '/index.php?title=MediaWiki:Common.js/calc_party.js&action=raw',success: function(codigo) { | |||
/* Get HTML Code */ | |||
var codigo_html = codigo.slice(codigo.search('<pre id="calc_xp_party_html">') + 29, codigo.search('</pre>')); | |||
$('.calc_xp_party_html').html(codigo_html); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
/* Get JavaScript Code */ | |||
var codigo_js = codigo.slice(codigo.search('<pre id="calc_xp_party_js">') + 27, codigo.search('</pre>')); | |||
$('.calc_xp_party_js').html('<script type="text/javascript">'+codigo_js+'</script>'); | |||
}}); | |||
} | |||
}); | |||
} | |||
/* Calculadoras - Blessings */ | |||
if (mw.config.values.wgPageName === 'Calculadoras') { | |||
$(document).ready(function(){ | |||
//mw.loader.load( '/index.php?title=MediaWiki:Common.js/blessing.js&action=raw&ctype=text/javascript' ); | |||
$.ajax({ url: '/index.php?title=MediaWiki:Common.js/blessing.js&action=raw',success: function(codigo) { | |||
/* Get HTML Code */ | |||
var codigo_html = codigo.slice(codigo.search('<pre id="calc_blessing_html">') + 29, codigo.search('</pre>')); | |||
$('.calc_bless_price_html').html(codigo_html); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
/* Get JavaScript Code */ | |||
var codigo_js = codigo.slice(codigo.search('<pre id="calc_blessing_js">') + 27, codigo.search('</pre>')); | |||
$('.calc_bless_price_js').html('<script type="text/javascript">'+codigo_js+'</script>'); | |||
}}); | |||
}); | |||
} | |||
/* Calculadoras - Skill */ | |||
$(document).ready(function () { | |||
mw.loader.load( '/index.php?title=MediaWiki:Common.js/calc_skill.js&action=raw&ctype=text/javascript' ); | |||
}); | |||
/* Calculadoras - Profile */ | |||
$("#input_nome").append('<form action="/Sano/char.php" type="post" id="searchForm"><input name="character" id="nome" type="text" size="25" align="center" value="Nome do Personagem" onclick="this.value='';" onblur="this.value=!this.value?'Nome do Personagem':this.value;"/> <input type="submit" value="Ir" /></form>'); | |||
$("#searchForm").submit(function(event) { | |||
event.preventDefault(); | |||
var $form = $( this ), | |||
term = $form.find('input[name="character"]').val(), | |||
url = $form.attr( 'action' ); | |||
$.post( '/Sano/char.php', $("#searchForm").serialize(), | |||
function( data ) { | |||
$( "#result_personagem" ).empty().append('<center><table id="alter" style="text-align:left;border:none;margin-top:5px;"><tr><td colspan="4" style="text-align:center;"><b>Informações do Personagem</b></td></tr><tr><td style="width:5%"><b>Nome:</b></td><td style="width:45%">' + data.Nome + '</td><td style="width:5%"><b>Level:</b></td><td style="width:45%">' + data.Level + '</td></tr><tr class="dif"><td><b>Vocação:</b></td><td>' + data.Vocacao + '</td><td><b>Mundo:</b></td><td>' + data.Mundo + '</td></tr><tr><td><b>Guild:</b></td><td>' + data.Guild + '</td><td><b>Tutor:</b></td><td>' + data.Tutor + '</td></tr><tr class="dif"><td><b>Residencia:</b></td><td>' + data.Residencia + '</td><td><b>Casa:</b></td><td>' + data.Casa + '</td></tr><tr><td><b>Casado com:</b></td><td>' + data.Casado + '</td><td><b>Sexo:</b></td><td>' + data.Sexo + '</td></tr><tr class="dif"><td><b>Achievements:</b></td><td>' + data.Achievements + '</td><td><b>Capacidade:</b></td><td>' + data.Capacidade + '</td></tr><tr><td><b>Vida:</b></td><td>' + data.Life + '</td><td><b>Mana:</b></td><td>' + data.Mana + '</td></tr><tr class="dif"><td><b>Status:</b></td><td>' + data.Status + '</td><td><b>Velocidade:</b></td><td>' + data.Velocidade + '</td></tr><tr><td colspan="4">Você pagará ' + data.Bless + ' gps por cada benção comum e pagará ' + data.Bless3 + ' gps por cada bênção melhorada.Tendo assim o valor total de ' + data.Bless2 + ' gps por todas elas.<br/>Em uma party, você poderá compartilhar experiência com leveis: ' + data.Party + '</td></tr></table></center>'); | |||
}, "json"); | |||
}); | |||
/* Abas */ | |||
$(document).ready(function(){ | |||
$('.showDiv').on('click', function () { | |||
$(this).siblings(); | |||
$('.targetDiv').hide(); | |||
$('.targetDiv2').hide(); | |||
$('#div' + $(this).data('target')).show(); | |||
}); | |||
}); | |||
/* Abas Menu*/ | |||
$(document).ready(function () { | |||
$('.mostrar-aba').click(function () { | |||
var aba_id = $(this).attr('data-aba'); | |||
var check = $("#aba-" + aba_id).css('display'); | |||
if (check == "block") { | |||
$("#aba-" + aba_id).removeClass('atual'); | |||
} else { | |||
$('.aba').removeClass('atual'); | |||
$("#aba-" + aba_id).addClass('atual'); | |||
} | |||
}); | |||
$('.mostrar-todas-abas').click(function () { | |||
var check = $('.aba').css('display'); | |||
if (check == "block") { | |||
$('.aba').removeClass('atual'); | |||
} else { | |||
$('div.aba').toggleClass('atual'); | |||
} | |||
}); | }); | ||
var url = location.href; | |||
hash = url.split('#')[1]; | |||
if ((hash != null || hash != undefined) && hash.length > 0){ | |||
$("#aba-" + hash).addClass('atual'); | |||
} | |||
}); | |||
/** Cidade Rashid | |||
* Esse código converte o horário local para o horário de Berlin, pegando o dia da semana corretamente, independente do Horário de Verão. | |||
*/ | |||
$(document).ready(function () { | |||
/** Objeto que contém os dados do Rashid | |||
* Dia da Semana | |||
* 0: Domingo. | |||
* 1: Segunda-Feira. | |||
* 2: Terça-Feira. | |||
* 3: Quarta-Feira. | |||
* 4: Quinta-Feira. | |||
* 5: Sexta-Feira. | |||
* 6: Sábado. | |||
* | |||
* @param day Variavel que recebe o dia da semana. | |||
* @param city Variavel que recebe a Cidade em que o Rashid está. | |||
* @param image Variavel que recebe o link da Imagem de Background com o mapa de onde o Rashid está. | |||
*/ | |||
var rashidCities = { | |||
0: { | |||
"day": "domingo", | |||
"city": "Carlin", | |||
"image": "/images/5/5f/Rashid_Carlin.png" | |||
}, | |||
1: { | |||
"day": "segunda-feira", | |||
"city": "Svargrond", | |||
"image": "/images/3/34/Rashid_Svargrond.png" | |||
}, | |||
2: { | |||
"day": "terça-feira", | |||
"city": "Liberty Bay", | |||
"image": "/images/3/33/Rashid_Liberty_Bay.png" | |||
}, | |||
3: { | |||
"day": "quarta-feira", | |||
"city": "Port Hope", | |||
"image": "/images/c/cf/Rashid_Port_Hope.png" | |||
}, | |||
4: { | |||
"day": "quinta-feira", | |||
"city": "Ankrahmun", | |||
"image": "/images/2/2a/Rashid_Ankrahmun.png" | |||
}, | |||
5: { | |||
"day": "sexta-feira", | |||
"city": "Darashia", | |||
"image": "/images/c/cb/Rashid_Darashia.png" | |||
}, | |||
6: { | |||
"day": "sábado", | |||
"city": "Edron", | |||
"image": "/images/6/6f/Rashid_Edron.png" | |||
} | |||
} | |||
/** | |||
* @param data Variavel que recebe a data e hora atual de qualquer país e converte para a data e hora de Berlin. | |||
* @param hora Variavel que recebe a Hora atual de Berlin. | |||
* @param dia Variavel que recebe o dia da semana, e assim ele calcula se já ocorreu o SS ou não. | |||
*/ | |||
var data = new Date(new Date().toLocaleString('en-US', { timeZone: 'Europe/Berlin' })); | |||
var hora = data.getHours(); | |||
var sDay = data.getDay(); | |||
var dia = (hora >= 10) ? sDay : ((sDay == 0) ? 6 : sDay - 1) ; | |||
/** Popula o HTML do box do Rashid na página do TibiaWiki */ | |||
$('#rashid_city_white').html('<a style="color:#FFFFFF; text-decoration:none;" href="'+rashidCities[dia].city+'">'+rashidCities[dia].city+'</a>'); | |||
$('#rashid_city_link').html('<a style="color:#0645ad;" href="'+rashidCities[dia].city+'">'+rashidCities[dia].city+'</a>'); | |||
$('#tibiaday').html(''+rashidCities[dia].day+''); | |||
$('#rashid_home').css('background','url("'+rashidCities[dia].image+'")'); | |||
$('#rashid_home').css('background-repeat','no-repeat'); | |||
$('#rashid_home').css('background-size','cover'); | |||
$('#rashid_home').css('background-position','35% 0%'); | |||
$('#rashid_home').css('height','120px'); | |||
}); | |||
/* Semana Atual */ | |||
$(document).ready(function () { | |||
Date.prototype.getWeek = function () { | |||
var onejan = new Date(this.getFullYear(), 0, 1); | |||
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7); | |||
} | |||
var today = new Date(); | |||
var currentWeekNumber = today.getWeek(); | |||
$('#semanaatual').html(currentWeekNumber); | |||
var currentDay = today.getDate(); | |||
$('#diaatual').html(currentDay); | |||
}); | |||
/* Imbuing */ | |||
if (mw.config.values.wgPageName === 'Imbuement_Tool') { | |||
$(document).ready(function(){ | |||
$.ajax({ url: '/index.php?title=Tibia_Wiki:Imbuing/Codigo&action=raw',success: function(codigo) { | |||
var codigo_html = codigo.slice(codigo.search('<pre id="imbuing_html">') + 24, codigo.search('</pre>')); | |||
$('.imbuing').html(codigo_html); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_css = codigo.slice(codigo.search('<pre id="imbuing_css">') + 23, codigo.search('</pre>')); | |||
$('head').append('<style type="text/css">'+codigo_css+'</style>'); | |||
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length); | |||
var codigo_js = codigo.slice(codigo.search('<pre id="imbuing_js">') + 22, codigo.search('</pre>')); | |||
$('.imbuing_js').html('<script type="text/javascript">'+codigo_js+'</script>'); | |||
}}); | |||
}); | |||
} | |||
/* Geografia */ | |||
$(document).ready(function() { $('#casa').hover(function() { $("#house").removeClass('no'); }, function() { $("#house").addClass("no"); }); $('#guild').hover(function() { $("#guildh").removeClass('no'); }, function() { $("#guildh").addClass("no"); }); $('#biblioteca').hover(function() { $("#library").removeClass('no'); }, function() { $("#library").addClass("no"); }); $('#ruas').hover(function() { $("#street").removeClass('no'); }, function() { $("#street").addClass("no"); }); $('#invasao').hover(function() { $("#raid").removeClass('no'); }, function() { $("#raid").addClass("no"); }); $('.huntopc a').removeAttr('href');}); | |||
/* Toggle Diálogos */ | |||
$(document).ready(function(){ | |||
$('[data-dialog-text]').hide(); | |||
$('[data-dialog-show]').on('click', function() { | |||
$element = $(this).parents('[data-dialog]').children('[data-dialog-text]') | |||
if($element.is(":hidden")) { | |||
$element.show(); | |||
} else { | |||
$element.hide(); | |||
} | |||
}); | |||
}); | |||
/* Server Save */ | |||
if (mw.config.values.wgPageName === 'Home') { | |||
$(document).ready(function () { | |||
const threadTime = 1000; // Tempo que atualiza o Tempo para o SS. 1000 = 1 segundo. | |||
var ssHour = 10; // Hora do SS. 10:00:00h AM de Berlin. | |||
var ssMinute = 0; // Minuto do SS. | |||
var ssSecond = 0; // Segundo do SS. | |||
var ss = new Date(); // Variavel de SS. | |||
var countDownDate = ss.getTime(); // Variavel de Time do SS. | |||
var x = setInterval(function() { | |||
/* Pega Hora do SS em Berlin | |||
* - Pega o horário de Berlin, e seta para o horário do SS, 10:00:00 AM sempre do dia atual ou dia seguinte, caso necessário. | |||
*/ | |||
ss = new Date(new Date().toLocaleString('en-US', { timeZone: 'Europe/Berlin' })); | |||
if (ss.getHours() >= ssHour) { | |||
ss.setDate(ss.getDate() + 1); | |||
} | |||
ss.setHours(ssHour, ssMinute, ssSecond); | |||
countDownDate = ss.getTime(); | |||
/* Fim - Pega Hora do SS em Berlin */ | |||
/* Pega Hora atual em Berlin | |||
* - Essa forma, não importa o país, ele converte para o horário atual de Berlin. | |||
*/ | |||
var now = new Date(new Date().toLocaleString('en-US', { timeZone: 'Europe/Berlin' })).getTime(); | |||
var distance = countDownDate - now; // Realiza o Calculo para saber a "Distancia" entre a hora atual até o horáio do SS. | |||
/* Fim - Pega Hora atual em Berlin*/ | |||
/* Calculo de Horas para o SS. | |||
* Transforma a distancia de horários entre o SS e a hora atual, em formato de Horas. | |||
*/ | |||
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | |||
var pluralH = hours === 1 ? "" : "s"; // Verifica se é mais de uma Hora, se for, acrescenta o 'S' para poder deixar a descrição em plural. | |||
/* Calculo de Minutos para o SS. | |||
* Transforma a distancia de horários entre o SS e a hora atual, em formato de Minutos. | |||
*/ | |||
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); | |||
var pluralM = minutes === 1 ? "" : "s"; // Verifica se é mais de um Minuto, se for, acrescenta o 'S' para poder deixar a descrição em plural. | |||
if (hours >= 1) { | |||
$('#serversave').text('Faltam ' + hours + 'h ' + minutes + 'min'+ ' para o Server Save.'); | |||
} else { | |||
if (minutes >= 1) { | |||
$('#serversave').text('Faltam ' + minutes + ' min'+pluralM+ ' para o Server Save.'); | |||
} else { | |||
/* Calculo de Segundos para o SS. | |||
* Transforma a distancia de horários entre o SS e a hora atual, em formato de Segundos. | |||
*/ | |||
var seconds = Math.floor((distance % (1000 * 60 * 60)) / 1000); | |||
var pluralS = seconds === 1 ? "" : "s"; // Verifica se é mais de um Segundo, se for, acrescenta o 'S' para poder deixar a descrição em plural. | |||
$('#serversave').text('Faltam ' + seconds + ' segundo' + pluralS + ' para o Server Save.'); | |||
} | |||
} | |||
}, threadTime); | |||
}); | }); | ||
} | |||
const loaded_scripts = [] | |||
$( | $(document).ready(function () { | ||
$('.load_js').each(function () { | |||
const script = $(this).attr('data-script') | |||
if (!loaded_scripts.includes(script)) { | |||
mw.loader.load('/index.php?title=MediaWiki:' + script + '&action=raw&ctype=text/javascript') | |||
loaded_scripts.push(script) | |||
} | |||
}) | |||
}) | |||
Edição atual tal como às 18h14min de 23 de novembro de 2024
/* Abrir Spoilers */
$(document).ready(function(){
$('.showspoiler').click(function(){
var a = $('.spoiler').css('display');
if (a == "none"){
$('.showspoiler').text("Clique para fechar todos os spoilers");
$('div.spoiler').css({'display': 'block'});
} else {
$('.showspoiler').text("Clique para abrir todos os spoilers");
$('div.spoiler').css({'display': 'none'});
}
});
});
/* Sempre mostra Spoilers */
$(document).ready(function(){
$('[data-sempre-mostrar]').click(function(){
if($.cookie('sempre-mostrar-spoilers') === "true") {
$.cookie('sempre-mostrar-spoilers', "false", { expires: 360, path: '/' });
} else {
$.cookie('sempre-mostrar-spoilers', "true", { expires: 360, path: '/' });
}
$('#spoil').toggle();
$('.showhide').toggle();
});
});
/* anuncio */
$(document).ready(function() {
if (typeof googletag !== 'undefined') {
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1540046116529-0'); });
}
});
/* Quest Spoils */
$(document).ready(function(){
var url = location.hash;
if (url.length > 0 || $.cookie('sempre-mostrar-spoilers') === "true"){
$('.showhide').click(function(){
$('#spoil').toggle();
$('.showhide').toggle();
});
} else {
$('#spoil').toggle();
$('.showhide').toggle();
$('.showhide').click(function(){
$('#spoil').toggle();
$('.showhide').toggle();
});
}
});
/* Tirar ícone de links externos */
$('.mapa > a').removeClass('external text');
$('#siteNotice a').removeClass('external text');
/* Tirar atributo title de links */
$('.tooltip > a').removeAttr('title');
/* Transcrições NPCs */
$(document).ready(function() {
$('#show2, #show3').click(function() {
$('.hide').toggle();
});
});
/* Criaturas */
$(document).ready(function () {
var height = $('#hab').height();
if (height >= 50) {
$('#hab').addClass('hide');
$('#show').removeClass('hide');
}
$('#show').click(function () {
$('.hide').toggle();
$('.showhab').toggle();
$('#NPC').addClass('hide');
});
});
/* Simulador de Charms - Charm Simulator */
if (mw.config.values.wgPageName === 'Simulador_de_Charms' || mw.config.values.wgPageName === 'Simulador_de_Charms' || mw.config.values.wgPageName === 'Calculadoras') {
$(document).ready(function(){
if ($('.charm_simulator_html') !== null) {
$.ajax({ url: '/index.php?title=Tibia_Wiki:Charm_Simulator/codigo&action=raw',success: function(codigo) {
var codigo_html = codigo.slice(codigo.search('<pre id="charm_html">') + 21, codigo.search('</pre>'));
$('.charm_simulator_html').html(codigo_html);
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_css = codigo.slice(codigo.search('<pre id="charm_css">') + 20, codigo.search('</pre>'));
$('head').append('<style type="text/css">'+codigo_css+'</style>');
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_js = codigo.slice(codigo.search('<pre id="charm_js">') + 19, codigo.search('</pre>'));
$('.charm_simulator_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
}
});
}
/* Hot Cuisine Calculator System */
if (mw.config.values.wgPageName === 'Hot_Cuisine_Calculator_System' || mw.config.values.wgPageName === 'Hot_Cuisine_Quest' || mw.config.values.wgPageName === 'Calculadoras') {
$(document).ready(function(){
if ($('.hot_cuisine_calc_system') !== null) {
$.ajax({ url: '/index.php?title=Tibia_Wiki:Hot_Cuisine_Calculator_System/Codigo&action=raw',success: function(codigo) {
var codigo_html = codigo.slice(codigo.search('<pre id="hot_cuisine_system_html">') + 34, codigo.search('</pre>'));
$('.hot_cuisine_calc_system').html(codigo_html);
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_css = codigo.slice(codigo.search('<pre id="hot_cuisine_system_css">') + 33, codigo.search('</pre>'));
$('head').append('<style type="text/css">'+codigo_css+'</style>');
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_js = codigo.slice(codigo.search('<pre id="hot_cuisine_system_js">') + 32, codigo.search('</pre>'));
$('.hot_cuisine_calc_system_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
}
});
}
/* Exercise Weapons Calculator */
if (mw.config.values.wgPageName === 'Exercise_Weapons_Calculator' || mw.config.values.wgPageName === 'Calculadoras') {
$(document).ready(function(){
if ($('.exercise_weapon_calc') !== null) {
$.ajax({ url: '/index.php?title=Tibia_Wiki:Exercise_Weapons_Calculator/Codigo&action=raw',success: function(codigo) {
var codigo_html = codigo.slice(codigo.search('<pre id="exercise_weapons_html">') + 32, codigo.search('</pre>'));
$('.exercise_weapon_calc').html(codigo_html);
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_css = codigo.slice(codigo.search('<pre id="exercise_weapons_css">') + 31, codigo.search('</pre>'));
$('head').append('<style type="text/css">'+codigo_css+'</style>');
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_js = codigo.slice(codigo.search('<pre id="exercise_weapons_js">') + 30, codigo.search('</pre>'));
$('.exercise_weapon_calc_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
}
});
}
/* Skills Calculator */
if (mw.config.values.wgPageName === 'Calculadora_de_Skills' || mw.config.values.wgPageName === 'Calculadoras') {
$(document).ready(function(){
if ($('.skills_calc_system') !== null) {
$.ajax({ url: '/index.php?title=Tibia_Wiki:Skills_Calculator/Codigo&action=raw',success: function(codigo) {
var codigo_html = codigo.slice(codigo.search('<pre id="skills_calculator_html">') + 33, codigo.search('</pre>'));
$('.skills_calc_system').html(codigo_html);
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_css = codigo.slice(codigo.search('<pre id="skills_calculator_css">') + 32, codigo.search('</pre>'));
$('head').append('<style type="text/css">'+codigo_css+'</style>');
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_js = codigo.slice(codigo.search('<pre id="skills_calculator_js">') + 31, codigo.search('</pre>'));
$('.skills_calc_system_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
}
});
}
/* Mapa */
if (mw.config.values.wgPageName === 'Mapa') {
$(document).ready(function(){
var url = location.hash;
$(".map_wiki").append('<div id="map" style="width: 100%; height: 100%;"></div>');
loadMapScripts();
});
}
/* Mapa Popup */
/** Abre o popup de mapa de Monstros e NPCs */
$('.map_show').click(function() {
var display = $('.map_frame',this).css('display');
if (display == 'none') { showMap(this); }
return false;
});
/** Fecha o mapa ao clicar na parte Preta (Overlay) */
$('.map_overlay').click(function() {
$('.map_show').each(function( index ) {
hideMap($('.map_show')[index]);
});
return false;
});
$('.map_logobox').click(function(event){
event.stopPropagation();
});
/* Mapa Infobox Hunt */
$('.map_hunt').ready(function(){
var coord = $('.map_hunt_coord',this).text();
/** Transforma a logo do TibiaWiki em um link para a página do Mapa com as coordenadas da localiação */
$(".map_logobox",this).append('<a href="https://www.tibiawiki.com.br/wiki/mapa#'+coord+':1" class="map_logo" target="_blank" title="Ver no mapa do Tibia Wiki"></a>');
/** Box do Map */
var mapBox = $(".map_hunt_box",this);
mapBox.html("");
/** Cria o iFrame que conterá o Mapa */
mapBox.append('<iframe id="mapa_frame" scrolling="no" frameborder="0" width="100%" height="310" style="border-radius:8px"></iframe>');
/** Pega o Map iFrame */
var mapFrame = $("#mapa_frame",mapBox);
/** Seta as Coordenadas do Mapa */
// mapFrame.attr("src", mapFrame.contents().get(0).URL + "#" + coord + ":1");
mapFrame.ready(function() {
//let iframeMap = mapFrame[0];
//if (iframeMap !== null) {
// loadMapOnIFrame(coord, mapFrame[0]);
//}
loadMapOnIFrame(coord, mapFrame[0]);
});
});
/* Mapa Infobox Geo */
$('.map_hunt_geo').ready(function(){
var coord = $('.map_hunt_coord_geo',this).text();
/** Transforma a logo do TibiaWiki em um link para a página do Mapa com as coordenadas da localiação */
$(".map_logobox",this).append('<a href="https://www.tibiawiki.com.br/wiki/mapa#'+coord+':1" class="map_logo" target="_blank" title="Ver no mapa do Tibia Wiki"></a>');
/** Box do Map */
var mapBox = $(".map_hunt_box_geo",this);
mapBox.html("");
/** Cria o iFrame que conterá o Mapa */
mapBox.append('<iframe id="mapa_frame" scrolling="no" frameborder="0" width="100%" height="430" style="border-radius:8px"></iframe>');
/** Pega o Map iFrame */
var mapFrame = $("#mapa_frame",mapBox);
/** Seta as Coordenadas do Mapa */
// mapFrame.attr("src", mapFrame.contents().get(0).URL + "#" + coord + ":1");
mapFrame.ready(function() {
//let iframeMap = mapFrame[0];
//if (iframeMap !== null) {
// loadMapOnIFrame(coord, mapFrame[0]);
//}
loadMapOnIFrame(coord, mapFrame[0]);
});
});
/** Mapa internalizado ao Wiki - Teste */
if (mw.config.values.wgPageName === 'Mapa/Teste') {
$(document).ready( function () {
$(".map_wiki").append('<div id="map" style="width: 100%; height: 100%;"></div>');
loadMapScripts();
});
}
/** Função que faz o popup em lightbox do Mapa apareça. */
function showMap(container) {
$('.map_frame',container).css('display', 'inline');
$('.map_overlay',container).css('display', 'inline');
configPopupMap(container);
}
/** Função que faz o popup em lightbox do Mapa desaparecer. */
function hideMap(container) {
$('.map_frame',container).css('display', 'none');
$('.map_overlay',container).css('display', 'none');
}
/** Configura o Popup (LightBox) de Mapa */
function configPopupMap(container) {
/** Configura o Mapa. */
$('.map_box').each(function( index ) {
$(this).html("")
});
var coord = $('.map_frame_coord',container).text();
window.history.replaceState("map", null, "#" + coord + ":1");
$(".map_box", container).css("width", "100%").css("height", "100%")
$(".map_box", container).append('<div id="map" style="width: 100%; height: 100%;"></div>');
/** Transforma a logo do TibiaWiki em um link para a página do Mapa com as coordenadas da localiação */
$(".map_logobox",container).append('<a href="https://www.tibiawiki.com.br/wiki/mapa#'+coord+':1" class="map_logo" target="_blank" title="Ver no mapa do Tibia Wiki"></a>');
loadMapScripts();
}
/** Função que realiza o load dos scripts de Map. */
function loadMapScripts() {
$('link[href="https://tibiamaps.io/_css/map.css"]').remove();
$('head').append('<link rel="stylesheet" href="https://tibiamaps.io/_css/map.css">');
$('script[src="https://tibiamaps.io/_js/map.js"]').remove();
$('<script>').attr('src', "https://tibiamaps.io/_js/map.js").appendTo('head');
}
/** Carrega o Mapa no iframe. */
function loadMapOnIFrame(coord, iframe) {
if (iframe === null || iframe === undefined) { return; }
createCss(iframe.contentDocument, iframe.contentDocument.getElementsByTagName('head').item(0), 'https://tibiamaps.io/_css/map.css');
createStyle(iframe.contentDocument, iframe.contentDocument.getElementsByTagName('head').item(0), {"body": {"margin": "0px"}});
createComponent("map", {"width": "100%", "height": "100%"} ,iframe.contentDocument, iframe.contentDocument.getElementsByTagName('body').item(0));
$.ajax({ url: '/index.php?title=Tibia_Wiki:Mapa/Codigo&action=raw',success: function(codigo) {
var codigo_js = codigo.slice(codigo.search('<pre id="mapa_js">') + 18, codigo.search('</pre>'));
var bodyFrame = $(iframe).contents().find('body');
bodyFrame.append('<script type="text/javascript">var mapLocation = "#' + coord + ':1";\n'+codigo_js+'</script>');
}});
}
/** Cria component DIV. */
function createComponent(id, css, doc, target, callback) {
var params = {
"name": "div",
"id": id,
"css": css
};
iframeInsertComponents(params, doc, target, callback);
}
/** Cria component LINK que carrega CSS. */
function createCss(doc, target, href, callback) {
var params = {
"name": "link",
"rel": "stylesheet",
"href": href
};
iframeInsertComponents(params, doc, target, callback);
}
/** Cria component Script que carrega JavaScript. */
function createScript(doc, target, code, callback) {
var params = {
"name": "script",
"type": "text/javascript",
"code": code
};
iframeInsertComponents(params, doc, target, callback);
}
/** Cria component STYLE que carrega CSS na HEAD. */
function createStyle(doc, target, css, callback) {
var params = {
"name": "style",
"css": css
};
iframeInsertComponents(params, doc, target, callback);
}
/** Checa se a Variavel existe */
function isDefined(variable) {
return typeof variable !== 'undefined';
}
/** Algumas telas utiliza iFrames e precisa injetar JavaScripts para funcionar corretamente */
function iframeInsertComponents(params, doc, target, callback) {
//doc, target, src, callback
var s = doc.createElement(params.name);
if (params.name == "script") {
s.type = params.type;
}
if (params.name == "link") {
s.rel = params.rel;
}
if (params.name == "div") {
s.id = params.id;
if (params.css != null) {
Object.entries(params.css).forEach(function(arr, i) {
$(s).css(arr[0], arr[1]);
});
}
}
if(callback) {
if (s.readyState){ //IE
s.onreadystatechange = function(){
if (s.readyState == "loaded" ||
s.readyState == "complete"){
s.onreadystatechange = null;
callback();
}
};
} else { //Others
s.onload = function(){
callback();
};
}
}
if (params.name == "style") {
Object.entries(params.css).forEach(function(arr, i) {
var attrs = "";
Object.entries(arr[1]).forEach(function(attr, i) {
attrs += '\n' + attr[0] + ': ' + attr[1];
});
if (i === 0) {
s.innerText = arr[0] + ' {' + attrs + '\n}';
}
});
}
if (params.name == "script") {
if (params.code.src != null && params.code.src != "") {
s.src = params.src;
}
if (params.code.code != null) {
console.log(params.code.code);
var re = new RegExp('\n', 'g');
s.innerText = params.code.code.replace(re, '');//.split('<br>').join('\n');
}
}
if (params.name == "link") {
s.href = params.href;
}
target.appendChild(s);
}
/* Calculadoras - Shards */
if (mw.config.values.wgPageName === 'Calculadoras') {
$(document).ready(function(){
if ($('.calc_exp_events') !== null) {
$.ajax({ url: '/index.php?title=Tibia_Wiki:Experience_Events_Calculator/Codigo&action=raw',success: function(codigo) {
/* Get HTML Code */
var codigo_html = codigo.slice(codigo.search('<pre id="calc_exp_events_code_html">') + 36, codigo.search('</pre>'));
$('.calc_exp_events').html(codigo_html);
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
/* Get JavaScript Code */
var codigo_js = codigo.slice(codigo.search('<pre id="calc_exp_events_code_js">') + 34, codigo.search('</pre>'));
$('.calc_exp_events_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
}
});
}
/* Calculadoras - Party */
if (mw.config.values.wgPageName === 'Calculadoras') {
$(document).ready(function(){
if ($('.calc_exp_events') !== null) {
$.ajax({ url: '/index.php?title=MediaWiki:Common.js/calc_party.js&action=raw',success: function(codigo) {
/* Get HTML Code */
var codigo_html = codigo.slice(codigo.search('<pre id="calc_xp_party_html">') + 29, codigo.search('</pre>'));
$('.calc_xp_party_html').html(codigo_html);
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
/* Get JavaScript Code */
var codigo_js = codigo.slice(codigo.search('<pre id="calc_xp_party_js">') + 27, codigo.search('</pre>'));
$('.calc_xp_party_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
}
});
}
/* Calculadoras - Blessings */
if (mw.config.values.wgPageName === 'Calculadoras') {
$(document).ready(function(){
//mw.loader.load( '/index.php?title=MediaWiki:Common.js/blessing.js&action=raw&ctype=text/javascript' );
$.ajax({ url: '/index.php?title=MediaWiki:Common.js/blessing.js&action=raw',success: function(codigo) {
/* Get HTML Code */
var codigo_html = codigo.slice(codigo.search('<pre id="calc_blessing_html">') + 29, codigo.search('</pre>'));
$('.calc_bless_price_html').html(codigo_html);
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
/* Get JavaScript Code */
var codigo_js = codigo.slice(codigo.search('<pre id="calc_blessing_js">') + 27, codigo.search('</pre>'));
$('.calc_bless_price_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
});
}
/* Calculadoras - Skill */
$(document).ready(function () {
mw.loader.load( '/index.php?title=MediaWiki:Common.js/calc_skill.js&action=raw&ctype=text/javascript' );
});
/* Calculadoras - Profile */
$("#input_nome").append('<form action="/Sano/char.php" type="post" id="searchForm"><input name="character" id="nome" type="text" size="25" align="center" value="Nome do Personagem" onclick="this.value='';" onblur="this.value=!this.value?'Nome do Personagem':this.value;"/> <input type="submit" value="Ir" /></form>');
$("#searchForm").submit(function(event) {
event.preventDefault();
var $form = $( this ),
term = $form.find('input[name="character"]').val(),
url = $form.attr( 'action' );
$.post( '/Sano/char.php', $("#searchForm").serialize(),
function( data ) {
$( "#result_personagem" ).empty().append('<center><table id="alter" style="text-align:left;border:none;margin-top:5px;"><tr><td colspan="4" style="text-align:center;"><b>Informações do Personagem</b></td></tr><tr><td style="width:5%"><b>Nome:</b></td><td style="width:45%">' + data.Nome + '</td><td style="width:5%"><b>Level:</b></td><td style="width:45%">' + data.Level + '</td></tr><tr class="dif"><td><b>Vocação:</b></td><td>' + data.Vocacao + '</td><td><b>Mundo:</b></td><td>' + data.Mundo + '</td></tr><tr><td><b>Guild:</b></td><td>' + data.Guild + '</td><td><b>Tutor:</b></td><td>' + data.Tutor + '</td></tr><tr class="dif"><td><b>Residencia:</b></td><td>' + data.Residencia + '</td><td><b>Casa:</b></td><td>' + data.Casa + '</td></tr><tr><td><b>Casado com:</b></td><td>' + data.Casado + '</td><td><b>Sexo:</b></td><td>' + data.Sexo + '</td></tr><tr class="dif"><td><b>Achievements:</b></td><td>' + data.Achievements + '</td><td><b>Capacidade:</b></td><td>' + data.Capacidade + '</td></tr><tr><td><b>Vida:</b></td><td>' + data.Life + '</td><td><b>Mana:</b></td><td>' + data.Mana + '</td></tr><tr class="dif"><td><b>Status:</b></td><td>' + data.Status + '</td><td><b>Velocidade:</b></td><td>' + data.Velocidade + '</td></tr><tr><td colspan="4">Você pagará ' + data.Bless + ' gps por cada benção comum e pagará ' + data.Bless3 + ' gps por cada bênção melhorada.Tendo assim o valor total de ' + data.Bless2 + ' gps por todas elas.<br/>Em uma party, você poderá compartilhar experiência com leveis: ' + data.Party + '</td></tr></table></center>');
}, "json");
});
/* Abas */
$(document).ready(function(){
$('.showDiv').on('click', function () {
$(this).siblings();
$('.targetDiv').hide();
$('.targetDiv2').hide();
$('#div' + $(this).data('target')).show();
});
});
/* Abas Menu*/
$(document).ready(function () {
$('.mostrar-aba').click(function () {
var aba_id = $(this).attr('data-aba');
var check = $("#aba-" + aba_id).css('display');
if (check == "block") {
$("#aba-" + aba_id).removeClass('atual');
} else {
$('.aba').removeClass('atual');
$("#aba-" + aba_id).addClass('atual');
}
});
$('.mostrar-todas-abas').click(function () {
var check = $('.aba').css('display');
if (check == "block") {
$('.aba').removeClass('atual');
} else {
$('div.aba').toggleClass('atual');
}
});
var url = location.href;
hash = url.split('#')[1];
if ((hash != null || hash != undefined) && hash.length > 0){
$("#aba-" + hash).addClass('atual');
}
});
/** Cidade Rashid
* Esse código converte o horário local para o horário de Berlin, pegando o dia da semana corretamente, independente do Horário de Verão.
*/
$(document).ready(function () {
/** Objeto que contém os dados do Rashid
* Dia da Semana
* 0: Domingo.
* 1: Segunda-Feira.
* 2: Terça-Feira.
* 3: Quarta-Feira.
* 4: Quinta-Feira.
* 5: Sexta-Feira.
* 6: Sábado.
*
* @param day Variavel que recebe o dia da semana.
* @param city Variavel que recebe a Cidade em que o Rashid está.
* @param image Variavel que recebe o link da Imagem de Background com o mapa de onde o Rashid está.
*/
var rashidCities = {
0: {
"day": "domingo",
"city": "Carlin",
"image": "/images/5/5f/Rashid_Carlin.png"
},
1: {
"day": "segunda-feira",
"city": "Svargrond",
"image": "/images/3/34/Rashid_Svargrond.png"
},
2: {
"day": "terça-feira",
"city": "Liberty Bay",
"image": "/images/3/33/Rashid_Liberty_Bay.png"
},
3: {
"day": "quarta-feira",
"city": "Port Hope",
"image": "/images/c/cf/Rashid_Port_Hope.png"
},
4: {
"day": "quinta-feira",
"city": "Ankrahmun",
"image": "/images/2/2a/Rashid_Ankrahmun.png"
},
5: {
"day": "sexta-feira",
"city": "Darashia",
"image": "/images/c/cb/Rashid_Darashia.png"
},
6: {
"day": "sábado",
"city": "Edron",
"image": "/images/6/6f/Rashid_Edron.png"
}
}
/**
* @param data Variavel que recebe a data e hora atual de qualquer país e converte para a data e hora de Berlin.
* @param hora Variavel que recebe a Hora atual de Berlin.
* @param dia Variavel que recebe o dia da semana, e assim ele calcula se já ocorreu o SS ou não.
*/
var data = new Date(new Date().toLocaleString('en-US', { timeZone: 'Europe/Berlin' }));
var hora = data.getHours();
var sDay = data.getDay();
var dia = (hora >= 10) ? sDay : ((sDay == 0) ? 6 : sDay - 1) ;
/** Popula o HTML do box do Rashid na página do TibiaWiki */
$('#rashid_city_white').html('<a style="color:#FFFFFF; text-decoration:none;" href="'+rashidCities[dia].city+'">'+rashidCities[dia].city+'</a>');
$('#rashid_city_link').html('<a style="color:#0645ad;" href="'+rashidCities[dia].city+'">'+rashidCities[dia].city+'</a>');
$('#tibiaday').html(''+rashidCities[dia].day+'');
$('#rashid_home').css('background','url("'+rashidCities[dia].image+'")');
$('#rashid_home').css('background-repeat','no-repeat');
$('#rashid_home').css('background-size','cover');
$('#rashid_home').css('background-position','35% 0%');
$('#rashid_home').css('height','120px');
});
/* Semana Atual */
$(document).ready(function () {
Date.prototype.getWeek = function () {
var onejan = new Date(this.getFullYear(), 0, 1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
}
var today = new Date();
var currentWeekNumber = today.getWeek();
$('#semanaatual').html(currentWeekNumber);
var currentDay = today.getDate();
$('#diaatual').html(currentDay);
});
/* Imbuing */
if (mw.config.values.wgPageName === 'Imbuement_Tool') {
$(document).ready(function(){
$.ajax({ url: '/index.php?title=Tibia_Wiki:Imbuing/Codigo&action=raw',success: function(codigo) {
var codigo_html = codigo.slice(codigo.search('<pre id="imbuing_html">') + 24, codigo.search('</pre>'));
$('.imbuing').html(codigo_html);
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_css = codigo.slice(codigo.search('<pre id="imbuing_css">') + 23, codigo.search('</pre>'));
$('head').append('<style type="text/css">'+codigo_css+'</style>');
codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
var codigo_js = codigo.slice(codigo.search('<pre id="imbuing_js">') + 22, codigo.search('</pre>'));
$('.imbuing_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
});
}
/* Geografia */
$(document).ready(function() { $('#casa').hover(function() { $("#house").removeClass('no'); }, function() { $("#house").addClass("no"); }); $('#guild').hover(function() { $("#guildh").removeClass('no'); }, function() { $("#guildh").addClass("no"); }); $('#biblioteca').hover(function() { $("#library").removeClass('no'); }, function() { $("#library").addClass("no"); }); $('#ruas').hover(function() { $("#street").removeClass('no'); }, function() { $("#street").addClass("no"); }); $('#invasao').hover(function() { $("#raid").removeClass('no'); }, function() { $("#raid").addClass("no"); }); $('.huntopc a').removeAttr('href');});
/* Toggle Diálogos */
$(document).ready(function(){
$('[data-dialog-text]').hide();
$('[data-dialog-show]').on('click', function() {
$element = $(this).parents('[data-dialog]').children('[data-dialog-text]')
if($element.is(":hidden")) {
$element.show();
} else {
$element.hide();
}
});
});
/* Server Save */
if (mw.config.values.wgPageName === 'Home') {
$(document).ready(function () {
const threadTime = 1000; // Tempo que atualiza o Tempo para o SS. 1000 = 1 segundo.
var ssHour = 10; // Hora do SS. 10:00:00h AM de Berlin.
var ssMinute = 0; // Minuto do SS.
var ssSecond = 0; // Segundo do SS.
var ss = new Date(); // Variavel de SS.
var countDownDate = ss.getTime(); // Variavel de Time do SS.
var x = setInterval(function() {
/* Pega Hora do SS em Berlin
* - Pega o horário de Berlin, e seta para o horário do SS, 10:00:00 AM sempre do dia atual ou dia seguinte, caso necessário.
*/
ss = new Date(new Date().toLocaleString('en-US', { timeZone: 'Europe/Berlin' }));
if (ss.getHours() >= ssHour) {
ss.setDate(ss.getDate() + 1);
}
ss.setHours(ssHour, ssMinute, ssSecond);
countDownDate = ss.getTime();
/* Fim - Pega Hora do SS em Berlin */
/* Pega Hora atual em Berlin
* - Essa forma, não importa o país, ele converte para o horário atual de Berlin.
*/
var now = new Date(new Date().toLocaleString('en-US', { timeZone: 'Europe/Berlin' })).getTime();
var distance = countDownDate - now; // Realiza o Calculo para saber a "Distancia" entre a hora atual até o horáio do SS.
/* Fim - Pega Hora atual em Berlin*/
/* Calculo de Horas para o SS.
* Transforma a distancia de horários entre o SS e a hora atual, em formato de Horas.
*/
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var pluralH = hours === 1 ? "" : "s"; // Verifica se é mais de uma Hora, se for, acrescenta o 'S' para poder deixar a descrição em plural.
/* Calculo de Minutos para o SS.
* Transforma a distancia de horários entre o SS e a hora atual, em formato de Minutos.
*/
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var pluralM = minutes === 1 ? "" : "s"; // Verifica se é mais de um Minuto, se for, acrescenta o 'S' para poder deixar a descrição em plural.
if (hours >= 1) {
$('#serversave').text('Faltam ' + hours + 'h ' + minutes + 'min'+ ' para o Server Save.');
} else {
if (minutes >= 1) {
$('#serversave').text('Faltam ' + minutes + ' min'+pluralM+ ' para o Server Save.');
} else {
/* Calculo de Segundos para o SS.
* Transforma a distancia de horários entre o SS e a hora atual, em formato de Segundos.
*/
var seconds = Math.floor((distance % (1000 * 60 * 60)) / 1000);
var pluralS = seconds === 1 ? "" : "s"; // Verifica se é mais de um Segundo, se for, acrescenta o 'S' para poder deixar a descrição em plural.
$('#serversave').text('Faltam ' + seconds + ' segundo' + pluralS + ' para o Server Save.');
}
}
}, threadTime);
});
}
const loaded_scripts = []
$(document).ready(function () {
$('.load_js').each(function () {
const script = $(this).attr('data-script')
if (!loaded_scripts.includes(script)) {
mw.loader.load('/index.php?title=MediaWiki:' + script + '&action=raw&ctype=text/javascript')
loaded_scripts.push(script)
}
})
})