Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 { | 90 { |
91 // Make sure that Acceptable Ads is always last, since it cannot be | 91 // Make sure that Acceptable Ads is always last, since it cannot be |
92 // disabled, but only be removed. That way it's grouped together with | 92 // disabled, but only be removed. That way it's grouped together with |
93 // the "Own filter list" which cannot be disabled either at the bottom | 93 // the "Own filter list" which cannot be disabled either at the bottom |
94 // of the filter lists in the Advanced tab. | 94 // of the filter lists in the Advanced tab. |
95 if (a.url == acceptableAdsUrl) | 95 if (a.url == acceptableAdsUrl) |
96 return 1; | 96 return 1; |
97 if (b.url == acceptableAdsUrl) | 97 if (b.url == acceptableAdsUrl) |
98 return -1; | 98 return -1; |
99 | 99 |
100 // Make sure that duplicated whitelist entries are always being moved to | 100 // Make sure that newly added entries always appear on top in descending |
Thomas Greiner
2017/06/16 10:35:45
Detail: This is not about handling duplicated entr
saroyanm
2017/06/16 11:13:54
That's a very good question, I didn't know about t
saroyanm
2017/06/16 13:05:11
The mentioned behavior was confirmed, so I'll upda
saroyanm
2017/06/16 16:44:07
Done.
| |
101 // the top of the list | 101 // chronological order |
102 let aTimestamp = a[timestampUI] || 0; | 102 let aTimestamp = a[timestampUI] || 0; |
103 let bTimestamp = b[timestampUI] || 0; | 103 let bTimestamp = b[timestampUI] || 0; |
104 if (aTimestamp || bTimestamp) | 104 if (aTimestamp || bTimestamp) |
105 return bTimestamp - aTimestamp; | 105 return bTimestamp - aTimestamp; |
106 | 106 |
107 let aTitle = this._getItemTitle(a, 0).toLowerCase(); | 107 let aTitle = this._getItemTitle(a, 0).toLowerCase(); |
108 let bTitle = this._getItemTitle(b, 0).toLowerCase(); | 108 let bTitle = this._getItemTitle(b, 0).toLowerCase(); |
109 return aTitle.localeCompare(bTitle); | 109 return aTitle.localeCompare(bTitle); |
110 }); | 110 }); |
111 }; | 111 }; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 } | 191 } |
192 | 192 |
193 element.parentElement.removeChild(element); | 193 element.parentElement.removeChild(element); |
194 if (this.items.length == 0) | 194 if (this.items.length == 0) |
195 this._setEmpty(table, detail.emptyText); | 195 this._setEmpty(table, detail.emptyText); |
196 } | 196 } |
197 }; | 197 }; |
198 | 198 |
199 Collection.prototype.updateItem = function(item) | 199 Collection.prototype.updateItem = function(item) |
200 { | 200 { |
201 var oldIndex = this.items.indexOf(item); | 201 let oldIndex = this.items.indexOf(item); |
202 this._sortItems(); | 202 this._sortItems(); |
203 let access = (item.url || item.text).replace(/'/g, "\\'"); | 203 let access = (item.url || item.text).replace(/'/g, "\\'"); |
204 for (let i = 0; i < this.details.length; i++) | 204 for (let i = 0; i < this.details.length; i++) |
205 { | 205 { |
206 let table = E(this.details[i].id); | 206 let table = E(this.details[i].id); |
207 let element = table.querySelector("[data-access='" + access + "']"); | 207 let element = table.querySelector("[data-access='" + access + "']"); |
208 if (!element) | 208 if (!element) |
209 continue; | 209 continue; |
210 | 210 |
211 let title = this._getItemTitle(item, i); | 211 let title = this._getItemTitle(item, i); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 if (item.homepage) | 256 if (item.homepage) |
257 websiteElement.setAttribute("href", item.homepage); | 257 websiteElement.setAttribute("href", item.homepage); |
258 else | 258 else |
259 websiteElement.setAttribute("aria-hidden", true); | 259 websiteElement.setAttribute("aria-hidden", true); |
260 } | 260 } |
261 | 261 |
262 let sourceElement = element.querySelector(".context-menu .source"); | 262 let sourceElement = element.querySelector(".context-menu .source"); |
263 if (sourceElement) | 263 if (sourceElement) |
264 sourceElement.setAttribute("href", item.url); | 264 sourceElement.setAttribute("href", item.url); |
265 | 265 |
266 if (oldIndex != this.items.indexOf(item)) | 266 let newIndex = this.items.indexOf(item); |
Thomas Greiner
2017/06/16 10:35:46
Detail: `this.items.indexOf(item)` is duplicated s
saroyanm
2017/06/16 16:44:06
Done.
| |
267 table.insertBefore(element, table.childNodes[this.items.indexOf(item)]); | 267 if (oldIndex != newIndex) |
268 table.insertBefore(element, table.childNodes[newIndex]); | |
268 } | 269 } |
269 }; | 270 }; |
270 | 271 |
271 Collection.prototype.clearAll = function() | 272 Collection.prototype.clearAll = function() |
272 { | 273 { |
273 this.items = []; | 274 this.items = []; |
274 for (let detail of this.details) | 275 for (let detail of this.details) |
275 { | 276 { |
276 let table = E(detail.id); | 277 let table = E(detail.id); |
277 let element = table.firstChild; | 278 let element = table.firstChild; |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 | 758 |
758 updateShareLink(); | 759 updateShareLink(); |
759 updateTooltips(); | 760 updateTooltips(); |
760 | 761 |
761 // Initialize interactive UI elements | 762 // Initialize interactive UI elements |
762 document.body.addEventListener("click", onClick, false); | 763 document.body.addEventListener("click", onClick, false); |
763 document.body.addEventListener("keyup", onKeyUp, false); | 764 document.body.addEventListener("keyup", onKeyUp, false); |
764 let placeholderValue = getMessage("options_dialog_language_find"); | 765 let placeholderValue = getMessage("options_dialog_language_find"); |
765 E("find-language").setAttribute("placeholder", placeholderValue); | 766 E("find-language").setAttribute("placeholder", placeholderValue); |
766 E("find-language").addEventListener("keyup", onFindLanguageKeyUp, false); | 767 E("find-language").addEventListener("keyup", onFindLanguageKeyUp, false); |
767 let exampleValue = getMessages("options_whitelist_placeholder_example", | 768 let exampleValue = getMessage("options_whitelist_placeholder_example", |
saroyanm
2017/06/14 11:51:22
Nit: This should be getMessage(...)
Thomas Greiner
2017/06/16 10:35:46
Indeed.
saroyanm
2017/06/16 16:43:07
Done.
| |
768 ["www.example.com"]); | 769 ["www.example.com"]); |
769 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); | 770 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); |
770 E("whitelisting-textbox").addEventListener("keyup", (e) => | 771 E("whitelisting-textbox").addEventListener("keyup", (e) => |
771 { | 772 { |
772 let addWhitelistButton = E("whitelisting-add-button"); | 773 E("whitelisting-add-button").disabled = !e.target.value; |
773 addWhitelistButton.disabled = false; | |
774 if (getKey(e) == "Enter") | |
775 { | |
776 if (!addWhitelistButton.disabled) | |
777 addWhitelistedDomain(); | |
Thomas Greiner
2017/06/16 10:35:46
This will clear the input field so the whitelist b
saroyanm
2017/06/16 15:53:45
We do need:
`
domain.value = "";
E("whitelisting-a
saroyanm
2017/06/16 16:43:07
Done.
| |
778 } | |
779 else | |
780 { | |
781 addWhitelistButton.disabled = !e.target.value; | |
782 } | |
783 }, false); | 774 }, false); |
784 | 775 |
785 // Advanced tab | 776 // Advanced tab |
786 let tweaks = document.querySelectorAll("#tweaks li[data-pref]"); | 777 let tweaks = document.querySelectorAll("#tweaks li[data-pref]"); |
787 tweaks = Array.prototype.map.call(tweaks, (checkbox) => | 778 tweaks = Array.prototype.map.call(tweaks, (checkbox) => |
788 { | 779 { |
789 return checkbox.getAttribute("data-pref"); | 780 return checkbox.getAttribute("data-pref"); |
790 }); | 781 }); |
791 for (let key of tweaks) | 782 for (let key of tweaks) |
792 { | 783 { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1044 message.homepage = homepage; | 1035 message.homepage = homepage; |
1045 | 1036 |
1046 ext.backgroundPage.sendMessage(message); | 1037 ext.backgroundPage.sendMessage(message); |
1047 } | 1038 } |
1048 | 1039 |
1049 function onFilterMessage(action, filter) | 1040 function onFilterMessage(action, filter) |
1050 { | 1041 { |
1051 switch (action) | 1042 switch (action) |
1052 { | 1043 { |
1053 case "added": | 1044 case "added": |
1045 filter[timestampUI] = Date.now(); | |
1054 updateFilter(filter); | 1046 updateFilter(filter); |
1055 updateShareLink(); | 1047 updateShareLink(); |
1056 break; | 1048 break; |
1057 case "loaded": | 1049 case "loaded": |
1058 populateLists(); | 1050 populateLists(); |
1059 break; | 1051 break; |
1060 case "removed": | 1052 case "removed": |
1061 let knownFilter = filtersMap[filter.text]; | 1053 let knownFilter = filtersMap[filter.text]; |
1062 collections.whitelist.removeItem(knownFilter); | 1054 collections.whitelist.removeItem(knownFilter); |
1063 collections.customFilters.removeItem(knownFilter); | 1055 collections.customFilters.removeItem(knownFilter); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1324 }); | 1316 }); |
1325 ext.backgroundPage.sendMessage({ | 1317 ext.backgroundPage.sendMessage({ |
1326 type: "subscriptions.listen", | 1318 type: "subscriptions.listen", |
1327 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1319 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1328 "title", "downloadStatus", "downloading"] | 1320 "title", "downloadStatus", "downloading"] |
1329 }); | 1321 }); |
1330 | 1322 |
1331 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1323 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1332 window.addEventListener("hashchange", onHashChange, false); | 1324 window.addEventListener("hashchange", onHashChange, false); |
1333 } | 1325 } |
LEFT | RIGHT |