| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 var cacheStorage = null; | 26 var cacheStorage = null; |
| 27 var noFlash = false; | 27 var noFlash = false; |
| 28 | 28 |
| 29 // Matcher for disabled filters | 29 // Matcher for disabled filters |
| 30 var disabledMatcher = new CombinedMatcher(); | 30 var disabledMatcher = new CombinedMatcher(); |
| 31 | 31 |
| 32 // Cached string values | 32 // Cached string values |
| 33 var docDomainThirdParty = null; | 33 var docDomainThirdParty = null; |
| 34 var docDomainFirstParty = null; | 34 var docDomainFirstParty = null; |
| 35 | 35 |
| 36 // Localized type names |
| 37 var localizedTypes = new Map(); |
| 38 |
| 36 function init() { | 39 function init() { |
| 37 docDomainThirdParty = document.documentElement.getAttribute("docDomainThirdPar
ty"); | 40 docDomainThirdParty = document.documentElement.getAttribute("docDomainThirdPar
ty"); |
| 38 docDomainFirstParty = document.documentElement.getAttribute("docDomainFirstPar
ty"); | 41 docDomainFirstParty = document.documentElement.getAttribute("docDomainFirstPar
ty"); |
| 39 | 42 |
| 40 var list = E("list"); | 43 var list = E("list"); |
| 41 list.view = treeView; | 44 list.view = treeView; |
| 42 | 45 |
| 43 // Restore previous state | 46 // Restore previous state |
| 44 var params = Utils.getParams(); | 47 var params = Utils.getParams(); |
| 45 if (params && params.filter) | 48 if (params && params.filter) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 97 |
| 95 // Activate flasher | 98 // Activate flasher |
| 96 list.addEventListener("select", onSelectionChange, false); | 99 list.addEventListener("select", onSelectionChange, false); |
| 97 | 100 |
| 98 // Initialize data | 101 // Initialize data |
| 99 handleLocationChange(); | 102 handleLocationChange(); |
| 100 | 103 |
| 101 // Install a progress listener to catch location changes | 104 // Install a progress listener to catch location changes |
| 102 if (addBrowserLocationListener) | 105 if (addBrowserLocationListener) |
| 103 addBrowserLocationListener(mainWin, handleLocationChange, true); | 106 addBrowserLocationListener(mainWin, handleLocationChange, true); |
| 107 |
| 108 for (let type of Policy.contentTypes) |
| 109 localizedTypes.set(type, Utils.getString("type_label_" + type.toLowerCase())
); |
| 104 } | 110 } |
| 105 | 111 |
| 106 // To be called for a detached window when the main window has been closed | 112 // To be called for a detached window when the main window has been closed |
| 107 function mainUnload() { | 113 function mainUnload() { |
| 108 parent.close(); | 114 parent.close(); |
| 109 } | 115 } |
| 110 | 116 |
| 111 // To be called on unload | 117 // To be called on unload |
| 112 function cleanUp() { | 118 function cleanUp() { |
| 113 flasher.stop(); | 119 flasher.stop(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 E("tooltipFilterRow").hidden = !filter; | 257 E("tooltipFilterRow").hidden = !filter; |
| 252 E("tooltipFilterSourceRow").hidden = !subscriptions.length; | 258 E("tooltipFilterSourceRow").hidden = !subscriptions.length; |
| 253 | 259 |
| 254 if ("tooltip" in item) | 260 if ("tooltip" in item) |
| 255 E("tooltipDummy").setAttribute("value", item.tooltip); | 261 E("tooltipDummy").setAttribute("value", item.tooltip); |
| 256 else | 262 else |
| 257 { | 263 { |
| 258 E("tooltipAddress").parentNode.hidden = (item.typeDescr == "ELEMHIDE"); | 264 E("tooltipAddress").parentNode.hidden = (item.typeDescr == "ELEMHIDE"); |
| 259 setMultilineContent(E("tooltipAddress"), item.location); | 265 setMultilineContent(E("tooltipAddress"), item.location); |
| 260 | 266 |
| 261 var type = item.localizedDescr; | 267 var type = localizedTypes.get(item.type); |
| 262 if (filter && filter instanceof WhitelistFilter) | 268 if (filter && filter instanceof WhitelistFilter) |
| 263 type += " " + E("tooltipType").getAttribute("whitelisted"); | 269 type += " " + E("tooltipType").getAttribute("whitelisted"); |
| 264 else if (filter && item.typeDescr != "ELEMHIDE") | 270 else if (filter && item.typeDescr != "ELEMHIDE") |
| 265 type += " " + E("tooltipType").getAttribute("filtered"); | 271 type += " " + E("tooltipType").getAttribute("filtered"); |
| 266 E("tooltipType").setAttribute("value", type); | 272 E("tooltipType").setAttribute("value", type); |
| 267 | 273 |
| 268 if (size) | 274 if (size) |
| 269 E("tooltipSize").setAttribute("value", size.join(" x ")); | 275 E("tooltipSize").setAttribute("value", size.join(" x ")); |
| 270 | 276 |
| 271 E("tooltipDocDomain").setAttribute("value", item.docDomain + " " + (item.thi
rdParty ? docDomainThirdParty : docDomainFirstParty)); | 277 E("tooltipDocDomain").setAttribute("value", item.docDomain + " " + (item.thi
rdParty ? docDomainThirdParty : docDomainFirstParty)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 { | 313 { |
| 308 let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInf
o.jsm", null); | 314 let {LoadContextInfo} = Cu.import("resource://gre/modules/LoadContextInf
o.jsm", null); |
| 309 let loadContext = content.QueryInterface(Ci.nsIInterfaceRequestor) | 315 let loadContext = content.QueryInterface(Ci.nsIInterfaceRequestor) |
| 310 .getInterface(Ci.nsIWebNavigation) | 316 .getInterface(Ci.nsIWebNavigation) |
| 311 .QueryInterface(Ci.nsILoadContext); | 317 .QueryInterface(Ci.nsILoadContext); |
| 312 cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.fromLoad
Context(loadContext, false), false); | 318 cacheStorage = Services.cache2.diskCacheStorage(LoadContextInfo.fromLoad
Context(loadContext, false), false); |
| 313 } | 319 } |
| 314 else | 320 else |
| 315 cacheStorage = Services.cache.createSession("HTTP", Ci.nsICache.STORE_AN
YWHERE, true); | 321 cacheStorage = Services.cache.createSession("HTTP", Ci.nsICache.STORE_AN
YWHERE, true); |
| 316 } | 322 } |
| 317 | 323 |
| 318 let showTooltipPreview = function () | 324 let showTooltipPreview = function () |
| 319 { | 325 { |
| 320 E("tooltipPreview").setAttribute("src", item.location); | 326 E("tooltipPreview").setAttribute("src", item.location); |
| 321 E("tooltipPreviewBox").hidden = false; | 327 E("tooltipPreviewBox").hidden = false; |
| 322 }; | 328 }; |
| 323 try | 329 try |
| 324 { | 330 { |
| 325 if (Ci.nsICacheStorage && cacheStorage instanceof Ci.nsICacheStorage) | 331 if (Ci.nsICacheStorage && cacheStorage instanceof Ci.nsICacheStorage) |
| 326 { | 332 { |
| 327 cacheStorage.asyncOpenURI(Utils.makeURI(item.location), "", Ci.nsICacheS
torage.OPEN_READONLY, { | 333 cacheStorage.asyncOpenURI(Utils.makeURI(item.location), "", Ci.nsICacheS
torage.OPEN_READONLY, { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 return 1; | 677 return 1; |
| 672 else | 678 else |
| 673 return 0; | 679 return 0; |
| 674 } | 680 } |
| 675 | 681 |
| 676 function sortByAddressDesc(item1, item2) { | 682 function sortByAddressDesc(item1, item2) { |
| 677 return -sortByAddress(item1, item2); | 683 return -sortByAddress(item1, item2); |
| 678 } | 684 } |
| 679 | 685 |
| 680 function compareType(item1, item2) { | 686 function compareType(item1, item2) { |
| 681 if (item1.localizedDescr < item2.localizedDescr) | 687 let type1 = localizedTypes.get(item1.type); |
| 688 let type2 = localizedTypes.get(item2.type); |
| 689 if (type1 < type2) |
| 682 return -1; | 690 return -1; |
| 683 else if (item1.localizedDescr > item2.localizedDescr) | 691 else if (type1 > type2) |
| 684 return 1; | 692 return 1; |
| 685 else | 693 else |
| 686 return 0; | 694 return 0; |
| 687 } | 695 } |
| 688 | 696 |
| 689 function compareFilter(item1, item2) { | 697 function compareFilter(item1, item2) { |
| 690 var hasFilter1 = (item1.filter ? 1 : 0); | 698 var hasFilter1 = (item1.filter ? 1 : 0); |
| 691 var hasFilter2 = (item2.filter ? 1 : 0); | 699 var hasFilter2 = (item2.filter ? 1 : 0); |
| 692 if (hasFilter1 != hasFilter2) | 700 if (hasFilter1 != hasFilter2) |
| 693 return hasFilter1 - hasFilter2; | 701 return hasFilter1 - hasFilter2; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 return (this.data && this.data.length ? this.data.length : 1); | 847 return (this.data && this.data.length ? this.data.length : 1); |
| 840 }, | 848 }, |
| 841 getCellText: function(row, col) { | 849 getCellText: function(row, col) { |
| 842 col = col.id; | 850 col = col.id; |
| 843 if (col != "type" && col != "address" && col != "filter" && col != "size" &&
col != "docDomain" && col != "filterSource") | 851 if (col != "type" && col != "address" && col != "filter" && col != "size" &&
col != "docDomain" && col != "filterSource") |
| 844 return ""; | 852 return ""; |
| 845 if (this.data && this.data.length) { | 853 if (this.data && this.data.length) { |
| 846 if (row >= this.data.length) | 854 if (row >= this.data.length) |
| 847 return ""; | 855 return ""; |
| 848 if (col == "type") | 856 if (col == "type") |
| 849 return this.data[row].localizedDescr; | 857 return localizedTypes.get(this.data[row].type); |
| 850 else if (col == "filter") | 858 else if (col == "filter") |
| 851 return (this.data[row].filter ? this.data[row].filter.text : ""); | 859 return (this.data[row].filter ? this.data[row].filter.text : ""); |
| 852 else if (col == "size") | 860 else if (col == "size") |
| 853 { | 861 { |
| 854 let size = getItemSize(this.data[row]); | 862 let size = getItemSize(this.data[row]); |
| 855 return (size ? size.join(" x ") : ""); | 863 return (size ? size.join(" x ") : ""); |
| 856 } | 864 } |
| 857 else if (col == "docDomain") | 865 else if (col == "docDomain") |
| 858 return this.data[row].docDomain + " " + (this.data[row].thirdParty ? doc
DomainThirdParty : docDomainFirstParty); | 866 return this.data[row].docDomain + " " + (this.data[row].thirdParty ? doc
DomainThirdParty : docDomainFirstParty); |
| 859 else if (col == "filterSource") | 867 else if (col == "filterSource") |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 * @return {Boolean} true if the item should be shown | 1162 * @return {Boolean} true if the item should be shown |
| 1155 */ | 1163 */ |
| 1156 matchesFilter: function(item) | 1164 matchesFilter: function(item) |
| 1157 { | 1165 { |
| 1158 if (!this.filter) | 1166 if (!this.filter) |
| 1159 return true; | 1167 return true; |
| 1160 | 1168 |
| 1161 return (item.location.toLowerCase().indexOf(this.filter) >= 0 || | 1169 return (item.location.toLowerCase().indexOf(this.filter) >= 0 || |
| 1162 (item.filter && item.filter.text.toLowerCase().indexOf(this.filter)
>= 0) || | 1170 (item.filter && item.filter.text.toLowerCase().indexOf(this.filter)
>= 0) || |
| 1163 item.typeDescr.toLowerCase().indexOf(this.filter.replace(/-/g, "_"))
>= 0 || | 1171 item.typeDescr.toLowerCase().indexOf(this.filter.replace(/-/g, "_"))
>= 0 || |
| 1164 item.localizedDescr.toLowerCase().indexOf(this.filter) >= 0 || | 1172 localizedTypes.get(item.type).toLowerCase().indexOf(this.filter) >=
0 || |
| 1165 (item.docDomain && item.docDomain.toLowerCase().indexOf(this.filter)
>= 0) || | 1173 (item.docDomain && item.docDomain.toLowerCase().indexOf(this.filter)
>= 0) || |
| 1166 (item.docDomain && item.thirdParty && docDomainThirdParty.toLowerCas
e().indexOf(this.filter) >= 0) || | 1174 (item.docDomain && item.thirdParty && docDomainThirdParty.toLowerCas
e().indexOf(this.filter) >= 0) || |
| 1167 (item.docDomain && !item.thirdParty && docDomainFirstParty.toLowerCa
se().indexOf(this.filter) >= 0)); | 1175 (item.docDomain && !item.thirdParty && docDomainFirstParty.toLowerCa
se().indexOf(this.filter) >= 0)); |
| 1168 }, | 1176 }, |
| 1169 | 1177 |
| 1170 setFilter: function(filter) { | 1178 setFilter: function(filter) { |
| 1171 var oldRows = this.rowCount; | 1179 var oldRows = this.rowCount; |
| 1172 | 1180 |
| 1173 this.filter = filter.toLowerCase(); | 1181 this.filter = filter.toLowerCase(); |
| 1174 this.refilter(); | 1182 this.refilter(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 return {tooltip: this.itemsDummyTooltip}; | 1251 return {tooltip: this.itemsDummyTooltip}; |
| 1244 }, | 1252 }, |
| 1245 | 1253 |
| 1246 invalidateItem: function(item) | 1254 invalidateItem: function(item) |
| 1247 { | 1255 { |
| 1248 let row = this.data.indexOf(item); | 1256 let row = this.data.indexOf(item); |
| 1249 if (row >= 0) | 1257 if (row >= 0) |
| 1250 this.boxObject.invalidateRow(row); | 1258 this.boxObject.invalidateRow(row); |
| 1251 } | 1259 } |
| 1252 } | 1260 } |
| OLD | NEW |