Doublexp doubleskill.png Double Exp & Skill: Matar monstros rende o dobro de pontos de experiência. O progresso de skills é duas vezes mais rápido! Doublexp doubleskill.png
Bone Overlord.gif The Roost of the Graveborn Quest Spoiler!
Domine Graveborn: todos os bosses e mecânicas ilustradas!
Saiba mais ➔
Winter Tree.png Winter Update 2025
Acompanhe tudo sobre o Winter Update 2025!
Saiba mais ➔
Stag.gif The Order of the Stag Quest Spoiler!
Conheça Isle of Ada: sua quest, missões secundárias e todos os bosses!
Saiba mais ➔

MediaWiki:Common.js: mudanças entre as edições

De Tibia Wiki - A Enciclopédia do Tibia
Ir para navegação Ir para pesquisar
m
JovicXD
JovicXD (discussão | contribs) (Foram revertidas as edições de Jovic (disc) para a última versão por Ricci)
m
Linha 411: Linha 411:
     /** Popula o HTML do box do Rashid na página do TibiaWiki */
     /** Popula o HTML do box do Rashid na página do TibiaWiki */
     $('#rashid_city_black').html('<a style="color:#000000;" href="'+rashidCities[dia].city+'">'+rashidCities[dia].city+'</a>');
     $('#rashid_city_black').html('<a style="color:#000000;" href="'+rashidCities[dia].city+'">'+rashidCities[dia].city+'</a>');
     $('#rashid_city_link').html('<a style="color:#FFFFFF;" 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+'');
     $('#tibiaday').html(''+rashidCities[dia].day+'');
     $('#rashid_home').css('background','url("'+rashidCities[dia].image+'")');
     $('#rashid_home').css('background','url("'+rashidCities[dia].image+'")');

Edição das 21h33min de 17 de agosto de 2021

/* 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() {
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');
    });
});

/* Mapa */
$(document).ready(function(){
    var url = location.hash;
    $(".map_wiki").append('<iframe src="https://jessleewyn.github.io/MapaTeste/'+url+'" scrolling="no" frameborder="0" width="800" height="500"></iframe>');
});

/* Mapa Popup */
$('.map_show').click(function() {
        var id = $(this).attr('id');
     $('#div' + id).toggle();
     $('.map_frame',this).toggle(); 
        // alert(id);
     return false;
});

$('.map_show').click(function() {
        var id = $(this).attr('id');
     $('#div' + id).toggle();
     $('.map_overlay',this).toggle(); 
        // alert(id);
     return false;
});

$('.map_logobox').click(function(event){
    event.stopPropagation();
});

/** Mapas de Localização de NPCs/Monsters */
$('.map_show').one("click", function() {
    var url = location.host;
    var link = url.split('.');
    var text = link[0];
    var coord = $('.map_frame_coord',this).text()

    var mapShow = this;

    $.ajax({ url: '/index.php?title=Tibia_Wiki:Mapa/Codigo&action=raw',success: function(codigo) {
        /** Popup do Map */
        var mapBox = $(".map_box",mapShow);
        /** Cria o iFrame que conterá o Mapa */
        mapBox.append('<iframe id="mapa_frame" scrolling="no" frameborder="0" width="520" height="450"></iframe>');
        /** Pega o Map iFrame */
        var mapFrame = $("#mapa_frame",mapBox);

        /** Carrega o container do MAPA */
        var codigo_html = codigo.slice(codigo.search('<pre id="mapa_html">') + 20, codigo.search('</pre>'));

        /** Pega o body do iframe que conterá o Mapa */
        var bodyFrame = mapFrame.contents().find('body');
        /** Carrega o Mapa */
        bodyFrame.html(codigo_html);

        /** Seta as Coordenadas do Mapa */
        mapFrame.attr("src", mapFrame.contents().get(0).URL + "#" + coord + ":1");

        /** Carrega o CSS do Mapa */
        codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
        var codigo_css = codigo.slice(codigo.search('<pre id="mapa_css">') + 19, codigo.search('</pre>'));
        var headFrame = mapFrame.contents().find('head');
        headFrame.append('<style type="text/css">'+codigo_css+'</style>');
        headFrame.append('<style>body{margin:0}</style>');
    
        /** Carrega o JavaScript do Mapa */
        codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
        var codigo_js = codigo.slice(codigo.search('<pre id="mapa_js">') + 18, codigo.search('</pre>'));
        bodyFrame.append('<script type="text/javascript">'+codigo_js+'</script>');

        /** Transforma a logo do TibiaWiki em um link para a página do Mapa com as coordenadas da localiação */
        $(".map_logobox",mapShow).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>');
    }});
});

/* Mapa Infobox Hunt */
$('.map_hunt').ready(function(){
    var url = location.host;
    var link = url.split('.');
    var text = link[0];
    var coord = $('.map_hunt_coord',this).text();
    console.log(coord);
    var mapHunt = this;

    $.ajax({ url: '/index.php?title=Tibia_Wiki:Mapa/Codigo&action=raw',success: function(codigo) {
        /** Popup do Map */
        var mapBox = $(".map_hunt_box",mapHunt);
        /** Cria o iFrame que conterá o Mapa */
        mapBox.append('<iframe id="mapa_frame" scrolling="no" frameborder="0" width="100%" height="310" style="border-radius:12px"></iframe>');
        /** Pega o Map iFrame */
        var mapFrame = $("#mapa_frame",mapBox);

        /** Carrega o container do MAPA */
        var codigo_html = codigo.slice(codigo.search('<pre id="mapa_html">') + 20, codigo.search('</pre>'));

        /** Pega o body do iframe que conterá o Mapa */
        var bodyFrame = mapFrame.contents().find('body');
        /** Carrega o Mapa */
        bodyFrame.html(codigo_html);

        /** Seta as Coordenadas do Mapa */
        mapFrame.attr("src", mapFrame.contents().get(0).URL + "#" + coord + ":1");

        /** Carrega o CSS do Mapa */
        codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
        var codigo_css = codigo.slice(codigo.search('<pre id="mapa_css">') + 19, codigo.search('</pre>'));
        var headFrame = mapFrame.contents().find('head');
        headFrame.append('<style type="text/css">'+codigo_css+'</style>');
        headFrame.append('<style>body{margin:0}</style>');
    
        /** Carrega o JavaScript do Mapa */
        codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
        var codigo_js = codigo.slice(codigo.search('<pre id="mapa_js">') + 18, codigo.search('</pre>'));
        bodyFrame.append('<script type="text/javascript">'+codigo_js+'</script>');

        /** Transforma a logo do TibiaWiki em um link para a página do Mapa com as coordenadas da localiação */
        $(".map_logobox",mapHunt).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>');
    }});    
});

/** Mapa internalizado ao Wiki - Teste */
if (wgPageName === 'Mapa/Teste') {
    $(document).ready( function () {
        $(".mapa_html").append('<div id="map" style="width: 100%; height: 100%;"></div>');
        $("head").append('<link rel="stylesheet" href="https://tibiamaps.io/_css/map.css">');
        $.getScript("https://tibiamaps.io/_js/map.js");
    });
}

/* Calculadoras - Shards */
$(document).ready(function () {
    $('#calc_shard').bind("keyup change", function () {
        var level = $('#level').val();
        var quantidade = $('#quantidade').val();
        var item = $("select#item").val();
        if (item == 2) {
            if (quantidade <= 0) {
                $('#shard-result').addClass("hide");
                $('#shard-result3').addClass("hide");
            } else if (quantidade >= 2) {
                $('#shard-result').text('Você receberá ' + $('#level').val() * $('#level').val() * 100 * $('#quantidade').val() + ' de experiência.');
                $('#shard-result').removeClass("hide");
                $('#shard-result3').removeClass("hide");
            } else {
                $('#shard-result').text('Você receberá ' + $('#level').val() * $('#level').val() * 100 + ' de experiência.');
                $('#shard-result').removeClass("hide");
                $('#shard-result3').addClass("hide");
            }
        } else {
            $('#shard-result3').addClass("hide");
            if (quantidade >= 41) {
            $('#shard-result2').removeClass("hide");
        } else {
            $('#shard-result2').addClass("hide");
        }
            if (quantidade <= 0) {
                $('#shard-result').addClass("hide");
                $('#shard-result2').addClass("hide");
            } else if (quantidade >= 1) {
                if (level >= 200) {
                    $('#shard-result').removeClass("hide");
                    $('#shard-result').text('Você receberá ' + (300 * 200) * $('#quantidade').val() + ' de experiência.');
                } else {
                    $('#shard-result').removeClass("hide");
                    $('#shard-result').text('Você receberá ' + (300 * $('#level').val()) * $('#quantidade').val() + ' de experiência.');
                }
            }
        }
        if (level >= 1 && quantidade <= 0) {
            $('#shard-result').addClass("hide");
            $('#shard-result2').addClass("hide");
            $('#shard-result3').addClass("hide");
        } else if (level <= 0 && quantidade <= 0) {
            $('#shard-result').addClass("hide");
            $('#shard-result2').addClass("hide");
            $('#shard-result3').addClass("hide");
        } else if (level <= 0 && quantidade >= 1) {
            $('#shard-result').addClass("hide");
            $('#shard-result2').addClass("hide");
            $('#shard-result3').addClass("hide");
        }
    });
});

$(document).ready(function () {
    $("#calc_shard").keydown(function (event) {
        if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || (event.keyCode == 65 && event.ctrlKey === true) || (event.keyCode >= 35 && event.keyCode <= 39)) {
            return;
        } else {
            if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                event.preventDefault();
            }
        }
    });
});

$("#botao_shard").append('<input name="quantidade" maxlength="3" id="quantidade" type="text" size="10" align="center" value="1" onclick="this.value=&#39;&#39;;" onblur="this.value=!this.value?&#39;1&#39;:this.value;" />');
$("#botao_level").append('<input name="level" maxlength="3" id="level" type="text" size="10" align="center" value="0" onclick="this.value=&#39;&#39;;" onblur="this.value=!this.value?&#39;0&#39;:this.value;" />');
$("#botao_item").append('<select id="item"><option value="1">Midnight Shard</option><option value="2">Stone of Insight</option></select>');

/* Calculadoras - Party */
$(document).ready(function () {
mw.loader.load( '/index.php?title=MediaWiki:Common.js/calc_party.js&action=raw&ctype=text/javascript' );
});  


/* Calculadoras - Blessings */
$(document).ready(function () {
mw.loader.load( '/index.php?title=MediaWiki:Common.js/blessing.js&action=raw&ctype=text/javascript' );
});  

/* 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=&#39;&#39;;" onblur="this.value=!this.value?&#39;Nome do Personagem&#39;: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.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_black').html('<a style="color:#000000;" 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','center');
});

/* Boosted Creature */
$(document).ready(function(){
    $("#boostedcreature_home").css("background-image", "url('https://www.tibiawiki.com.br/images/b/b4/Boosted_Creature_BG.png')");
    $.ajax({ url: '/index.php?title=Tibia_Wiki:BoostedCreature/Codigo&action=raw',success: function(codigo) {
        var codigo_js = codigo.slice(codigo.search('<pre id="boosted_creature_js">') + 31, codigo.search('</pre>'));

        $('.boosted_creature_js').html('<script type="text/javascript">'+codigo_js+'</script>');
    }});
});

/* Dream Scar Boss */
$(document).ready(function(){
    $("#dreamscarboss_home").css("background-image", "url('https://www.tibiawiki.com.br/images/6/68/Background_Artwork_12.00.jpg')");
    $.ajax({ url: '/index.php?title=Tibia_Wiki:DreamScarBoss/Codigo&action=raw',success: function(codigo) {
        var codigo_js = codigo.slice(codigo.search('<pre id="dream_scar_boss_js">') + 31, codigo.search('</pre>'));

        $('.dream_scar_boss_js').html('<script type="text/javascript">'+codigo_js+'</script>');
    }});
});

/* 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);
});

/* Outfiter */
if (wgPageName === 'Outfiter') {
$(document).ready(function(){
$.ajax({ url: '/index.php?title=Tibia_Wiki:Outfiter/Codigo&action=raw',success: function(codigo) {
  var codigo_html = codigo.slice(codigo.search('<pre id="outfiter_html">') + 24, codigo.search('</pre>'));
  $('.outfiter').html(codigo_html);
  codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
  var codigo_css = codigo.slice(codigo.search('<pre id="outfiter_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="outfiter_js">') + 22, codigo.search('</pre>'));
  $('.outfiter_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
});
}

/* Outfiter Teste */
if (wgPageName === 'Tibia_Wiki:Outfiter/Teste') {
$(document).ready(function(){
$.ajax({ url: '/index.php?title=Tibia_Wiki:Outfiter/CodigoTeste&action=raw',success: function(codigo) {
  var codigo_html = codigo.slice(codigo.search('<pre id="outfiter_html">') + 24, codigo.search('</pre>'));
  $('.outfiter').html(codigo_html);
  codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
  var codigo_css = codigo.slice(codigo.search('<pre id="outfiter_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="outfiter_js">') + 22, codigo.search('</pre>'));
  $('.outfiter_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
});
}

/* Calculadora_de_Skills */
if (wgPageName === 'Calculadora de Skills') {
$(document).ready(function(){
$.ajax({ url: '/index.php?title=Tibia_Wiki:Calculadora_de_Skills/Codigo&action=raw',success: function(codigo) {
  var codigo_html = codigo.slice(codigo.search('<pre id="Calculadora_de_Skills_html">') + 24, codigo.search('</pre>'));
  $('.Calculadora_de_Skills').html(codigo_html);
  codigo = codigo.slice(codigo.search('</pre>') + 6, codigo.length);
  var codigo_css = codigo.slice(codigo.search('<pre id="Calculadora_de_Skills_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="Calculadora_de_Skills_js">') + 22, codigo.search('</pre>'));
  $('.Calculadora_de_Skills_js').html('<script type="text/javascript">'+codigo_js+'</script>');
}});
});
}

/* Feed do Facebook */
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/pt_BR/sdk.js#xfbml=1&version=v2.4";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

/* Imbuing */
if (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]')
    console.log($(this).parent('[data-dialog]'));

    if($element.is(":hidden")) {
      $element.show();
    } else { 
      $element.hide();
    }
  });
});

/* Lista Dropdown */
function ddm() {

    // Variables, change these in case you need to set other class names (mmhide_ for 
    // contribute users for example)
    var parentClass = 'isParent'; //gets applied when the LI has a nested UL
    var activeParentClass = 'isActive'; //gets applied when the nested UL is visible
    var preventHoverClass = 'nohover'; //denotes a navigation that should not get any hover effects
    var indicateJSClass = 'dhtml'; //gets applied to the main navigation when JavaScript is available
    var toHideClass = 'hiddenChild'; //gets applied to hide the nested UL
    var toShowClass = 'shownChild'; //gets applied to show the nested UL
    var currentClass = 'current'; //denotes the current active sub element and prevents collapsing
    var d = document.getElementById('nav'); //denotes the navigation element 

    // if DOM is not available stop right here.
    if (!document.getElementById && !document.createTextNode) {
        return;
    }

    // if the navigation element is available, apply the class denoting DHTML capabilities
    if (d) {
        d.className += d.className == '' ? indicateJSClass : ' ' + indicateJSClass;
        var lis, i, firstUL, j, apply;

        // loop through all LIs and check which ones have a nested UL
        lis = d.getElementsByTagName('li');
        for (i = 0; i < lis.length; i++) {
            firstUL = lis[i].getElementsByTagName('ul')[0];
                // if there is a nested UL, deactivate the first nested link and apply the class to show 
                // there is a nested list
            if (firstUL) {
                lis[i].childNodes[0].onclick = function() {
                    return false;
                };
                lis[i].className += lis[i].className == '' ? parentClass : ' ' + parentClass;
                // check if there is a "current" element 
                apply = true;
                if (new RegExp('\\b' + currentClass + '\\b').test(lis[i].className)) {
                    apply = false;
                }
                if (apply) {
                    for (j = 0; j < firstUL.getElementsByTagName('li').length; j++) {
                        if (new RegExp('\\b' + currentClass + '\\b').test(firstUL.getElementsByTagName('li')[j].className)) {
                            apply = false;
                            break;
                        }
                    }
                }
                // if there is no current element, apply the class to hide the nested list
                if (apply) {
                    firstUL.className += firstUL.className == '' ? toHideClass : ' ' + toHideClass;
                    // check if there is a class to prevent hover effects and only apply the function
                    // onclick if that is the case, otherwise apply it onclick and onhover
                    if (new RegExp('\\b' + preventHoverClass + '\\b').test(d.className)) {
                        lis[i].onclick = function() {
                            doddm(this);
                        };
                    } else {
                        lis[i].onclick = function() {
                            doddm(this);
                        };
                        lis[i].onmouseover = function() {
                            doddm(this);
                        };
                        lis[i].onmouseout = function() {
                            doddm(null);
                        };
                    }
                    // if there is a current element, define the list as being kept open and apply the 
                    // classes to show the nested list and define the parent LI as an active one
                } else {
                    lis[i].keepopen = 1;
                    firstUL.className += firstUL.className == '' ? toShowClass : ' ' + toShowClass;
                    lis[i].className = lis[i].className.replace(parentClass, activeParentClass);
                }
            }
        }
    }
    // function to show and hide the nested lists and add the classes to the parent LIs
    function doddm(o) {
        var childUL, isobj, swap;

        // loop through all LIs of the navigation       
        lis = d.getElementsByTagName('li');
        for (i = 0; i < lis.length; i++) {
            isobj = lis[i] == o;
            // function to exchange class names in an object
            swap = function(tmpobj, tmporg, tmprep) {
                tmpobj.className = tmpobj.className.replace(tmporg, tmprep);
            };
            // if the current LI does not have an indicator to be kept visible
            if (!lis[i].keepopen) {
                childUL = lis[i].getElementsByTagName('ul')[0];
                // check if there is a nested UL and if the current LI is not the one clicked on
                // and exchange the classes accordingly (ie. hide all other nested lists and 
                // make the LIs parent rather than active.
                if (childUL) {
                    if (new RegExp('\\b' + preventHoverClass + '\\b').test(d.className)) {
                        if (new RegExp('\\b' + activeParentClass + '\\b').test(lis[i].className)) {
                            swap(childUL, isobj ? toShowClass : toHideClass, isobj ? toHideClass : toShowClass);
                            swap(lis[i], isobj ? activeParentClass : parentClass, isobj ? parentClass : activeParentClass);
                        } else {

                            swap(childUL, isobj ? toHideClass : toShowClass, isobj ? toShowClass : toHideClass);
                            swap(lis[i], isobj ? parentClass : activeParentClass, isobj ? activeParentClass : parentClass);
                        }
                    } else {
                        swap(childUL, isobj ? toHideClass : toShowClass, isobj ? toShowClass : toHideClass);
                        swap(lis[i], isobj ? parentClass : activeParentClass, isobj ? activeParentClass : parentClass);
                    }
                }
            }
        }
    }
}
window.onload = function() {
    ddm();
    // add other functions to be called onload below
};

/* Server Save */
$(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);
});