Ok, now it works.
This commit is contained in:
parent
82646724e5
commit
eb1b6e39fc
@ -2983,15 +2983,14 @@
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
$.remove = function(array, value) {
|
$.remove = function(arr, value) {
|
||||||
var i;
|
var i;
|
||||||
i = array.indexOf(value);
|
i = arr.indexOf(value);
|
||||||
if (i > -1) {
|
if (i === -1) {
|
||||||
array.splice(i, 1);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
arr.splice(i, 1);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
$$ = function(selector, root) {
|
$$ = function(selector, root) {
|
||||||
@ -13143,11 +13142,10 @@
|
|||||||
return Settings.open("Mascots");
|
return Settings.open("Mascots");
|
||||||
},
|
},
|
||||||
importMascot: function() {
|
importMascot: function() {
|
||||||
var file, len, reader;
|
var file, reader;
|
||||||
file = this.files[0];
|
file = this.files[0];
|
||||||
reader = new FileReader();
|
reader = new FileReader();
|
||||||
len = Conf["Deleted Mascots"].length;
|
reader.onload = function(e) {
|
||||||
reader.onload = function() {
|
|
||||||
var err, mascots;
|
var err, mascots;
|
||||||
try {
|
try {
|
||||||
mascots = JSON.parse(e.target.result);
|
mascots = JSON.parse(e.target.result);
|
||||||
@ -13156,34 +13154,39 @@
|
|||||||
alert(err);
|
alert(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.get("userMascots", {}, function(_arg) {
|
return $.get("userMascots", {}, function(_arg) {
|
||||||
var mascot, message, name, userMascots, _i, _len;
|
var userMascots;
|
||||||
userMascots = _arg.userMascots;
|
userMascots = _arg.userMascots;
|
||||||
if (name = mascots["Mascot"]) {
|
return MascotTools.load(mascots, userMascots);
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$.set('userMascots', userMascots);
|
|
||||||
if (len !== Conf["Deleted Mascots"].length) {
|
|
||||||
$.set('Deleted Mascots', Conf['Deleted Mascots']);
|
|
||||||
}
|
|
||||||
new Notice('info', message, 10);
|
|
||||||
return Settings.openSection.call({
|
|
||||||
open: Settings.mascots,
|
|
||||||
hyphenatedTitle: 'mascots'
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return reader.readAsText(file);
|
return reader.readAsText(file);
|
||||||
},
|
},
|
||||||
|
load: function(mascots, userMascots) {
|
||||||
|
var len, mascot, message, name, _i, _len;
|
||||||
|
len = Conf["Deleted Mascots"].length;
|
||||||
|
if (name = mascots["Mascot"]) {
|
||||||
|
MascotTools.parse(mascots, userMascots);
|
||||||
|
message = "" + name + " successfully imported!";
|
||||||
|
} else if (mascots.length) {
|
||||||
|
for (_i = 0, _len = mascots.length; _i < _len; _i++) {
|
||||||
|
mascot = mascots[_i];
|
||||||
|
MascotTools.parse(mascot, userMascots);
|
||||||
|
}
|
||||||
|
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.openSection.call({
|
||||||
|
open: Settings.mascots,
|
||||||
|
hyphenatedTitle: 'mascots'
|
||||||
|
});
|
||||||
|
},
|
||||||
parse: function(mascot, userMascots) {
|
parse: function(mascot, userMascots) {
|
||||||
var name;
|
var name;
|
||||||
if (!(name = mascot["Mascot"])) {
|
if (!(name = mascot["Mascot"])) {
|
||||||
|
|||||||
@ -2988,15 +2988,14 @@
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
$.remove = function(array, value) {
|
$.remove = function(arr, value) {
|
||||||
var i;
|
var i;
|
||||||
i = array.indexOf(value);
|
i = arr.indexOf(value);
|
||||||
if (i > -1) {
|
if (i === -1) {
|
||||||
array.splice(i, 1);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
arr.splice(i, 1);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
$$ = function(selector, root) {
|
$$ = function(selector, root) {
|
||||||
@ -13132,11 +13131,10 @@
|
|||||||
return Settings.open("Mascots");
|
return Settings.open("Mascots");
|
||||||
},
|
},
|
||||||
importMascot: function() {
|
importMascot: function() {
|
||||||
var file, len, reader;
|
var file, reader;
|
||||||
file = this.files[0];
|
file = this.files[0];
|
||||||
reader = new FileReader();
|
reader = new FileReader();
|
||||||
len = Conf["Deleted Mascots"].length;
|
reader.onload = function(e) {
|
||||||
reader.onload = function() {
|
|
||||||
var err, mascots;
|
var err, mascots;
|
||||||
try {
|
try {
|
||||||
mascots = JSON.parse(e.target.result);
|
mascots = JSON.parse(e.target.result);
|
||||||
@ -13145,34 +13143,39 @@
|
|||||||
alert(err);
|
alert(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.get("userMascots", {}, function(_arg) {
|
return $.get("userMascots", {}, function(_arg) {
|
||||||
var mascot, message, name, userMascots, _i, _len;
|
var userMascots;
|
||||||
userMascots = _arg.userMascots;
|
userMascots = _arg.userMascots;
|
||||||
if (name = mascots["Mascot"]) {
|
return MascotTools.load(mascots, userMascots);
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$.set('userMascots', userMascots);
|
|
||||||
if (len !== Conf["Deleted Mascots"].length) {
|
|
||||||
$.set('Deleted Mascots', Conf['Deleted Mascots']);
|
|
||||||
}
|
|
||||||
new Notice('info', message, 10);
|
|
||||||
return Settings.openSection.call({
|
|
||||||
open: Settings.mascots,
|
|
||||||
hyphenatedTitle: 'mascots'
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return reader.readAsText(file);
|
return reader.readAsText(file);
|
||||||
},
|
},
|
||||||
|
load: function(mascots, userMascots) {
|
||||||
|
var len, mascot, message, name, _i, _len;
|
||||||
|
len = Conf["Deleted Mascots"].length;
|
||||||
|
if (name = mascots["Mascot"]) {
|
||||||
|
MascotTools.parse(mascots, userMascots);
|
||||||
|
message = "" + name + " successfully imported!";
|
||||||
|
} else if (mascots.length) {
|
||||||
|
for (_i = 0, _len = mascots.length; _i < _len; _i++) {
|
||||||
|
mascot = mascots[_i];
|
||||||
|
MascotTools.parse(mascot, userMascots);
|
||||||
|
}
|
||||||
|
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.openSection.call({
|
||||||
|
open: Settings.mascots,
|
||||||
|
hyphenatedTitle: 'mascots'
|
||||||
|
});
|
||||||
|
},
|
||||||
parse: function(mascot, userMascots) {
|
parse: function(mascot, userMascots) {
|
||||||
var name;
|
var name;
|
||||||
if (!(name = mascot["Mascot"])) {
|
if (!(name = mascot["Mascot"])) {
|
||||||
|
|||||||
@ -404,13 +404,11 @@ $.set = do ->
|
|||||||
return
|
return
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
$.remove = (array, value) ->
|
$.remove = (arr, value) ->
|
||||||
i = array.indexOf value
|
i = arr.indexOf value
|
||||||
if i > -1
|
return false if i is -1
|
||||||
array.splice i, 1
|
arr.splice i, 1
|
||||||
true
|
true
|
||||||
else
|
|
||||||
false
|
|
||||||
|
|
||||||
$$ = (selector, root=d.body) ->
|
$$ = (selector, root=d.body) ->
|
||||||
[root.querySelectorAll(selector)...]
|
[root.querySelectorAll(selector)...]
|
||||||
|
|||||||
@ -337,9 +337,8 @@ MascotTools =
|
|||||||
importMascot: ->
|
importMascot: ->
|
||||||
file = @files[0]
|
file = @files[0]
|
||||||
reader = new FileReader()
|
reader = new FileReader()
|
||||||
len = Conf["Deleted Mascots"].length
|
|
||||||
|
|
||||||
reader.onload = ->
|
reader.onload = (e) ->
|
||||||
try
|
try
|
||||||
mascots = JSON.parse e.target.result
|
mascots = JSON.parse e.target.result
|
||||||
catch err
|
catch err
|
||||||
@ -347,26 +346,30 @@ MascotTools =
|
|||||||
return
|
return
|
||||||
|
|
||||||
$.get "userMascots", {}, ({userMascots}) ->
|
$.get "userMascots", {}, ({userMascots}) ->
|
||||||
if name = mascots["Mascot"]
|
MascotTools.load mascots, userMascots
|
||||||
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.openSection.call
|
|
||||||
open: Settings.mascots
|
|
||||||
hyphenatedTitle: 'mascots'
|
|
||||||
|
|
||||||
reader.readAsText file
|
reader.readAsText file
|
||||||
|
|
||||||
|
load: (mascots, userMascots) ->
|
||||||
|
len = Conf["Deleted Mascots"].length
|
||||||
|
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.openSection.call
|
||||||
|
open: Settings.mascots
|
||||||
|
hyphenatedTitle: 'mascots'
|
||||||
|
|
||||||
parse: (mascot, userMascots) ->
|
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user