10 172
edições
Sem resumo de edição |
Sem resumo de edição |
||
Linha 54: | Linha 54: | ||
var isAscending = true; | var isAscending = true; | ||
var $sortButton = $('<div class="sort-button" style="width: 60px; height: 50px; 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; float: right; margin-right: 0.5%;margin-top: -50px;"></div>'); | var $sortButton = $('<div class="sort-button" style="width: 60px; height: 50px; 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; float: right; margin-right: 0.5%;margin-top: -50px;"></div>'); | ||
$('.square-div- | $('.square-div-shiny').before($sortButton); | ||
$sortButton.on('click', function () { | $sortButton.on('click', function () { | ||
var $container = $('.square-div- | var $container = $('.square-div-shiny'); | ||
var $boxes = $container.children('.square-box- | var $boxes = $container.children('.square-box-shiny'); | ||
$boxes.sort(function (a, b) { | $boxes.sort(function (a, b) { | ||
var numA = parseInt($(a).find('.square-name- | var numA = parseInt($(a).find('.square-name-shiny').text().match(/\d+/)[0], 10); | ||
var numB = parseInt($(b).find('.square-name- | var numB = parseInt($(b).find('.square-name-shiny').text().match(/\d+/)[0], 10); | ||
return isAscending ? numA - numB : numB - numA; | return isAscending ? numA - numB : numB - numA; |