| 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-2013 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 | 
|   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the |   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|   12  * GNU General Public License for more details. |   12  * GNU General Public License for more details. | 
|   13  * |   13  * | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|   24   enabled: true, |   24   enabled: true, | 
|   25   data_directory: "", |   25   data_directory: "", | 
|   26   patternsbackups: 5, |   26   patternsbackups: 5, | 
|   27   patternsbackupinterval: 24, |   27   patternsbackupinterval: 24, | 
|   28   savestats: false, |   28   savestats: false, | 
|   29   privateBrowsing: false, |   29   privateBrowsing: false, | 
|   30   subscriptions_fallbackerrors: 5, |   30   subscriptions_fallbackerrors: 5, | 
|   31   subscriptions_fallbackurl: "https://adblockplus.org/getSubscription?version=%V
     ERSION%&url=%SUBSCRIPTION%&downloadURL=%URL%&error=%ERROR%&channelStatus=%CHANNE
     LSTATUS%&responseStatus=%RESPONSESTATUS%", |   31   subscriptions_fallbackurl: "https://adblockplus.org/getSubscription?version=%V
     ERSION%&url=%SUBSCRIPTION%&downloadURL=%URL%&error=%ERROR%&channelStatus=%CHANNE
     LSTATUS%&responseStatus=%RESPONSESTATUS%", | 
|   32   subscriptions_autoupdate: true, |   32   subscriptions_autoupdate: true, | 
|   33   subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/excep
     tionrules.txt", |   33   subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/excep
     tionrules.txt", | 
 |   34   subscriptions_antiadblockurl: "https://easylist-downloads.adblockplus.org/anti
     adblockfilters.txt", | 
|   34   documentation_link: "https://adblockplus.org/redirect?link=%LINK%&lang=%LANG%"
     , |   35   documentation_link: "https://adblockplus.org/redirect?link=%LINK%&lang=%LANG%"
     , | 
|   35   notificationdata: {}, |   36   notificationdata: {}, | 
|   36   notificationurl: "https://notification.adblockplus.org/notification.json", |   37   notificationurl: "https://notification.adblockplus.org/notification.json", | 
|   37   stats_total: {}, |   38   stats_total: {}, | 
|   38   show_statsinicon: true, |   39   show_statsinicon: true, | 
|   39   show_statsinpopup: true |   40   show_statsinpopup: true, | 
 |   41   shouldShowBlockElementMenu: true, | 
 |   42   hidePlaceholders: true | 
|   40 }; |   43 }; | 
|   41  |   44  | 
|   42 let listeners = []; |   45 let listeners = []; | 
|   43  |   46  | 
|   44 function defineProperty(key) |   47 function defineProperty(key) | 
|   45 { |   48 { | 
|   46   let value = null; |   49   let value = null; | 
|   47   Prefs.__defineGetter__(key, function() |   50   Prefs.__defineGetter__(key, function() | 
|   48   { |   51   { | 
|   49     if (value === null) |   52     if (value === null) | 
|   50     { |   53     { | 
|   51       if (key in localStorage) |   54       if (key in ext.storage) | 
|   52       { |   55       { | 
|   53         try |   56         try | 
|   54         { |   57         { | 
|   55           value = JSON.parse(localStorage[key]); |   58           value = JSON.parse(ext.storage[key]); | 
|   56         } |   59         } | 
|   57         catch(e) |   60         catch(e) | 
|   58         { |   61         { | 
|   59           Cu.reportError(e); |   62           Cu.reportError(e); | 
|   60         } |   63         } | 
|   61       } |   64       } | 
|   62  |   65  | 
|   63       if (value === null) |   66       if (value === null) | 
|   64         value = JSON.parse(JSON.stringify(defaults[key])); |   67         value = JSON.parse(JSON.stringify(defaults[key])); | 
|   65     } |   68     } | 
|   66     return value; |   69     return value; | 
|   67   }); |   70   }); | 
|   68   Prefs.__defineSetter__(key, function(newValue) |   71   Prefs.__defineSetter__(key, function(newValue) | 
|   69   { |   72   { | 
|   70     if (typeof newValue != typeof defaults[key]) |   73     if (typeof newValue != typeof defaults[key]) | 
|   71       throw new Error("Attempt to change preference type"); |   74       throw new Error("Attempt to change preference type"); | 
|   72  |   75  | 
|   73     let stringified = JSON.stringify(newValue); |   76     let stringified = JSON.stringify(newValue); | 
|   74     if (stringified != JSON.stringify(defaults[key])) |   77     if (stringified != JSON.stringify(defaults[key])) | 
|   75       localStorage[key] = stringified; |   78       ext.storage[key] = stringified; | 
|   76     else |   79     else | 
|   77       delete localStorage[key]; |   80       delete ext.storage[key]; | 
|   78  |   81  | 
|   79     value = newValue; |   82     value = newValue; | 
|   80  |   83  | 
|   81     for each (let listener in listeners) |   84     for (let listener of listeners) | 
|   82       listener(key); |   85       listener(key); | 
|   83  |   86  | 
|   84     return value; |   87     return value; | 
|   85   }); |   88   }); | 
|   86 } |   89 } | 
|   87  |   90  | 
|   88  |   91  | 
|   89 let Prefs = exports.Prefs = { |   92 let Prefs = exports.Prefs = { | 
|   90   addListener: function(listener) |   93   addListener: function(listener) | 
|   91   { |   94   { | 
|   92     if (listeners.indexOf(listener) < 0) |   95     if (listeners.indexOf(listener) < 0) | 
|   93       listeners.push(listener); |   96       listeners.push(listener); | 
|   94   }, |   97   }, | 
|   95  |   98  | 
|   96   removeListener: function(listener) |   99   removeListener: function(listener) | 
|   97   { |  100   { | 
|   98     let index = listeners.indexOf(listener); |  101     let index = listeners.indexOf(listener); | 
|   99     if (index >= 0) |  102     if (index >= 0) | 
|  100       listeners.splice(index, 1); |  103       listeners.splice(index, 1); | 
|  101   }, |  104   }, | 
|  102 }; |  105 }; | 
|  103  |  106  | 
|  104 for (let key in defaults) |  107 for (let key in defaults) | 
|  105   defineProperty(key); |  108   defineProperty(key); | 
| OLD | NEW |