From: Ailin Nemui Date: Tue, 30 Oct 2018 23:42:02 +0000 (+0100) Subject: sort votes first X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=92c0b12fb782ca8a0df913ee8e4efe4103e5a25c;p=irssi-scripts.irssi.org.git sort votes first --- diff --git a/assets/js/sorttable.js b/assets/js/sorttable.js index 38b0fc6..6d54c1a 100644 --- a/assets/js/sorttable.js +++ b/assets/js/sorttable.js @@ -148,9 +148,9 @@ sorttable = { row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]]; } /* If you want a stable sort, uncomment the following line */ - //sorttable.shaker_sort(row_array, this.sorttable_sortfunction); + sorttable.shaker_sort(row_array, this.sorttable_sortfunction); /* and comment out this one */ - row_array.sort(this.sorttable_sortfunction); + //row_array.sort(this.sorttable_sortfunction); tb = this.sorttable_tbody; for (var j=0; j= 0) { var empty = queue[what].length == 0; queue[what].push([how, arg]); + if (console && console.log && empty && when > 2000) { + console.log("GitHub rate limit on: " + arg + " time to wait: " + + (when > 120 * 1000 ? Math.ceil(when / 1000 / 60) + " m" : Math.ceil(when / 1000) + " s")); + } if (empty) window.setTimeout(function(){reQueue(what);}, when); } else { ghLimits[what].remaining--; @@ -27,7 +31,22 @@ } function signalDone() { - if (!todo) $("#th-votes").html("Votes"); + if (!todo) { + var myTH = $("#th-votes"); + myTH.html("Votes"); + var isSorted = [0]; + Array.prototype.forEach.call(myTH[0].parentNode.children, function(e) { + if (e.classList.contains("sorttable_sorted") || e.classList.contains("sorttable_sorted_reverse")) { + isSorted[0] = 1; + } + }); + if (!isSorted[0]) { + sorttable.innerSortFunction.apply(myTH[0].parentNode.children[0], []); + sorttable.innerSortFunction.apply(myTH[0].parentNode.children[0], []); + sorttable.innerSortFunction.apply(myTH[0], []); + sorttable.innerSortFunction.apply(myTH[0], []); + } + } } function _jsonpToJson(dta, typ) {