| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 throw new Error("Attempt to change preference type"); | 74 throw new Error("Attempt to change preference type"); |
| 75 | 75 |
| 76 let stringified = JSON.stringify(newValue); | 76 let stringified = JSON.stringify(newValue); |
| 77 if (stringified != JSON.stringify(defaults[key])) | 77 if (stringified != JSON.stringify(defaults[key])) |
| 78 ext.storage[key] = stringified; | 78 ext.storage[key] = stringified; |
| 79 else | 79 else |
| 80 delete ext.storage[key]; | 80 delete ext.storage[key]; |
| 81 | 81 |
| 82 value = newValue; | 82 value = newValue; |
| 83 | 83 |
| 84 for each (let listener in listeners) | 84 for (let listener of listeners) |
| 85 listener(key); | 85 listener(key); |
| 86 | 86 |
| 87 return value; | 87 return value; |
| 88 }); | 88 }); |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 let Prefs = exports.Prefs = { | 92 let Prefs = exports.Prefs = { |
| 93 addListener: function(listener) | 93 addListener: function(listener) |
| 94 { | 94 { |
| 95 if (listeners.indexOf(listener) < 0) | 95 if (listeners.indexOf(listener) < 0) |
| 96 listeners.push(listener); | 96 listeners.push(listener); |
| 97 }, | 97 }, |
| 98 | 98 |
| 99 removeListener: function(listener) | 99 removeListener: function(listener) |
| 100 { | 100 { |
| 101 let index = listeners.indexOf(listener); | 101 let index = listeners.indexOf(listener); |
| 102 if (index >= 0) | 102 if (index >= 0) |
| 103 listeners.splice(index, 1); | 103 listeners.splice(index, 1); |
| 104 }, | 104 }, |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 for (let key in defaults) | 107 for (let key in defaults) |
| 108 defineProperty(key); | 108 defineProperty(key); |
| OLD | NEW |