diff options
author | gorhill <rhill@raymondhill.net> | 2015-02-07 15:32:20 -0500 |
---|---|---|
committer | gorhill <rhill@raymondhill.net> | 2015-02-07 15:32:20 -0500 |
commit | 92e26cb3d787be12393c1246acb61a84c21e6dee (patch) | |
tree | 4d16bc9fac7abdae5ff1c824b6d5c39b11ad830c | |
parent | 1103beb21f29d78ef7be5330a8d3e3b6f1edd255 (diff) | |
download | uBlock-92e26cb3d787be12393c1246acb61a84c21e6dee.zip uBlock-92e26cb3d787be12393c1246acb61a84c21e6dee.tar.gz uBlock-92e26cb3d787be12393c1246acb61a84c21e6dee.tar.bz2 |
fixed request count indicators for incrementally built popup
-rw-r--r-- | src/js/popup.js | 25 | ||||
-rw-r--r-- | src/popup.html | 6 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/js/popup.js b/src/js/popup.js index ad5e4be..d72ff6a 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -196,27 +196,32 @@ var updateDynamicFilterCell = function(scope, des, type, rule) { } cell.toggleClass('ownRule', ownRule); - if ( scope !== '.' || des === '*' ) { - return; - } - if ( popupData.hostnameDict.hasOwnProperty(des) === false ) { + // IMPORTANT: It is completely assumed the first node is a TEXT_NODE, so + // ensure this in the HTML file counterpart when you make + // changes + var textNode = cell.nodeAt(0).firstChild; + + // Since this may be a cell from a reused row, we need to clear text + // content if we can't compute request counts. + if ( scope !== '.' || des === '*' || popupData.hostnameDict.hasOwnProperty(des) === false ) { + textNode.nodeValue = ' '; return; } + var hnDetails = popupData.hostnameDict[des]; var aCount = hnDetails.allowCount; var bCount = hnDetails.blockCount; if ( aCount === 0 && bCount === 0 ) { + textNode.nodeValue = ' '; return; } + // https://github.com/gorhill/uBlock/issues/471 aCount = Math.min(Math.ceil(Math.log(aCount + 1) / Math.LN10), 3); bCount = Math.min(Math.ceil(Math.log(bCount + 1) / Math.LN10), 3); - // IMPORTANT: It is completely assumed the first node is a TEXT_NODE, so - // ensure this in the HTML file counterpart when you make - // changes - cell.nodeAt(0).firstChild.nodeValue = threePlus.slice(0, aCount) + - sixSpace.slice(aCount + bCount) + - threeMinus.slice(0, bCount); + textNode.nodeValue = threePlus.slice(0, aCount) + + sixSpace.slice(aCount + bCount) + + threeMinus.slice(0, bCount); }; /******************************************************************************/ diff --git a/src/popup.html b/src/popup.html index 07a39d4..d276932 100644 --- a/src/popup.html +++ b/src/popup.html @@ -28,9 +28,9 @@ <div id="refresh" class="fa"></div> </div><!-- DO NOT REMOVE --><div> <div id="dynamicFilteringContainer"> - <div><span data-i18n="popupAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="*"> </span><span data-src="." data-des="*" data-type="*"></span></div> - <div><span data-i18n="popupImageRulePrompt"></span><span data-src="/" data-des="*" data-type="image"> </span><span data-src="." data-des="*" data-type="image"></span></div> - <div><span data-i18n="popup3pAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="3p"> </span><span data-src="." data-des="*" data-type="3p"></span></div> + <div><span data-i18n="popupAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="*"> </span><span data-src="." data-des="*" data-type="*"> </span></div> + <div><span data-i18n="popupImageRulePrompt"></span><span data-src="/" data-des="*" data-type="image"> </span><span data-src="." data-des="*" data-type="image"> </span></div> + <div><span data-i18n="popup3pAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="3p"> </span><span data-src="." data-des="*" data-type="3p"> </span></div> <div><span data-i18n="popupInlineScriptRulePrompt"></span><span data-src="/" data-des="*" data-type="inline-script"> </span><span data-src="." data-des="*" data-type="inline-script"> </span></div> <div><span data-i18n="popup1pScriptRulePrompt"></span><span data-src="/" data-des="*" data-type="1p-script"> </span><span data-src="." data-des="*" data-type="1p-script"> </span></div> <div><span data-i18n="popup3pScriptRulePrompt"></span><span data-src="/" data-des="*" data-type="3p-script"> </span><span data-src="." data-des="*" data-type="3p-script"> </span></div> |