mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-02 09:09:38 +02:00
code review
This commit is contained in:
parent
ace190a33e
commit
2bed24bb99
@ -172,7 +172,7 @@
|
||||
"description":""
|
||||
},
|
||||
"popupHitDomainCountPrompt":{
|
||||
"message":"Connected to {{count}} distinct domain(s)",
|
||||
"message":"Connected to {{count}} distinct domain(s) out of {{total}}",
|
||||
"description":"appear in dynamic filtering pane"
|
||||
},
|
||||
"pickerCreate":{
|
||||
|
@ -147,7 +147,7 @@ body.advancedUser #panes.dfEnabled #dfToggler::before {
|
||||
}
|
||||
#dynamicFilteringContainer > div#privacyInfo {
|
||||
background-color: white;
|
||||
color: gray;
|
||||
color: #444;
|
||||
padding: 4px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ var dfTypes = [
|
||||
var popupHeight;
|
||||
var reIP = /^\d+(?:\.\d+){1,3}$/;
|
||||
var reSrcHostnameFromResult = /^d[abn]:([^ ]+) ([^ ]+)/;
|
||||
var touchedDomains = {};
|
||||
var scopeToSrcHostnameMap = {
|
||||
'/': '*',
|
||||
'.': ''
|
||||
@ -51,6 +50,9 @@ var threeMinus = '−−−';
|
||||
var sixSpace = '\u2007\u2007\u2007\u2007\u2007\u2007';
|
||||
var dfHotspots = null;
|
||||
var hostnameToSortableTokenMap = {};
|
||||
var allDomains = {};
|
||||
var allDomainCount = 0;
|
||||
var touchedDomainCount = 0;
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -64,13 +66,16 @@ var cachePopupData = function(data) {
|
||||
popupData = {};
|
||||
scopeToSrcHostnameMap['.'] = '';
|
||||
hostnameToSortableTokenMap = {};
|
||||
|
||||
if ( typeof data !== 'object' ) {
|
||||
return popupData;
|
||||
}
|
||||
popupData = data;
|
||||
scopeToSrcHostnameMap['.'] = popupData.pageHostname || '';
|
||||
var hostnameDict = popupData.hostnameDict;
|
||||
if ( typeof hostnameDict === 'object' ) {
|
||||
if ( typeof hostnameDict !== 'object' ) {
|
||||
return popupData;
|
||||
}
|
||||
var domain, prefix;
|
||||
for ( var hostname in hostnameDict ) {
|
||||
if ( hostnameDict.hasOwnProperty(hostname) === false ) {
|
||||
@ -83,7 +88,6 @@ var cachePopupData = function(data) {
|
||||
prefix = hostname.slice(0, 0 - domain.length);
|
||||
hostnameToSortableTokenMap[hostname] = domain + prefix.split('.').reverse().join('.');
|
||||
}
|
||||
}
|
||||
return popupData;
|
||||
};
|
||||
|
||||
@ -122,8 +126,15 @@ var addDynamicFilterRow = function(des) {
|
||||
var hnDetails = popupData.hostnameDict[des] || {};
|
||||
var isDomain = des === hnDetails.domain;
|
||||
row.toggleClass('isDomain', isDomain);
|
||||
if ( allDomains.hasOwnProperty(hnDetails.domain) === false ) {
|
||||
allDomains[hnDetails.domain] = false;
|
||||
allDomainCount += 1;
|
||||
}
|
||||
if ( hnDetails.allowCount !== 0 ) {
|
||||
touchedDomains[hnDetails.domain] = true;
|
||||
if ( allDomains[hnDetails.domain] === false ) {
|
||||
allDomains[hnDetails.domain] = true;
|
||||
touchedDomainCount += 1;
|
||||
}
|
||||
row.addClass('allowed');
|
||||
}
|
||||
if ( hnDetails.blockCount !== 0 ) {
|
||||
@ -223,7 +234,10 @@ var syncAllDynamicFilters = function() {
|
||||
syncDynamicFilterCell(key.charAt(0), key.slice(2, key.indexOf(' ', 2)), '*', rules[key]);
|
||||
}
|
||||
|
||||
uDom('#privacyInfo').text(vAPI.i18n('popupHitDomainCountPrompt').replace('{{count}}', Object.keys(touchedDomains).length));
|
||||
var summary = vAPI.i18n('popupHitDomainCountPrompt')
|
||||
.replace('{{count}}', touchedDomainCount)
|
||||
.replace('{{total}}', allDomainCount);
|
||||
uDom('#privacyInfo').text(summary);
|
||||
|
||||
if ( dfPaneBuilt !== true ) {
|
||||
uDom('#dynamicFilteringContainer')
|
||||
|
Loading…
Reference in New Issue
Block a user