From cabf766fba3c91cdd5859d6beef0bb29026d56ff Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Fri, 12 Sep 2014 16:27:27 -0700 Subject: [PATCH] Improve sidebar message counter --- client/js/shout.js | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/js/shout.js b/client/js/shout.js index 97508edd..5f324838 100644 --- a/client/js/shout.js +++ b/client/js/shout.js @@ -327,6 +327,7 @@ $(function() { self.addClass("active") .find(".badge") .removeClass("highlight") + .data("count", "") .empty(); if (sidebar.find(".highlight").length == 0) { @@ -432,8 +433,9 @@ $(function() { var badge = btn.find(".badge"); if (badge.length !== 0) { - var i = (parseInt(badge.html()) || 0) + 1; - badge.html(i); + var i = (badge.data("count") || 0) + 1; + badge.data("count", i); + badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i); if (highlight || query) { badge.addClass("highlight"); } diff --git a/package.json b/package.json index 8b0c1e1b..2f733552 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "shout", "description": "A web IRC client", - "version": "0.25.2", + "version": "0.25.3", "author": "Mattias Erming", "preferGlobal": true, "bin": {