Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/prefs.js

Issue 5740786045943808: Issue 189 - Implement API changes from #117, #153, #192 in libadblockplus (Closed)
Patch Set: Created April 14, 2014, 9:14 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/init.js ('K') | « lib/io.js ('k') | lib/utils.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 { 54 {
55 if (typeof value != typeof defaults[key]) 55 if (typeof value != typeof defaults[key])
56 throw new Error("Attempt to change preference type"); 56 throw new Error("Attempt to change preference type");
57 57
58 if (value == defaults[key]) 58 if (value == defaults[key])
59 delete values[key]; 59 delete values[key];
60 else 60 else
61 values[key] = value; 61 values[key] = value;
62 save(); 62 save();
63 63
64 for each (let listener in listeners) 64 for (let listener of listeners)
65 listener(key); 65 listener(key);
66 }); 66 });
67 } 67 }
68 68
69 function load() 69 function load()
70 { 70 {
71 _fileSystem.read(path, function(result) 71 _fileSystem.read(path, function(result)
72 { 72 {
73 // prefs.json is expected to be missing, ignore errors reading file 73 // prefs.json is expected to be missing, ignore errors reading file
74 if (!result.error) 74 if (!result.error)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 let index = listeners.indexOf(listener); 121 let index = listeners.indexOf(listener);
122 if (index >= 0) 122 if (index >= 0)
123 listeners.splice(index, 1); 123 listeners.splice(index, 1);
124 }, 124 },
125 }; 125 };
126 126
127 for (let key in defaults) 127 for (let key in defaults)
128 defineProperty(key); 128 defineProperty(key);
129 129
130 load(); 130 load();
OLDNEW
« lib/init.js ('K') | « lib/io.js ('k') | lib/utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld