Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: new-options.js

Issue 29346555: Issue 4156 - Adblocking filter only being removed in advanced tab fix (Closed)
Patch Set: Rebased to changeset #87 Created Aug. 1, 2016, 6:10 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 collections.filterLists = new Collection( 330 collections.filterLists = new Collection(
331 [ 331 [
332 { 332 {
333 id: "all-filter-lists-table", 333 id: "all-filter-lists-table",
334 useOriginalTitle: true 334 useOriginalTitle: true
335 } 335 }
336 ]); 336 ]);
337 337
338 function updateLanguageCollections(subscription) 338 function updateLanguageCollections(subscription)
339 { 339 {
340 if (subscription.recommended == "ads") 340 if (subscription.disabled)
341 { 341 {
342 if (subscription.disabled) 342 collections.allLangs.addItems(subscription);
343 { 343 collections.langs.removeItem(subscription);
344 collections.allLangs.addItems(subscription); 344 }
345 collections.langs.removeItem(subscription); 345 else
346 } 346 {
347 else 347 collections.allLangs.removeItem(subscription);
348 { 348 collections.langs.addItems(subscription);
349 collections.allLangs.removeItem(subscription);
350 collections.langs.addItems(subscription);
351 }
352 } 349 }
353 } 350 }
354 351
355 function addSubscription(subscription) 352 function addSubscription(subscription)
356 { 353 {
357 var collection; 354 var collection;
358 if (subscription.recommended) 355 if (subscription.recommended)
359 { 356 {
360 if (subscription.recommended != "ads") 357 if (subscription.recommended != "ads")
361 collection = collections.popular; 358 collection = collections.popular;
362 else if (subscription.disabled == false) 359 else if (subscription.disabled == false)
363 collection = collections.langs; 360 collection = collections.langs;
364 else 361 else
365 collection = collections.allLangs; 362 collection = collections.allLangs;
366 } 363 }
367 else if (subscription.url == acceptableAdsUrl) 364 else if (subscription.url == acceptableAdsUrl)
368 collection = collections.acceptableAds; 365 collection = collections.acceptableAds;
369 else 366 else
370 collection = collections.custom; 367 collection = collections.custom;
371 368
372 collection.addItems(subscription); 369 collection.addItems(subscription);
373 subscriptionsMap[subscription.url] = subscription; 370 subscriptionsMap[subscription.url] = subscription;
374 updateTooltips(); 371 updateTooltips();
375 } 372 }
376 373
377 function updateSubscription(subscription) 374 function updateSubscription(subscription)
378 { 375 {
379 var knownSubscription = subscriptionsMap[subscription.url];
380 for (var property in subscription)
381 {
382 if (property == "title" && subscription.recommended)
383 knownSubscription.originalTitle = subscription.title;
384 else
385 knownSubscription[property] = subscription[property];
386 }
387
388 for (var name in collections) 376 for (var name in collections)
389 collections[name].updateItem(knownSubscription); 377 collections[name].updateItem(subscription);
390
391 return knownSubscription;
392 } 378 }
393 379
394 function updateFilter(filter) 380 function updateFilter(filter)
395 { 381 {
396 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/); 382 var match = filter.text.match(/^@@\|\|([^\/:]+)\^\$document$/);
397 if (match && !filtersMap[filter.text]) 383 if (match && !filtersMap[filter.text])
398 { 384 {
399 filter.title = match[1]; 385 filter.title = match[1];
400 collections.whitelist.addItems(filter); 386 collections.whitelist.addItems(filter);
401 } 387 }
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 collections.whitelist.removeItem(knownFilter); 1005 collections.whitelist.removeItem(knownFilter);
1020 collections.customFilters.removeItem(knownFilter); 1006 collections.customFilters.removeItem(knownFilter);
1021 delete filtersMap[filter.text]; 1007 delete filtersMap[filter.text];
1022 updateShareLink(); 1008 updateShareLink();
1023 break; 1009 break;
1024 } 1010 }
1025 } 1011 }
1026 1012
1027 function onSubscriptionMessage(action, subscription) 1013 function onSubscriptionMessage(action, subscription)
1028 { 1014 {
1015 if (subscription.url in subscriptionsMap)
1016 {
1017 var knownSubscription = subscriptionsMap[subscription.url];
1018 for (var property in subscription)
1019 {
1020 if (property == "title" && knownSubscription.recommended)
1021 knownSubscription.originalTitle = subscription.title;
1022 else
1023 knownSubscription[property] = subscription[property];
1024 }
1025 subscription = knownSubscription;
1026 }
1029 switch (action) 1027 switch (action)
1030 { 1028 {
1031 case "disabled": 1029 case "disabled":
1032 subscription = updateSubscription(subscription); 1030 if (subscription.recommended == "ads")
1033 updateLanguageCollections(subscription); 1031 updateLanguageCollections(subscription);
1032 updateSubscription(subscription);
1034 break; 1033 break;
1035 case "downloading": 1034 case "downloading":
1036 case "downloadStatus": 1035 case "downloadStatus":
1037 case "homepage": 1036 case "homepage":
1038 case "lastDownload": 1037 case "lastDownload":
1039 case "title": 1038 case "title":
1040 updateSubscription(subscription); 1039 updateSubscription(subscription);
1041 break; 1040 break;
1042 case "added": 1041 case "added":
1043 if (subscription.url in subscriptionsMap) 1042 if (subscription.recommended == "ads")
1044 subscription = updateSubscription(subscription); 1043 updateLanguageCollections(subscription);
1044 else if (subscription.url in subscriptionsMap)
1045 updateSubscription(subscription);
1045 else 1046 else
1046 addSubscription(subscription); 1047 addSubscription(subscription);
1047 1048
1048 collections.filterLists.addItems(subscription); 1049 collections.filterLists.addItems(subscription);
1049 updateLanguageCollections(subscription);
1050 break; 1050 break;
1051 case "removed": 1051 case "removed":
1052 var knownSubscription = subscriptionsMap[subscription.url];
1053 if (subscription.url == acceptableAdsUrl || subscription.recommended) 1052 if (subscription.url == acceptableAdsUrl || subscription.recommended)
1054 { 1053 {
1055 subscription.disabled = true; 1054 subscription.disabled = true;
1056 onSubscriptionMessage("disabled", subscription); 1055 onSubscriptionMessage("disabled", subscription);
1057 } 1056 }
1058 else 1057 else
1059 { 1058 {
1060 collections.custom.removeItem(knownSubscription); 1059 collections.custom.removeItem(subscription);
1061 delete subscriptionsMap[subscription.url]; 1060 delete subscriptionsMap[subscription.url];
1062 } 1061 }
1063 collections.filterLists.removeItem(knownSubscription); 1062 collections.filterLists.removeItem(subscription);
1064 break; 1063 break;
1065 } 1064 }
1066 1065
1067 updateShareLink(); 1066 updateShareLink();
1068 } 1067 }
1069 1068
1070 function hidePref(key, value) 1069 function hidePref(key, value)
1071 { 1070 {
1072 var element = document.querySelector("[data-pref='" + key + "']"); 1071 var element = document.querySelector("[data-pref='" + key + "']");
1073 if (element) 1072 if (element)
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 ext.backgroundPage.sendMessage( 1280 ext.backgroundPage.sendMessage(
1282 { 1281 {
1283 type: "subscriptions.listen", 1282 type: "subscriptions.listen",
1284 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1283 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1285 "title", "downloadStatus", "downloading"] 1284 "title", "downloadStatus", "downloading"]
1286 }); 1285 });
1287 1286
1288 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1287 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1289 window.addEventListener("hashchange", onHashChange, false); 1288 window.addEventListener("hashchange", onHashChange, false);
1290 })(); 1289 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld