MediaWiki:Common.js: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição |
Sem resumo de edição |
||
| Linha 53: | Linha 53: | ||
$(document).ready(function () { | $(document).ready(function () { | ||
var isAscending = true; | var isAscending = true; | ||
var $sortButton = $('<div class="sort-button" style="width: 25px; height: 25px; background-image: url(https://wiki.otpokemon.com/images/9/92/O-c.png); background-position: center; background-repeat: no-repeat; background-size: cover; border-radius: 3px; cursor: pointer;"></div>'); | |||
var $sortButton = $('<div class="sort-button" style="width: 25px; height: 25px; background-image: url(https://wiki.otpokemon.com/images/ | |||
$('.square-div-gym').before($sortButton); | $('.square-div-gym').before($sortButton); | ||
| Linha 70: | Linha 69: | ||
$container.append($boxes); | $container.append($boxes); | ||
isAscending = !isAscending; | isAscending = !isAscending; | ||
var newImage = isAscending | |||
? 'https://wiki.otpokemon.com/images/9/92/O-c.png' | |||
: 'https://wiki.otpokemon.com/images/e/e2/O-d.png'; | |||
$sortButton.css('background-image', 'url(' + newImage + ')'); | |||
}); | }); | ||
}); | }); | ||
}); | }); | ||
Edição das 17h48min de 14 de março de 2025
var coll1 = document.getElementsByClassName("collapsible-battle-pass");
var coll2 = document.getElementsByClassName("collapsible-pokemon");
function toggleContent(clickedButton, contentToToggle) {
var allContents = document.getElementsByClassName("content");
for (var j = 0; j < allContents.length; j++) {
allContents[j].style.maxHeight = null;
}
var allButtons = document.getElementsByClassName("collapsible-battle-pass");
for (var k = 0; k < allButtons.length; k++) {
allButtons[k].classList.remove("active");
}
allButtons = document.getElementsByClassName("collapsible-pokemon");
for (var k = 0; k < allButtons.length; k++) {
allButtons[k].classList.remove("active");
}
if (contentToToggle.style.maxHeight) {
contentToToggle.style.maxHeight = null;
} else {
contentToToggle.style.maxHeight = contentToToggle.scrollHeight + "px";
}
clickedButton.classList.add("active");
}
for (var i = 0; i < coll1.length; i++) {
coll1[i].addEventListener("click", function() {
var content = this.nextElementSibling;
toggleContent(this, content);
});
}
for (var i = 0; i < coll2.length; i++) {
coll2[i].addEventListener("click", function() {
var content = this.nextElementSibling;
toggleContent(this, content);
});
}
function toggleShinyList() {
var shinyList = document.getElementById("shiny-list");
if (shinyList.style.display === "none" || shinyList.style.display === "") {
shinyList.style.display = "block";
} else {
shinyList.style.display = "flex";
}
}
mw.loader.using('jquery', function () {
$(document).ready(function () {
var isAscending = true;
var $sortButton = $('<div class="sort-button" style="width: 25px; height: 25px; background-image: url(https://wiki.otpokemon.com/images/9/92/O-c.png); background-position: center; background-repeat: no-repeat; background-size: cover; border-radius: 3px; cursor: pointer;"></div>');
$('.square-div-gym').before($sortButton);
$sortButton.on('click', function () {
var $container = $('.square-div-gym');
var $boxes = $container.children('.square-box-gym');
$boxes.sort(function (a, b) {
var numA = parseInt($(a).find('.square-name-gym').text().match(/\d+/)[0], 10);
var numB = parseInt($(b).find('.square-name-gym').text().match(/\d+/)[0], 10);
return isAscending ? numA - numB : numB - numA;
});
$container.append($boxes);
isAscending = !isAscending;
var newImage = isAscending
? 'https://wiki.otpokemon.com/images/9/92/O-c.png'
: 'https://wiki.otpokemon.com/images/e/e2/O-d.png';
$sortButton.css('background-image', 'url(' + newImage + ')');
});
});
});