Browse Source

code review

pull/2/head
gorhill 10 years ago
parent
commit
dbe14694c8
  1. 2
      platform/chromium/manifest.json
  2. 23
      src/js/async.js

2
platform/chromium/manifest.json

@ -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"

23
src/js/async.js

@ -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;
if ( total ) {
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);
var pageStore = this.pageStoreFromTabId(tabId);
if ( pageStore !== null ) {
var total = pageStore.perLoadAllowedRequestCount +
pageStore.perLoadBlockedRequestCount;
if ( total ) {
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);

Loading…
Cancel
Save