Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 "use strict"; | 18 "use strict"; |
19 | 19 |
20 (function() | 20 (function() |
21 { | 21 { |
22 var subscriptionsMap = Object.create(null); | 22 var subscriptionsMap = Object.create(null); |
23 var recommendationsMap = Object.create(null); | 23 var recommendationsMap = Object.create(null); |
24 var filtersMap = Object.create(null); | 24 var filtersMap = Object.create(null); |
25 var collections = Object.create(null); | 25 var collections = Object.create(null); |
26 | 26 |
27 function Collection(details) | 27 function Collection(details) |
28 { | 28 { |
29 this.details = details; | 29 this.details = details; |
30 } | 30 this.items = []; |
31 | 31 } |
32 Collection.prototype = Object.create(Array.prototype); | 32 |
33 Collection.prototype.addItems = function(item) | 33 Collection.prototype.addItems = function() |
34 { | 34 { |
35 var length = Array.prototype.push.apply(this, arguments); | 35 var length = Array.prototype.push.apply(this.items, arguments); |
36 if (length == 0) | 36 if (length == 0) |
37 return; | 37 return; |
38 | 38 |
39 this.sort(function(a, b) | 39 this.items.sort(function(a, b) |
40 { | 40 { |
41 var aValue = (a.title || a.url || a.text).toLowerCase(); | 41 var aValue = (a.title || a.url || a.text).toLowerCase(); |
42 var bValue = (b.title || b.url || a.text).toLowerCase(); | 42 var bValue = (b.title || b.url || a.text).toLowerCase(); |
43 if (aValue < bValue) | 43 return aValue.localeCompare(bValue); |
44 return -1; | |
45 if (aValue > bValue) | |
46 return 1; | |
47 return 0; | |
48 }); | 44 }); |
49 | 45 |
50 for (var j = 0; j < this.details.length; j++) | 46 for (var j = 0; j < this.details.length; j++) |
51 { | 47 { |
52 var table = E(this.details[j].id); | 48 var table = E(this.details[j].id); |
53 var template = table.querySelector("template"); | 49 var template = table.querySelector("template"); |
54 for (var i = 0; i < arguments.length; i++) | 50 for (var i = 0; i < arguments.length; i++) |
55 { | 51 { |
56 var object = arguments[i]; | 52 var item = arguments[i]; |
Thomas Greiner
2015/03/12 11:41:56
What you're calling "object" here is the same thin
saroyanm
2015/03/12 14:03:22
Done.
| |
57 var text = object.title || object.url || object.text; | 53 var text = item.title || item.url || item.text; |
58 var listItem = document.createElement("li"); | 54 var listItem = document.createElement("li"); |
59 listItem.appendChild(document.importNode(template.content, true)); | 55 listItem.appendChild(document.importNode(template.content, true)); |
60 listItem.dataset.access = object.url || object.text; | 56 listItem.dataset.access = item.url || item.text; |
61 listItem.querySelector(".display").textContent = text; | 57 listItem.querySelector(".display").textContent = text; |
62 if (text) | 58 if (text) |
63 listItem.dataset.search = text.toLowerCase(); | 59 listItem.dataset.search = text.toLowerCase(); |
64 | 60 |
65 var control = listItem.querySelector(".control"); | 61 var control = listItem.querySelector(".control"); |
66 if (control) | 62 if (control) |
67 { | 63 { |
68 control.addEventListener("click", this.details[j].onClick, false); | 64 control.addEventListener("click", this.details[j].onClick, false); |
69 control.checked = object.disabled == false; | 65 control.checked = item.disabled == false; |
70 } | 66 } |
71 | 67 |
72 if (table.hasChildNodes) | 68 if (table.hasChildNodes()) |
73 table.insertBefore(listItem, table.childNodes[this.indexOf(object)]); | 69 table.insertBefore(listItem, table.childNodes[this.items.indexOf(item) ]); |
74 else | 70 else |
75 table.appendChild(listItem); | 71 table.appendChild(listItem); |
76 } | 72 } |
77 } | 73 } |
78 return length; | 74 return length; |
79 }; | 75 }; |
80 | 76 |
81 Collection.prototype.removeItem = function(item) | 77 Collection.prototype.removeItem = function(item) |
82 { | 78 { |
83 var index = this.indexOf(item); | 79 var index = this.items.indexOf(item); |
84 if (index == -1) | 80 if (index == -1) |
85 return; | 81 return; |
86 | 82 |
87 this.splice(index, 1); | 83 this.items.splice(index, 1); |
88 var access = (item.url || item.text).replace(/'/g, "\\'"); | 84 var access = (item.url || item.text).replace(/'/g, "\\'"); |
89 for (var i = 0; i < this.details.length; i++) | 85 for (var i = 0; i < this.details.length; i++) |
90 { | 86 { |
91 var table = E(this.details[i].id); | 87 var table = E(this.details[i].id); |
92 var element = table.querySelector("[data-access='" + access + "']"); | 88 var element = table.querySelector("[data-access='" + access + "']"); |
93 element.parentElement.removeChild(element); | 89 element.parentElement.removeChild(element); |
94 } | 90 } |
95 }; | 91 }; |
96 | 92 |
97 Collection.prototype.clearAll = function() | 93 Collection.prototype.clearAll = function() |
98 { | 94 { |
99 for (var i = 0; i < this.details.length; i++) | 95 for (var i = 0; i < this.details.length; i++) |
100 { | 96 { |
101 var table = E(this.details[i].id); | 97 var table = E(this.details[i].id); |
102 var template = table.querySelector("template"); | 98 var template = table.querySelector("template"); |
103 table.innerHTML = ""; | 99 table.innerHTML = ""; |
104 table.appendChild(template); | 100 table.appendChild(template); |
105 } | 101 } |
106 this.length = 0; | 102 this.items.length = 0; |
107 }; | 103 }; |
108 | 104 |
109 function toggleSubscription(e) | 105 function onToggleSubscriptionClick(e) |
110 { | 106 { |
111 e.preventDefault(); | 107 e.preventDefault(); |
112 var subscriptionUrl = e.target.parentNode.dataset.access; | 108 var subscriptionUrl = e.target.parentNode.dataset.access; |
113 if (!e.target.checked) | 109 if (!e.target.checked) |
114 removeSubscription(subscriptionUrl); | 110 removeSubscription(subscriptionUrl); |
115 else | 111 else |
116 addEnableSubscription(subscriptionUrl); | 112 addEnableSubscription(subscriptionUrl); |
117 } | 113 } |
118 | 114 |
119 function addLanguageSubscription(e) | 115 function onAddLanguageSubscriptionClick(e) |
120 { | 116 { |
121 e.preventDefault(); | 117 e.preventDefault(); |
122 var url = this.parentNode.dataset.access; | 118 var url = this.parentNode.dataset.access; |
123 addEnableSubscription(url); | 119 addEnableSubscription(url); |
124 } | 120 } |
125 | 121 |
126 function triggerRemoveFilter() | 122 function onRemoveFilterClick() |
127 { | 123 { |
128 var filter = this.parentNode.dataset.access; | 124 var filter = this.parentNode.dataset.access; |
129 removeFilter(filter); | 125 removeFilter(filter); |
130 } | 126 } |
131 | 127 |
132 collections.popular = new Collection( | 128 collections.popular = new Collection( |
133 [ | 129 [ |
134 { | 130 { |
135 id: "recommend-list-table", | 131 id: "recommend-list-table", |
136 onClick: toggleSubscription | 132 onClick: onToggleSubscriptionClick |
137 } | 133 } |
138 ]); | 134 ]); |
139 collections.langs = new Collection( | 135 collections.langs = new Collection( |
140 [ | 136 [ |
141 { | 137 { |
142 id: "blocking-languages-table", | 138 id: "blocking-languages-table", |
143 onClick: toggleSubscription | 139 onClick: onToggleSubscriptionClick |
144 }, | 140 }, |
145 { | 141 { |
146 id: "blocking-languages-modal-table" | 142 id: "blocking-languages-dialog-table" |
147 } | 143 } |
148 ]); | 144 ]); |
149 collections.allLangs = new Collection( | 145 collections.allLangs = new Collection( |
150 [ | 146 [ |
151 { | 147 { |
152 id: "all-lang-table", | 148 id: "all-lang-table", |
153 onClick: addLanguageSubscription | 149 onClick: onAddLanguageSubscriptionClick |
154 } | 150 } |
155 ]); | 151 ]); |
156 collections.acceptableAds = new Collection( | 152 collections.acceptableAds = new Collection( |
157 [ | 153 [ |
158 { | 154 { |
159 id: "acceptableads-table", | 155 id: "acceptableads-table", |
160 onClick: toggleSubscription | 156 onClick: onToggleSubscriptionClick |
161 } | 157 } |
162 ]); | 158 ]); |
163 collections.custom = new Collection( | 159 collections.custom = new Collection( |
164 [ | 160 [ |
165 { | 161 { |
166 id: "custom-list-table", | 162 id: "custom-list-table", |
167 onClick: toggleSubscription | 163 onClick: onToggleSubscriptionClick |
168 } | 164 } |
169 ]); | 165 ]); |
170 collections.whitelist = new Collection( | 166 collections.whitelist = new Collection( |
171 [ | 167 [ |
172 { | 168 { |
173 id: "whitelisting-table", | 169 id: "whitelisting-table", |
174 onClick: triggerRemoveFilter | 170 onClick: onRemoveFilterClick |
175 } | 171 } |
176 ]); | 172 ]); |
177 | 173 |
178 function updateSubscription(subscription) | 174 function updateSubscription(subscription) |
179 { | 175 { |
180 var subscriptionUrl = subscription.url; | 176 var subscriptionUrl = subscription.url; |
181 var knownSubscription = subscriptionsMap[subscriptionUrl]; | 177 var knownSubscription = subscriptionsMap[subscriptionUrl]; |
182 if (knownSubscription) | 178 if (knownSubscription) |
183 knownSubscription.disabled = subscription.disabled; | 179 knownSubscription.disabled = subscription.disabled; |
184 else | 180 else |
(...skipping 25 matching lines...) Expand all Loading... | |
210 collections.allLangs.addItems(subscription); | 206 collections.allLangs.addItems(subscription); |
211 collections.langs.removeItem(subscription); | 207 collections.langs.removeItem(subscription); |
212 } | 208 } |
213 } | 209 } |
214 } | 210 } |
215 } | 211 } |
216 } | 212 } |
217 | 213 |
218 if (!Object.observe) | 214 if (!Object.observe) |
219 { | 215 { |
216 // Currently only "disabled" property of subscription used for observa tion | |
217 // but with Advanced tab implementation we should also add more proper ties. | |
220 ["disabled"].forEach(function(property) | 218 ["disabled"].forEach(function(property) |
221 { | 219 { |
222 subscription["$" + property] = subscription[property]; | 220 subscription["$" + property] = subscription[property]; |
223 Object.defineProperty(subscription, property, | 221 Object.defineProperty(subscription, property, |
224 { | 222 { |
225 get: function() | 223 get: function() |
226 { | 224 { |
227 return this["$" + property]; | 225 return this["$" + property]; |
228 }, | 226 }, |
229 set: function(value) | 227 set: function(value) |
230 { | 228 { |
231 this["$" + property] = value; | 229 this["$" + property] = value; |
232 onObjectChanged(); | 230 onObjectChanged(); |
233 } | 231 } |
234 }); | 232 }); |
235 }); | 233 }); |
236 } | 234 } |
237 else | 235 else |
238 { | 236 { |
239 Object.observe(subscription, function(changes) | 237 Object.observe(subscription, onObjectChanged); |
240 { | |
241 onObjectChanged(); | |
242 }); | |
243 } | 238 } |
244 | 239 |
245 var collection = null; | 240 var collection = null; |
246 if (subscriptionUrl in recommendationsMap) | 241 if (subscriptionUrl in recommendationsMap) |
247 { | 242 { |
248 var recommendation = recommendationsMap[subscriptionUrl]; | 243 var recommendation = recommendationsMap[subscriptionUrl]; |
249 if (recommendation.isPopular) | 244 if (recommendation.isPopular) |
250 collection = collections.popular; | 245 collection = collections.popular; |
251 else if (recommendation.isAdsType && subscription.disabled == false) | 246 else if (recommendation.isAdsType && subscription.disabled == false) |
252 collection = collections.langs; | 247 collection = collections.langs; |
(...skipping 23 matching lines...) Expand all Loading... | |
276 else | 271 else |
277 { | 272 { |
278 // TODO: add `filters[i].text` to list of custom filters | 273 // TODO: add `filters[i].text` to list of custom filters |
279 } | 274 } |
280 } | 275 } |
281 | 276 |
282 function loadRecommendations() | 277 function loadRecommendations() |
283 { | 278 { |
284 var request = new XMLHttpRequest(); | 279 var request = new XMLHttpRequest(); |
285 request.open("GET", "subscriptions.xml", false); | 280 request.open("GET", "subscriptions.xml", false); |
286 request.onload = function() | 281 request.addEventListener("load", function() |
287 { | 282 { |
288 var list = document.getElementById("subscriptionSelector"); | 283 var list = document.getElementById("subscriptionSelector"); |
289 var docElem = request.responseXML.documentElement; | 284 var docElem = request.responseXML.documentElement; |
290 var elements = docElem.getElementsByTagName("subscription"); | 285 var elements = docElem.getElementsByTagName("subscription"); |
291 for (var i = 0; i < elements.length; i++) | 286 for (var i = 0; i < elements.length; i++) |
292 { | 287 { |
293 var element = elements[i]; | 288 var element = elements[i]; |
294 var subscription = Object.create(null); | 289 var subscription = Object.create(null); |
295 subscription.title = element.getAttribute("title"); | 290 subscription.title = element.getAttribute("title"); |
296 subscription.url = element.getAttribute("url"); | 291 subscription.url = element.getAttribute("url"); |
(...skipping 13 matching lines...) Expand all Loading... | |
310 } | 305 } |
311 else | 306 else |
312 subscription.title = element.getAttribute("specialization"); | 307 subscription.title = element.getAttribute("specialization"); |
313 | 308 |
314 if (element.getAttribute("popular")) | 309 if (element.getAttribute("popular")) |
315 recommendation.isPopular = true; | 310 recommendation.isPopular = true; |
316 | 311 |
317 recommendationsMap[subscription.url] = recommendation; | 312 recommendationsMap[subscription.url] = recommendation; |
318 updateSubscription(subscription); | 313 updateSubscription(subscription); |
319 } | 314 } |
320 }; | 315 }, false); |
321 request.send(null); | 316 request.send(null); |
322 } | 317 } |
323 | 318 |
324 function onDOMLoaded() | 319 function onDOMLoaded() |
325 { | 320 { |
326 var recommendationTemplate = document.querySelector("#recommend-list-table t emplate"); | 321 var recommendationTemplate = document.querySelector("#recommend-list-table t emplate"); |
327 var popularText = ext.i18n.getMessage("options_popular"); | 322 var popularText = ext.i18n.getMessage("options_popular"); |
328 recommendationTemplate.content.querySelector(".popular").textContent = popul arText; | 323 recommendationTemplate.content.querySelector(".popular").textContent = popul arText; |
329 var languagesTemplate = document.querySelector("#all-lang-table template"); | 324 var languagesTemplate = document.querySelector("#all-lang-table template"); |
330 var buttonText = "+" + ext.i18n.getMessage("options_button_add"); | 325 var buttonText = ext.i18n.getMessage("options_button_add"); |
Thomas Greiner
2015/03/12 11:41:56
I suppose the "+" should be on the other side of t
saroyanm
2015/03/12 14:03:22
Should work now.
| |
331 languagesTemplate.content.querySelector(".button-add span").textContent = bu ttonText; | 326 languagesTemplate.content.querySelector(".button-add span").textContent = bu ttonText; |
332 | 327 |
333 updateShareLink(); | 328 updateShareLink(); |
334 populateLists(); | 329 populateLists(); |
335 | 330 |
336 var tabList = document.querySelectorAll("#main-navigation-tabs li"); | 331 var tabList = document.querySelectorAll("#main-navigation-tabs li"); |
337 for (var i = 0; i < tabList.length; i++) | 332 for (var i = 0; i < tabList.length; i++) |
338 { | 333 { |
339 tabList[i].addEventListener("click", function(e) | 334 tabList[i].addEventListener("click", function(e) |
340 { | 335 { |
341 document.body.dataset.tab = e.currentTarget.dataset.show; | 336 document.body.dataset.tab = e.currentTarget.dataset.show; |
342 }, false); | 337 }, false); |
343 } | 338 } |
344 | 339 |
345 function searchLanguage() | 340 function onFindLanguageKeyUp() |
346 { | 341 { |
347 var searchStyle = E("search-style"); | 342 var searchStyle = E("search-style"); |
348 if (!this.value) | 343 if (!this.value) |
349 searchStyle.innerHTML = ""; | 344 searchStyle.innerHTML = ""; |
350 else | 345 else |
351 searchStyle.innerHTML = "#all-lang-table li:not([data-search*=\"" + this .value.toLowerCase() + "\"]) { display: none; }"; | 346 searchStyle.innerHTML = "#all-lang-table li:not([data-search*=\"" + this .value.toLowerCase() + "\"]) { display: none; }"; |
352 } | 347 } |
353 | 348 |
354 // Update version number in navigation sidebar | 349 // Update version number in navigation sidebar |
355 ext.backgroundPage.sendMessage( | 350 ext.backgroundPage.sendMessage( |
356 { | 351 { |
357 method: "app.get", | 352 method: "app.get", |
358 what: "addonVersion" | 353 what: "addonVersion" |
359 }, | 354 }, |
360 function(addonVersion) | 355 function(addonVersion) |
361 { | 356 { |
362 E("abp-version").textContent = addonVersion; | 357 E("abp-version").textContent = addonVersion; |
363 }); | 358 }); |
364 | 359 |
365 var placeholderValue = ext.i18n.getMessage("options_modal_language_find"); | 360 var placeholderValue = ext.i18n.getMessage("options_dialog_language_find"); |
366 E("find-language").setAttribute("placeholder", placeholderValue); | 361 E("find-language").setAttribute("placeholder", placeholderValue); |
367 E("add-blocking-list").addEventListener("click", function() | 362 E("add-blocking-list").addEventListener("click", function() |
368 { | 363 { |
369 openModal("customlist"); | 364 openDialog("customlist"); |
370 }, false); | 365 }, false); |
371 E("add-website-language").addEventListener("click", function() | 366 E("add-website-language").addEventListener("click", function() |
372 { | 367 { |
373 openModal("language"); | 368 openDialog("language"); |
374 }, false); | 369 }, false); |
375 E("modal-close").addEventListener("click", function() | 370 E("dialog-close").addEventListener("click", function() |
376 { | 371 { |
377 delete document.body.dataset.modal; | 372 delete document.body.dataset.dialog; |
378 }, false); | 373 }, false); |
379 E("edit-ownBlockingList-button").addEventListener("click", editCustomFilters , false); | 374 E("edit-ownBlockingList-button").addEventListener("click", editCustomFilters , false); |
380 E("find-language").addEventListener("keyup", searchLanguage, false); | 375 E("find-language").addEventListener("keyup", onFindLanguageKeyUp, false); |
381 E("find-language").addEventListener("search", searchLanguage, false); | |
382 E("whitelisting").addEventListener("click", function(e) | 376 E("whitelisting").addEventListener("click", function(e) |
383 { | 377 { |
384 var id = e.target.id; | 378 var id = e.target.id; |
385 if (id == "whitelisting-add-icon" || id == "whitelisting-enter-icon") | 379 if (id == "whitelisting-add-icon" || id == "whitelisting-enter-icon") |
386 addWhitelistedDomain(); | 380 addWhitelistedDomain(); |
387 else if (id == "whitelisting-cancel-button") | 381 else if (id == "whitelisting-cancel-button") |
388 E("whitelisting-textbox").value = ""; | 382 E("whitelisting-textbox").value = ""; |
389 }, false); | 383 }, false); |
390 E("whitelisting-add-button").addEventListener("click", addWhitelistedDomain, false); | 384 E("whitelisting-add-button").addEventListener("click", addWhitelistedDomain, false); |
391 E("whitelisting-textbox").addEventListener("keypress", function(e) | 385 E("whitelisting-textbox").addEventListener("keypress", function(e) |
392 { | 386 { |
393 // e.keyCode has been deprecated so we use e.key instead | 387 // e.keyCode has been deprecated so we attempt to use e.key |
394 if (e.key && e.key == "Enter") | 388 // keyCode "13" corresponds to "Enter" |
395 addWhitelistedDomain(); | 389 if ((e.key && e.key == "Enter") || (!e.key && e.keyCode == 13)) |
396 else if (!e.key && e.keyCode == 13) //keyCode "13" corresponds to "Enter" | |
397 addWhitelistedDomain(); | 390 addWhitelistedDomain(); |
398 }, false); | 391 }, false); |
399 E("import-blockingList-button").addEventListener("click", function() | 392 E("import-blockingList-button").addEventListener("click", function() |
400 { | 393 { |
401 var url = E("blockingList-textbox").value; | 394 var url = E("blockingList-textbox").value; |
402 addEnableSubscription(url); | 395 addEnableSubscription(url); |
403 delete document.body.dataset.modal; | 396 delete document.body.dataset.dialog; |
404 }, false); | 397 }, false); |
405 } | 398 } |
406 | 399 |
407 function openModal(name) | 400 function openDialog(name) |
408 { | 401 { |
409 document.body.dataset.modal = name; | 402 document.body.dataset.dialog = name; |
410 } | 403 } |
411 | 404 |
412 function populateLists() | 405 function populateLists() |
413 { | 406 { |
414 subscriptionsMap = Object.create(null); | 407 subscriptionsMap = Object.create(null); |
415 filtersMap = Object.create(null); | 408 filtersMap = Object.create(null); |
416 recommendationsMap = Object.create(null); | 409 recommendationsMap = Object.create(null); |
417 | 410 |
418 // Empty collections and lists | 411 // Empty collections and lists |
419 for (var property in collections) | 412 for (var property in collections) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 type: "filters.add", | 467 type: "filters.add", |
475 text: "@@||" + domain.value.toLowerCase() + "^$document" | 468 text: "@@||" + domain.value.toLowerCase() + "^$document" |
476 }); | 469 }); |
477 } | 470 } |
478 | 471 |
479 domain.value = ""; | 472 domain.value = ""; |
480 } | 473 } |
481 | 474 |
482 function editCustomFilters() | 475 function editCustomFilters() |
483 { | 476 { |
484 | 477 //TODO: NYI |
485 } | 478 } |
486 | 479 |
487 function getAcceptableAdsURL(callback) | 480 function getAcceptableAdsURL(callback) |
488 { | 481 { |
489 ext.backgroundPage.sendMessage( | 482 ext.backgroundPage.sendMessage( |
490 { | 483 { |
491 type: "prefs.get", | 484 type: "prefs.get", |
492 key: "subscriptions_exceptionsurl" | 485 key: "subscriptions_exceptionsurl" |
493 }, | 486 }, |
494 function(value) | 487 function(value) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 updateShareLink(); | 551 updateShareLink(); |
559 break; | 552 break; |
560 } | 553 } |
561 } | 554 } |
562 | 555 |
563 function onSubscriptionMessage(action, subscription) | 556 function onSubscriptionMessage(action, subscription) |
564 { | 557 { |
565 switch (action) | 558 switch (action) |
566 { | 559 { |
567 case "added": | 560 case "added": |
568 updateSubscription(subscription); | |
569 updateShareLink(); | |
570 break; | |
571 case "disabled": | 561 case "disabled": |
572 updateSubscription(subscription); | 562 updateSubscription(subscription); |
573 updateShareLink(); | 563 updateShareLink(); |
574 break; | 564 break; |
575 case "homepage": | 565 case "homepage": |
576 // TODO: NYI | 566 // TODO: NYI |
577 break; | 567 break; |
578 case "removed": | 568 case "removed": |
579 getAcceptableAdsURL(function(acceptableAdsUrl) | 569 getAcceptableAdsURL(function(acceptableAdsUrl) |
580 { | 570 { |
(...skipping 18 matching lines...) Expand all Loading... | |
599 break; | 589 break; |
600 case "title": | 590 case "title": |
601 // TODO: NYI | 591 // TODO: NYI |
602 break; | 592 break; |
603 } | 593 } |
604 } | 594 } |
605 | 595 |
606 function showAddSubscriptionDialog(subscription) | 596 function showAddSubscriptionDialog(subscription) |
607 { | 597 { |
608 E("blockingList-textbox").value = subscription.url; | 598 E("blockingList-textbox").value = subscription.url; |
609 openModal("customlist"); | 599 openDialog("customlist"); |
610 } | 600 } |
611 | 601 |
612 function updateShareLink() | 602 function updateShareLink() |
613 { | 603 { |
614 ext.backgroundPage.sendMessage( | 604 ext.backgroundPage.sendMessage( |
615 { | 605 { |
616 type: "filters.blocked", | 606 type: "filters.blocked", |
617 url: "https://platform.twitter.com/widgets/", | 607 url: "https://platform.twitter.com/widgets/", |
618 requestType: "SCRIPT", | 608 requestType: "SCRIPT", |
619 docDomain: "adblockplus.org", | 609 docDomain: "adblockplus.org", |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 filter: ["added", "loaded", "removed"] | 648 filter: ["added", "loaded", "removed"] |
659 }); | 649 }); |
660 ext.backgroundPage.sendMessage( | 650 ext.backgroundPage.sendMessage( |
661 { | 651 { |
662 type: "subscriptions.listen", | 652 type: "subscriptions.listen", |
663 filter: ["added", "disabled", "homepage", "removed", "title"] | 653 filter: ["added", "disabled", "homepage", "removed", "title"] |
664 }); | 654 }); |
665 | 655 |
666 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 656 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
667 })(); | 657 })(); |
LEFT | RIGHT |