From: Ailin Nemui Date: Thu, 15 Mar 2018 08:52:51 +0000 (+0100) Subject: fix website votes off by one X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=ef1bf1aafcaa165c240ec6a7e60431ace4bb8c95;p=irssi-scripts.irssi.org.git fix website votes off by one [skip ci] --- diff --git a/assets/js/votes.js b/assets/js/votes.js index 2fa9097..dc08bec 100644 --- a/assets/js/votes.js +++ b/assets/js/votes.js @@ -56,7 +56,7 @@ + 'repo:' + url + ';sort=updated'; jj(start).done(function(r) { var hasMore = fetchNext('search', r.meta, searchVotes); - if (hasMore) todo++; + if (hasMore) { todo++; } r.data.items.forEach(function(e) { if (stopId && e.number > stopId) return; if (e.title != "votes") return; @@ -76,7 +76,7 @@ } function rateTimeout(what) { - if ($.isEmptyObject(ghLimits[what])) return -1; + if ($.isEmptyObject(ghLimits[what])) { return -1; } var remaining = ghLimits[what].remaining; var rateReset = ghLimits[what].reset; @@ -91,8 +91,8 @@ } function updateLimits(what, meta) { - ghLimits[what].remaining = meta['X-RateLimit-Remaining']; - ghLimits[what].reset = meta['X-RateLimit-Reset']; + ghLimits[what].remaining = ~~ meta['X-RateLimit-Remaining']; + ghLimits[what].reset = ~~ meta['X-RateLimit-Reset']; } function fetchNext(what, meta, how) { @@ -130,9 +130,10 @@ var votes = 1+ e.reactions['+1'] - e.reactions['-1']; var link = "*"; if (e.reactions['heart'] >= votes) link = "💜"; - row.html( "" + votes ); + row.html( "" + (e.reactions['+1'] == 0 && e.reactions['-1'] == 0 ? "" : votes-1) ); row.append(""+link+""); + row.attr("sorttable_customkey", 9999+votes); } return false; });