More bulk.
This commit is contained in:
parent
91f1154296
commit
82646724e5
@ -13143,11 +13143,12 @@
|
|||||||
return Settings.open("Mascots");
|
return Settings.open("Mascots");
|
||||||
},
|
},
|
||||||
importMascot: function() {
|
importMascot: function() {
|
||||||
var file, reader;
|
var file, len, reader;
|
||||||
file = this.files[0];
|
file = this.files[0];
|
||||||
reader = new FileReader();
|
reader = new FileReader();
|
||||||
reader.onload = function(e) {
|
len = Conf["Deleted Mascots"].length;
|
||||||
var err, mascot, mascots, message, name, _i, _len;
|
reader.onload = function() {
|
||||||
|
var err, mascots;
|
||||||
try {
|
try {
|
||||||
mascots = JSON.parse(e.target.result);
|
mascots = JSON.parse(e.target.result);
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
@ -13155,24 +13156,35 @@
|
|||||||
alert(err);
|
alert(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (name = mascots["Mascot"]) {
|
$.get("userMascots", {}, function(_arg) {
|
||||||
MascotTools.parse(mascots);
|
var mascot, message, name, userMascots, _i, _len;
|
||||||
message = "" + name + " successfully imported!";
|
userMascots = _arg.userMascots;
|
||||||
} else if (mascots.length) {
|
if (name = mascots["Mascot"]) {
|
||||||
for (_i = 0, _len = mascots.length; _i < _len; _i++) {
|
MascotTools.parse(mascots, userMascots);
|
||||||
mascot = mascots[_i];
|
return message = "" + name + " successfully imported!";
|
||||||
MascotTools.parse(mascot);
|
} 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 {
|
$.set('userMascots', userMascots);
|
||||||
return new Notice('warning', "Failed to import mascot. Is file a properly formatted JSON file?", 5);
|
if (len !== Conf["Deleted Mascots"].length) {
|
||||||
|
$.set('Deleted Mascots', Conf['Deleted Mascots']);
|
||||||
}
|
}
|
||||||
new Notice('info', message, 10);
|
new Notice('info', message, 10);
|
||||||
return Settings.open('Mascots');
|
return Settings.openSection.call({
|
||||||
|
open: Settings.mascots,
|
||||||
|
hyphenatedTitle: 'mascots'
|
||||||
|
});
|
||||||
};
|
};
|
||||||
return reader.readAsText(file);
|
return reader.readAsText(file);
|
||||||
},
|
},
|
||||||
parse: function(mascot) {
|
parse: function(mascot, userMascots) {
|
||||||
var name;
|
var name;
|
||||||
if (!(name = mascot["Mascot"])) {
|
if (!(name = mascot["Mascot"])) {
|
||||||
new Notice('warning', "Failed to import a mascot. Mascot has no name.", 5);
|
new Notice('warning', "Failed to import a mascot. Mascot has no name.", 5);
|
||||||
@ -13184,13 +13196,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mascots[name] = mascot;
|
return userMascots[name] = Mascots[name] = mascot;
|
||||||
return $.get("userMascots", {}, function(_arg) {
|
|
||||||
var userMascots;
|
|
||||||
userMascots = _arg.userMascots;
|
|
||||||
userMascots[name] = Mascots[name];
|
|
||||||
return $.set('userMascots', userMascots);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
position: function(mascot) {
|
position: function(mascot) {
|
||||||
if (!Style.sheets.mascots) {
|
if (!Style.sheets.mascots) {
|
||||||
|
|||||||
@ -13132,11 +13132,12 @@
|
|||||||
return Settings.open("Mascots");
|
return Settings.open("Mascots");
|
||||||
},
|
},
|
||||||
importMascot: function() {
|
importMascot: function() {
|
||||||
var file, reader;
|
var file, len, reader;
|
||||||
file = this.files[0];
|
file = this.files[0];
|
||||||
reader = new FileReader();
|
reader = new FileReader();
|
||||||
reader.onload = function(e) {
|
len = Conf["Deleted Mascots"].length;
|
||||||
var err, mascot, mascots, message, name, _i, _len;
|
reader.onload = function() {
|
||||||
|
var err, mascots;
|
||||||
try {
|
try {
|
||||||
mascots = JSON.parse(e.target.result);
|
mascots = JSON.parse(e.target.result);
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
@ -13144,24 +13145,35 @@
|
|||||||
alert(err);
|
alert(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (name = mascots["Mascot"]) {
|
$.get("userMascots", {}, function(_arg) {
|
||||||
MascotTools.parse(mascots);
|
var mascot, message, name, userMascots, _i, _len;
|
||||||
message = "" + name + " successfully imported!";
|
userMascots = _arg.userMascots;
|
||||||
} else if (mascots.length) {
|
if (name = mascots["Mascot"]) {
|
||||||
for (_i = 0, _len = mascots.length; _i < _len; _i++) {
|
MascotTools.parse(mascots, userMascots);
|
||||||
mascot = mascots[_i];
|
return message = "" + name + " successfully imported!";
|
||||||
MascotTools.parse(mascot);
|
} 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 {
|
$.set('userMascots', userMascots);
|
||||||
return new Notice('warning', "Failed to import mascot. Is file a properly formatted JSON file?", 5);
|
if (len !== Conf["Deleted Mascots"].length) {
|
||||||
|
$.set('Deleted Mascots', Conf['Deleted Mascots']);
|
||||||
}
|
}
|
||||||
new Notice('info', message, 10);
|
new Notice('info', message, 10);
|
||||||
return Settings.open('Mascots');
|
return Settings.openSection.call({
|
||||||
|
open: Settings.mascots,
|
||||||
|
hyphenatedTitle: 'mascots'
|
||||||
|
});
|
||||||
};
|
};
|
||||||
return reader.readAsText(file);
|
return reader.readAsText(file);
|
||||||
},
|
},
|
||||||
parse: function(mascot) {
|
parse: function(mascot, userMascots) {
|
||||||
var name;
|
var name;
|
||||||
if (!(name = mascot["Mascot"])) {
|
if (!(name = mascot["Mascot"])) {
|
||||||
new Notice('warning', "Failed to import a mascot. Mascot has no name.", 5);
|
new Notice('warning', "Failed to import a mascot. Mascot has no name.", 5);
|
||||||
@ -13173,13 +13185,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mascots[name] = mascot;
|
return userMascots[name] = Mascots[name] = mascot;
|
||||||
return $.get("userMascots", {}, function(_arg) {
|
|
||||||
var userMascots;
|
|
||||||
userMascots = _arg.userMascots;
|
|
||||||
userMascots[name] = Mascots[name];
|
|
||||||
return $.set('userMascots', userMascots);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
position: function(mascot) {
|
position: function(mascot) {
|
||||||
if (!Style.sheets.mascots) {
|
if (!Style.sheets.mascots) {
|
||||||
|
|||||||
@ -337,30 +337,37 @@ MascotTools =
|
|||||||
importMascot: ->
|
importMascot: ->
|
||||||
file = @files[0]
|
file = @files[0]
|
||||||
reader = new FileReader()
|
reader = new FileReader()
|
||||||
|
len = Conf["Deleted Mascots"].length
|
||||||
|
|
||||||
reader.onload = (e) ->
|
reader.onload = ->
|
||||||
try
|
try
|
||||||
mascots = JSON.parse e.target.result
|
mascots = JSON.parse e.target.result
|
||||||
catch err
|
catch err
|
||||||
alert err
|
alert err
|
||||||
return
|
return
|
||||||
|
|
||||||
if name = mascots["Mascot"]
|
$.get "userMascots", {}, ({userMascots}) ->
|
||||||
MascotTools.parse mascots
|
if name = mascots["Mascot"]
|
||||||
message = "#{name} successfully imported!"
|
MascotTools.parse mascots, userMascots
|
||||||
else if mascots.length
|
message = "#{name} successfully imported!"
|
||||||
MascotTools.parse mascot for mascot in mascots
|
else if mascots.length
|
||||||
message = "Mascots imported!"
|
MascotTools.parse mascot, userMascots for mascot in mascots
|
||||||
else
|
message = "Mascots imported!"
|
||||||
return new Notice 'warning', "Failed to import mascot. Is file a properly formatted JSON file?", 5
|
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
|
new Notice 'info', message, 10
|
||||||
|
|
||||||
Settings.open 'Mascots'
|
Settings.openSection.call
|
||||||
|
open: Settings.mascots
|
||||||
|
hyphenatedTitle: 'mascots'
|
||||||
|
|
||||||
reader.readAsText file
|
reader.readAsText file
|
||||||
|
|
||||||
parse: (mascot) ->
|
parse: (mascot, userMascots) ->
|
||||||
unless name = mascot["Mascot"]
|
unless name = mascot["Mascot"]
|
||||||
new Notice 'warning', "Failed to import a mascot. Mascot has no name.", 5
|
new Notice 'warning', "Failed to import a mascot. Mascot has no name.", 5
|
||||||
return
|
return
|
||||||
@ -370,11 +377,7 @@ MascotTools =
|
|||||||
if Mascots[name] and not $.remove Conf["Deleted Mascots"], name
|
if Mascots[name] and not $.remove Conf["Deleted Mascots"], name
|
||||||
return unless confirm "The mascot #{name} already exists? Would you like to overwrite it?"
|
return unless confirm "The mascot #{name} already exists? Would you like to overwrite it?"
|
||||||
|
|
||||||
Mascots[name] = mascot
|
userMascots[name] = Mascots[name] = mascot
|
||||||
|
|
||||||
$.get "userMascots", {}, ({userMascots}) ->
|
|
||||||
userMascots[name] = Mascots[name]
|
|
||||||
$.set 'userMascots', userMascots
|
|
||||||
|
|
||||||
position: (mascot) ->
|
position: (mascot) ->
|
||||||
return unless Style.sheets.mascots
|
return unless Style.sheets.mascots
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user