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

Side by Side Diff: chrome/content/ui/filters-backup.js

Issue 4831974724206592: Issue 192 - Clean up from #153 (Closed)
Patch Set: Created April 14, 2014, 6:56 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | defaults/patterns.ini » ('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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return; 167 return;
168 168
169 FilterStorage.loadFromDisk(file); 169 FilterStorage.loadFromDisk(file);
170 }, 170 },
171 171
172 /** 172 /**
173 * Restores custom filters from a file. 173 * Restores custom filters from a file.
174 */ 174 */
175 restoreCustomFilters: function(/**nsIFile*/ file) 175 restoreCustomFilters: function(/**nsIFile*/ file)
176 { 176 {
177 IO.readFromFile(file, true, { 177 IO.readFromFile(file, {
178 seenHeader: false, 178 seenHeader: false,
179 subscription: null, 179 subscription: null,
180 process: function(line) 180 process: function(line)
181 { 181 {
182 if (!this.seenHeader) 182 if (!this.seenHeader)
183 { 183 {
184 // This should be a header 184 // This should be a header
185 this.seenHeader = true; 185 this.seenHeader = true;
186 let match = /\[Adblock(?:\s*Plus\s*([\d\.]+)?)?\]/i.exec(line); 186 let match = /\[Adblock(?:\s*Plus\s*([\d\.]+)?)?\]/i.exec(line);
187 if (match) 187 if (match)
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 list.pop(); 324 list.pop();
325 if (checksum) 325 if (checksum)
326 list.splice(1, 0, "! Checksum: " + checksum); 326 list.splice(1, 0, "! Checksum: " + checksum);
327 327
328 function generator() 328 function generator()
329 { 329 {
330 for (let i = 0; i < list.length; i++) 330 for (let i = 0; i < list.length; i++)
331 yield list[i]; 331 yield list[i];
332 } 332 }
333 333
334 IO.writeToFile(file, true, generator(), function(e) 334 IO.writeToFile(file, generator(), function(e)
335 { 335 {
336 if (e) 336 if (e)
337 { 337 {
338 Cu.reportError(e); 338 Cu.reportError(e);
339 Utils.alert(window, E("backupButton").getAttribute("_backupError"), E("b ackupButton").getAttribute("_backupDialogTitle")); 339 Utils.alert(window, E("backupButton").getAttribute("_backupError"), E("b ackupButton").getAttribute("_backupDialogTitle"));
340 } 340 }
341 }); 341 });
342 } 342 }
343 }; 343 };
344 344
345 window.addEventListener("load", function() 345 window.addEventListener("load", function()
346 { 346 {
347 Backup.init(); 347 Backup.init();
348 }, false); 348 }, false);
OLDNEW
« no previous file with comments | « no previous file | defaults/patterns.ini » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld