If you have a suggestion for the site, create a topic here and telll us about it
-
Christen57
- Posts: 2037
- Joined: Sun May 07, 2017 10:37 pm
- Reputation: 182
- Location: New York, United States of America
Post #1 by Christen57 » Wed Feb 23, 2022 1:18 am
I asked Genexwrecker to give us an option to sort monsters in our deck constructors based on factors besides name, such as monster type, attribute, level, rank, link rating, attack value, defense value, and pendulum scale, and she said "noted" meaning she'd do it. https://forum.duelingbook.com/viewtopic.php?p=73860#p73860
That was over 3 months ago and we still haven't gotten such an option, but today, I figured out how to put this option in myself using a little javascript, and managed to do so all in under 2 hours.
Create a bookmark on your browser and name it whatever you want. I'll be naming mine "sort monsters".
In the Address/URL/Location box, copy and paste this code:
Code: Select all
javascript:{let u = prompt("Enter 1 to sort monsters based on type\nEnter 2 to sort monsters based on attribute\nEnter 3 to sort monsters based on level/rank\nEnter 4 to sort monsters based on attack value\nEnter 5 to sort monsters based on defense value\nEnter 6 to sort monsters based on combined attack and defense value\nEnter 7 to sort monsters based on pendulum scale");
if (u == 1) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (a.data("type") > b.data("type")) {
return 1;
}
if (a.data("type") < b.data("type")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 2) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (a.data("attribute") > b.data("attribute")) {
return 1;
}
if (a.data("attribute") < b.data("attribute")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 3) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (~~a.data("level") > ~~b.data("level")) {
return 1;
}
if (~~a.data("level") < ~~b.data("level")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 4) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (~~a.data("atk") > ~~b.data("atk")) {
return 1;
}
if (~~a.data("atk") < ~~b.data("atk")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 5) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (~~a.data("def") > ~~b.data("def")) {
return 1;
}
if (~~a.data("def") < ~~b.data("def")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 6) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (~~a.data("atk") + ~~a.data("def") > ~~b.data("atk") + ~~b.data("def")) {
return 1;
}
if (~~a.data("atk") + ~~a.data("def") < ~~b.data("atk") + ~~b.data("def")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 7) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("pendulum") > b.data("pendulum")) {
return 1;
}
if (a.data("pendulum") < b.data("pendulum")) {
return -1;
}
if (~~a.data("scale") > ~~b.data("scale")) {
return 1;
}
if (~~a.data("scale") < ~~b.data("scale")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
};
}
Click save to save your bookmark.
![Image](https://i.imgur.com/VEpKCut.png)
Now go into the deck constructor, click your bookmark, and if everything was done successfully, something like this should appear:
![Image](https://i.imgur.com/3mYFaMO.png)
Now you have a few options. You can type a number from 1 to 7 in the box and hit enter on your keyboard to sort the monsters in the deck based on the corresponding factor.
If you enter 1, the monsters in the deck will be sorted based on their printed type in alphabetical order, meaning Aqua monsters will be listed first, Zombie monsters will be listed last, and so on.
If you enter 2, the monsters in the deck will be sorted based on their printed attribute in the alphabetical order of DARK, DIVINE, EARTH, FIRE, LIGHT, WATER, and WIND (DARK monsters will be listed first, WIND monsters will be listed last, and so on).
If you enter 3, the monsters in the deck will be sorted based on their level, rank, and link rating, from lowest level, rank, or link rating, to highest level, rank, or link rating. Monsters that don't have a printed level or rank, such as Ultimaya Tzolkin or Number F0: Utopic Draco Future, will be treated by this code as having a level/rank of 0, even if their effects specify that they have a higher level/rank than that.
If you enter 4, the monsters in the deck will be sorted based on their printed ATK value from lowest atk value to highest atk value. Monsters with ? ATK will be treated by this code as having an attack value of 0.
If you enter 5, it'll be just like entering 4, but with DEF value instead of ATK value. Also, link monsters will be unaffected by this code since they lack any defense value.
If you enter 6, the monsters in the deck will be sorted based on their combined printed atk and def values from lowest to highest, though I'm not sure how useful this one will be, as very few effects revolve around a specific sum of atk and def.
That's what a monster's combined atk and def value refers to — it's atk value + it's defense value, so for example, a monster with an atk value of 200 and a def value of 300 will have a "combined atk and def value" of 500. Like entering 4 or 5, monsters with ? atk and def will be treated by this code as having an attack and defense value (respectively) of 0. Link monsters have no defense value, so the code will also treat them as having 0 def.
If you enter 7, the monsters in the deck will be sorted based on their pendulum scales from lowest to highest (something I really wish was an option prior to master rule 4). Afterwards, any remaining cards in the deck that don't have pendulum scales will be sorted normally (by their names in alphabetical order).
If you enter anything other than a number from 1 to 7, or you click "Cancel" instead of entering anything, the code will reset duelingbook's sort function back to sorting cards by their names in alphabetical order.
Here's a video of the code in action! https://imgur.com/a/m5Pa1wH
And here's the code sorting the pendulum monsters based on their pendulum scale:
![Image](https://i.ibb.co/Q62qPpX/ezgif-1-4427d9f4fa.gif)
-
Christen57
- Posts: 2037
- Joined: Sun May 07, 2017 10:37 pm
- Reputation: 182
- Location: New York, United States of America
Post #2 by Christen57 » Fri Sep 15, 2023 4:06 pm
Duelingbook made a slight change to how the sort button works. I updated my code so it works properly with the new change.
Code: Select all
javascript:{let u = prompt("Enter 1 to sort monsters based on type\nEnter 2 to sort monsters based on attribute\nEnter 3 to sort monsters based on level/rank\nEnter 4 to sort monsters based on attack value\nEnter 5 to sort monsters based on defense value\nEnter 6 to sort monsters based on combined attack and defense value\nEnter 7 to sort monsters based on pendulum scale");
if (u == 1) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (a.data("type") > b.data("type")) {
return 1;
}
if (a.data("type") < b.data("type")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 2) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (a.data("attribute") > b.data("attribute")) {
return 1;
}
if (a.data("attribute") < b.data("attribute")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 3) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (~~a.data("level") > ~~b.data("level")) {
return 1;
}
if (~~a.data("level") < ~~b.data("level")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 4) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (~~a.data("atk") > ~~b.data("atk")) {
return 1;
}
if (~~a.data("atk") < ~~b.data("atk")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 5) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (~~a.data("def") > ~~b.data("def")) {
return 1;
}
if (~~a.data("def") < ~~b.data("def")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 6) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (~~a.data("atk") + ~~a.data("def") > ~~b.data("atk") + ~~b.data("def")) {
return 1;
}
if (~~a.data("atk") + ~~a.data("def") < ~~b.data("atk") + ~~b.data("def")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else if (u == 7) {function sortCards2(a,b) {
if (a.data("card_type") > b.data("card_type")) {
return 1;
}
if (a.data("card_type") < b.data("card_type")) {
return -1;
}
if (a.data("pendulum") > b.data("pendulum")) {
return 1;
}
if (a.data("pendulum") < b.data("pendulum")) {
return -1;
}
if (~~a.data("scale") > ~~b.data("scale")) {
return 1;
}
if (~~a.data("scale") < ~~b.data("scale")) {
return -1;
}
if (a.data("is_link") > b.data("is_link")) {
return 1;
}
if (a.data("is_link") < b.data("is_link")) {
return -1;
}
if (a.data("monster_color") > b.data("monster_color")) {
return 1;
}
if (a.data("monster_color") < b.data("monster_color")) {
return -1;
}
if (a.data("name").toLowerCase() > b.data("name").toLowerCase()) {
return 1;
}
if (a.data("name").toLowerCase() < b.data("name").toLowerCase()) {
return -1;
}
if (a.data("id") > b.data("id")) {
return 1;
}
if (a.data("id") < b.data("id")) {
return -1;
}
};
sortDeck();}
else {function sortCards2(_0x324ec9, _0x17b9c2) {
if (_0x324ec9['data']('card_type') > _0x17b9c2['data']('card_type'))
return 0x1;
if (_0x324ec9['data']('card_type') < _0x17b9c2['data']('card_type'))
return -0x1;
if (!_0x324ec9['data']('pendulum') && _0x17b9c2['data']('pendulum'))
return -0x1;
if (_0x324ec9['data']('pendulum') && !_0x17b9c2['data']('pendulum'))
return 0x1;
if (_0x324ec9['data']('is_link') > _0x17b9c2['data']('is_link'))
return 0x1;
if (_0x324ec9['data']('is_link') < _0x17b9c2['data']('is_link'))
return -0x1;
if (_0x324ec9['data']('monster_color') > _0x17b9c2['data']('monster_color'))
return 0x1;
if (_0x324ec9['data']('monster_color') < _0x17b9c2['data']('monster_color'))
return -0x1;
if (_0x324ec9['data']('name')['toLowerCase']() > _0x17b9c2['data']('name')['toLowerCase']())
return 0x1;
if (_0x324ec9['data']('name')['toLowerCase']() < _0x17b9c2['data']('name')['toLowerCase']())
return -0x1;
if (_0x324ec9['data']('id') > _0x17b9c2['data']('id'))
return 0x1;
if (_0x324ec9['data']('id') < _0x17b9c2['data']('id'))
return -0x1;
};
};
}
-
Christen57
- Posts: 2037
- Joined: Sun May 07, 2017 10:37 pm
- Reputation: 182
- Location: New York, United States of America
Post #3 by Christen57 » Mon Jan 22, 2024 12:11 am
I updated my code again. This time, clicking Cancel is no longer necessary to reset duelingbook's sort button's function back to the default one.
Code: Select all
javascript:{let SortNumber = prompt("Enter 1 to sort monsters based on type\nEnter 2 to sort monsters based on attribute\nEnter 3 to sort monsters based on level/rank\nEnter 4 to sort monsters based on attack value\nEnter 5 to sort monsters based on defense value\nEnter 6 to sort monsters based on combined attack and defense value\nEnter 7 to sort monsters based on pendulum scale");
if (SortNumber == 1) {
function sortCards3(_0x21e217, _0x87f8f0) {
if (_0x21e217['data']('card_type') > _0x87f8f0['data']('card_type'))
return 0x1;
if (_0x21e217['data']('card_type') < _0x87f8f0['data']('card_type'))
return -0x1;
if (_0x21e217['data']('type') > _0x87f8f0['data']('type'))
return 0x1;
if (_0x21e217['data']('type') < _0x87f8f0['data']('type'))
return -0x1;
if (!_0x21e217['data']('pendulum') && _0x87f8f0['data']('pendulum'))
return -0x1;
if (_0x21e217['data']('pendulum') && !_0x87f8f0['data']('pendulum'))
return 0x1;
if (_0x21e217['data']('is_link') > _0x87f8f0['data']('is_link'))
return 0x1;
if (_0x21e217['data']('is_link') < _0x87f8f0['data']('is_link'))
return -0x1;
if (_0x21e217['data']('monster_color') > _0x87f8f0['data']('monster_color'))
return 0x1;
if (_0x21e217['data']('monster_color') < _0x87f8f0['data']('monster_color'))
return -0x1;
if (_0x21e217['data']('name')['toLowerCase']() > _0x87f8f0['data']('name')['toLowerCase']())
return 0x1;
if (_0x21e217['data']('name')['toLowerCase']() < _0x87f8f0['data']('name')['toLowerCase']())
return -0x1;
if (_0x21e217['data']('id') > _0x87f8f0['data']('id'))
return 0x1;
if (_0x21e217['data']('id') < _0x87f8f0['data']('id'))
return -0x1;
}
} else if (SortNumber == 2) {
function sortCards3(_0x21e217, _0x87f8f0) {
if (_0x21e217['data']('card_type') > _0x87f8f0['data']('card_type'))
return 0x1;
if (_0x21e217['data']('card_type') < _0x87f8f0['data']('card_type'))
return -0x1;
if (_0x21e217['data']('attribute') > _0x87f8f0['data']('attribute'))
return 0x1;
if (_0x21e217['data']('attribute') < _0x87f8f0['data']('attribute'))
return -0x1;
if (!_0x21e217['data']('pendulum') && _0x87f8f0['data']('pendulum'))
return -0x1;
if (_0x21e217['data']('pendulum') && !_0x87f8f0['data']('pendulum'))
return 0x1;
if (_0x21e217['data']('is_link') > _0x87f8f0['data']('is_link'))
return 0x1;
if (_0x21e217['data']('is_link') < _0x87f8f0['data']('is_link'))
return -0x1;
if (_0x21e217['data']('monster_color') > _0x87f8f0['data']('monster_color'))
return 0x1;
if (_0x21e217['data']('monster_color') < _0x87f8f0['data']('monster_color'))
return -0x1;
if (_0x21e217['data']('name')['toLowerCase']() > _0x87f8f0['data']('name')['toLowerCase']())
return 0x1;
if (_0x21e217['data']('name')['toLowerCase']() < _0x87f8f0['data']('name')['toLowerCase']())
return -0x1;
if (_0x21e217['data']('id') > _0x87f8f0['data']('id'))
return 0x1;
if (_0x21e217['data']('id') < _0x87f8f0['data']('id'))
return -0x1;
}
} else if (SortNumber == 3) {
function sortCards3(_0x21e217, _0x87f8f0) {
if (_0x21e217['data']('card_type') > _0x87f8f0['data']('card_type'))
return 0x1;
if (_0x21e217['data']('card_type') < _0x87f8f0['data']('card_type'))
return -0x1;
if (_0x21e217['data']('level') > _0x87f8f0['data']('level'))
return 0x1;
if (_0x21e217['data']('level') < _0x87f8f0['data']('level'))
return -0x1;
if (!_0x21e217['data']('pendulum') && _0x87f8f0['data']('pendulum'))
return -0x1;
if (_0x21e217['data']('pendulum') && !_0x87f8f0['data']('pendulum'))
return 0x1;
if (_0x21e217['data']('is_link') > _0x87f8f0['data']('is_link'))
return 0x1;
if (_0x21e217['data']('is_link') < _0x87f8f0['data']('is_link'))
return -0x1;
if (_0x21e217['data']('monster_color') > _0x87f8f0['data']('monster_color'))
return 0x1;
if (_0x21e217['data']('monster_color') < _0x87f8f0['data']('monster_color'))
return -0x1;
if (_0x21e217['data']('name')['toLowerCase']() > _0x87f8f0['data']('name')['toLowerCase']())
return 0x1;
if (_0x21e217['data']('name')['toLowerCase']() < _0x87f8f0['data']('name')['toLowerCase']())
return -0x1;
if (_0x21e217['data']('id') > _0x87f8f0['data']('id'))
return 0x1;
if (_0x21e217['data']('id') < _0x87f8f0['data']('id'))
return -0x1;
}
} else if (SortNumber == 4) {
function sortCards3(_0x21e217, _0x87f8f0) {
if (_0x21e217['data']('card_type') > _0x87f8f0['data']('card_type'))
return 0x1;
if (_0x21e217['data']('card_type') < _0x87f8f0['data']('card_type'))
return -0x1;
if (_0x21e217['data']('atk') > _0x87f8f0['data']('atk'))
return 0x1;
if (_0x21e217['data']('atk') < _0x87f8f0['data']('atk'))
return -0x1;
if (!_0x21e217['data']('pendulum') && _0x87f8f0['data']('pendulum'))
return -0x1;
if (_0x21e217['data']('pendulum') && !_0x87f8f0['data']('pendulum'))
return 0x1;
if (_0x21e217['data']('is_link') > _0x87f8f0['data']('is_link'))
return 0x1;
if (_0x21e217['data']('is_link') < _0x87f8f0['data']('is_link'))
return -0x1;
if (_0x21e217['data']('monster_color') > _0x87f8f0['data']('monster_color'))
return 0x1;
if (_0x21e217['data']('monster_color') < _0x87f8f0['data']('monster_color'))
return -0x1;
if (_0x21e217['data']('name')['toLowerCase']() > _0x87f8f0['data']('name')['toLowerCase']())
return 0x1;
if (_0x21e217['data']('name')['toLowerCase']() < _0x87f8f0['data']('name')['toLowerCase']())
return -0x1;
if (_0x21e217['data']('id') > _0x87f8f0['data']('id'))
return 0x1;
if (_0x21e217['data']('id') < _0x87f8f0['data']('id'))
return -0x1;
}
} else if (SortNumber == 5) {
function sortCards3(_0x21e217, _0x87f8f0) {
if (_0x21e217['data']('card_type') > _0x87f8f0['data']('card_type'))
return 0x1;
if (_0x21e217['data']('card_type') < _0x87f8f0['data']('card_type'))
return -0x1;
if (_0x21e217['data']('def') > _0x87f8f0['data']('def'))
return 0x1;
if (_0x21e217['data']('def') < _0x87f8f0['data']('def'))
return -0x1;
if (!_0x21e217['data']('pendulum') && _0x87f8f0['data']('pendulum'))
return -0x1;
if (_0x21e217['data']('pendulum') && !_0x87f8f0['data']('pendulum'))
return 0x1;
if (_0x21e217['data']('is_link') > _0x87f8f0['data']('is_link'))
return 0x1;
if (_0x21e217['data']('is_link') < _0x87f8f0['data']('is_link'))
return -0x1;
if (_0x21e217['data']('monster_color') > _0x87f8f0['data']('monster_color'))
return 0x1;
if (_0x21e217['data']('monster_color') < _0x87f8f0['data']('monster_color'))
return -0x1;
if (_0x21e217['data']('name')['toLowerCase']() > _0x87f8f0['data']('name')['toLowerCase']())
return 0x1;
if (_0x21e217['data']('name')['toLowerCase']() < _0x87f8f0['data']('name')['toLowerCase']())
return -0x1;
if (_0x21e217['data']('id') > _0x87f8f0['data']('id'))
return 0x1;
if (_0x21e217['data']('id') < _0x87f8f0['data']('id'))
return -0x1;
}
} else if (SortNumber == 6) {
function sortCards3(_0x21e217, _0x87f8f0) {
if (_0x21e217['data']('card_type') > _0x87f8f0['data']('card_type'))
return 0x1;
if (_0x21e217['data']('card_type') < _0x87f8f0['data']('card_type'))
return -0x1;
if (parseInt(_0x21e217['data']('atk')) + parseInt(_0x21e217['data']('def')) > parseInt(_0x87f8f0['data']('atk')) + parseInt(_0x87f8f0['data']('def')))
return 0x1;
if (parseInt(_0x21e217['data']('atk')) + parseInt(_0x21e217['data']('def')) < parseInt(_0x87f8f0['data']('atk')) + parseInt(_0x87f8f0['data']('def')))
return -0x1;
if (!_0x21e217['data']('pendulum') && _0x87f8f0['data']('pendulum'))
return -0x1;
if (_0x21e217['data']('pendulum') && !_0x87f8f0['data']('pendulum'))
return 0x1;
if (_0x21e217['data']('is_link') > _0x87f8f0['data']('is_link'))
return 0x1;
if (_0x21e217['data']('is_link') < _0x87f8f0['data']('is_link'))
return -0x1;
if (_0x21e217['data']('monster_color') > _0x87f8f0['data']('monster_color'))
return 0x1;
if (_0x21e217['data']('monster_color') < _0x87f8f0['data']('monster_color'))
return -0x1;
if (_0x21e217['data']('name')['toLowerCase']() > _0x87f8f0['data']('name')['toLowerCase']())
return 0x1;
if (_0x21e217['data']('name')['toLowerCase']() < _0x87f8f0['data']('name')['toLowerCase']())
return -0x1;
if (_0x21e217['data']('id') > _0x87f8f0['data']('id'))
return 0x1;
if (_0x21e217['data']('id') < _0x87f8f0['data']('id'))
return -0x1;
}
} else if (SortNumber == 7) {
function sortCards3(_0x21e217, _0x87f8f0) {
if (_0x21e217['data']('card_type') > _0x87f8f0['data']('card_type'))
return 0x1;
if (_0x21e217['data']('card_type') < _0x87f8f0['data']('card_type'))
return -0x1;
if (!_0x21e217['data']('pendulum') && _0x87f8f0['data']('pendulum'))
return -0x1;
if (_0x21e217['data']('pendulum') && !_0x87f8f0['data']('pendulum'))
return 0x1;
if (_0x21e217['data']('scale') > _0x87f8f0['data']('scale'))
return 0x1;
if (_0x21e217['data']('scale') < _0x87f8f0['data']('scale'))
return -0x1;
if (_0x21e217['data']('is_link') > _0x87f8f0['data']('is_link'))
return 0x1;
if (_0x21e217['data']('is_link') < _0x87f8f0['data']('is_link'))
return -0x1;
if (_0x21e217['data']('monster_color') > _0x87f8f0['data']('monster_color'))
return 0x1;
if (_0x21e217['data']('monster_color') < _0x87f8f0['data']('monster_color'))
return -0x1;
if (_0x21e217['data']('name')['toLowerCase']() > _0x87f8f0['data']('name')['toLowerCase']())
return 0x1;
if (_0x21e217['data']('name')['toLowerCase']() < _0x87f8f0['data']('name')['toLowerCase']())
return -0x1;
if (_0x21e217['data']('id') > _0x87f8f0['data']('id'))
return 0x1;
if (_0x21e217['data']('id') < _0x87f8f0['data']('id'))
return -0x1;
}
}
}
deck_filled_arr['sort'](sortCards3);
side_filled_arr['sort'](sortCards3);
extra_filled_arr['sort'](sortCards3);
initializeDeckCards();
-
Christen57
- Posts: 2037
- Joined: Sun May 07, 2017 10:37 pm
- Reputation: 182
- Location: New York, United States of America
Post #4 by Christen57 » Sat Mar 30, 2024 2:43 am
I updated my code once again. This time, it's no longer necessary to manually enter a number from 1 to 7 to choose what to sort the cards based on. Instead, a drop down menu will appear where you can choose any of the following to sort the monsters based on:
- type
- attribute
- level / rank / link rating
- atk
- def
- ability
- pendulum scale
- combined atk & def value
Here's the updated code:
Code: Select all
javascript:function sortCards4() {
switch ($('#combo\x20.combo_cb')['val']()) {
case "Type": {
function sortCards3(_0x59a17a, _0x5421aa) {
if (_0x59a17a['data']('card_type') > _0x5421aa['data']('card_type'))
return 1;
if (_0x59a17a['data']('card_type') < _0x5421aa['data']('card_type'))
return -1;
if (_0x59a17a['data']('type') > _0x5421aa['data']('type'))
return 1;
if (_0x59a17a['data']('type') < _0x5421aa['data']('type'))
return -1;
if (!_0x59a17a['data']('pendulum') && _0x5421aa['data']('pendulum'))
return -1;
if (_0x59a17a['data']('pendulum') && !_0x5421aa['data']('pendulum'))
return 1;
if (_0x59a17a['data']('is_link') > _0x5421aa['data']('is_link'))
return 1;
if (_0x59a17a['data']('is_link') < _0x5421aa['data']('is_link'))
return -1;
if (_0x59a17a['data']('monster_color') > _0x5421aa['data']('monster_color'))
return 1;
if (_0x59a17a['data']('monster_color') < _0x5421aa['data']('monster_color'))
return -1;
if (_0x59a17a['data']('name')['toLowerCase']() > _0x5421aa['data']('name')['toLowerCase']())
return 1;
if (_0x59a17a['data']('name')['toLowerCase']() < _0x5421aa['data']('name')['toLowerCase']())
return -1;
if (_0x59a17a['data']('id') > _0x5421aa['data']('id'))
return 1;
if (_0x59a17a['data']('id') < _0x5421aa['data']('id'))
return -1;
}
break;
}
case "Attribute": {
function sortCards3(_0x59a17a, _0x5421aa) {
if (_0x59a17a['data']('card_type') > _0x5421aa['data']('card_type'))
return 1;
if (_0x59a17a['data']('card_type') < _0x5421aa['data']('card_type'))
return -1;
if (_0x59a17a['data']('attribute') > _0x5421aa['data']('attribute'))
return 1;
if (_0x59a17a['data']('attribute') < _0x5421aa['data']('attribute'))
return -1;
if (!_0x59a17a['data']('pendulum') && _0x5421aa['data']('pendulum'))
return -1;
if (_0x59a17a['data']('pendulum') && !_0x5421aa['data']('pendulum'))
return 1;
if (_0x59a17a['data']('is_link') > _0x5421aa['data']('is_link'))
return 1;
if (_0x59a17a['data']('is_link') < _0x5421aa['data']('is_link'))
return -1;
if (_0x59a17a['data']('monster_color') > _0x5421aa['data']('monster_color'))
return 1;
if (_0x59a17a['data']('monster_color') < _0x5421aa['data']('monster_color'))
return -1;
if (_0x59a17a['data']('name')['toLowerCase']() > _0x5421aa['data']('name')['toLowerCase']())
return 1;
if (_0x59a17a['data']('name')['toLowerCase']() < _0x5421aa['data']('name')['toLowerCase']())
return -1;
if (_0x59a17a['data']('id') > _0x5421aa['data']('id'))
return 1;
if (_0x59a17a['data']('id') < _0x5421aa['data']('id'))
return -1;
}
break;
}
case "Level / Rank / Link Rating": {
function sortCards3(_0x59a17a, _0x5421aa) {
if (_0x59a17a['data']('card_type') > _0x5421aa['data']('card_type'))
return 1;
if (_0x59a17a['data']('card_type') < _0x5421aa['data']('card_type'))
return -1;
if (_0x59a17a['data']('level') > _0x5421aa['data']('level'))
return 1;
if (_0x59a17a['data']('level') < _0x5421aa['data']('level'))
return -1;
if (!_0x59a17a['data']('pendulum') && _0x5421aa['data']('pendulum'))
return -1;
if (_0x59a17a['data']('pendulum') && !_0x5421aa['data']('pendulum'))
return 1;
if (_0x59a17a['data']('is_link') > _0x5421aa['data']('is_link'))
return 1;
if (_0x59a17a['data']('is_link') < _0x5421aa['data']('is_link'))
return -1;
if (_0x59a17a['data']('monster_color') > _0x5421aa['data']('monster_color'))
return 1;
if (_0x59a17a['data']('monster_color') < _0x5421aa['data']('monster_color'))
return -1;
if (_0x59a17a['data']('name')['toLowerCase']() > _0x5421aa['data']('name')['toLowerCase']())
return 1;
if (_0x59a17a['data']('name')['toLowerCase']() < _0x5421aa['data']('name')['toLowerCase']())
return -1;
if (_0x59a17a['data']('id') > _0x5421aa['data']('id'))
return 1;
if (_0x59a17a['data']('id') < _0x5421aa['data']('id'))
return -1;
}
break;
}
case "ATK": {
function sortCards3(_0x59a17a, _0x5421aa) {
if (_0x59a17a['data']('card_type') > _0x5421aa['data']('card_type'))
return 1;
if (_0x59a17a['data']('card_type') < _0x5421aa['data']('card_type'))
return -1;
if (parseInt(_0x59a17a['data']('atk')) > parseInt(_0x5421aa['data']('atk')))
return 1;
if (parseInt(_0x59a17a['data']('atk')) < parseInt(_0x5421aa['data']('atk')))
return -1;
if (!_0x59a17a['data']('pendulum') && _0x5421aa['data']('pendulum'))
return -1;
if (_0x59a17a['data']('pendulum') && !_0x5421aa['data']('pendulum'))
return 1;
if (_0x59a17a['data']('is_link') > _0x5421aa['data']('is_link'))
return 1;
if (_0x59a17a['data']('is_link') < _0x5421aa['data']('is_link'))
return -1;
if (_0x59a17a['data']('monster_color') > _0x5421aa['data']('monster_color'))
return 1;
if (_0x59a17a['data']('monster_color') < _0x5421aa['data']('monster_color'))
return -1;
if (_0x59a17a['data']('name')['toLowerCase']() > _0x5421aa['data']('name')['toLowerCase']())
return 1;
if (_0x59a17a['data']('name')['toLowerCase']() < _0x5421aa['data']('name')['toLowerCase']())
return -1;
if (_0x59a17a['data']('id') > _0x5421aa['data']('id'))
return 1;
if (_0x59a17a['data']('id') < _0x5421aa['data']('id'))
return -1;
}
break;
}
case "DEF": {
function sortCards3(_0x59a17a, _0x5421aa) {
if (_0x59a17a['data']('card_type') > _0x5421aa['data']('card_type'))
return 1;
if (_0x59a17a['data']('card_type') < _0x5421aa['data']('card_type'))
return -1;
if (parseInt(_0x59a17a['data']('def')) > parseInt(_0x5421aa['data']('def')))
return 1;
if (parseInt(_0x59a17a['data']('def')) < parseInt(_0x5421aa['data']('def')))
return -1;
if (!_0x59a17a['data']('pendulum') && _0x5421aa['data']('pendulum'))
return -1;
if (_0x59a17a['data']('pendulum') && !_0x5421aa['data']('pendulum'))
return 1;
if (_0x59a17a['data']('is_link') > _0x5421aa['data']('is_link'))
return 1;
if (_0x59a17a['data']('is_link') < _0x5421aa['data']('is_link'))
return -1;
if (_0x59a17a['data']('monster_color') > _0x5421aa['data']('monster_color'))
return 1;
if (_0x59a17a['data']('monster_color') < _0x5421aa['data']('monster_color'))
return -1;
if (_0x59a17a['data']('name')['toLowerCase']() > _0x5421aa['data']('name')['toLowerCase']())
return 1;
if (_0x59a17a['data']('name')['toLowerCase']() < _0x5421aa['data']('name')['toLowerCase']())
return -1;
if (_0x59a17a['data']('id') > _0x5421aa['data']('id'))
return 1;
if (_0x59a17a['data']('id') < _0x5421aa['data']('id'))
return -1;
}
break;
}
case "Ability / Subtype": {
function sortCards3(_0x59a17a, _0x5421aa) {
if (_0x59a17a['data']('card_type') > _0x5421aa['data']('card_type'))
return 1;
if (_0x59a17a['data']('card_type') < _0x5421aa['data']('card_type'))
return -1;
if (_0x59a17a['data']('ability') > _0x5421aa['data']('ability') || _0x5421aa['data']('ability') == undefined)
return 1;
if (_0x59a17a['data']('ability') == undefined || _0x59a17a['data']('ability') < _0x5421aa['data']('ability'))
return -1;
if (!_0x59a17a['data']('pendulum') && _0x5421aa['data']('pendulum'))
return -1;
if (_0x59a17a['data']('pendulum') && !_0x5421aa['data']('pendulum'))
return 1;
if (_0x59a17a['data']('is_link') > _0x5421aa['data']('is_link'))
return 1;
if (_0x59a17a['data']('is_link') < _0x5421aa['data']('is_link'))
return -1;
if (_0x59a17a['data']('monster_color') > _0x5421aa['data']('monster_color'))
return 1;
if (_0x59a17a['data']('monster_color') < _0x5421aa['data']('monster_color'))
return -1;
if (_0x59a17a['data']('name')['toLowerCase']() > _0x5421aa['data']('name')['toLowerCase']())
return 1;
if (_0x59a17a['data']('name')['toLowerCase']() < _0x5421aa['data']('name')['toLowerCase']())
return -1;
if (_0x59a17a['data']('id') > _0x5421aa['data']('id'))
return 1;
if (_0x59a17a['data']('id') < _0x5421aa['data']('id'))
return -1;
}
break;
}
case "Pendulum Scale": {
function sortCards3(_0x59a17a, _0x5421aa) {
if (_0x59a17a['data']('card_type') > _0x5421aa['data']('card_type'))
return 1;
if (_0x59a17a['data']('card_type') < _0x5421aa['data']('card_type'))
return -1;
if (_0x59a17a['data']('scale') > _0x5421aa['data']('scale'))
return 1;
if (_0x59a17a['data']('scale') < _0x5421aa['data']('scale'))
return -1;
if (!_0x59a17a['data']('pendulum') && _0x5421aa['data']('pendulum'))
return -1;
if (_0x59a17a['data']('pendulum') && !_0x5421aa['data']('pendulum'))
return 1;
if (_0x59a17a['data']('is_link') > _0x5421aa['data']('is_link'))
return 1;
if (_0x59a17a['data']('is_link') < _0x5421aa['data']('is_link'))
return -1;
if (_0x59a17a['data']('monster_color') > _0x5421aa['data']('monster_color'))
return 1;
if (_0x59a17a['data']('monster_color') < _0x5421aa['data']('monster_color'))
return -1;
if (_0x59a17a['data']('name')['toLowerCase']() > _0x5421aa['data']('name')['toLowerCase']())
return 1;
if (_0x59a17a['data']('name')['toLowerCase']() < _0x5421aa['data']('name')['toLowerCase']())
return -1;
if (_0x59a17a['data']('id') > _0x5421aa['data']('id'))
return 1;
if (_0x59a17a['data']('id') < _0x5421aa['data']('id'))
return -1;
}
break;
}
case "Combined ATK & DEF": {
function sortCards3(_0x59a17a, _0x5421aa) {
if (_0x59a17a['data']('card_type') > _0x5421aa['data']('card_type'))
return 1;
if (_0x59a17a['data']('card_type') < _0x5421aa['data']('card_type'))
return -1;
if (parseInt(_0x59a17a['data']('atk')) + parseInt(_0x59a17a['data']('def')) > parseInt(_0x5421aa['data']('atk')) + parseInt(_0x5421aa['data']('def')))
return 1;
if (parseInt(_0x59a17a['data']('atk')) + parseInt(_0x59a17a['data']('def')) < parseInt(_0x5421aa['data']('atk')) + parseInt(_0x5421aa['data']('def')))
return -1;
if (!_0x59a17a['data']('pendulum') && _0x5421aa['data']('pendulum'))
return -1;
if (_0x59a17a['data']('pendulum') && !_0x5421aa['data']('pendulum'))
return 1;
if (_0x59a17a['data']('is_link') > _0x5421aa['data']('is_link'))
return 1;
if (_0x59a17a['data']('is_link') < _0x5421aa['data']('is_link'))
return -1;
if (_0x59a17a['data']('monster_color') > _0x5421aa['data']('monster_color'))
return 1;
if (_0x59a17a['data']('monster_color') < _0x5421aa['data']('monster_color'))
return -1;
if (_0x59a17a['data']('name')['toLowerCase']() > _0x5421aa['data']('name')['toLowerCase']())
return 1;
if (_0x59a17a['data']('name')['toLowerCase']() < _0x5421aa['data']('name')['toLowerCase']())
return -1;
if (_0x59a17a['data']('id') > _0x5421aa['data']('id'))
return 1;
if (_0x59a17a['data']('id') < _0x5421aa['data']('id'))
return -1;
}
break;
}
}
deck_filled_arr['sort'](sortCards3);
side_filled_arr['sort'](sortCards3);
extra_filled_arr['sort'](sortCards3);
initializeDeckCards();
}
getComboBox('Sort Monsters', 'Sort monsters based on:', [
"Type",
"Attribute",
"Level / Rank / Link Rating",
"ATK",
"DEF",
"Ability / Subtype",
"Pendulum Scale",
"Combined ATK & DEF"
], 0, sortCards4);
Return to “Suggestions”
Who is online
Users browsing this forum: No registered users and 460 guests