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-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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 if (!len) | 228 if (!len) |
229 return; | 229 return; |
230 | 230 |
231 let current = (Math.random() * len) | 0; | 231 let current = (Math.random() * len) | 0; |
232 let step; | 232 let step; |
233 do | 233 do |
234 { | 234 { |
235 step = primes[(Math.random() * primes.length) | 0]; | 235 step = primes[(Math.random() * primes.length) | 0]; |
236 } while (len % step == 0); | 236 } while (len % step == 0); |
237 | 237 |
238 for (let i = 0; i < len; i++, current = (current + step) % len) | 238 for (let i = 0; i < len; i++, current = (current + step) % len) |
kzar
2016/05/24 12:36:49
I didn't intuitively understand that this should w
Wladimir Palant
2016/05/24 12:49:50
That's because 61%6 happens to be 1. On the other
kzar
2016/05/24 12:57:45
Acknowledged.
| |
239 addFilter(filters[current]); | 239 addFilter(filters[current]); |
240 } | 240 } |
241 | 241 |
242 function onSubscriptionAdded(subscription) | 242 function onSubscriptionAdded(subscription) |
243 { | 243 { |
244 FilterListener.setDirty(1); | 244 FilterListener.setDirty(1); |
245 | 245 |
246 if (!subscription.disabled) | 246 if (!subscription.disabled) |
247 { | 247 { |
248 subscription.filters.forEach(addFilter); | 248 addFilters(subscription.filters); |
249 flushElemHide(); | 249 flushElemHide(); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 function onSubscriptionRemoved(subscription) | 253 function onSubscriptionRemoved(subscription) |
254 { | 254 { |
255 FilterListener.setDirty(1); | 255 FilterListener.setDirty(1); |
256 | 256 |
257 if (!subscription.disabled) | 257 if (!subscription.disabled) |
258 { | 258 { |
259 subscription.filters.forEach(removeFilter); | 259 subscription.filters.forEach(removeFilter); |
260 flushElemHide(); | 260 flushElemHide(); |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 function onSubscriptionDisabled(subscription, newValue) | 264 function onSubscriptionDisabled(subscription, newValue) |
265 { | 265 { |
266 FilterListener.setDirty(1); | 266 FilterListener.setDirty(1); |
267 | 267 |
268 if (subscription.url in FilterStorage.knownSubscriptions) | 268 if (subscription.url in FilterStorage.knownSubscriptions) |
269 { | 269 { |
270 if (newValue == false) | 270 if (newValue == false) |
271 subscription.filters.forEach(addFilter); | 271 addFilters(subscription.filters); |
272 else | 272 else |
273 subscription.filters.forEach(removeFilter); | 273 subscription.filters.forEach(removeFilter); |
274 flushElemHide(); | 274 flushElemHide(); |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 function onSubscriptionUpdated(subscription) | 278 function onSubscriptionUpdated(subscription) |
279 { | 279 { |
280 FilterListener.setDirty(1); | 280 FilterListener.setDirty(1); |
281 | 281 |
282 if (subscription.url in FilterStorage.knownSubscriptions && | 282 if (subscription.url in FilterStorage.knownSubscriptions && |
283 !subscription.disabled) | 283 !subscription.disabled) |
284 { | 284 { |
285 subscription.oldFilters.forEach(removeFilter); | 285 subscription.oldFilters.forEach(removeFilter); |
286 subscription.filters.forEach(addFilter); | 286 addFilters(subscription.filters); |
287 flushElemHide(); | 287 flushElemHide(); |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 function onFilterHitCount(filter, newValue) | 291 function onFilterHitCount(filter, newValue) |
292 { | 292 { |
293 if (newValue == 0) | 293 if (newValue == 0) |
294 FilterListener.setDirty(0); | 294 FilterListener.setDirty(0); |
295 else | 295 else |
296 FilterListener.setDirty(0.002); | 296 FilterListener.setDirty(0.002); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 for (let subscription of FilterStorage.subscriptions) | 349 for (let subscription of FilterStorage.subscriptions) |
350 if (!subscription.disabled) | 350 if (!subscription.disabled) |
351 addFilters(subscription.filters); | 351 addFilters(subscription.filters); |
352 flushElemHide(); | 352 flushElemHide(); |
353 } | 353 } |
354 | 354 |
355 function onSave() | 355 function onSave() |
356 { | 356 { |
357 isDirty = 0; | 357 isDirty = 0; |
358 } | 358 } |
LEFT | RIGHT |