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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 | 90 |
91 /** | 91 /** |
92 * Called when the Restore menu is being opened, fills in "Automated backup" | 92 * Called when the Restore menu is being opened, fills in "Automated backup" |
93 * entries. | 93 * entries. |
94 */ | 94 */ |
95 fillRestorePopup: function() | 95 fillRestorePopup: function() |
96 { | 96 { |
97 while (this.restoreInsertionPoint.nextSibling && !this.restoreInsertionPoint .nextSibling.id) | 97 while (this.restoreInsertionPoint.nextSibling && !this.restoreInsertionPoint .nextSibling.id) |
98 this.restoreInsertionPoint.parentNode.removeChild(this.restoreInsertionPoi nt.nextSibling); | 98 this.restoreInsertionPoint.parentNode.removeChild(this.restoreInsertionPoi nt.nextSibling); |
99 | 99 |
100 let files = FilterStorage.getBackupFiles().reverse(); | 100 FilterStorage.getBackupFiles().then(backups => |
101 for (let i = 0; i < files.length; i++) | |
102 { | 101 { |
103 let file = files[i]; | 102 backups.reverse(); |
104 let item = this.restoreTemplate.cloneNode(true); | 103 for (let backup of backups) |
105 let label = item.getAttribute("label"); | |
106 label = label.replace(/\?1\?/, Utils.formatTime(file.lastModifiedTime)); | |
107 item.setAttribute("label", label); | |
108 item.addEventListener("command", function() | |
109 { | 104 { |
110 Backup.restoreAllData(file); | 105 let item = this.restoreTemplate.cloneNode(true); |
111 }, false); | 106 let label = item.getAttribute("label"); |
112 this.restoreInsertionPoint.parentNode.insertBefore(item, this.restoreInser tionPoint.nextSibling); | 107 label = label.replace(/\?1\?/, Utils.formatTime(backup.lastModified)); |
113 } | 108 item.setAttribute("label", label); |
109 item.addEventListener("command", function() | |
kzar
2017/03/30 05:45:51
Nit: Any reason not to use an arrow function here?
Wladimir Palant
2017/03/30 10:13:11
I'd rather not make unnecessary changes to this co
| |
110 { | |
111 Backup.restoreAllData(backup.file); | |
112 }, false); | |
113 this.restoreInsertionPoint.parentNode.insertBefore(item, this.restoreIns ertionPoint.nextSibling); | |
kzar
2017/03/30 05:45:51
Nit: Long line.
Wladimir Palant
2017/03/30 10:13:11
Same here, I'd rather not make unnecessary changes
| |
114 } | |
115 }); | |
114 }, | 116 }, |
115 | 117 |
116 /** | 118 /** |
117 * Lets the user choose a file to restore filters from. | 119 * Lets the user choose a file to restore filters from. |
118 */ | 120 */ |
119 restoreFromFile: function() | 121 restoreFromFile: function() |
120 { | 122 { |
121 let picker = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker ); | 123 let picker = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker ); |
122 picker.init(window, E("backupButton").getAttribute("_restoreDialogTitle"), p icker.modeOpen); | 124 picker.init(window, E("backupButton").getAttribute("_restoreDialogTitle"), p icker.modeOpen); |
123 picker.defaultExtension = ".ini"; | 125 picker.defaultExtension = ".ini"; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 Utils.alert(window, E("backupButton").getAttribute("_backupError"), E("b ackupButton").getAttribute("_backupDialogTitle")); | 348 Utils.alert(window, E("backupButton").getAttribute("_backupError"), E("b ackupButton").getAttribute("_backupDialogTitle")); |
347 } | 349 } |
348 }); | 350 }); |
349 } | 351 } |
350 }; | 352 }; |
351 | 353 |
352 window.addEventListener("load", function() | 354 window.addEventListener("load", function() |
353 { | 355 { |
354 Backup.init(); | 356 Backup.init(); |
355 }, false); | 357 }, false); |
OLD | NEW |