summaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-08-02 02:12:20 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-08-02 02:12:20 +0200
commit0246d2340b2db208de3fad48e7d45608351e3ab5 (patch)
treec55ffa27572c006b74ec5d0add478b98fab78234 /p/scripts
parent8e5d98c4be836eed824260c01714e8d3624b9bef (diff)
Dynamic favicon large numbers
https://github.com/marienfressinaud/FreshRSS/issues/539
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 6876a9995..d18a02668 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -1069,7 +1069,7 @@ function init_password_observers() {
function faviconNbUnread(n) {
if (typeof n === 'undefined') {
- n = parseInt($('.category.all>a').attr('data-unread'));
+ n = str2int($('.category.all>a').attr('data-unread'));
}
//http://remysharp.com/2010/08/24/dynamic-favicons/
var canvas = document.createElement('canvas'),
@@ -1078,10 +1078,19 @@ function faviconNbUnread(n) {
canvas.height = canvas.width = 16;
var img = document.createElement('img');
img.onload = function () {
- var ctx = canvas.getContext('2d'),
- text = n < 100 ? n : '99+';
+ var ctx = canvas.getContext('2d');
ctx.drawImage(this, 0, 0);
if (n > 0) {
+ var text = '';
+ if (n < 100) {
+ text = n;
+ } else if (n < 1000) {
+ text = Math.floor(n / 100) + 'h+';
+ } else if (n < 10000) {
+ text = Math.floor(n / 1000) + 'k+';
+ } else {
+ text = '10k+';
+ }
ctx.font = 'bold 9px "Arial", sans-serif';
ctx.fillStyle = 'rgba(255, 255, 255, 127)';
ctx.fillRect(0, 8, 1 + ctx.measureText(text).width, 7);