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 |
(...skipping 26 matching lines...) Expand all Loading... |
37 ["synchronize_checksum_mismatch", | 37 ["synchronize_checksum_mismatch", |
38 "options_filterList_lastDownload_checksumMismatch"] | 38 "options_filterList_lastDownload_checksumMismatch"] |
39 ]); | 39 ]); |
40 | 40 |
41 function Collection(details) | 41 function Collection(details) |
42 { | 42 { |
43 this.details = details; | 43 this.details = details; |
44 this.items = []; | 44 this.items = []; |
45 } | 45 } |
46 | 46 |
47 Collection.prototype._setEmpty = function(table, text) | 47 Collection.prototype._setEmpty = function(table, texts) |
48 { | 48 { |
49 let placeholder = table.querySelector(".empty-placeholder"); | 49 let placeholders = table.querySelectorAll(".empty-placeholder"); |
50 if (text && !placeholder) | 50 |
| 51 if (texts && placeholders.length == 0) |
51 { | 52 { |
52 placeholder = document.createElement("li"); | 53 for (let text of texts) |
53 placeholder.className = "empty-placeholder"; | 54 { |
54 placeholder.textContent = getMessage(text); | 55 let placeholder = document.createElement("li"); |
55 table.appendChild(placeholder); | 56 placeholder.className = "empty-placeholder"; |
| 57 placeholder.textContent = getMessage(text); |
| 58 table.appendChild(placeholder); |
| 59 } |
56 } | 60 } |
57 else if (placeholder) | 61 else if (placeholders.length > 0) |
58 table.removeChild(placeholder); | 62 { |
| 63 for (let placeholder of placeholders) |
| 64 table.removeChild(placeholder); |
| 65 } |
59 }; | 66 }; |
60 | 67 |
61 Collection.prototype._createElementQuery = function(item) | 68 Collection.prototype._createElementQuery = function(item) |
62 { | 69 { |
63 let access = (item.url || item.text).replace(/'/g, "\\'"); | 70 let access = (item.url || item.text).replace(/'/g, "\\'"); |
64 return function(container) | 71 return function(container) |
65 { | 72 { |
66 return container.querySelector("[data-access='" + access + "']"); | 73 return container.querySelector("[data-access='" + access + "']"); |
67 }; | 74 }; |
68 }; | 75 }; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 285 } |
279 | 286 |
280 collections.popular = new Collection([ | 287 collections.popular = new Collection([ |
281 { | 288 { |
282 id: "recommend-list-table" | 289 id: "recommend-list-table" |
283 } | 290 } |
284 ]); | 291 ]); |
285 collections.langs = new Collection([ | 292 collections.langs = new Collection([ |
286 { | 293 { |
287 id: "blocking-languages-table", | 294 id: "blocking-languages-table", |
288 emptyText: "options_dialog_language_added_empty" | 295 emptyText: ["options_dialog_language_added_empty"] |
289 }, | 296 }, |
290 { | 297 { |
291 id: "blocking-languages-dialog-table", | 298 id: "blocking-languages-dialog-table", |
292 emptyText: "options_dialog_language_added_empty" | 299 emptyText: ["options_dialog_language_added_empty"] |
293 } | 300 } |
294 ]); | 301 ]); |
295 collections.allLangs = new Collection([ | 302 collections.allLangs = new Collection([ |
296 { | 303 { |
297 id: "all-lang-table", | 304 id: "all-lang-table", |
298 emptyText: "options_dialog_language_other_empty", | 305 emptyText: ["options_dialog_language_other_empty"], |
299 searchable: true | 306 searchable: true |
300 } | 307 } |
301 ]); | 308 ]); |
302 collections.acceptableAds = new Collection([ | 309 collections.acceptableAds = new Collection([ |
303 { | 310 { |
304 id: "acceptableads-table" | 311 id: "acceptableads-table" |
305 } | 312 } |
306 ]); | 313 ]); |
307 collections.custom = new Collection([ | 314 collections.custom = new Collection([ |
308 { | 315 { |
309 id: "custom-list-table" | 316 id: "custom-list-table" |
310 } | 317 } |
311 ]); | 318 ]); |
312 collections.whitelist = new Collection([ | 319 collections.whitelist = new Collection([ |
313 { | 320 { |
314 id: "whitelisting-table", | 321 id: "whitelisting-table", |
315 emptyText: "options_whitelisted_empty" | 322 emptyText: ["options_whitelist_empty_1", "options_whitelist_empty_2"] |
316 } | 323 } |
317 ]); | 324 ]); |
318 collections.customFilters = new Collection([ | 325 collections.customFilters = new Collection([ |
319 { | 326 { |
320 id: "custom-filters-table", | 327 id: "custom-filters-table", |
321 emptyText: "options_customFilters_empty" | 328 emptyText: ["options_customFilters_empty"] |
322 } | 329 } |
323 ]); | 330 ]); |
324 collections.filterLists = new Collection([ | 331 collections.filterLists = new Collection([ |
325 { | 332 { |
326 id: "all-filter-lists-table", | 333 id: "all-filter-lists-table", |
327 useOriginalTitle: true | 334 useOriginalTitle: true |
328 } | 335 } |
329 ]); | 336 ]); |
330 | 337 |
331 function toggleShowLanguage(subscription) | 338 function toggleShowLanguage(subscription) |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 let dialog = E("dialog-content-predefined"); | 495 let dialog = E("dialog-content-predefined"); |
489 let title = dialog.querySelector("h3").textContent; | 496 let title = dialog.querySelector("h3").textContent; |
490 let url = dialog.querySelector(".url").textContent; | 497 let url = dialog.querySelector(".url").textContent; |
491 addEnableSubscription(url, title); | 498 addEnableSubscription(url, title); |
492 closeDialog(); | 499 closeDialog(); |
493 break; | 500 break; |
494 } | 501 } |
495 case "cancel-custom-filters": | 502 case "cancel-custom-filters": |
496 E("custom-filters").classList.remove("mode-edit"); | 503 E("custom-filters").classList.remove("mode-edit"); |
497 break; | 504 break; |
498 case "cancel-domain-exception": | |
499 E("whitelisting-textbox").value = ""; | |
500 document.querySelector("#whitelisting .controls").classList | |
501 .remove("mode-edit"); | |
502 break; | |
503 case "close-dialog": | 505 case "close-dialog": |
504 closeDialog(); | 506 closeDialog(); |
505 break; | 507 break; |
506 case "edit-custom-filters": | 508 case "edit-custom-filters": |
507 editCustomFilters(); | 509 editCustomFilters(); |
508 break; | 510 break; |
509 case "edit-domain-exception": | |
510 document.querySelector("#whitelisting .controls").classList | |
511 .add("mode-edit"); | |
512 E("whitelisting-textbox").focus(); | |
513 break; | |
514 case "import-subscription": { | 511 case "import-subscription": { |
515 let url = E("blockingList-textbox").value; | 512 let url = E("blockingList-textbox").value; |
516 addEnableSubscription(url); | 513 addEnableSubscription(url); |
517 closeDialog(); | 514 closeDialog(); |
518 break; | 515 break; |
519 } | 516 } |
520 case "open-context-menu": { | 517 case "open-context-menu": { |
521 let listItem = findParentData(element, "access", true); | 518 let listItem = findParentData(element, "access", true); |
522 if (listItem && !listItem.classList.contains("show-context-menu")) | 519 if (listItem && !listItem.classList.contains("show-context-menu")) |
523 listItem.classList.add("show-context-menu"); | 520 listItem.classList.add("show-context-menu"); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 | 740 |
744 updateShareLink(); | 741 updateShareLink(); |
745 updateTooltips(); | 742 updateTooltips(); |
746 | 743 |
747 // Initialize interactive UI elements | 744 // Initialize interactive UI elements |
748 document.body.addEventListener("click", onClick, false); | 745 document.body.addEventListener("click", onClick, false); |
749 document.body.addEventListener("keyup", onKeyUp, false); | 746 document.body.addEventListener("keyup", onKeyUp, false); |
750 let placeholderValue = getMessage("options_dialog_language_find"); | 747 let placeholderValue = getMessage("options_dialog_language_find"); |
751 E("find-language").setAttribute("placeholder", placeholderValue); | 748 E("find-language").setAttribute("placeholder", placeholderValue); |
752 E("find-language").addEventListener("keyup", onFindLanguageKeyUp, false); | 749 E("find-language").addEventListener("keyup", onFindLanguageKeyUp, false); |
753 E("whitelisting-textbox").addEventListener("keypress", (e) => | 750 let exampleValue = getMessage("options_whitelist_placeholder_example"); |
| 751 E("whitelisting-textbox").setAttribute("placeholder", exampleValue); |
| 752 E("whitelisting-textbox").addEventListener("keyup", (e) => |
754 { | 753 { |
| 754 let addWhitelistButton = E("whitelisting-add-button"); |
| 755 addWhitelistButton.disabled = false; |
755 if (getKey(e) == "Enter") | 756 if (getKey(e) == "Enter") |
756 addWhitelistedDomain(); | 757 { |
| 758 if (!addWhitelistButton.disabled) |
| 759 addWhitelistedDomain(); |
| 760 } |
| 761 else |
| 762 { |
| 763 for (let whitelistItem of collections.whitelist.items) |
| 764 { |
| 765 if (!e.target.value) |
| 766 { |
| 767 addWhitelistButton.disabled = true; |
| 768 } |
| 769 if (whitelistItem.title == e.target.value) |
| 770 { |
| 771 addWhitelistButton.disabled = true; |
| 772 E("whitelisting-validation").textContent = |
| 773 getMessage("options_whitelist_duplicate"); |
| 774 } |
| 775 } |
| 776 } |
757 }, false); | 777 }, false); |
758 | 778 |
759 // Advanced tab | 779 // Advanced tab |
760 let tweaks = document.querySelectorAll("#tweaks li[data-pref]"); | 780 let tweaks = document.querySelectorAll("#tweaks li[data-pref]"); |
761 tweaks = Array.prototype.map.call(tweaks, (checkbox) => | 781 tweaks = Array.prototype.map.call(tweaks, (checkbox) => |
762 { | 782 { |
763 return checkbox.getAttribute("data-pref"); | 783 return checkbox.getAttribute("data-pref"); |
764 }); | 784 }); |
765 for (let key of tweaks) | 785 for (let key of tweaks) |
766 { | 786 { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 let domain = E("whitelisting-textbox"); | 984 let domain = E("whitelisting-textbox"); |
965 if (domain.value) | 985 if (domain.value) |
966 { | 986 { |
967 sendMessageHandleErrors({ | 987 sendMessageHandleErrors({ |
968 type: "filters.add", | 988 type: "filters.add", |
969 text: "@@||" + domain.value.toLowerCase() + "^$document" | 989 text: "@@||" + domain.value.toLowerCase() + "^$document" |
970 }); | 990 }); |
971 } | 991 } |
972 | 992 |
973 domain.value = ""; | 993 domain.value = ""; |
974 document.querySelector("#whitelisting .controls") | 994 E("whitelisting-add-button").disabled = true; |
975 .classList.remove("mode-edit"); | |
976 } | 995 } |
977 | 996 |
978 function editCustomFilters() | 997 function editCustomFilters() |
979 { | 998 { |
980 if (!isCustomFiltersLoaded) | 999 if (!isCustomFiltersLoaded) |
981 { | 1000 { |
982 console.error("Custom filters are not loaded"); | 1001 console.error("Custom filters are not loaded"); |
983 return; | 1002 return; |
984 } | 1003 } |
985 | 1004 |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 }); | 1308 }); |
1290 ext.backgroundPage.sendMessage({ | 1309 ext.backgroundPage.sendMessage({ |
1291 type: "subscriptions.listen", | 1310 type: "subscriptions.listen", |
1292 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1311 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1293 "title", "downloadStatus", "downloading"] | 1312 "title", "downloadStatus", "downloading"] |
1294 }); | 1313 }); |
1295 | 1314 |
1296 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1315 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1297 window.addEventListener("hashchange", onHashChange, false); | 1316 window.addEventListener("hashchange", onHashChange, false); |
1298 } | 1317 } |
OLD | NEW |