Quote:
Originally Posted by mgpai
Code:
/*
Filter and sort by package status
Trigger : Toolbar button pressed
Customize toolbar > Add a new "Eventscripter Trigger" button > Rename it to "Sort by status"
*/
var filter = "Not enough traffic available";
if (name == "Sort by status") {
callAPI("downloadsV2", "queryPackages", {
status: true
}).filter(function(package) {
return package.status && package.status.indexOf(filter) > -1;
}).sort(function(a, b) {
var x = a.status.toLowerCase();
var y = b.status.toLowerCase();
return x < y ? -1 : x > y ? 1 : 0;
}).reverse().forEach(function(package) {
callAPI("downloadsV2", "movePackages", [package.uuid], -1);
})
}
|
Hello and thank you very much for helping me with that script you wrote!
Sorry, I have missed the original post completely, so the very late reply.
This is what happened, after starting the script:
https://imgur.com/a/NpDng61
As you see, the sorting is not very reliable. (it should sort from 0KB to 1000MB and not mix the unities)
I have no idea on how to fix this.
Also, as another plea, would you mind to makte the sorting work in both ways?
say, on 1st click, the scripts sorts desc
and on 2nd click, the script sorts asc
is this possible?
Thank you very much.
EDIT: An unattractive Error pops up, when activating the script without any text in the status column:
https://imgur.com/a/MVd2fp6