| 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 10 matching lines...) Expand all Loading... | |
| 21 var Subscription = require("subscriptionClasses").Subscription; | 21 var Subscription = require("subscriptionClasses").Subscription; |
| 22 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription; | 22 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription; |
| 23 var FilterStorage = require("filterStorage").FilterStorage; | 23 var FilterStorage = require("filterStorage").FilterStorage; |
| 24 var defaultMatcher = require("matcher").defaultMatcher; | 24 var defaultMatcher = require("matcher").defaultMatcher; |
| 25 var ElemHide = require("elemHide").ElemHide; | 25 var ElemHide = require("elemHide").ElemHide; |
| 26 var Synchronizer = require("synchronizer").Synchronizer; | 26 var Synchronizer = require("synchronizer").Synchronizer; |
| 27 var Prefs = require("prefs").Prefs; | 27 var Prefs = require("prefs").Prefs; |
| 28 var checkForUpdates = require("updater").checkForUpdates; | 28 var checkForUpdates = require("updater").checkForUpdates; |
| 29 var Notification = require("notification").Notification; | 29 var Notification = require("notification").Notification; |
| 30 | 30 |
| 31 // returns first element of the array that satifies predicate. | |
|
sergei
2016/12/02 16:36:06
Should I move it into utils.js or extend Array.pro
sergei
2016/12/02 16:38:02
I meant extend in compat.js.
The link is https://
Eric
2016/12/05 14:40:58
At the point of use, it would be better to use the
sergei
2017/03/17 15:55:25
Done.
| |
| 32 var find = function (array, pred) { | |
| 33 for (var i = 0; i < array.length; ++i) | |
| 34 if (pred(array[i])) | |
| 35 return array[i]; | |
| 36 }; | |
| 37 | |
| 31 return { | 38 return { |
| 32 getFilterFromText: function(text) | 39 getFilterFromText: function(text) |
| 33 { | 40 { |
| 34 text = Filter.normalize(text); | 41 text = Filter.normalize(text); |
| 35 if (!text) | 42 if (!text) |
| 36 throw "Attempted to create a filter from empty text"; | 43 throw "Attempted to create a filter from empty text"; |
| 37 return Filter.fromText(text); | 44 return Filter.fromText(text); |
| 38 }, | 45 }, |
| 39 | 46 |
| 40 isListedFilter: function(filter) | 47 isListedFilter: function(filter) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 | 137 |
| 131 // These aren't normally properties of a Subscription object | 138 // These aren't normally properties of a Subscription object |
| 132 subscription.author = subscriptions[i].author; | 139 subscription.author = subscriptions[i].author; |
| 133 subscription.prefixes = subscriptions[i].prefixes; | 140 subscription.prefixes = subscriptions[i].prefixes; |
| 134 subscription.specialization = subscriptions[i].specialization; | 141 subscription.specialization = subscriptions[i].specialization; |
| 135 result.push(subscription); | 142 result.push(subscription); |
| 136 } | 143 } |
| 137 return result; | 144 return result; |
| 138 }, | 145 }, |
| 139 | 146 |
| 147 isAASubscription: function(subscription) | |
| 148 { | |
| 149 return subscription.url == Prefs.subscriptions_exceptionsurl; | |
| 150 }, | |
| 151 | |
| 152 setAASubscriptionEnabled: function (enabled) | |
|
Eric
2016/12/05 14:40:58
Nit: extra space after 'function'
sergei
2017/03/17 15:55:25
Done.
| |
| 153 { | |
| 154 var aaSubscription = find(FilterStorage.subscriptions, API.isAASubscriptio n); | |
|
Eric
2016/12/05 14:40:58
See comment on line 173
| |
| 155 if (!enabled) | |
| 156 { | |
| 157 if (aaSubscription && !aaSubscription.disabled) | |
| 158 aaSubscription.disabled = true; | |
| 159 return; | |
| 160 } | |
| 161 if (!aaSubscription) { | |
| 162 aaSubscription = Subscription.fromURL(Prefs.subscriptions_exceptionsurl) ; | |
| 163 FilterStorage.addSubscription(aaSubscription); | |
| 164 } | |
| 165 if (aaSubscription.disabled) | |
| 166 aaSubscription.disabled = false; | |
| 167 if (!aaSubscription.lastDownload) | |
| 168 Synchronizer.execute(aaSubscription); | |
| 169 }, | |
| 170 | |
| 171 isAASubscriptionEnabled: function() | |
| 172 { | |
| 173 var aaSubscription = find(FilterStorage.subscriptions, API.isAASubscriptio n); | |
|
Eric
2016/12/05 14:40:58
Also see comment on line 154.
With the above line
sergei
2017/03/17 15:55:25
I would like to avoid augmenting of FilterStorage
| |
| 174 return aaSubscription && !aaSubscription.disabled; | |
| 175 }, | |
| 176 | |
| 140 showNextNotification: function(url) | 177 showNextNotification: function(url) |
| 141 { | 178 { |
| 142 Notification.showNext(url); | 179 Notification.showNext(url); |
| 143 }, | 180 }, |
| 144 | 181 |
| 145 getNotificationTexts: function(notification) | 182 getNotificationTexts: function(notification) |
| 146 { | 183 { |
| 147 return Notification.getLocalizedTexts(notification); | 184 return Notification.getLocalizedTexts(notification); |
| 148 }, | 185 }, |
| 149 | 186 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 174 Prefs[pref] = value; | 211 Prefs[pref] = value; |
| 175 }, | 212 }, |
| 176 | 213 |
| 177 forceUpdateCheck: function(eventName) | 214 forceUpdateCheck: function(eventName) |
| 178 { | 215 { |
| 179 checkForUpdates(_triggerEvent.bind(null, eventName)); | 216 checkForUpdates(_triggerEvent.bind(null, eventName)); |
| 180 }, | 217 }, |
| 181 | 218 |
| 182 getHostFromUrl: function(url) | 219 getHostFromUrl: function(url) |
| 183 { | 220 { |
| 184 return extractHostFromURL(url); | 221 return extractHostFromURL(url); |
| 185 }, | 222 }, |
| 186 | 223 |
| 187 compareVersions: function(v1, v2) | 224 compareVersions: function(v1, v2) |
| 188 { | 225 { |
| 189 return Services.vc.compare(v1, v2); | 226 return Services.vc.compare(v1, v2); |
| 190 } | 227 } |
| 191 }; | 228 }; |
| 192 })(); | 229 })(); |
| OLD | NEW |