| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 | 440 |
| 441 function updateSubscription(subscription) | 441 function updateSubscription(subscription) |
| 442 { | 442 { |
| 443 var subscriptionUrl = subscription.url; | 443 var subscriptionUrl = subscription.url; |
| 444 var knownSubscription = subscriptionsMap[subscriptionUrl]; | 444 var knownSubscription = subscriptionsMap[subscriptionUrl]; |
| 445 if (knownSubscription) | 445 if (knownSubscription) |
| 446 { | 446 { |
| 447 for (var property in subscription) | 447 for (var property in subscription) |
| 448 if (property != "title") | 448 { |
| 449 if (property == "title" && subscriptionUrl in recommendationsMap) |
| 450 knownSubscription.originalTitle = subscription.title; |
| 451 else |
| 449 knownSubscription[property] = subscription[property]; | 452 knownSubscription[property] = subscription[property]; |
| 453 } |
| 450 } | 454 } |
| 451 else | 455 else |
| 452 { | 456 { |
| 453 observeSubscription(subscription); | 457 observeSubscription(subscription); |
| 454 getAcceptableAdsURL(function(acceptableAdsUrl) | 458 getAcceptableAdsURL(function(acceptableAdsUrl) |
| 455 { | 459 { |
| 456 var collection = null; | 460 var collection = null; |
| 457 if (subscriptionUrl in recommendationsMap) | 461 if (subscriptionUrl in recommendationsMap) |
| 458 { | 462 { |
| 459 var recommendation = recommendationsMap[subscriptionUrl]; | 463 var recommendation = recommendationsMap[subscriptionUrl]; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 { | 909 { |
| 906 var customFilterItems = collections.customFilters.items; | 910 var customFilterItems = collections.customFilters.items; |
| 907 var filterTexts = []; | 911 var filterTexts = []; |
| 908 for (var i = 0; i < customFilterItems.length; i++) | 912 for (var i = 0; i < customFilterItems.length; i++) |
| 909 filterTexts.push(customFilterItems[i].text); | 913 filterTexts.push(customFilterItems[i].text); |
| 910 E("custom-filters-raw").value = filterTexts.join("\n"); | 914 E("custom-filters-raw").value = filterTexts.join("\n"); |
| 911 } | 915 } |
| 912 | 916 |
| 913 function getAcceptableAdsURL(callback) | 917 function getAcceptableAdsURL(callback) |
| 914 { | 918 { |
| 915 getPref("subscriptions_exceptionsurl", function(value) | 919 getPref("subscriptions_exceptionsurl", function(value) |
| 916 { | 920 { |
| 917 getAcceptableAdsURL = function(callback) | 921 getAcceptableAdsURL = function(callback) |
| 918 { | 922 { |
| 919 callback(value); | 923 callback(value); |
| 920 }; | 924 }; |
| 921 getAcceptableAdsURL(callback); | 925 getAcceptableAdsURL(callback); |
| 922 }); | 926 }); |
| 923 } | 927 } |
| 924 | 928 |
| 925 function addEnableSubscription(url, title, homepage) | 929 function addEnableSubscription(url, title, homepage) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 var knownSubscription = subscriptionsMap[subscription.url]; | 979 var knownSubscription = subscriptionsMap[subscription.url]; |
| 976 if (knownSubscription) | 980 if (knownSubscription) |
| 977 collections.filterLists.addItems(knownSubscription); | 981 collections.filterLists.addItems(knownSubscription); |
| 978 else | 982 else |
| 979 collections.filterLists.addItems(subscription); | 983 collections.filterLists.addItems(subscription); |
| 980 break; | 984 break; |
| 981 case "disabled": | 985 case "disabled": |
| 982 updateSubscription(subscription); | 986 updateSubscription(subscription); |
| 983 updateShareLink(); | 987 updateShareLink(); |
| 984 break; | 988 break; |
| 985 case "lastDownload": | |
| 986 case "downloadStatus": | |
| 987 case "downloading": | |
| 988 updateSubscription(subscription); | |
| 989 break; | |
| 990 case "homepage": | |
| 991 // TODO: NYI | |
| 992 break; | |
| 993 case "removed": | 989 case "removed": |
| 994 var knownSubscription = subscriptionsMap[subscription.url]; | 990 var knownSubscription = subscriptionsMap[subscription.url]; |
| 995 getAcceptableAdsURL(function(acceptableAdsUrl) | 991 getAcceptableAdsURL(function(acceptableAdsUrl) |
| 996 { | 992 { |
| 997 if (subscription.url == acceptableAdsUrl) | 993 if (subscription.url == acceptableAdsUrl) |
| 998 { | 994 { |
| 999 subscription.disabled = true; | 995 subscription.disabled = true; |
| 1000 updateSubscription(subscription); | 996 updateSubscription(subscription); |
| 1001 } | 997 } |
| 1002 else | 998 else |
| 1003 { | 999 { |
| 1004 if (subscription.url in recommendationsMap) | 1000 if (subscription.url in recommendationsMap) |
| 1005 knownSubscription.disabled = true; | 1001 knownSubscription.disabled = true; |
| 1006 else | 1002 else |
| 1007 { | 1003 { |
| 1008 collections.custom.removeItem(knownSubscription); | 1004 collections.custom.removeItem(knownSubscription); |
| 1009 delete subscriptionsMap[subscription.url]; | 1005 delete subscriptionsMap[subscription.url]; |
| 1010 } | 1006 } |
| 1011 } | 1007 } |
| 1012 updateShareLink(); | 1008 updateShareLink(); |
| 1013 collections.filterLists.removeItem(knownSubscription); | 1009 collections.filterLists.removeItem(knownSubscription); |
| 1014 }); | 1010 }); |
| 1015 break; | 1011 break; |
| 1016 case "title": | 1012 default: |
| 1017 // TODO: NYI | 1013 updateSubscription(subscription); |
| 1018 break; | 1014 break; |
| 1019 } | 1015 } |
| 1020 } | 1016 } |
| 1021 | 1017 |
| 1022 function hidePref(key, value) | 1018 function hidePref(key, value) |
| 1023 { | 1019 { |
| 1024 var element = document.querySelector("[data-pref='" + key + "']"); | 1020 var element = document.querySelector("[data-pref='" + key + "']"); |
| 1025 if (element) | 1021 if (element) |
| 1026 element.setAttribute("aria-hidden", value); | 1022 element.setAttribute("aria-hidden", value); |
| 1027 } | 1023 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 }); | 1167 }); |
| 1172 ext.backgroundPage.sendMessage( | 1168 ext.backgroundPage.sendMessage( |
| 1173 { | 1169 { |
| 1174 type: "subscriptions.listen", | 1170 type: "subscriptions.listen", |
| 1175 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1171 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
| 1176 "title", "downloadStatus", "downloading"] | 1172 "title", "downloadStatus", "downloading"] |
| 1177 }); | 1173 }); |
| 1178 | 1174 |
| 1179 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1175 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 1180 })(); | 1176 })(); |
| OLD | NEW |