Skip to content
This repository has been archived by the owner on Oct 6, 2021. It is now read-only.

Commit

Permalink
Revamping updateBadge function
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Jul 22, 2015
1 parent 9e725ec commit 0da36c5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
45 changes: 27 additions & 18 deletions extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,37 @@

// update badge
function updateBadge() {
var color;
var color, badgeText = true;
new FriendsCount(function (count, status, statusLabel) {
if (count !== false) {
color = colorOffline;
if (status == 'ingame') {
color = colorIngame;
if (localStorage.iconShowIngame == 'false') {
count = '0';
}
}
if (status == 'online') {
color = colorOnline;
if (localStorage.iconShowOnline == 'false') {
count = '0';
}
switch(status) {
case 'ingame':
color = colorIngame;
if (localStorage.iconShowIngame == 'false') {
count = '0';
badgeText = false;
}
break;
case 'online':
color = colorOnline;
if (localStorage.iconShowOnline == 'false') {
count = '0';
badgeText = false;
}
break;
case 'offline':
if (localStorage.iconShowOffline == 'false') {
count = '0';
badgeText = false;
}
default:
color = colorOffline;
}
if (status == 'offline') {
if (localStorage.iconShowOffline == 'false') {
count = '0';
}
if (badgeText) {
renderBadge((count !== '0' ? count : ''), color, chrome.i18n.getMessage('browserActionDefaultTitle', [count, statusLabel]));
} else {
renderBadge('', color, '');
}
renderBadge((count !== '0' ? count : ''), color, chrome.i18n.getMessage('browserActionDefaultTitle', [count, statusLabel]));
} else {
renderBadge('?', [190, 190, 190, 230], chrome.i18n.getMessage('browserActionErrorTitle'));
}
Expand Down
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_extName__",
"description": "__MSG_extDescription__",
"version": "0.0.97",
"version": "0.0.98",
"background": {
"persistent": false,
"scripts": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Battlelog-Notifier",
"version": "0.0.97",
"version": "0.0.98",
"description": "Displays the count of your Battlelog friends in the extension's badge, by status: in game, online or offline.",
"homepage": "http://narno.org/Battlelog-Notifier",
"author": "Arnaud Ligny",
Expand Down

0 comments on commit 0da36c5

Please sign in to comment.