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

Side by Side Diff: options.js

Issue 5088751004942336: Issue 370 - Right-clicked element is removed independent of created filter (Closed)
Patch Set: Rebase to rev 3c9cea80c481 Created July 18, 2014, 8:54 a.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 | « options.html ('k') | popup.html » ('j') | 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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2014 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 var require = ext.backgroundPage.getWindow().require; 18 var backgroundPage = ext.backgroundPage.getWindow();
19 var require = backgroundPage.require;
19 20
20 with(require("filterClasses")) 21 with(require("filterClasses"))
21 { 22 {
22 this.Filter = Filter; 23 this.Filter = Filter;
23 this.WhitelistFilter = WhitelistFilter; 24 this.WhitelistFilter = WhitelistFilter;
24 } 25 }
25 with(require("subscriptionClasses")) 26 with(require("subscriptionClasses"))
26 { 27 {
27 this.Subscription = Subscription; 28 this.Subscription = Subscription;
28 this.SpecialSubscription = SpecialSubscription; 29 this.SpecialSubscription = SpecialSubscription;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 hasAcceptable = true; 115 hasAcceptable = true;
115 continue; 116 continue;
116 } 117 }
117 118
118 addSubscriptionEntry(subscription); 119 addSubscriptionEntry(subscription);
119 } 120 }
120 121
121 $("#acceptableAds").prop("checked", hasAcceptable); 122 $("#acceptableAds").prop("checked", hasAcceptable);
122 123
123 // User-entered filters 124 // User-entered filters
124 showUserFilters(); 125 var userFilters = backgroundPage.getUserFilters();
126 populateList("userFiltersBox", userFilters.filters);
127 populateList("excludedDomainsBox", userFilters.exceptions);
125 } 128 }
126 129
127 // Cleans up when the options window is closed 130 // Cleans up when the options window is closed
128 function unloadOptions() 131 function unloadOptions()
129 { 132 {
130 FilterNotifier.removeListener(onFilterChange); 133 FilterNotifier.removeListener(onFilterChange);
131 } 134 }
132 135
133 function initCheckbox(id) 136 function initCheckbox(id)
134 { 137 {
135 var checkbox = document.getElementById(id); 138 var checkbox = document.getElementById(id);
136 checkbox.checked = typeof localStorage[id] == "undefined" ? true : localStorag e[id] == "true"; 139 checkbox.checked = Prefs[id];
137 checkbox.addEventListener("click", function() 140 checkbox.addEventListener("click", function()
138 { 141 {
139 localStorage[id] = checkbox.checked; 142 Prefs[id] = checkbox.checked;
140 }, false); 143 }, false);
141 } 144 }
142 145
143 function showUserFilters()
144 {
145 var filters = [];
146 var exceptions = [];
147 for (var i = 0; i < FilterStorage.subscriptions.length; i++)
148 {
149 var subscription = FilterStorage.subscriptions[i];
150 if (!(subscription instanceof SpecialSubscription))
151 continue;
152
153 for (var j = 0; j < subscription.filters.length; j++)
154 {
155 var filter = subscription.filters[j];
156 if (filter instanceof WhitelistFilter && /^@@\|\|([^\/:]+)\^\$document$/.t est(filter.text))
157 exceptions.push(RegExp.$1)
158 else
159 filters.push(filter.text);
160 }
161 }
162
163 populateList("userFiltersBox", filters);
164 populateList("excludedDomainsBox", exceptions);
165 }
166
167 var delayedSubscriptionSelection = null; 146 var delayedSubscriptionSelection = null;
168 147
169 function loadRecommendations() 148 function loadRecommendations()
170 { 149 {
171 var request = new XMLHttpRequest(); 150 var request = new XMLHttpRequest();
172 request.open("GET", "subscriptions.xml"); 151 request.open("GET", "subscriptions.xml");
173 request.onload = function() 152 request.onload = function()
174 { 153 {
175 var selectedIndex = 0; 154 var selectedIndex = 0;
176 var selectedPrefix = null; 155 var selectedPrefix = null;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 links[i].href = arguments[i + 1]; 625 links[i].href = arguments[i + 1];
647 links[i].setAttribute("target", "_blank"); 626 links[i].setAttribute("target", "_blank");
648 } 627 }
649 else if (typeof arguments[i + 1] == "function") 628 else if (typeof arguments[i + 1] == "function")
650 { 629 {
651 links[i].href = "javascript:void(0);"; 630 links[i].href = "javascript:void(0);";
652 links[i].addEventListener("click", arguments[i + 1], false); 631 links[i].addEventListener("click", arguments[i + 1], false);
653 } 632 }
654 } 633 }
655 } 634 }
OLDNEW
« no previous file with comments | « options.html ('k') | popup.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld