Left: | ||
Right: |
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-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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 /* globals checkShareResource, getDocLink, i18nFormatDateTime, openSharePopup, | 18 /* globals checkShareResource, getDocLink, i18nFormatDateTime, openSharePopup, |
19 setLinks, E */ | 19 setLinks, E */ |
20 | 20 |
21 "use strict"; | 21 "use strict"; |
22 | 22 |
23 { | 23 { |
24 let subscriptionsMap = Object.create(null); | 24 let subscriptionsMap = Object.create(null); |
25 let filtersMap = Object.create(null); | 25 let filtersMap = Object.create(null); |
26 let collections = Object.create(null); | 26 let collections = Object.create(null); |
27 let acceptableAdsUrl = null; | 27 let acceptableAdsUrl = null; |
28 let acceptableAdsPrivacyUrl = null; | |
29 let subscriptionToChange = null; | |
28 let isCustomFiltersLoaded = false; | 30 let isCustomFiltersLoaded = false; |
29 let {getMessage} = ext.i18n; | 31 let {getMessage} = ext.i18n; |
30 let customFilters = []; | 32 let customFilters = []; |
31 let filterErrors = new Map([ | 33 let filterErrors = new Map([ |
32 ["synchronize_invalid_url", | 34 ["synchronize_invalid_url", |
33 "options_filterList_lastDownload_invalidURL"], | 35 "options_filterList_lastDownload_invalidURL"], |
34 ["synchronize_connection_error", | 36 ["synchronize_connection_error", |
35 "options_filterList_lastDownload_connectionError"], | 37 "options_filterList_lastDownload_connectionError"], |
36 ["synchronize_invalid_data", | 38 ["synchronize_invalid_data", |
37 "options_filterList_lastDownload_invalidData"], | 39 "options_filterList_lastDownload_invalidData"], |
38 ["synchronize_checksum_mismatch", | 40 ["synchronize_checksum_mismatch", |
39 "options_filterList_lastDownload_checksumMismatch"] | 41 "options_filterList_lastDownload_checksumMismatch"] |
40 ]); | 42 ]); |
41 const timestampUI = Symbol(); | 43 const timestampUI = Symbol(); |
42 const whitelistedDomainRegexp = /^@@\|\|([^/:]+)\^\$document$/; | 44 const whitelistedDomainRegexp = /^@@\|\|([^/:]+)\^\$document$/; |
43 // Period of time in milliseconds | 45 // Period of time in milliseconds |
44 const minuteInMs = 60000; | 46 const minuteInMs = 60000; |
45 const hourInMs = 3600000; | 47 const hourInMs = 3600000; |
46 const fullDayInMs = 86400000; | 48 const fullDayInMs = 86400000; |
49 const privacySubscriptions = ["privacy", "social"]; | |
50 const moreSubscriptions = ["malware", "anti-adblock"]; | |
47 | 51 |
48 function Collection(details) | 52 function Collection(details) |
49 { | 53 { |
50 this.details = details; | 54 this.details = details; |
51 this.items = []; | 55 this.items = []; |
52 } | 56 } |
53 | 57 |
54 Collection.prototype._setEmpty = function(table, texts) | 58 Collection.prototype._setEmpty = function(table, texts) |
55 { | 59 { |
56 let placeholders = table.querySelectorAll(".empty-placeholder"); | 60 let placeholders = table.querySelectorAll(".empty-placeholder"); |
(...skipping 19 matching lines...) Expand all Loading... | |
76 { | 80 { |
77 let access = (item.url || item.text).replace(/'/g, "\\'"); | 81 let access = (item.url || item.text).replace(/'/g, "\\'"); |
78 return function(container) | 82 return function(container) |
79 { | 83 { |
80 return container.querySelector("[data-access='" + access + "']"); | 84 return container.querySelector("[data-access='" + access + "']"); |
81 }; | 85 }; |
82 }; | 86 }; |
83 | 87 |
84 Collection.prototype._getItemTitle = function(item, i) | 88 Collection.prototype._getItemTitle = function(item, i) |
85 { | 89 { |
86 if (item.url == acceptableAdsUrl) | 90 if (item.url === acceptableAdsUrl) |
Thomas Greiner
2017/08/09 18:14:49
Do we even need this special handling of Acceptabl
saroyanm
2017/08/14 14:00:10
I think that we want the title to be translated, a
Thomas Greiner
2017/08/15 17:10:29
What's so bad about showing the original (i.e. unt
saroyanm
2017/08/16 14:17:38
Nevermind I totally agree, I thought that this als
| |
87 return getMessage("options_acceptableAds_description"); | 91 return getMessage("options_aa_tracking_label"); |
Thomas Greiner
2017/08/09 18:14:49
Detail: Let's be consistent with the naming scheme
saroyanm
2017/08/14 14:00:09
Agree, I'll change.
saroyanm
2017/08/16 14:17:38
Done.
| |
92 if (item.url === acceptableAdsPrivacyUrl) | |
93 return getMessage("options_aa_no_tracking_label"); | |
88 if (this.details[i].useOriginalTitle && item.originalTitle) | 94 if (this.details[i].useOriginalTitle && item.originalTitle) |
89 return item.originalTitle; | 95 return item.originalTitle; |
90 return item.title || item.url || item.text; | 96 return item.title || item.url || item.text; |
91 }; | 97 }; |
92 | 98 |
93 Collection.prototype._sortItems = function() | 99 Collection.prototype._sortItems = function() |
94 { | 100 { |
95 this.items.sort((a, b) => | 101 this.items.sort((a, b) => |
96 { | 102 { |
97 // Make sure that Acceptable Ads is always last, since it cannot be | 103 // Make sure that Acceptable Ads is always last, since it cannot be |
98 // disabled, but only be removed. That way it's grouped together with | 104 // disabled, but only be removed. That way it's grouped together with |
99 // the "Own filter list" which cannot be disabled either at the bottom | 105 // the "Own filter list" which cannot be disabled either at the bottom |
100 // of the filter lists in the Advanced tab. | 106 // of the filter lists in the Advanced tab. |
101 if (a.url == acceptableAdsUrl) | 107 if (a.url == acceptableAdsUrl || a.url == acceptableAdsPrivacyUrl) |
102 return 1; | 108 return 1; |
103 if (b.url == acceptableAdsUrl) | 109 if (b.url == acceptableAdsUrl || b.url == acceptableAdsPrivacyUrl) |
104 return -1; | 110 return -1; |
105 | 111 |
106 // Make sure that newly added entries always appear on top in descending | 112 // Make sure that newly added entries always appear on top in descending |
107 // chronological order | 113 // chronological order |
108 let aTimestamp = a[timestampUI] || 0; | 114 let aTimestamp = a[timestampUI] || 0; |
109 let bTimestamp = b[timestampUI] || 0; | 115 let bTimestamp = b[timestampUI] || 0; |
110 if (aTimestamp || bTimestamp) | 116 if (aTimestamp || bTimestamp) |
111 return bTimestamp - aTimestamp; | 117 return bTimestamp - aTimestamp; |
112 | 118 |
113 let aTitle = this._getItemTitle(a, 0).toLowerCase(); | 119 let aTitle = this._getItemTitle(a, 0).toLowerCase(); |
(...skipping 13 matching lines...) Expand all Loading... | |
127 { | 133 { |
128 let detail = this.details[j]; | 134 let detail = this.details[j]; |
129 let table = E(detail.id); | 135 let table = E(detail.id); |
130 let template = table.querySelector("template"); | 136 let template = table.querySelector("template"); |
131 let listItem = document.createElement("li"); | 137 let listItem = document.createElement("li"); |
132 listItem.appendChild(document.importNode(template.content, true)); | 138 listItem.appendChild(document.importNode(template.content, true)); |
133 listItem.setAttribute("aria-label", this._getItemTitle(item, j)); | 139 listItem.setAttribute("aria-label", this._getItemTitle(item, j)); |
134 listItem.setAttribute("data-access", item.url || item.text); | 140 listItem.setAttribute("data-access", item.url || item.text); |
135 listItem.setAttribute("role", "section"); | 141 listItem.setAttribute("role", "section"); |
136 | 142 |
137 let label = listItem.querySelector(".display"); | 143 let tooltip = listItem.querySelector("[data-tooltip]"); |
138 if (item.recommended && label.hasAttribute("data-tooltip")) | 144 if (tooltip && tooltip.hasAttribute("data-tooltip")) |
Thomas Greiner
2017/08/09 18:14:48
Detail: The second condition is redundant because
saroyanm
2017/08/14 14:00:10
Well spotted.
saroyanm
2017/08/16 14:17:38
Done.
| |
139 { | 145 { |
140 let tooltipId = label.getAttribute("data-tooltip"); | 146 if (item.recommended) |
Thomas Greiner
2017/08/09 18:14:48
According to the spec, not all subscriptions that
saroyanm
2017/08/14 14:00:08
I agree, make sense to first check if the string f
saroyanm
2017/08/16 14:17:37
Done.
| |
141 tooltipId = tooltipId.replace("%value%", item.recommended); | 147 { |
142 label.setAttribute("data-tooltip", tooltipId); | 148 let tooltipId = tooltip.getAttribute("data-tooltip"); |
149 tooltipId = tooltipId.replace("%value%", item.recommended); | |
150 tooltip.setAttribute("data-tooltip", tooltipId); | |
151 } | |
152 else | |
153 { | |
154 tooltip.parentNode.removeChild(tooltip); | |
155 } | |
143 } | 156 } |
144 | 157 |
145 for (let control of listItem.querySelectorAll(".control")) | 158 for (let control of listItem.querySelectorAll(".control")) |
146 { | 159 { |
147 if (control.hasAttribute("title")) | 160 if (control.hasAttribute("title")) |
148 { | 161 { |
149 let titleValue = getMessage(control.getAttribute("title")); | 162 let titleValue = getMessage(control.getAttribute("title")); |
150 control.setAttribute("title", titleValue); | 163 control.setAttribute("title", titleValue); |
151 } | 164 } |
152 } | 165 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 | 228 |
216 let title = this._getItemTitle(item, i); | 229 let title = this._getItemTitle(item, i); |
217 element.querySelector(".display").textContent = title; | 230 element.querySelector(".display").textContent = title; |
218 element.setAttribute("aria-label", title); | 231 element.setAttribute("aria-label", title); |
219 if (this.details[i].searchable) | 232 if (this.details[i].searchable) |
220 element.setAttribute("data-search", title.toLowerCase()); | 233 element.setAttribute("data-search", title.toLowerCase()); |
221 let control = element.querySelector(".control[role='checkbox']"); | 234 let control = element.querySelector(".control[role='checkbox']"); |
222 if (control) | 235 if (control) |
223 { | 236 { |
224 control.setAttribute("aria-checked", item.disabled == false); | 237 control.setAttribute("aria-checked", item.disabled == false); |
225 if (item.url == acceptableAdsUrl && this == collections.filterLists) | 238 if ((item.url == acceptableAdsUrl || |
239 item.url == acceptableAdsPrivacyUrl) && | |
Thomas Greiner
2017/08/09 18:14:50
Detail: This is already the third time that you're
saroyanm
2017/08/14 14:00:10
agree.
saroyanm
2017/08/16 14:17:36
Done.
| |
240 this == collections.filterLists) | |
226 control.disabled = true; | 241 control.disabled = true; |
227 } | 242 } |
228 | 243 |
229 let lastUpdateElement = element.querySelector(".last-update"); | 244 let lastUpdateElement = element.querySelector(".last-update"); |
230 if (lastUpdateElement) | 245 if (lastUpdateElement) |
231 { | 246 { |
232 let message = element.querySelector(".message"); | 247 let message = element.querySelector(".message"); |
233 if (item.isDownloading) | 248 if (item.isDownloading) |
234 { | 249 { |
235 let text = getMessage("options_filterList_lastDownload_inProgress"); | 250 let text = getMessage("options_filterList_lastDownload_inProgress"); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 index += (index == focusables.length - 1) ? -1 : 1; | 338 index += (index == focusables.length - 1) ? -1 : 1; |
324 | 339 |
325 let nextElement = focusables[index]; | 340 let nextElement = focusables[index]; |
326 if (!nextElement) | 341 if (!nextElement) |
327 return false; | 342 return false; |
328 | 343 |
329 nextElement.focus(); | 344 nextElement.focus(); |
330 return true; | 345 return true; |
331 } | 346 } |
332 | 347 |
333 collections.popular = new Collection([ | 348 collections.security = new Collection([ |
334 { | 349 { |
335 id: "recommend-list-table" | 350 id: "recommend-security-list-table" |
336 } | 351 } |
337 ]); | 352 ]); |
338 collections.langs = new Collection([ | 353 collections.langs = new Collection([ |
339 { | 354 { |
340 id: "blocking-languages-table", | 355 id: "blocking-languages-table", |
341 emptyText: ["options_dialog_language_added_empty"] | 356 emptyText: ["options_language_empty"], |
342 }, | 357 switchSingleEntryControl: true |
Thomas Greiner
2017/08/09 18:14:48
Detail: This property appears to be unused.
saroyanm
2017/08/14 14:00:09
right, will remove.
saroyanm
2017/08/16 14:17:38
Done.
| |
343 { | |
344 id: "blocking-languages-dialog-table", | |
345 emptyText: ["options_dialog_language_added_empty"] | |
346 } | 358 } |
347 ]); | 359 ]); |
348 collections.allLangs = new Collection([ | 360 collections.allLangs = new Collection([ |
349 { | 361 { |
350 id: "all-lang-table", | 362 id: "all-lang-table-add", |
351 emptyText: ["options_dialog_language_other_empty"], | 363 emptyText: ["options_dialog_language_other_empty"] |
352 searchable: true | 364 }, |
353 } | |
354 ]); | |
355 collections.acceptableAds = new Collection([ | |
356 { | 365 { |
357 id: "acceptableads-table" | 366 id: "all-lang-table-change", |
367 emptyText: ["options_dialog_language_other_empty"] | |
358 } | 368 } |
359 ]); | 369 ]); |
360 collections.custom = new Collection([ | 370 collections.custom = new Collection([ |
361 { | 371 { |
362 id: "custom-list-table" | 372 id: "custom-list-table" |
363 } | 373 } |
364 ]); | 374 ]); |
365 collections.whitelist = new Collection([ | 375 collections.whitelist = new Collection([ |
366 { | 376 { |
367 id: "whitelisting-table", | 377 id: "whitelisting-table", |
368 emptyText: ["options_whitelist_empty_1", "options_whitelist_empty_2"] | 378 emptyText: ["options_whitelist_empty_1", "options_whitelist_empty_2"] |
369 } | 379 } |
370 ]); | 380 ]); |
371 collections.filterLists = new Collection([ | 381 collections.filterLists = new Collection([ |
372 { | 382 { |
373 id: "all-filter-lists-table", | 383 id: "all-filter-lists-table", |
374 useOriginalTitle: true | 384 useOriginalTitle: true |
375 } | 385 } |
376 ]); | 386 ]); |
377 | 387 |
378 function toggleShowLanguage(subscription) | 388 function toggleShowRecommendation(subscription) |
379 { | 389 { |
380 if (subscription.recommended == "ads") | 390 if (subscription.recommended == "ads") |
381 { | 391 { |
382 if (subscription.disabled) | 392 if (subscription.disabled) |
383 { | |
384 collections.allLangs.addItem(subscription); | |
385 collections.langs.removeItem(subscription); | 393 collections.langs.removeItem(subscription); |
386 } | |
387 else | 394 else |
388 { | |
389 collections.allLangs.removeItem(subscription); | |
390 collections.langs.addItem(subscription); | 395 collections.langs.addItem(subscription); |
391 } | 396 } |
397 | |
398 if (moreSubscriptions.indexOf(subscription.recommended) >= 0 && | |
Thomas Greiner
2017/08/09 18:14:50
This is the opposite of what the spec says: "All f
saroyanm
2017/08/14 14:00:08
Hmmm, good point.. I'll update this.
saroyanm
2017/08/16 14:17:36
Done.
| |
399 subscription.disabled == false) | |
400 { | |
401 collections.custom.addItem(subscription); | |
402 updateTooltips(); | |
392 } | 403 } |
393 } | 404 } |
394 | 405 |
395 function addSubscription(subscription) | 406 function addSubscription(subscription) |
396 { | 407 { |
397 let collection; | 408 let collection; |
398 if (subscription.recommended) | 409 if (subscription.recommended) |
399 { | 410 { |
400 if (subscription.recommended != "ads") | 411 if (privacySubscriptions.indexOf(subscription.recommended) >= 0) |
Thomas Greiner
2017/08/09 18:14:49
Detail: This naming doesn't make sense. You're put
Thomas Greiner
2017/08/09 18:14:50
Detail: You're only using this variable here and w
saroyanm
2017/08/14 14:00:09
Good point.
saroyanm
2017/08/16 14:17:36
Done.
saroyanm
2017/08/16 14:17:36
Not anymore
| |
401 collection = collections.popular; | 412 collection = collections.security; |
413 else if (subscription.recommended == "ads") | |
414 { | |
415 if (subscription.disabled == false) | |
416 collection = collections.langs; | |
417 else | |
418 collection = collections.allLangs; | |
419 } | |
402 else if (subscription.disabled == false) | 420 else if (subscription.disabled == false) |
403 collection = collections.langs; | 421 { |
422 collection = collections.custom; | |
423 } | |
404 else | 424 else |
405 collection = collections.allLangs; | 425 { |
426 subscriptionsMap[subscription.url] = subscription; | |
427 return; | |
428 } | |
406 } | 429 } |
407 else if (subscription.url == acceptableAdsUrl) | 430 else if (subscription.url == acceptableAdsUrl || |
408 collection = collections.acceptableAds; | 431 subscription.url == acceptableAdsPrivacyUrl) |
432 { | |
433 return; | |
Thomas Greiner
2017/08/09 18:14:50
Doesn't this mean that neither of the Acceptable A
saroyanm
2017/08/14 14:00:09
I think I tried to be consistent with previous imp
Thomas Greiner
2017/08/15 17:10:29
Ok, thanks.
saroyanm
2017/08/16 14:17:37
I did updated the implementation on how subscripti
| |
434 } | |
409 else | 435 else |
410 collection = collections.custom; | 436 collection = collections.custom; |
411 | 437 |
412 collection.addItem(subscription); | 438 collection.addItem(subscription); |
413 subscriptionsMap[subscription.url] = subscription; | 439 subscriptionsMap[subscription.url] = subscription; |
414 toggleShowLanguage(subscription); | 440 toggleShowRecommendation(subscription); |
415 updateTooltips(); | 441 updateTooltips(); |
416 } | 442 } |
417 | 443 |
418 function updateSubscription(subscription) | 444 function updateSubscription(subscription) |
419 { | 445 { |
420 for (let name in collections) | 446 for (let name in collections) |
421 collections[name].updateItem(subscription); | 447 collections[name].updateItem(subscription); |
422 | 448 |
423 toggleShowLanguage(subscription); | 449 toggleShowRecommendation(subscription); |
424 } | 450 } |
425 | 451 |
426 function updateFilter(filter) | 452 function updateFilter(filter) |
427 { | 453 { |
428 let match = filter.text.match(whitelistedDomainRegexp); | 454 let match = filter.text.match(whitelistedDomainRegexp); |
429 if (match && !filtersMap[filter.text]) | 455 if (match && !filtersMap[filter.text]) |
430 { | 456 { |
431 filter.title = match[1]; | 457 filter.title = match[1]; |
432 collections.whitelist.addItem(filter); | 458 collections.whitelist.addItem(filter); |
433 } | 459 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 addEnableSubscription(findParentData(element, "access", false)); | 577 addEnableSubscription(findParentData(element, "access", false)); |
552 break; | 578 break; |
553 case "add-predefined-subscription": { | 579 case "add-predefined-subscription": { |
554 let dialog = E("dialog-content-predefined"); | 580 let dialog = E("dialog-content-predefined"); |
555 let title = dialog.querySelector("h3").textContent; | 581 let title = dialog.querySelector("h3").textContent; |
556 let url = dialog.querySelector(".url").textContent; | 582 let url = dialog.querySelector(".url").textContent; |
557 addEnableSubscription(url, title); | 583 addEnableSubscription(url, title); |
558 closeDialog(); | 584 closeDialog(); |
559 break; | 585 break; |
560 } | 586 } |
587 case "block-all": | |
588 ext.backgroundPage.sendMessage({ | |
589 type: "subscriptions.remove", | |
590 url: acceptableAdsPrivacyUrl | |
591 }); | |
592 ext.backgroundPage.sendMessage({ | |
593 type: "subscriptions.remove", | |
594 url: acceptableAdsUrl | |
595 }); | |
596 setDntNotification(false); | |
Thomas Greiner
2017/08/09 18:14:48
Placing this here may cause inconsistent behavior
saroyanm
2017/08/14 14:00:09
Noted
saroyanm
2017/08/16 14:17:37
Done.
| |
597 break; | |
561 case "cancel-custom-filters": | 598 case "cancel-custom-filters": |
562 setCustomFiltersView("read"); | 599 setCustomFiltersView("read"); |
563 break; | 600 break; |
601 case "change-language-subscription": | |
602 ext.backgroundPage.sendMessage({ | |
603 type: "subscriptions.remove", | |
604 url: subscriptionToChange | |
Thomas Greiner
2017/08/09 18:14:50
This variable seems redundant because you should b
saroyanm
2017/08/14 14:00:09
agree.
saroyanm
2017/08/16 14:17:38
Done.
| |
605 }); | |
606 ext.backgroundPage.sendMessage({ | |
607 type: "subscriptions.add", | |
608 url: findParentData(element, "access", false) | |
609 }); | |
610 break; | |
Thomas Greiner
2017/08/09 18:14:49
What if one of those two actions fails? In theory
saroyanm
2017/08/14 14:00:10
We still have a button for adding subscription, I
Thomas Greiner
2017/08/15 17:10:29
That's fine with me as long as we make sure that t
| |
564 case "close-dialog": | 611 case "close-dialog": |
565 closeDialog(); | 612 closeDialog(); |
566 break; | 613 break; |
567 case "edit-custom-filters": | 614 case "edit-custom-filters": |
568 setCustomFiltersView("write"); | 615 setCustomFiltersView("write"); |
569 break; | 616 break; |
617 case "enable-aa": | |
saroyanm
2017/07/26 20:56:50
Adding acceptableAds multiple times, causes the "A
Thomas Greiner
2017/08/09 18:14:48
Acknowledged.
| |
618 ext.backgroundPage.sendMessage({ | |
619 type: "subscriptions.remove", | |
620 url: acceptableAdsPrivacyUrl | |
621 }); | |
622 ext.backgroundPage.sendMessage({ | |
623 type: "subscriptions.add", | |
624 url: acceptableAdsUrl | |
625 }); | |
626 setDntNotification(false); | |
627 break; | |
628 case "enable-privacy-aa": | |
saroyanm
2017/07/26 20:56:50
The "Acceptable Ads notification" I think will be
Thomas Greiner
2017/08/09 18:14:49
Acknowledged.
| |
629 ext.backgroundPage.sendMessage({ | |
630 type: "subscriptions.remove", | |
631 url: acceptableAdsUrl | |
632 }); | |
633 ext.backgroundPage.sendMessage({ | |
634 type: "subscriptions.add", | |
635 url: acceptableAdsPrivacyUrl | |
636 }); | |
637 break; | |
570 case "import-subscription": { | 638 case "import-subscription": { |
571 let url = E("blockingList-textbox").value; | 639 let url = E("blockingList-textbox").value; |
572 addEnableSubscription(url); | 640 addEnableSubscription(url); |
573 closeDialog(); | 641 closeDialog(); |
574 break; | 642 break; |
575 } | 643 } |
576 case "open-context-menu": { | 644 case "open-context-menu": { |
577 let listItem = findParentData(element, "access", true); | 645 let listItem = findParentData(element, "access", true); |
578 if (listItem && !listItem.classList.contains("show-context-menu")) | 646 if (listItem && !listItem.classList.contains("show-context-menu")) |
579 listItem.classList.add("show-context-menu"); | 647 listItem.classList.add("show-context-menu"); |
(...skipping 14 matching lines...) Expand all Loading... | |
594 type: "filters.remove", | 662 type: "filters.remove", |
595 text: findParentData(element, "access", false) | 663 text: findParentData(element, "access", false) |
596 }); | 664 }); |
597 break; | 665 break; |
598 case "remove-subscription": | 666 case "remove-subscription": |
599 ext.backgroundPage.sendMessage({ | 667 ext.backgroundPage.sendMessage({ |
600 type: "subscriptions.remove", | 668 type: "subscriptions.remove", |
601 url: findParentData(element, "access", false) | 669 url: findParentData(element, "access", false) |
602 }); | 670 }); |
603 break; | 671 break; |
672 case "save-change-subscription": | |
673 subscriptionToChange = findParentData(element, "access", false); | |
674 break; | |
604 case "save-custom-filters": | 675 case "save-custom-filters": |
605 sendMessageHandleErrors({ | 676 sendMessageHandleErrors({ |
606 type: "filters.importRaw", | 677 type: "filters.importRaw", |
607 text: E("custom-filters-raw").value, | 678 text: E("custom-filters-raw").value, |
608 removeExisting: true | 679 removeExisting: true |
609 }, | 680 }, |
610 () => | 681 () => |
611 { | 682 { |
612 setCustomFiltersView("read"); | 683 setCustomFiltersView("read"); |
613 }); | 684 }); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
781 let tabId = tabIds.slice(0, i + 1).join("-"); | 852 let tabId = tabIds.slice(0, i + 1).join("-"); |
782 tabContent = selectTabItem(tabId, tabContent, true); | 853 tabContent = selectTabItem(tabId, tabContent, true); |
783 if (!tabContent) | 854 if (!tabContent) |
784 break; | 855 break; |
785 } | 856 } |
786 } | 857 } |
787 | 858 |
788 function onDOMLoaded() | 859 function onDOMLoaded() |
789 { | 860 { |
790 populateLists(); | 861 populateLists(); |
791 function onFindLanguageKeyUp() | |
792 { | |
793 let searchStyle = E("search-style"); | |
794 if (!this.value) | |
795 searchStyle.innerHTML = ""; | |
796 else | |
797 { | |
798 searchStyle.innerHTML = "#all-lang-table li:not([data-search*=\"" + | |
799 this.value.toLowerCase() + "\"]) { display: none; }"; | |
800 } | |
801 } | |
802 | 862 |
803 // Initialize navigation sidebar | 863 // Initialize navigation sidebar |
804 ext.backgroundPage.sendMessage({ | 864 ext.backgroundPage.sendMessage({ |
805 type: "app.get", | 865 type: "app.get", |
806 what: "addonVersion" | 866 what: "addonVersion" |
807 }, | 867 }, |
808 (addonVersion) => | 868 (addonVersion) => |
809 { | 869 { |
810 E("abp-version").textContent = addonVersion; | 870 E("abp-version").textContent = addonVersion; |
811 }); | 871 }); |
812 getDocLink("releases", (link) => | 872 getDocLink("releases", (link) => |
813 { | 873 { |
814 E("link-version").setAttribute("href", link); | 874 E("link-version").setAttribute("href", link); |
815 }); | 875 }); |
816 | 876 |
817 updateShareLink(); | 877 updateShareLink(); |
818 updateTooltips(); | 878 updateTooltips(); |
819 | 879 |
820 // Initialize interactive UI elements | 880 // Initialize interactive UI elements |
821 document.body.addEventListener("click", onClick, false); | 881 document.body.addEventListener("click", onClick, false); |
822 document.body.addEventListener("keyup", onKeyUp, false); | 882 document.body.addEventListener("keyup", onKeyUp, false); |
823 let placeholderValue = getMessage("options_dialog_language_find"); | |
824 E("find-language").setAttribute("placeholder", placeholderValue); | |
825 E("find-language").addEventListener("keyup", onFindLanguageKeyUp, false); | |
826 let exampleValue = getMessage("options_whitelist_placeholder_example", | 883 let exampleValue = getMessage("options_whitelist_placeholder_example", |
827 ["www.example.com"]); | 884 ["www.example.com"]); |
828 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); | 885 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); |
829 E("whitelisting-textbox").addEventListener("keyup", (e) => | 886 E("whitelisting-textbox").addEventListener("keyup", (e) => |
830 { | 887 { |
831 E("whitelisting-add-button").disabled = !e.target.value; | 888 E("whitelisting-add-button").disabled = !e.target.value; |
832 }, false); | 889 }, false); |
833 | 890 |
891 getDocLink("acceptable_ads_criteria", (link) => | |
892 { | |
893 setLinks("enable-aa-description", link); | |
894 }); | |
895 | |
834 // Advanced tab | 896 // Advanced tab |
835 let customize = document.querySelectorAll("#customize li[data-pref]"); | 897 let customize = document.querySelectorAll("#customize li[data-pref]"); |
836 customize = Array.prototype.map.call(customize, (checkbox) => | 898 customize = Array.prototype.map.call(customize, (checkbox) => |
837 { | 899 { |
838 return checkbox.getAttribute("data-pref"); | 900 return checkbox.getAttribute("data-pref"); |
839 }); | 901 }); |
840 for (let key of customize) | 902 for (let key of customize) |
841 { | 903 { |
842 getPref(key, (value) => | 904 getPref(key, (value) => |
843 { | 905 { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
962 | 1024 |
963 function closeDialog() | 1025 function closeDialog() |
964 { | 1026 { |
965 let dialog = E("dialog"); | 1027 let dialog = E("dialog"); |
966 dialog.setAttribute("aria-hidden", true); | 1028 dialog.setAttribute("aria-hidden", true); |
967 dialog.removeAttribute("aria-labelledby"); | 1029 dialog.removeAttribute("aria-labelledby"); |
968 document.body.removeAttribute("data-dialog"); | 1030 document.body.removeAttribute("data-dialog"); |
969 focusedBeforeDialog.focus(); | 1031 focusedBeforeDialog.focus(); |
970 } | 1032 } |
971 | 1033 |
1034 function setDntNotification(state) | |
1035 { | |
1036 if (state) | |
1037 E("acceptable-ads").classList.add("show-dnt-notification"); | |
1038 else | |
1039 E("acceptable-ads").classList.remove("show-dnt-notification"); | |
1040 } | |
1041 | |
972 function populateLists() | 1042 function populateLists() |
973 { | 1043 { |
974 subscriptionsMap = Object.create(null); | 1044 subscriptionsMap = Object.create(null); |
975 filtersMap = Object.create(null); | 1045 filtersMap = Object.create(null); |
976 | 1046 |
977 // Empty collections and lists | 1047 // Empty collections and lists |
978 for (let property in collections) | 1048 for (let property in collections) |
979 collections[property].clearAll(); | 1049 collections[property].clearAll(); |
980 | 1050 |
981 ext.backgroundPage.sendMessage({ | 1051 ext.backgroundPage.sendMessage({ |
(...skipping 25 matching lines...) Expand all Loading... | |
1007 key: "subscriptions_exceptionsurl" | 1077 key: "subscriptions_exceptionsurl" |
1008 }, | 1078 }, |
1009 (url) => | 1079 (url) => |
1010 { | 1080 { |
1011 acceptableAdsUrl = url; | 1081 acceptableAdsUrl = url; |
1012 addSubscription({ | 1082 addSubscription({ |
1013 url: acceptableAdsUrl, | 1083 url: acceptableAdsUrl, |
1014 disabled: true | 1084 disabled: true |
1015 }); | 1085 }); |
1016 | 1086 |
1017 // Load user subscriptions | |
1018 ext.backgroundPage.sendMessage({ | 1087 ext.backgroundPage.sendMessage({ |
1019 type: "subscriptions.get", | 1088 type: "prefs.get", |
1020 downloadable: true | 1089 key: "subscriptions_exceptionsurl_privacy" |
1021 }, | 1090 }, |
1022 (subscriptions) => | 1091 (urlPrivacy) => |
1023 { | 1092 { |
1024 for (let subscription of subscriptions) | 1093 acceptableAdsPrivacyUrl = urlPrivacy; |
1025 onSubscriptionMessage("added", subscription); | 1094 addSubscription({ |
Thomas Greiner
2017/08/09 18:14:50
This looks odd. The subscription is not installed
saroyanm
2017/08/14 14:00:10
Agree it's odd :)
Will fix.
saroyanm
2017/08/16 14:17:37
Done.
| |
1095 url: acceptableAdsPrivacyUrl, | |
1096 disabled: true | |
1097 }); | |
1098 | |
1099 // Load user subscriptions | |
Thomas Greiner
2017/08/09 18:14:49
This code doesn't depend on the value of `urlPriva
saroyanm
2017/08/14 14:00:09
There are checks involved dependant on acceptableA
Thomas Greiner
2017/08/15 17:10:29
Which checks in particular are you referring to?
saroyanm
2017/08/16 14:17:37
To checks in "onSubscriptionMessage", we do same f
Thomas Greiner
2017/08/16 17:57:08
Ok, makes sense.
| |
1100 ext.backgroundPage.sendMessage({ | |
1101 type: "subscriptions.get", | |
1102 downloadable: true | |
1103 }, | |
1104 (subscriptions) => | |
1105 { | |
1106 for (let subscription of subscriptions) | |
1107 onSubscriptionMessage("added", subscription); | |
1108 }); | |
1026 }); | 1109 }); |
1027 }); | 1110 }); |
1028 } | 1111 } |
1029 | 1112 |
1030 function addWhitelistedDomain() | 1113 function addWhitelistedDomain() |
1031 { | 1114 { |
1032 let domain = E("whitelisting-textbox"); | 1115 let domain = E("whitelisting-textbox"); |
1033 for (let whitelistItem of collections.whitelist.items) | 1116 for (let whitelistItem of collections.whitelist.items) |
1034 { | 1117 { |
1035 if (whitelistItem.title == domain.value) | 1118 if (whitelistItem.title == domain.value) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1123 case "lastDownload": | 1206 case "lastDownload": |
1124 case "title": | 1207 case "title": |
1125 updateSubscription(subscription); | 1208 updateSubscription(subscription); |
1126 break; | 1209 break; |
1127 case "added": | 1210 case "added": |
1128 if (subscription.url in subscriptionsMap) | 1211 if (subscription.url in subscriptionsMap) |
1129 updateSubscription(subscription); | 1212 updateSubscription(subscription); |
1130 else | 1213 else |
1131 addSubscription(subscription); | 1214 addSubscription(subscription); |
1132 | 1215 |
1216 if (subscription.url == acceptableAdsUrl) | |
1217 document.querySelector( | |
1218 "[name='acceptable-ads'][value='tracking']").checked = true; | |
Thomas Greiner
2017/08/09 18:14:49
I noticed that you're only changing the value of `
Thomas Greiner
2017/08/09 18:14:49
Coding Style: "When an if statement, an else state
saroyanm
2017/08/14 14:00:10
Agree.
saroyanm
2017/08/16 14:17:37
Done.
| |
1219 if (subscription.url == acceptableAdsPrivacyUrl) | |
Thomas Greiner
2017/08/09 18:14:48
Detail: This condition will never be `true` if the
saroyanm
2017/08/14 14:00:10
agree.
Thomas Greiner
2017/08/16 17:57:08
Maybe I'm missing something but I can't find the c
| |
1220 { | |
1221 document.querySelector( | |
1222 "[name='acceptable-ads'][value='no-tracking']").checked = true; | |
1223 if (!navigator.doNotTrack) | |
saroyanm
2017/07/26 20:56:50
I couldn't find way to listen for "do not track" c
Thomas Greiner
2017/08/09 18:14:49
Users need to move away from the options page to c
saroyanm
2017/08/14 14:00:10
This is a good idea, but I think would be better t
Thomas Greiner
2017/08/15 17:10:30
Ok, sounds good.
| |
1224 setDntNotification(true); | |
1225 } | |
1226 | |
1133 collections.filterLists.addItem(subscription); | 1227 collections.filterLists.addItem(subscription); |
1134 break; | 1228 break; |
1135 case "removed": | 1229 case "removed": |
1136 if (subscription.url == acceptableAdsUrl || subscription.recommended) | 1230 if (subscription.url == acceptableAdsUrl || |
1231 subscription.url == acceptableAdsPrivacyUrl || | |
1232 subscription.recommended && | |
1233 moreSubscriptions.indexOf(subscription.recommended) == -1) | |
1137 { | 1234 { |
1138 subscription.disabled = true; | 1235 subscription.disabled = true; |
1139 onSubscriptionMessage("disabled", subscription); | 1236 onSubscriptionMessage("disabled", subscription); |
1140 } | 1237 } |
1141 else | 1238 else |
1142 { | 1239 { |
1143 collections.custom.removeItem(subscription); | 1240 collections.custom.removeItem(subscription); |
1144 delete subscriptionsMap[subscription.url]; | 1241 delete subscriptionsMap[subscription.url]; |
1145 } | 1242 } |
1146 collections.filterLists.removeItem(subscription); | 1243 collections.filterLists.removeItem(subscription); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1266 if (anchor.hasAttribute("data-tooltip-native")) | 1363 if (anchor.hasAttribute("data-tooltip-native")) |
1267 { | 1364 { |
1268 let title = topTexts.concat(bottomTexts).join("\n\n"); | 1365 let title = topTexts.concat(bottomTexts).join("\n\n"); |
1269 anchor.setAttribute("title", title); | 1366 anchor.setAttribute("title", title); |
1270 continue; | 1367 continue; |
1271 } | 1368 } |
1272 | 1369 |
1273 let tooltip = document.createElement("div"); | 1370 let tooltip = document.createElement("div"); |
1274 tooltip.setAttribute("role", "tooltip"); | 1371 tooltip.setAttribute("role", "tooltip"); |
1275 | 1372 |
1276 let flip = anchor.getAttribute("data-tooltip-flip"); | |
1277 if (flip) | |
1278 tooltip.className = "flip-" + flip; | |
Thomas Greiner
2017/08/09 18:14:48
How are you planning to handle tooltip orientation
saroyanm
2017/08/14 14:00:09
Not yet, sure, but I think it make sense to re-imp
| |
1279 | |
1280 let imageSource = anchor.getAttribute("data-tooltip-image"); | 1373 let imageSource = anchor.getAttribute("data-tooltip-image"); |
1281 if (imageSource) | 1374 if (imageSource) |
1282 { | 1375 { |
1283 let image = document.createElement("img"); | 1376 let image = document.createElement("img"); |
1284 image.src = imageSource; | 1377 image.src = imageSource; |
1285 image.alt = ""; | 1378 image.alt = ""; |
1286 tooltip.appendChild(image); | 1379 tooltip.appendChild(image); |
1287 } | 1380 } |
1288 | 1381 |
1289 for (let topText of topTexts) | 1382 for (let topText of topTexts) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1355 }); | 1448 }); |
1356 ext.backgroundPage.sendMessage({ | 1449 ext.backgroundPage.sendMessage({ |
1357 type: "subscriptions.listen", | 1450 type: "subscriptions.listen", |
1358 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1451 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1359 "title", "downloadStatus", "downloading"] | 1452 "title", "downloadStatus", "downloading"] |
1360 }); | 1453 }); |
1361 | 1454 |
1362 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1455 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1363 window.addEventListener("hashchange", onHashChange, false); | 1456 window.addEventListener("hashchange", onHashChange, false); |
1364 } | 1457 } |
OLD | NEW |