More bulk.

This commit is contained in:
Zixaphir 2014-01-14 02:35:11 -07:00
parent 91f1154296
commit 82646724e5
3 changed files with 75 additions and 60 deletions

View File

@ -13143,11 +13143,12 @@
return Settings.open("Mascots");
},
importMascot: function() {
var file, reader;
var file, len, reader;
file = this.files[0];
reader = new FileReader();
reader.onload = function(e) {
var err, mascot, mascots, message, name, _i, _len;
len = Conf["Deleted Mascots"].length;
reader.onload = function() {
var err, mascots;
try {
mascots = JSON.parse(e.target.result);
} catch (_error) {
@ -13155,24 +13156,35 @@
alert(err);
return;
}
if (name = mascots["Mascot"]) {
MascotTools.parse(mascots);
message = "" + name + " successfully imported!";
} else if (mascots.length) {
for (_i = 0, _len = mascots.length; _i < _len; _i++) {
mascot = mascots[_i];
MascotTools.parse(mascot);
$.get("userMascots", {}, function(_arg) {
var mascot, message, name, userMascots, _i, _len;
userMascots = _arg.userMascots;
if (name = mascots["Mascot"]) {
MascotTools.parse(mascots, userMascots);
return message = "" + name + " successfully imported!";
} else if (mascots.length) {
for (_i = 0, _len = mascots.length; _i < _len; _i++) {
mascot = mascots[_i];
MascotTools.parse(mascot, userMascots);
}
return message = "Mascots imported!";
} else {
return new Notice('warning', "Failed to import mascot. Is file a properly formatted JSON file?", 5);
}
message = "Mascots imported!";
} else {
return new Notice('warning', "Failed to import mascot. Is file a properly formatted JSON file?", 5);
});
$.set('userMascots', userMascots);
if (len !== Conf["Deleted Mascots"].length) {
$.set('Deleted Mascots', Conf['Deleted Mascots']);
}
new Notice('info', message, 10);
return Settings.open('Mascots');
return Settings.openSection.call({
open: Settings.mascots,
hyphenatedTitle: 'mascots'
});
};
return reader.readAsText(file);
},
parse: function(mascot) {
parse: function(mascot, userMascots) {
var name;
if (!(name = mascot["Mascot"])) {
new Notice('warning', "Failed to import a mascot. Mascot has no name.", 5);
@ -13184,13 +13196,7 @@
return;
}
}
Mascots[name] = mascot;
return $.get("userMascots", {}, function(_arg) {
var userMascots;
userMascots = _arg.userMascots;
userMascots[name] = Mascots[name];
return $.set('userMascots', userMascots);
});
return userMascots[name] = Mascots[name] = mascot;
},
position: function(mascot) {
if (!Style.sheets.mascots) {

View File

@ -13132,11 +13132,12 @@
return Settings.open("Mascots");
},
importMascot: function() {
var file, reader;
var file, len, reader;
file = this.files[0];
reader = new FileReader();
reader.onload = function(e) {
var err, mascot, mascots, message, name, _i, _len;
len = Conf["Deleted Mascots"].length;
reader.onload = function() {
var err, mascots;
try {
mascots = JSON.parse(e.target.result);
} catch (_error) {
@ -13144,24 +13145,35 @@
alert(err);
return;
}
if (name = mascots["Mascot"]) {
MascotTools.parse(mascots);
message = "" + name + " successfully imported!";
} else if (mascots.length) {
for (_i = 0, _len = mascots.length; _i < _len; _i++) {
mascot = mascots[_i];
MascotTools.parse(mascot);
$.get("userMascots", {}, function(_arg) {
var mascot, message, name, userMascots, _i, _len;
userMascots = _arg.userMascots;
if (name = mascots["Mascot"]) {
MascotTools.parse(mascots, userMascots);
return message = "" + name + " successfully imported!";
} else if (mascots.length) {
for (_i = 0, _len = mascots.length; _i < _len; _i++) {
mascot = mascots[_i];
MascotTools.parse(mascot, userMascots);
}
return message = "Mascots imported!";
} else {
return new Notice('warning', "Failed to import mascot. Is file a properly formatted JSON file?", 5);
}
message = "Mascots imported!";
} else {
return new Notice('warning', "Failed to import mascot. Is file a properly formatted JSON file?", 5);
});
$.set('userMascots', userMascots);
if (len !== Conf["Deleted Mascots"].length) {
$.set('Deleted Mascots', Conf['Deleted Mascots']);
}
new Notice('info', message, 10);
return Settings.open('Mascots');
return Settings.openSection.call({
open: Settings.mascots,
hyphenatedTitle: 'mascots'
});
};
return reader.readAsText(file);
},
parse: function(mascot) {
parse: function(mascot, userMascots) {
var name;
if (!(name = mascot["Mascot"])) {
new Notice('warning', "Failed to import a mascot. Mascot has no name.", 5);
@ -13173,13 +13185,7 @@
return;
}
}
Mascots[name] = mascot;
return $.get("userMascots", {}, function(_arg) {
var userMascots;
userMascots = _arg.userMascots;
userMascots[name] = Mascots[name];
return $.set('userMascots', userMascots);
});
return userMascots[name] = Mascots[name] = mascot;
},
position: function(mascot) {
if (!Style.sheets.mascots) {

View File

@ -337,30 +337,37 @@ MascotTools =
importMascot: ->
file = @files[0]
reader = new FileReader()
len = Conf["Deleted Mascots"].length
reader.onload = (e) ->
reader.onload = ->
try
mascots = JSON.parse e.target.result
catch err
alert err
return
if name = mascots["Mascot"]
MascotTools.parse mascots
message = "#{name} successfully imported!"
else if mascots.length
MascotTools.parse mascot for mascot in mascots
message = "Mascots imported!"
else
return new Notice 'warning', "Failed to import mascot. Is file a properly formatted JSON file?", 5
$.get "userMascots", {}, ({userMascots}) ->
if name = mascots["Mascot"]
MascotTools.parse mascots, userMascots
message = "#{name} successfully imported!"
else if mascots.length
MascotTools.parse mascot, userMascots for mascot in mascots
message = "Mascots imported!"
else
return new Notice 'warning', "Failed to import mascot. Is file a properly formatted JSON file?", 5
$.set 'userMascots', userMascots
$.set 'Deleted Mascots', Conf['Deleted Mascots'] unless len is Conf["Deleted Mascots"].length
new Notice 'info', message, 10
Settings.open 'Mascots'
Settings.openSection.call
open: Settings.mascots
hyphenatedTitle: 'mascots'
reader.readAsText file
parse: (mascot) ->
parse: (mascot, userMascots) ->
unless name = mascot["Mascot"]
new Notice 'warning', "Failed to import a mascot. Mascot has no name.", 5
return
@ -370,11 +377,7 @@ MascotTools =
if Mascots[name] and not $.remove Conf["Deleted Mascots"], name
return unless confirm "The mascot #{name} already exists? Would you like to overwrite it?"
Mascots[name] = mascot
$.get "userMascots", {}, ({userMascots}) ->
userMascots[name] = Mascots[name]
$.set 'userMascots', userMascots
userMascots[name] = Mascots[name] = mascot
position: (mascot) ->
return unless Style.sheets.mascots