1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-09-29 16:51:13 +13:00

code review

This commit is contained in:
gorhill 2015-05-02 00:18:31 -04:00
parent eb42375215
commit dbe14694c8
2 changed files with 12 additions and 13 deletions

View file

@ -10,7 +10,7 @@
}, },
"browser_action": { "browser_action": {
"default_icon": { "default_icon": {
"19": "img/browsericons/icon19-off.png" "19": "img/browsericons/icon19-19.png"
}, },
"default_title": "µMatrix", "default_title": "µMatrix",
"default_popup": "popup.html" "default_popup": "popup.html"

View file

@ -142,20 +142,19 @@ return asyncJobManager;
var updateBadge = function(tabId) { var updateBadge = function(tabId) {
delete tabIdToTimer[tabId]; delete tabIdToTimer[tabId];
var pageStore = this.pageStoreFromTabId(tabId);
if ( pageStore === null ) {
return;
}
var iconId = null; var iconId = null;
var badgeStr = ''; var badgeStr = '';
var total = pageStore.perLoadAllowedRequestCount +
pageStore.perLoadBlockedRequestCount; var pageStore = this.pageStoreFromTabId(tabId);
if ( total ) { if ( pageStore !== null ) {
var squareSize = 19; var total = pageStore.perLoadAllowedRequestCount +
var greenSize = squareSize * Math.sqrt(pageStore.perLoadAllowedRequestCount / total); pageStore.perLoadBlockedRequestCount;
iconId = greenSize < squareSize/2 ? Math.ceil(greenSize) : Math.floor(greenSize); if ( total ) {
badgeStr = this.formatCount(pageStore.distinctRequestCount); var squareSize = 19;
var greenSize = squareSize * Math.sqrt(pageStore.perLoadAllowedRequestCount / total);
iconId = greenSize < squareSize/2 ? Math.ceil(greenSize) : Math.floor(greenSize);
badgeStr = this.formatCount(pageStore.distinctRequestCount);
}
} }
vAPI.setIcon(tabId, iconId, badgeStr); vAPI.setIcon(tabId, iconId, badgeStr);