|
|
@ -133,8 +133,12 @@ return asyncJobManager;
|
|
|
|
// Update visual of extension icon.
|
|
|
|
// Update visual of extension icon.
|
|
|
|
// A time out is used to coalesce adjacent requests to update badge.
|
|
|
|
// A time out is used to coalesce adjacent requests to update badge.
|
|
|
|
|
|
|
|
|
|
|
|
µMatrix.updateBadge = function(pageUrl) {
|
|
|
|
µMatrix.updateBadgeAsync = (function(){
|
|
|
|
var updateBadgeCallback = function(pageUrl) {
|
|
|
|
var µm = µMatrix;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cache callback definition, it was a bad idea to define this one inside
|
|
|
|
|
|
|
|
// updateBadgeAsync
|
|
|
|
|
|
|
|
var updateBadge = function(pageUrl) {
|
|
|
|
var µm = µMatrix;
|
|
|
|
var µm = µMatrix;
|
|
|
|
if ( pageUrl === µm.behindTheSceneURL ) {
|
|
|
|
if ( pageUrl === µm.behindTheSceneURL ) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -143,18 +147,28 @@ return asyncJobManager;
|
|
|
|
if ( !tabId ) {
|
|
|
|
if ( !tabId ) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var pageStats = µm.pageStatsFromTabId(tabId);
|
|
|
|
var pageStore = µm.pageStatsFromTabId(tabId);
|
|
|
|
if ( pageStats ) {
|
|
|
|
if ( pageStore ) {
|
|
|
|
pageStats.updateBadge(tabId);
|
|
|
|
pageStore.updateBadge(tabId);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
chrome.browserAction.setIcon({ tabId: tabId, path: 'img/browsericons/icon19.png' });
|
|
|
|
|
|
|
|
chrome.browserAction.setBadgeText({ tabId: tabId, text: '?' });
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
µm.XAL.setIcon(
|
|
|
|
|
|
|
|
tabId,
|
|
|
|
|
|
|
|
{ '19': 'img/browsericons/icon19.png' },
|
|
|
|
|
|
|
|
'?'
|
|
|
|
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.asyncJobs.add('updateBadge ' + pageUrl, pageUrl, updateBadgeCallback, 250);
|
|
|
|
var updateBadgeAsync = function(pageUrl) {
|
|
|
|
|
|
|
|
if ( typeof pageUrl !== 'string' || pageUrl === '' ) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
µm.asyncJobs.add('updateBadge-' + pageUrl, pageUrl, updateBadge, 250);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return updateBadgeAsync;
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
// Notify whoever care that url stats have changed (they need to
|
|
|
|
// Notify whoever care that url stats have changed (they need to
|
|
|
|