|
||||||
|
|
|
||||||||||||||||||||||||
MediaWiki:Common.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
| Linha 272: | Linha 272: | ||
} | } | ||
$('.toctext').click(function () { | $('.toctext').click(function () { | ||
location.reload(); | |||
}); | }); | ||
}); | }); | ||
Edição das 06h25min de 6 de julho 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();
});
$('.map_show').one('click', function() {
var url = location.host;
var link = url.split('.');
var text = link[0];
var coord = $('.map_frame_coord',this).text()
if (text == 'www') {
$(".map_box",this).append('<iframe src="https://jessleewyn.github.io/MapaTeste/#'+coord+':1" scrolling="no" frameborder="0" width="800" height="500"></iframe>');
} else {
$(".map_box",this).append('<iframe src="https://jessleewyn.github.io/MapaTeste/#'+coord+':1" scrolling="no" frameborder="0" width="800" height="500"></iframe>');
}
$(".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>');
});
/* 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()
if (text == 'www') {
$(".map_hunt_box",this).append('<iframe src="https://jessleewyn.github.io/MapaTeste/#'+coord+':1" scrolling="no" frameborder="0" width="100%" height="310" style="border-radius:12px"></iframe>');
} else {
$(".map_hunt_box",this).append('<iframe src="https://jessleewyn.github.io/MapaTeste/#'+coord+':1" scrolling="no" frameborder="0" width="100%" height="310" style="border-radius:12px"></iframe>');
}
$(".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>');
});
/* 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='';" onblur="this.value=!this.value?'1':this.value;" />');
$("#botao_level").append('<input name="level" maxlength="3" id="level" type="text" size="10" align="center" value="0" onclick="this.value='';" onblur="this.value=!this.value?'0':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='';" 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.length > 0){
$("#aba-" + hash).addClass('atual');
}
$('.toctext').click(function () {
location.reload();
});
});
/* Cidade Rashid */
$(document).ready(function () {
function getDate(offset){
var now = new Date();
var hour = 60*60*1000;
var min = 60*1000;
return new Date(now.getTime() + (now.getTimezoneOffset() * min) + (offset * hour));
}
var data = getDate(2); // CEST 2 - CET 1
var hora = data.getHours();
if (hora >= 10) {
var dia = data.getDay();
} else {
var dia = data.getDay() - 1;
}
var cidade;
var diasemana;
switch (dia) {
case 0:
cidade = ('Carlin');
diasemana = ('domingo');
break;
case 1:
cidade = ('Svargrond');
diasemana = ('segunda-feira');
break;
case 2:
cidade = ('Liberty Bay');
diasemana = ('terça-feira');
break;
case 3:
cidade = ('Port Hope');
diasemana = ('quarta-feira');
break;
case 4:
cidade = ('Ankrahmun');
diasemana = ('quinta-feira');
break;
case 5:
cidade = ('Darashia');
diasemana = ('sexta-feira');
break;
case 6:
case -1:
cidade = ('Edron');
diasemana = ('sábado');
break;
}
$('#rashidcity').html('<a href="'+cidade+'">'+cidade+'</a>');
$('#tibiaday').html(''+diasemana+'');
var cidadebg = cidade.replace(" ","_");
var rashidbackground = $('#rashid_'+cidadebg+'').html();
$('#rashid_home').css('background','url("'+rashidbackground+'")');
});
/* 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 Dialogos */
$(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 () {
var countDownDate = new Date("Jan 5, 2029 5:00:00").getTime();
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var pluralH = hours === 1 ? "" : "s";
var pluralM = minutes === 1 ? "" : "s";
if (hours >= 1) {
$('#serversave').text('Faltam ' + hours + ' hora'+pluralH+ ' e ' + minutes + ' minuto'+pluralM+ ' para o Server Save.');
} else {
$('#serversave').text('Faltam ' + minutes + ' minuto'+pluralM+ ' para o Server Save.');
}
}, 1000);
});