Browse Source

fix meta row of blacklisted hostnames group

pull/2/head
gorhill 10 years ago
parent
commit
10ef2cf0f1
  1. 36
      src/js/popup.js
  2. 5
      src/popup.html
  3. 4
      tools/_locales/en/messages.json

36
src/js/popup.js

@ -63,6 +63,8 @@ var matrixHeaderPrettyNames = {
'other': '' 'other': ''
}; };
var blacklistedHostnamesLabel = '';
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/
@ -615,7 +617,7 @@ function makeMatrixMetaRow(totals) {
var cells = matrixRow.descendants('.matCell'); var cells = matrixRow.descendants('.matCell');
var contents = cells.at(0).addClass('t81').contents(); var contents = cells.at(0).addClass('t81').contents();
contents.nodeAt(0).textContent = ' '; contents.nodeAt(0).textContent = ' ';
contents.nodeAt(1).textContent = '\u202A' + totals[typeOffsets['*']] + ' blacklisted hostname(s)';
contents.nodeAt(1).textContent = blacklistedHostnamesLabel.replace('{{count}}', totals[typeOffsets['*']]);
renderMatrixMetaCellType(cells.at(1), totals[typeOffsets.cookie]); renderMatrixMetaCellType(cells.at(1), totals[typeOffsets.cookie]);
renderMatrixMetaCellType(cells.at(2), totals[typeOffsets.css]); renderMatrixMetaCellType(cells.at(2), totals[typeOffsets.css]);
renderMatrixMetaCellType(cells.at(3), totals[typeOffsets.image]); renderMatrixMetaCellType(cells.at(3), totals[typeOffsets.image]);
@ -630,18 +632,34 @@ function makeMatrixMetaRow(totals) {
/******************************************************************************/ /******************************************************************************/
function computeMatrixGroupMetaStats(group) { function computeMatrixGroupMetaStats(group) {
var types = Object.keys(matrixSnapshot.headers);
var i = types.length, j;
var headers = matrixSnapshot.headers;
var i = Object.keys(headers).length
var totals = new Array(i); var totals = new Array(i);
var domains = Object.keys(group);
while ( i-- ) { while ( i-- ) {
totals[i] = 0; totals[i] = 0;
j = domains.length;
while ( j-- ) {
totals[i] += matrixSnapshot.rows[domains[j]].totals[i];
}
var rows = matrixSnapshot.rows, row;
for ( var hostname in rows ) {
if ( rows.hasOwnProperty(hostname) === false ) {
continue;
} }
row = rows[hostname];
if ( group.hasOwnProperty(row.domain) === false ) {
continue;
}
if ( row.counts[headers['*']] === 0 ) {
continue;
}
totals[0] += 1;
totals[1] += row.counts[headers.cookie];
totals[2] += row.counts[headers.css];
totals[3] += row.counts[headers.image];
totals[4] += row.counts[headers.plugin];
totals[5] += row.counts[headers.script];
totals[6] += row.counts[headers.xhr];
totals[7] += row.counts[headers.frame];
totals[8] += row.counts[headers.other];
} }
// TODO: column 0 is supposed to be count of blacklisted hostnames
return totals; return totals;
} }
@ -924,6 +942,8 @@ function initMenuEnvironment() {
cell.text(text); cell.text(text);
prettyNames[key] = text; prettyNames[key] = text;
} }
blacklistedHostnamesLabel = '\u202A' + uDom('[data-i18n="matrixBlacklistedHostnames"]').text();
} }
/******************************************************************************/ /******************************************************************************/

5
src/popup.html

@ -72,6 +72,11 @@
<div id="noNetTrafficPrompt" style="display:none;text-align:center;font-size:large"></div> <div id="noNetTrafficPrompt" style="display:none;text-align:center;font-size:large"></div>
</div> </div>
<!-- Convenient to auto-fetch locale strings used in scripts -->
<div style="display: none;">
<span data-i18n="matrixBlacklistedHostnames"></span>
</div>
<script src="lib/punycode.min.js"></script> <script src="lib/punycode.min.js"></script>
<script src="js/udom.js"></script> <script src="js/udom.js"></script>
<script src="js/i18n.js"></script> <script src="js/i18n.js"></script>

4
tools/_locales/en/messages.json

@ -95,6 +95,10 @@
"message": "Reload the page.", "message": "Reload the page.",
"description": "Tool tip for the reload button" "description": "Tool tip for the reload button"
}, },
"matrixBlacklistedHostnames" : {
"message": "{{count}} blacklisted hostname(s)",
"description": "Appears in the metadata row of bottom-most group: **mind the limited width**"
},
"statsPageTitle" : { "statsPageTitle" : {

Loading…
Cancel
Save