| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 { | 82 { |
| 83 let access = (item.url || item.text).replace(/'/g, "\\'"); | 83 let access = (item.url || item.text).replace(/'/g, "\\'"); |
| 84 return function(container) | 84 return function(container) |
| 85 { | 85 { |
| 86 return container.querySelector("[data-access='" + access + "']"); | 86 return container.querySelector("[data-access='" + access + "']"); |
| 87 }; | 87 }; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 Collection.prototype._getItemTitle = function(item, i) | 90 Collection.prototype._getItemTitle = function(item, i) |
| 91 { | 91 { |
| 92 if (this.details[i].useSpecialization && item.specialization) | 92 if (this.details[i].getTitleFunction) |
| 93 { | 93 return this.details[i].getTitleFunction(item); |
|
ire
2018/01/04 08:32:52
NIT: I think this was cleaner without the nested `
saroyanm
2018/01/04 21:28:52
Yes, previously logic was bit different:
Previousl
ire
2018/01/05 09:23:45
Ack. Yes it is more clear, thanks!
| |
| 94 let title = item.specialization; | |
| 95 if (item.originalTitle && item.originalTitle.indexOf("+EasyList") >= 0) | |
|
ire
2018/01/04 08:32:52
NIT: I don't know if it actually makes a differenc
saroyanm
2018/01/04 21:28:52
Done.
| |
| 96 title += " + " + getMessage("options_english"); | |
| 97 return title; | |
| 98 } | |
| 99 return item.title || item.url || item.text; | 94 return item.title || item.url || item.text; |
| 100 }; | 95 }; |
| 101 | 96 |
| 102 Collection.prototype._sortItems = function() | 97 Collection.prototype._sortItems = function() |
| 103 { | 98 { |
| 104 this.items.sort((a, b) => | 99 this.items.sort((a, b) => |
| 105 { | 100 { |
| 106 // Make sure that Acceptable Ads is always last, since it cannot be | 101 // Make sure that Acceptable Ads is always last, since it cannot be |
| 107 // disabled, but only be removed. That way it's grouped together with | 102 // disabled, but only be removed. That way it's grouped together with |
| 108 // the "Own filter list" which cannot be disabled either at the bottom | 103 // the "Own filter list" which cannot be disabled either at the bottom |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 | 347 |
| 353 collections.protection = new Collection([ | 348 collections.protection = new Collection([ |
| 354 { | 349 { |
| 355 id: "recommend-protection-list-table" | 350 id: "recommend-protection-list-table" |
| 356 } | 351 } |
| 357 ]); | 352 ]); |
| 358 collections.langs = new Collection([ | 353 collections.langs = new Collection([ |
| 359 { | 354 { |
| 360 id: "blocking-languages-table", | 355 id: "blocking-languages-table", |
| 361 emptyTexts: ["options_language_empty"], | 356 emptyTexts: ["options_language_empty"], |
| 362 useSpecialization: true | 357 getTitleFunction: getLanguageTitle |
| 363 } | 358 } |
| 364 ]); | 359 ]); |
| 365 collections.allLangs = new Collection([ | 360 collections.allLangs = new Collection([ |
| 366 { | 361 { |
| 367 id: "all-lang-table-add", | 362 id: "all-lang-table-add", |
| 368 emptyTexts: ["options_dialog_language_other_empty"], | 363 emptyTexts: ["options_dialog_language_other_empty"], |
| 369 useSpecialization: true | 364 getTitleFunction: getLanguageTitle |
| 370 } | 365 } |
| 371 ]); | 366 ]); |
| 372 collections.more = new Collection([ | 367 collections.more = new Collection([ |
| 373 { | 368 { |
| 374 id: "more-list-table", | 369 id: "more-list-table", |
| 375 setEmptyAction: "hide-more-filters-section", | 370 setEmptyAction: "hide-more-filters-section", |
| 376 removeEmptyAction: "show-more-filters-section" | 371 removeEmptyAction: "show-more-filters-section" |
| 377 } | 372 } |
| 378 ]); | 373 ]); |
| 379 collections.whitelist = new Collection([ | 374 collections.whitelist = new Collection([ |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 if (index >= 0) | 478 if (index >= 0) |
| 484 customFilters.splice(index, 1); | 479 customFilters.splice(index, 1); |
| 485 | 480 |
| 486 updateCustomFiltersUi(); | 481 updateCustomFiltersUi(); |
| 487 } | 482 } |
| 488 | 483 |
| 489 function updateCustomFiltersUi() | 484 function updateCustomFiltersUi() |
| 490 { | 485 { |
| 491 let customFiltersListElement = E("custom-filters-raw"); | 486 let customFiltersListElement = E("custom-filters-raw"); |
| 492 customFiltersListElement.value = customFilters.join("\n"); | 487 customFiltersListElement.value = customFilters.join("\n"); |
| 488 } | |
| 489 | |
| 490 function getLanguageTitle(item) | |
| 491 { | |
| 492 let title = item.specialization; | |
| 493 if (item.originalTitle && item.originalTitle.indexOf("+EasyList") > -1) | |
| 494 title += " + " + getMessage("options_english"); | |
| 495 return title; | |
| 493 } | 496 } |
| 494 | 497 |
| 495 function loadRecommendations() | 498 function loadRecommendations() |
| 496 { | 499 { |
| 497 fetch("subscriptions.xml") | 500 fetch("subscriptions.xml") |
| 498 .then((response) => | 501 .then((response) => |
| 499 { | 502 { |
| 500 return response.text(); | 503 return response.text(); |
| 501 }) | 504 }) |
| 502 .then((text) => | 505 .then((text) => |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1466 }); | 1469 }); |
| 1467 browser.runtime.sendMessage({ | 1470 browser.runtime.sendMessage({ |
| 1468 type: "subscriptions.listen", | 1471 type: "subscriptions.listen", |
| 1469 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1472 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1470 "title", "downloadStatus", "downloading"] | 1473 "title", "downloadStatus", "downloading"] |
| 1471 }); | 1474 }); |
| 1472 | 1475 |
| 1473 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1476 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1474 window.addEventListener("hashchange", onHashChange, false); | 1477 window.addEventListener("hashchange", onHashChange, false); |
| 1475 } | 1478 } |
| LEFT | RIGHT |