| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 const minuteInMs = 60000; | 45 const minuteInMs = 60000; |
| 46 const hourInMs = 3600000; | 46 const hourInMs = 3600000; |
| 47 const fullDayInMs = 86400000; | 47 const fullDayInMs = 86400000; |
| 48 | 48 |
| 49 function Collection(details) | 49 function Collection(details) |
| 50 { | 50 { |
| 51 this.details = details; | 51 this.details = details; |
| 52 this.items = []; | 52 this.items = []; |
| 53 } | 53 } |
| 54 | 54 |
| 55 Collection.prototype._setEmpty = function(table, detail, removeEmpty) | 55 Collection.prototype._setEmpty = function(table, detail, removeEmpty) |
|
ire
2017/09/26 08:37:55
NIT: This function and the nested if statements ar
saroyanm
2017/09/26 16:35:25
Absolutely, my bad, now should be more readable I
| |
| 56 { | 56 { |
| 57 if (removeEmpty) | 57 if (removeEmpty) |
| 58 { | 58 { |
| 59 let placeholders = table.querySelectorAll(".empty-placeholder"); | 59 let placeholders = table.querySelectorAll(".empty-placeholder"); |
| 60 if (placeholders.length > 0) | 60 for (let placeholder of placeholders) |
| 61 { | 61 table.removeChild(placeholder); |
| 62 for (let placeholder of placeholders) | 62 |
| 63 table.removeChild(placeholder); | 63 execAction(detail.removeEmptyAction, table); |
| 64 } | |
| 65 | |
| 66 if (detail.removeEmptyAction) | |
| 67 execAction(detail.removeEmptyAction, table); | |
| 68 } | 64 } |
| 69 else | 65 else |
| 70 { | 66 { |
| 71 if (detail.emptyText) | 67 let {emptyTexts = []} = detail; |
| 72 { | 68 for (let text of emptyTexts) |
| 73 for (let text of detail.emptyText) | 69 { |
| 74 { | 70 let placeholder = document.createElement("li"); |
| 75 let placeholder = document.createElement("li"); | 71 placeholder.className = "empty-placeholder"; |
| 76 placeholder.className = "empty-placeholder"; | 72 placeholder.textContent = getMessage(text); |
| 77 placeholder.textContent = getMessage(text); | 73 table.appendChild(placeholder); |
| 78 table.appendChild(placeholder); | 74 } |
| 79 } | 75 |
| 80 } | 76 execAction(detail.setEmptyAction, table); |
| 81 | |
| 82 if (detail.setEmptyAction) | |
| 83 execAction(detail.setEmptyAction, table); | |
| 84 } | 77 } |
| 85 }; | 78 }; |
| 86 | 79 |
| 87 Collection.prototype._createElementQuery = function(item) | 80 Collection.prototype._createElementQuery = function(item) |
| 88 { | 81 { |
| 89 let access = (item.url || item.text).replace(/'/g, "\\'"); | 82 let access = (item.url || item.text).replace(/'/g, "\\'"); |
| 90 return function(container) | 83 return function(container) |
| 91 { | 84 { |
| 92 return container.querySelector("[data-access='" + access + "']"); | 85 return container.querySelector("[data-access='" + access + "']"); |
| 93 }; | 86 }; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 } | 340 } |
| 348 | 341 |
| 349 collections.protection = new Collection([ | 342 collections.protection = new Collection([ |
| 350 { | 343 { |
| 351 id: "recommend-protection-list-table" | 344 id: "recommend-protection-list-table" |
| 352 } | 345 } |
| 353 ]); | 346 ]); |
| 354 collections.langs = new Collection([ | 347 collections.langs = new Collection([ |
| 355 { | 348 { |
| 356 id: "blocking-languages-table", | 349 id: "blocking-languages-table", |
| 357 emptyText: ["options_language_empty"] | 350 emptyTexts: ["options_language_empty"] |
| 358 } | 351 } |
| 359 ]); | 352 ]); |
| 360 collections.allLangs = new Collection([ | 353 collections.allLangs = new Collection([ |
| 361 { | 354 { |
| 362 id: "all-lang-table-add", | 355 id: "all-lang-table-add", |
| 363 emptyText: ["options_dialog_language_other_empty"] | 356 emptyTexts: ["options_dialog_language_other_empty"] |
| 364 } | 357 } |
| 365 ]); | 358 ]); |
| 366 collections.more = new Collection([ | 359 collections.more = new Collection([ |
| 367 { | 360 { |
| 368 id: "more-list-table", | 361 id: "more-list-table", |
| 369 setEmptyAction: "hide-more-section", | 362 setEmptyAction: "hide-more-filters-section", |
| 370 removeEmptyAction: "show-more-section" | 363 removeEmptyAction: "show-more-filters-section" |
|
ire
2017/09/26 08:37:55
NIT: Calling it "hide-more-section" seems to gener
saroyanm
2017/09/26 16:35:25
I agree with you, done.
| |
| 371 } | 364 } |
| 372 ]); | 365 ]); |
| 373 collections.whitelist = new Collection([ | 366 collections.whitelist = new Collection([ |
| 374 { | 367 { |
| 375 id: "whitelisting-table", | 368 id: "whitelisting-table", |
| 376 emptyText: ["options_whitelist_empty_1", "options_whitelist_empty_2"] | 369 emptyTexts: ["options_whitelist_empty_1", "options_whitelist_empty_2"] |
| 377 } | 370 } |
| 378 ]); | 371 ]); |
| 379 collections.filterLists = new Collection([ | 372 collections.filterLists = new Collection([ |
| 380 { | 373 { |
| 381 id: "all-filter-lists-table", | 374 id: "all-filter-lists-table", |
| 382 useOriginalTitle: true | 375 useOriginalTitle: true |
| 383 } | 376 } |
| 384 ]); | 377 ]); |
| 385 | 378 |
| 386 function addSubscription(subscription) | 379 function addSubscription(subscription) |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 589 break; | 582 break; |
| 590 } | 583 } |
| 591 } | 584 } |
| 592 break; | 585 break; |
| 593 case "close-dialog": | 586 case "close-dialog": |
| 594 closeDialog(); | 587 closeDialog(); |
| 595 break; | 588 break; |
| 596 case "edit-custom-filters": | 589 case "edit-custom-filters": |
| 597 setCustomFiltersView("write"); | 590 setCustomFiltersView("write"); |
| 598 break; | 591 break; |
| 599 case "hide-more-section": | 592 case "hide-more-filters-section": |
| 600 E("more-filters").setAttribute("aria-hidden", true); | 593 E("more-filters").setAttribute("aria-hidden", true); |
| 601 break; | 594 break; |
| 602 case "hide-notification": | 595 case "hide-notification": |
| 603 hideNotification(); | 596 hideNotification(); |
| 604 break; | 597 break; |
| 605 case "import-subscription": { | 598 case "import-subscription": { |
| 606 let url = E("blockingList-textbox").value; | 599 let url = E("blockingList-textbox").value; |
| 607 addEnableSubscription(url); | 600 addEnableSubscription(url); |
| 608 closeDialog(); | 601 closeDialog(); |
| 609 break; | 602 break; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 635 sendMessageHandleErrors({ | 628 sendMessageHandleErrors({ |
| 636 type: "filters.importRaw", | 629 type: "filters.importRaw", |
| 637 text: E("custom-filters-raw").value, | 630 text: E("custom-filters-raw").value, |
| 638 removeExisting: true | 631 removeExisting: true |
| 639 }, | 632 }, |
| 640 () => | 633 () => |
| 641 { | 634 { |
| 642 setCustomFiltersView("read"); | 635 setCustomFiltersView("read"); |
| 643 }); | 636 }); |
| 644 break; | 637 break; |
| 645 case "show-more-section": | 638 case "show-more-filters-section": |
| 646 E("more-filters").setAttribute("aria-hidden", false); | 639 E("more-filters").setAttribute("aria-hidden", false); |
| 647 break; | 640 break; |
| 648 case "switch-acceptable-ads": | 641 case "switch-acceptable-ads": |
| 649 let value = element.value || element.dataset.value; | 642 let value = element.value || element.dataset.value; |
| 650 ext.backgroundPage.sendMessage({ | 643 ext.backgroundPage.sendMessage({ |
| 651 type: value == "privacy" ? "subscriptions.add" : | 644 type: value == "privacy" ? "subscriptions.add" : |
| 652 "subscriptions.remove", | 645 "subscriptions.remove", |
| 653 url: acceptableAdsPrivacyUrl | 646 url: acceptableAdsPrivacyUrl |
| 654 }); | 647 }); |
| 655 ext.backgroundPage.sendMessage({ | 648 ext.backgroundPage.sendMessage({ |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 }, false); | 870 }, false); |
| 878 | 871 |
| 879 getDocLink("contribute", (link) => | 872 getDocLink("contribute", (link) => |
| 880 { | 873 { |
| 881 E("contribute").href = link; | 874 E("contribute").href = link; |
| 882 }); | 875 }); |
| 883 getDocLink("acceptable_ads_criteria", (link) => | 876 getDocLink("acceptable_ads_criteria", (link) => |
| 884 { | 877 { |
| 885 setLinks("enable-aa-description", link); | 878 setLinks("enable-aa-description", link); |
| 886 }); | 879 }); |
| 880 getDocLink("adblock_plus_{browser}_dnt", url => | |
| 881 { | |
| 882 setLinks("dnt", url); | |
| 883 }); | |
| 887 | 884 |
| 888 // Advanced tab | 885 // Advanced tab |
| 889 let customize = document.querySelectorAll("#customize li[data-pref]"); | 886 let customize = document.querySelectorAll("#customize li[data-pref]"); |
| 890 customize = Array.prototype.map.call(customize, (checkbox) => | 887 customize = Array.prototype.map.call(customize, (checkbox) => |
| 891 { | 888 { |
| 892 return checkbox.getAttribute("data-pref"); | 889 return checkbox.getAttribute("data-pref"); |
| 893 }); | 890 }); |
| 894 for (let key of customize) | 891 for (let key of customize) |
| 895 { | 892 { |
| 896 getPref(key, (value) => | 893 getPref(key, (value) => |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 926 setLinks("report-issue", link); | 923 setLinks("report-issue", link); |
| 927 }); | 924 }); |
| 928 getDocLink("adblock_plus_report_ad", (link) => | 925 getDocLink("adblock_plus_report_ad", (link) => |
| 929 { | 926 { |
| 930 setLinks("report-ad", link); | 927 setLinks("report-ad", link); |
| 931 }); | 928 }); |
| 932 getDocLink("adblock_plus_report_bug", (link) => | 929 getDocLink("adblock_plus_report_bug", (link) => |
| 933 { | 930 { |
| 934 setLinks("report-bug", link); | 931 setLinks("report-bug", link); |
| 935 }); | 932 }); |
| 936 getDocLink("reporter_other_link", (link) => | 933 getDocLink("{browser}_support", url => |
| 937 { | 934 { |
| 938 setLinks("report-forum", link); | 935 setLinks("visit-forum", url); |
| 939 }); | 936 }); |
| 940 getDocLink("social_twitter", (link) => | 937 getDocLink("social_twitter", (link) => |
| 941 { | 938 { |
| 942 E("twitter").setAttribute("href", link); | 939 E("twitter").setAttribute("href", link); |
| 943 }); | 940 }); |
| 944 getDocLink("social_facebook", (link) => | 941 getDocLink("social_facebook", (link) => |
| 945 { | 942 { |
| 946 E("facebook").setAttribute("href", link); | 943 E("facebook").setAttribute("href", link); |
| 947 }); | 944 }); |
| 948 getDocLink("social_gplus", (link) => | 945 getDocLink("social_gplus", (link) => |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1396 }); | 1393 }); |
| 1397 ext.backgroundPage.sendMessage({ | 1394 ext.backgroundPage.sendMessage({ |
| 1398 type: "subscriptions.listen", | 1395 type: "subscriptions.listen", |
| 1399 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1396 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1400 "title", "downloadStatus", "downloading"] | 1397 "title", "downloadStatus", "downloading"] |
| 1401 }); | 1398 }); |
| 1402 | 1399 |
| 1403 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1400 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1404 window.addEventListener("hashchange", onHashChange, false); | 1401 window.addEventListener("hashchange", onHashChange, false); |
| 1405 } | 1402 } |
| LEFT | RIGHT |