| 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-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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 let values = Object.create(defaults); | 47 let values = Object.create(defaults); |
| 48 let path = _fileSystem.resolve("prefs.json"); | 48 let path = _fileSystem.resolve("prefs.json"); |
| 49 let listeners = []; | 49 let listeners = []; |
| 50 let isDirty = false; | 50 let isDirty = false; |
| 51 let isSaving = false; | 51 let isSaving = false; |
| 52 | 52 |
| 53 function defineProperty(key) | 53 function defineProperty(key) |
| 54 { | 54 { |
| 55 Prefs.__defineGetter__(key, function() values[key]); | 55 Prefs.__defineGetter__(key, function() { return values[key] }); |
|
Felix Dahlke
2015/04/29 16:47:38
Had to change this - jshydra doesn't handle functi
Wladimir Palant
2015/04/29 17:42:57
Why not change it into |() => values[key]|? Note t
Felix Dahlke
2015/04/30 05:06:11
Done.
| |
| 56 Prefs.__defineSetter__(key, function(value) | 56 Prefs.__defineSetter__(key, function(value) |
| 57 { | 57 { |
| 58 if (typeof value != typeof defaults[key]) | 58 if (typeof value != typeof defaults[key]) |
| 59 throw new Error("Attempt to change preference type"); | 59 throw new Error("Attempt to change preference type"); |
| 60 | 60 |
| 61 if (value == defaults[key]) | 61 if (value == defaults[key]) |
| 62 delete values[key]; | 62 delete values[key]; |
| 63 else | 63 else |
| 64 values[key] = value; | 64 values[key] = value; |
| 65 save(); | 65 save(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 let index = listeners.indexOf(listener); | 124 let index = listeners.indexOf(listener); |
| 125 if (index >= 0) | 125 if (index >= 0) |
| 126 listeners.splice(index, 1); | 126 listeners.splice(index, 1); |
| 127 }, | 127 }, |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 for (let key in defaults) | 130 for (let key in defaults) |
| 131 defineProperty(key); | 131 defineProperty(key); |
| 132 | 132 |
| 133 load(); | 133 load(); |
| OLD | NEW |