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-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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 else | 425 else |
426 collection = collections.custom; | 426 collection = collections.custom; |
427 | 427 |
428 collection.addItems(subscription); | 428 collection.addItems(subscription); |
429 subscriptionsMap[subscription.url] = subscription; | 429 subscriptionsMap[subscription.url] = subscription; |
430 updateTooltips(); | 430 updateTooltips(); |
431 } | 431 } |
432 | 432 |
433 function updateSubscription(subscription) | 433 function updateSubscription(subscription) |
434 { | 434 { |
435 var knownSubscription = subscriptionsMap[subscription.url]; | |
436 for (var property in subscription) | |
437 { | |
438 if (property == "title" && subscription.recommended) | |
439 knownSubscription.originalTitle = subscription.title; | |
440 else | |
441 knownSubscription[property] = subscription[property]; | |
442 } | |
443 | |
444 for (var name in collections) | 435 for (var name in collections) |
445 collections[name].updateItem(knownSubscription); | 436 collections[name].updateItem(subscription); |
446 | |
447 return knownSubscription; | |
448 } | 437 } |
449 | 438 |
450 function updateFilter(filter) | 439 function updateFilter(filter) |
451 { | 440 { |
452 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/); | 441 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/); |
453 if (match && !filtersMap[filter.text]) | 442 if (match && !filtersMap[filter.text]) |
454 { | 443 { |
455 filter.title = match[1]; | 444 filter.title = match[1]; |
456 collections.whitelist.addItems(filter); | 445 collections.whitelist.addItems(filter); |
457 } | 446 } |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
922 collections.whitelist.removeItem(knownFilter); | 911 collections.whitelist.removeItem(knownFilter); |
923 collections.customFilters.removeItem(knownFilter); | 912 collections.customFilters.removeItem(knownFilter); |
924 delete filtersMap[filter.text]; | 913 delete filtersMap[filter.text]; |
925 updateShareLink(); | 914 updateShareLink(); |
926 break; | 915 break; |
927 } | 916 } |
928 } | 917 } |
929 | 918 |
930 function onSubscriptionMessage(action, subscription) | 919 function onSubscriptionMessage(action, subscription) |
931 { | 920 { |
921 var knownSubscription = subscriptionsMap[subscription.url]; | |
Thomas Greiner
2016/06/16 11:09:33
I'd prefer not having to deal with two different v
saroyanm
2016/06/16 13:35:48
Very good point!
| |
922 if (knownSubscription) | |
923 { | |
924 for (var property in subscription) | |
925 { | |
926 if (property == "title" && knownSubscription.recommended) | |
927 knownSubscription.originalTitle = subscription.title; | |
928 else | |
929 knownSubscription[property] = subscription[property]; | |
930 } | |
931 } | |
932 | |
932 switch (action) | 933 switch (action) |
933 { | 934 { |
934 case "disabled": | 935 case "disabled": |
935 subscription = updateSubscription(subscription); | 936 updateSubscription(knownSubscription); |
936 updateLanguageCollections(subscription); | 937 updateLanguageCollections(knownSubscription); |
937 break; | 938 break; |
938 case "downloading": | 939 case "downloading": |
939 case "downloadStatus": | 940 case "downloadStatus": |
940 case "homepage": | 941 case "homepage": |
941 case "lastDownload": | 942 case "lastDownload": |
942 case "title": | 943 case "title": |
943 updateSubscription(subscription); | 944 updateSubscription(knownSubscription); |
944 break; | 945 break; |
945 case "added": | 946 case "added": |
946 if (subscription.url in subscriptionsMap) | 947 if (knownSubscription) |
947 subscription = updateSubscription(subscription); | 948 updateLanguageCollections(knownSubscription); |
948 else | 949 else |
949 addSubscription(subscription); | 950 addSubscription(subscription); |
950 | 951 |
951 collections.filterLists.addItems(subscription); | 952 subscription = updateSubscription(knownSubscription || subscription); |
952 updateLanguageCollections(subscription); | 953 collections.filterLists.addItems(knownSubscription || subscription); |
953 break; | 954 break; |
954 case "removed": | 955 case "removed": |
955 var knownSubscription = subscriptionsMap[subscription.url]; | 956 if (subscription.url == acceptableAdsUrl || knownSubscription.recommende d) |
956 | |
957 if (subscription.url == acceptableAdsUrl || subscription.recommended) | |
958 { | 957 { |
959 subscription.disabled = true; | 958 subscription.disabled = true; |
960 onSubscriptionMessage("disabled", subscription); | 959 onSubscriptionMessage("disabled", subscription); |
961 } | 960 } |
962 else | 961 else |
963 { | 962 { |
964 collections.custom.removeItem(knownSubscription); | 963 collections.custom.removeItem(knownSubscription); |
965 delete subscriptionsMap[subscription.url]; | 964 delete subscriptionsMap[subscription.url]; |
966 } | 965 } |
967 collections.filterLists.removeItem(knownSubscription); | 966 collections.filterLists.removeItem(knownSubscription); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1198 }); | 1197 }); |
1199 ext.backgroundPage.sendMessage( | 1198 ext.backgroundPage.sendMessage( |
1200 { | 1199 { |
1201 type: "subscriptions.listen", | 1200 type: "subscriptions.listen", |
1202 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1201 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1203 "title", "downloadStatus", "downloading"] | 1202 "title", "downloadStatus", "downloading"] |
1204 }); | 1203 }); |
1205 | 1204 |
1206 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1205 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1207 })(); | 1206 })(); |
OLD | NEW |