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 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 { | 88 { |
89 NotificationStorage.toggleIgnoreCategory("*"); | 89 NotificationStorage.toggleIgnoreCategory("*"); |
90 return this.get(); | 90 return this.get(); |
91 } | 91 } |
92 }); | 92 }); |
93 } | 93 } |
94 else | 94 else |
95 document.getElementById("shouldShowNotificationsContainer").hidden = true; | 95 document.getElementById("shouldShowNotificationsContainer").hidden = true; |
96 | 96 |
97 ext.onMessage.addListener(onMessage); | 97 ext.onMessage.addListener(onMessage); |
98 ext.backgroundPage.sendMessage({ | |
99 type: "app.listen", | |
100 filter: ["addSubscription"] | |
101 }); | |
98 | 102 |
99 // Load recommended subscriptions | 103 // Load recommended subscriptions |
100 loadRecommendations(); | 104 loadRecommendations(); |
101 | 105 |
102 // Show user's filters | 106 // Show user's filters |
103 reloadFilters(); | 107 reloadFilters(); |
104 } | 108 } |
105 $(loadOptions); | 109 $(loadOptions); |
106 | 110 |
107 function onMessage(msg) | 111 function onMessage(msg) |
108 { | 112 { |
109 if (msg.type == "add-subscription") | 113 if (msg.type == "app.listen") |
110 startSubscriptionSelection(msg.title, msg.url); | 114 { |
115 if (msg.action == "addSubscription") | |
116 { | |
117 var subscription = msg.args[0]; | |
118 startSubscriptionSelection(subscription.title, subscription.url); | |
119 } | |
120 } | |
111 else if (msg.type == "focus-section") | 121 else if (msg.type == "focus-section") |
112 { | 122 { |
113 var tabs = document.getElementsByClassName("ui-tabs-panel"); | 123 var tabs = document.getElementsByClassName("ui-tabs-panel"); |
114 for (var i = 0; i < tabs.length; i++) | 124 for (var i = 0; i < tabs.length; i++) |
115 { | 125 { |
116 var found = tabs[i].querySelector("[data-section='" + msg.section + "']"); | 126 var found = tabs[i].querySelector("[data-section='" + msg.section + "']"); |
117 if (!found) | 127 if (!found) |
118 continue; | 128 continue; |
119 | 129 |
120 var previous = document.getElementsByClassName("focused"); | 130 var previous = document.getElementsByClassName("focused"); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 var matchCount = 0; | 209 var matchCount = 0; |
200 | 210 |
201 var list = document.getElementById("subscriptionSelector"); | 211 var list = document.getElementById("subscriptionSelector"); |
202 var doc = new DOMParser().parseFromString(text, "application/xml"); | 212 var doc = new DOMParser().parseFromString(text, "application/xml"); |
203 var elements = doc.documentElement.getElementsByTagName("subscription"); | 213 var elements = doc.documentElement.getElementsByTagName("subscription"); |
204 | 214 |
205 for (var i = 0; i < elements.length; i++) | 215 for (var i = 0; i < elements.length; i++) |
206 { | 216 { |
207 var element = elements[i]; | 217 var element = elements[i]; |
208 var option = new Option(); | 218 var option = new Option(); |
209 option.text = element.getAttribute("title") + " (" + element.getAttribut e("specialization") + ")"; | 219 option.text = element.getAttribute("title") + " (" + |
kzar
2016/01/17 17:14:06
Nit: Mind fixing the long lines here as well while
Sebastian Noack
2016/01/19 14:58:10
Done.
| |
220 element.getAttribute("specialization") + ")"; | |
210 option._data = { | 221 option._data = { |
211 title: element.getAttribute("title"), | 222 title: element.getAttribute("title"), |
212 url: element.getAttribute("url"), | 223 url: element.getAttribute("url"), |
213 homepage: element.getAttribute("homepage") | 224 homepage: element.getAttribute("homepage") |
214 }; | 225 }; |
215 | 226 |
216 var prefix = Utils.checkLocalePrefixMatch(element.getAttribute("prefixes ")); | 227 var prefixes = element.getAttribute("prefixes"); |
228 var prefix = Utils.checkLocalePrefixMatch(prefixes); | |
217 if (prefix) | 229 if (prefix) |
218 { | 230 { |
219 option.style.fontWeight = "bold"; | 231 option.style.fontWeight = "bold"; |
220 option.style.backgroundColor = "#E0FFE0"; | 232 option.style.backgroundColor = "#E0FFE0"; |
221 option.style.color = "#000000"; | 233 option.style.color = "#000000"; |
222 if (!selectedPrefix || selectedPrefix.length < prefix.length) | 234 if (!selectedPrefix || selectedPrefix.length < prefix.length) |
223 { | 235 { |
224 selectedIndex = i; | 236 selectedIndex = i; |
225 selectedPrefix = prefix; | 237 selectedPrefix = prefix; |
226 matchCount = 1; | 238 matchCount = 1; |
(...skipping 10 matching lines...) Expand all Loading... | |
237 { | 249 { |
238 selectedIndex = i; | 250 selectedIndex = i; |
239 selectedPrefix = prefix; | 251 selectedPrefix = prefix; |
240 } | 252 } |
241 } | 253 } |
242 } | 254 } |
243 list.appendChild(option); | 255 list.appendChild(option); |
244 } | 256 } |
245 | 257 |
246 var option = new Option(); | 258 var option = new Option(); |
247 option.text = i18n.getMessage("filters_addSubscriptionOther_label") + "\u2 026"; | 259 var label = i18n.getMessage("filters_addSubscriptionOther_label"); |
260 option.text = label + "\u2026"; | |
248 option._data = null; | 261 option._data = null; |
249 list.appendChild(option); | 262 list.appendChild(option); |
250 | 263 |
251 list.selectedIndex = selectedIndex; | 264 list.selectedIndex = selectedIndex; |
252 | 265 |
253 if (delayedSubscriptionSelection) | 266 if (delayedSubscriptionSelection) |
254 startSubscriptionSelection.apply(null, delayedSubscriptionSelection); | 267 startSubscriptionSelection.apply(null, delayedSubscriptionSelection); |
255 }); | 268 }); |
256 } | 269 } |
257 | 270 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
686 links[i].href = arguments[i + 1]; | 699 links[i].href = arguments[i + 1]; |
687 links[i].setAttribute("target", "_blank"); | 700 links[i].setAttribute("target", "_blank"); |
688 } | 701 } |
689 else if (typeof arguments[i + 1] == "function") | 702 else if (typeof arguments[i + 1] == "function") |
690 { | 703 { |
691 links[i].href = "javascript:void(0);"; | 704 links[i].href = "javascript:void(0);"; |
692 links[i].addEventListener("click", arguments[i + 1], false); | 705 links[i].addEventListener("click", arguments[i + 1], false); |
693 } | 706 } |
694 } | 707 } |
695 } | 708 } |
LEFT | RIGHT |