using new string for blocked stats

This commit is contained in:
gorhill 2015-03-11 11:21:29 -04:00
parent 5b6a7b3aa4
commit ca0057e724

View file

@ -19,7 +19,7 @@
Home: https://github.com/gorhill/uBlock Home: https://github.com/gorhill/uBlock
*/ */
/* global vAPI, uDom */ /* global punycode, vAPI, uDom */
/******************************************************************************/ /******************************************************************************/
@ -49,7 +49,7 @@ var allHostnameRows = [];
var touchedDomainCount = 0; var touchedDomainCount = 0;
var rowsToRecycle = uDom(); var rowsToRecycle = uDom();
var cachedPopupHash = ''; var cachedPopupHash = '';
var orStr = vAPI.i18n('popupOr'); var statsStr = vAPI.i18n('popupBlockedStats');
var domainsHitStr = vAPI.i18n('popupHitDomainCount'); var domainsHitStr = vAPI.i18n('popupHitDomainCount');
/******************************************************************************/ /******************************************************************************/
@ -383,33 +383,26 @@ var renderPopup = function () {
.attr('href', 'devtools.html?tabId=' + popupData.tabId); .attr('href', 'devtools.html?tabId=' + popupData.tabId);
uDom('#gotoPick').toggleClass('enabled', popupData.canElementPicker === true); uDom('#gotoPick').toggleClass('enabled', popupData.canElementPicker === true);
var text;
var blocked = popupData.pageBlockedRequestCount; var blocked = popupData.pageBlockedRequestCount;
var total = popupData.pageAllowedRequestCount + blocked; var total = popupData.pageAllowedRequestCount + blocked;
var text = [];
if ( total === 0 ) { if ( total === 0 ) {
text.push(formatNumber(0)); text = formatNumber(0);
} else { } else {
text.push( text = statsStr.replace('{{count}}', formatNumber(blocked))
formatNumber(blocked), .replace('{{percent}}', formatNumber(Math.floor(blocked * 100 / total)));
'\u00a0', orStr, '\u00a0',
formatNumber(Math.floor(blocked * 100 / total)), '%'
);
} }
uDom('#page-blocked').text(text.join('')); uDom('#page-blocked').text(text);
blocked = popupData.globalBlockedRequestCount; blocked = popupData.globalBlockedRequestCount;
total = popupData.globalAllowedRequestCount + blocked; total = popupData.globalAllowedRequestCount + blocked;
text = [];
if ( total === 0 ) { if ( total === 0 ) {
text.push(formatNumber(0)); text = formatNumber(0);
} else { } else {
text.push( text = statsStr.replace('{{count}}', formatNumber(blocked))
formatNumber(blocked), .replace('{{percent}}', formatNumber(Math.floor(blocked * 100 / total)));
'\u00a0', orStr, '\u00a0',
formatNumber(Math.floor(blocked * 100 / total)), '%'
);
} }
uDom('#total-blocked').text(text.join('')); uDom('#total-blocked').text(text);
// This will collate all domains, touched or not // This will collate all domains, touched or not
renderPrivacyExposure(); renderPrivacyExposure();