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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 [ | 386 [ |
387 { | 387 { |
388 id: "all-filter-lists-table", | 388 id: "all-filter-lists-table", |
389 onClick: toggleDisableSubscription, | 389 onClick: toggleDisableSubscription, |
390 useOriginalTitle: true | 390 useOriginalTitle: true |
391 } | 391 } |
392 ]); | 392 ]); |
393 | 393 |
394 function updateLanguageCollections(subscription) | 394 function updateLanguageCollections(subscription) |
395 { | 395 { |
396 if (subscription.recommended == "ads") | 396 if (subscription.disabled) |
Thomas Greiner
2016/06/16 17:08:38
Why did you move this check out of here? This func
saroyanm
2016/06/16 17:42:11
For code readability, we were calling this functio
Thomas Greiner
2016/06/17 13:48:03
Ok, what about getting rid of this function then a
saroyanm
2016/06/21 12:53:07
I think it's bit trickier than we thought,I've mer
Thomas Greiner
2016/06/22 10:08:04
Ok, I guess I assumed that `addItems()` would only
saroyanm
2016/06/22 12:31:59
I agree, but if we only fix that we will fix simpt
| |
397 { | 397 { |
398 if (subscription.disabled) | 398 collections.allLangs.addItems(subscription); |
399 { | 399 collections.langs.removeItem(subscription); |
400 collections.allLangs.addItems(subscription); | 400 } |
401 collections.langs.removeItem(subscription); | 401 else |
402 } | 402 { |
403 else | 403 collections.allLangs.removeItem(subscription); |
404 { | 404 collections.langs.addItems(subscription); |
405 collections.allLangs.removeItem(subscription); | |
406 collections.langs.addItems(subscription); | |
407 } | |
408 } | 405 } |
409 } | 406 } |
410 | 407 |
411 function addSubscription(subscription) | 408 function addSubscription(subscription) |
412 { | 409 { |
413 var collection; | 410 var collection; |
414 if (subscription.recommended) | 411 if (subscription.recommended) |
415 { | 412 { |
416 if (subscription.recommended != "ads") | 413 if (subscription.recommended != "ads") |
417 collection = collections.popular; | 414 collection = collections.popular; |
418 else if (subscription.disabled == false) | 415 else if (subscription.disabled == false) |
419 collection = collections.langs; | 416 collection = collections.langs; |
420 else | 417 else |
421 collection = collections.allLangs; | 418 collection = collections.allLangs; |
422 } | 419 } |
423 else if (subscription.url == acceptableAdsUrl) | 420 else if (subscription.url == acceptableAdsUrl) |
424 collection = collections.acceptableAds; | 421 collection = collections.acceptableAds; |
425 else | 422 else |
426 collection = collections.custom; | 423 collection = collections.custom; |
427 | 424 |
428 collection.addItems(subscription); | 425 collection.addItems(subscription); |
429 subscriptionsMap[subscription.url] = subscription; | 426 subscriptionsMap[subscription.url] = subscription; |
430 updateTooltips(); | 427 updateTooltips(); |
431 } | 428 } |
432 | 429 |
433 function updateSubscription(subscription) | 430 function updateSubscription(subscription) |
434 { | 431 { |
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) | 432 for (var name in collections) |
445 collections[name].updateItem(knownSubscription); | 433 collections[name].updateItem(subscription); |
446 | |
447 return knownSubscription; | |
448 } | 434 } |
449 | 435 |
450 function updateFilter(filter) | 436 function updateFilter(filter) |
451 { | 437 { |
452 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/); | 438 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/); |
453 if (match && !filtersMap[filter.text]) | 439 if (match && !filtersMap[filter.text]) |
454 { | 440 { |
455 filter.title = match[1]; | 441 filter.title = match[1]; |
456 collections.whitelist.addItems(filter); | 442 collections.whitelist.addItems(filter); |
457 } | 443 } |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
922 collections.whitelist.removeItem(knownFilter); | 908 collections.whitelist.removeItem(knownFilter); |
923 collections.customFilters.removeItem(knownFilter); | 909 collections.customFilters.removeItem(knownFilter); |
924 delete filtersMap[filter.text]; | 910 delete filtersMap[filter.text]; |
925 updateShareLink(); | 911 updateShareLink(); |
926 break; | 912 break; |
927 } | 913 } |
928 } | 914 } |
929 | 915 |
930 function onSubscriptionMessage(action, subscription) | 916 function onSubscriptionMessage(action, subscription) |
931 { | 917 { |
918 if (subscription.url in subscriptionsMap) | |
919 { | |
920 var knownSubscription = subscriptionsMap[subscription.url]; | |
921 for (var property in subscription) | |
922 { | |
923 if (property == "title" && knownSubscription.recommended) | |
924 knownSubscription.originalTitle = subscription.title; | |
925 else | |
926 knownSubscription[property] = subscription[property]; | |
927 } | |
928 subscription = knownSubscription; | |
929 } | |
932 switch (action) | 930 switch (action) |
933 { | 931 { |
934 case "disabled": | 932 case "disabled": |
935 subscription = updateSubscription(subscription); | 933 if (subscription.recommended == "ads") |
936 updateLanguageCollections(subscription); | 934 updateLanguageCollections(subscription); |
935 updateSubscription(subscription); | |
937 break; | 936 break; |
938 case "downloading": | 937 case "downloading": |
939 case "downloadStatus": | 938 case "downloadStatus": |
940 case "homepage": | 939 case "homepage": |
941 case "lastDownload": | 940 case "lastDownload": |
942 case "title": | 941 case "title": |
943 updateSubscription(subscription); | 942 updateSubscription(subscription); |
944 break; | 943 break; |
945 case "added": | 944 case "added": |
946 if (subscription.url in subscriptionsMap) | 945 if (subscription.recommended == "ads") |
947 subscription = updateSubscription(subscription); | 946 updateLanguageCollections(subscription); |
947 else if (subscription.url in subscriptionsMap) | |
Thomas Greiner
2016/06/16 17:08:38
This else-if means that ad blocking subscriptions
saroyanm
2016/06/16 17:42:11
Yes the Advanced tab will be updated by the call b
Thomas Greiner
2016/06/23 14:54:29
Why isn't it updated by `addSubscription()` and `u
saroyanm
2016/06/23 16:27:12
We are also adding recommendations using "addSubsc
Thomas Greiner
2016/07/13 11:35:18
Ok, so the current behavior is:
- addSubscription:
saroyanm
2016/08/01 18:24:18
1. I've moved the call for updateLanguageCollectio
| |
948 updateSubscription(subscription); | |
948 else | 949 else |
949 addSubscription(subscription); | 950 addSubscription(subscription); |
950 | 951 |
Thomas Greiner
2016/06/16 17:08:38
Coding style: Trailing white space.
saroyanm
2016/06/22 12:31:59
Done.
| |
951 collections.filterLists.addItems(subscription); | 952 collections.filterLists.addItems(subscription); |
952 updateLanguageCollections(subscription); | |
953 break; | 953 break; |
954 case "removed": | 954 case "removed": |
955 var knownSubscription = subscriptionsMap[subscription.url]; | |
956 | |
957 if (subscription.url == acceptableAdsUrl || subscription.recommended) | 955 if (subscription.url == acceptableAdsUrl || subscription.recommended) |
958 { | 956 { |
959 subscription.disabled = true; | 957 subscription.disabled = true; |
960 onSubscriptionMessage("disabled", subscription); | 958 onSubscriptionMessage("disabled", subscription); |
961 } | 959 } |
962 else | 960 else |
963 { | 961 { |
964 collections.custom.removeItem(knownSubscription); | 962 collections.custom.removeItem(subscription); |
965 delete subscriptionsMap[subscription.url]; | 963 delete subscriptionsMap[subscription.url]; |
966 } | 964 } |
967 collections.filterLists.removeItem(knownSubscription); | 965 collections.filterLists.removeItem(subscription); |
968 break; | 966 break; |
969 } | 967 } |
970 | 968 |
971 updateShareLink(); | 969 updateShareLink(); |
972 } | 970 } |
973 | 971 |
974 function hidePref(key, value) | 972 function hidePref(key, value) |
975 { | 973 { |
976 var element = document.querySelector("[data-pref='" + key + "']"); | 974 var element = document.querySelector("[data-pref='" + key + "']"); |
977 if (element) | 975 if (element) |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1198 }); | 1196 }); |
1199 ext.backgroundPage.sendMessage( | 1197 ext.backgroundPage.sendMessage( |
1200 { | 1198 { |
1201 type: "subscriptions.listen", | 1199 type: "subscriptions.listen", |
1202 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1200 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1203 "title", "downloadStatus", "downloading"] | 1201 "title", "downloadStatus", "downloading"] |
1204 }); | 1202 }); |
1205 | 1203 |
1206 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1204 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1207 })(); | 1205 })(); |
OLD | NEW |