Skip to content

Commit

Permalink
update backbone
Browse files Browse the repository at this point in the history
  • Loading branch information
Quicksaver committed Feb 19, 2016
1 parent 26b08bc commit f5821f5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions resource/modules/utils/preferencesUtils.jsm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// VERSION 2.4.13
// VERSION 2.4.14
Modules.UTILS = true;

// dependsOn - object that adds a dependson attribute functionality to xul preference elements.
Expand Down Expand Up @@ -1039,20 +1039,26 @@ this.controllers = {
},

showFilePicker: function(mode, prefix, aCallback) {
let fileExt = '.json';
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.defaultExtension = 'json';
fp.appendFilter('JSON data', '*.json');

if(mode == Ci.nsIFilePicker.modeSave) {
let date = new Date();
let dateStr = date.getFullYear()+'-'+(date.getMonth() +1)+'-'+date.getDate()+'-'+date.getHours()+'-'+date.getMinutes()+'-'+date.getSeconds();
fp.defaultString = prefix+'-'+dateStr;
fp.defaultString = prefix+'-'+dateStr+fileExt;
}

fp.init(window, null, mode);
fp.open(function(aResult) {
if(aResult != Ci.nsIFilePicker.returnCancel) {
aCallback(fp.file);
let aFile = fp.file;
// We always make sure we're saving a .json text file, so that it can be recognized and loaded by the add-on.
if(mode == Ci.nsIFilePicker.modeSave && !aFile.path.endsWith(fileExt)) {
aFile.initWithPath(aFile.path+fileExt);
}
aCallback(aFile);
}
});
},
Expand Down

0 comments on commit f5821f5

Please sign in to comment.