A lot of backpedaling here.

This commit is contained in:
Zixaphir 2013-06-20 19:20:32 -07:00
parent ebfaaaacc4
commit 283a33c443
5 changed files with 82 additions and 131 deletions

View File

@ -7943,7 +7943,7 @@
if (response) { if (response) {
response = response.trim(); response = response.trim();
if (!/\s/.test(response)) { if (!/\s/.test(response)) {
response = "" + response + " " + response; response += " " + response;
} }
} }
return { return {
@ -10982,7 +10982,6 @@
editMascot = {}; editMascot = {};
} }
editMascot.name = key || ''; editMascot.name = key || '';
MascotTools.init(editMascot);
layout = { layout = {
name: ["Mascot Name", "", "text"], name: ["Mascot Name", "", "text"],
image: ["Image", "", "text"], image: ["Image", "", "text"],
@ -11002,6 +11001,7 @@
nodes = []; nodes = [];
for (name in layout) { for (name in layout) {
item = layout[name]; item = layout[name];
value = editMascot[name] || (editMascot[name] = item[1]);
switch (item[2]) { switch (item[2]) {
case "text": case "text":
div = this.input(item, name); div = this.input(item, name);
@ -11051,14 +11051,13 @@
}); });
break; break;
case "select": case "select":
value = editMascot[name] || item[1];
optionHTML = "<div class=optionlabel>" + item[0] + "</div><div class=option><select name='" + name + "' value='" + value + "'><br>"; optionHTML = "<div class=optionlabel>" + item[0] + "</div><div class=option><select name='" + name + "' value='" + value + "'><br>";
_ref = item[3]; _ref = item[3];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i]; option = _ref[_i];
optionHTML = optionHTML + ("<option value=\"" + option + "\">" + option + "</option>"); optionHTML += "<option value=\"" + option + "\">" + option + "</option>";
} }
optionHTML = optionHTML + "</select></div>"; optionHTML += "</select></div>";
div = $.el('div', { div = $.el('div', {
className: "mascotvar", className: "mascotvar",
innerHTML: optionHTML innerHTML: optionHTML
@ -11071,7 +11070,6 @@
}); });
break; break;
case "checkbox": case "checkbox":
value = editMascot[name] || item[1];
div = $.el("div", { div = $.el("div", {
className: "mascotvar", className: "mascotvar",
innerHTML: "<label><input type=" + item[2] + " class=field name='" + name + "' " + (value ? 'checked' : void 0) + ">" + item[0] + "</label>" innerHTML: "<label><input type=" + item[2] + " class=field name='" + name + "' " + (value ? 'checked' : void 0) + ">" + item[0] + "</label>"
@ -11083,6 +11081,7 @@
} }
nodes.push(div); nodes.push(div);
} }
MascotTools.init(editMascot);
$.add($("#mascotcontent", dialog), nodes); $.add($("#mascotcontent", dialog), nodes);
$.on($('#save > a', dialog), 'click', function() { $.on($('#save > a', dialog), 'click', function() {
return MascotTools.save(editMascot); return MascotTools.save(editMascot);
@ -11101,7 +11100,7 @@
value = editMascot[name][0]; value = editMascot[name][0];
} }
} else { } else {
value = editMascot[name] || item[1]; value = editMascot[name];
} }
editMascot[name] = value; editMascot[name] = value;
div = $.el("div", { div = $.el("div", {
@ -14135,10 +14134,9 @@
}); });
}, },
mascots: function(section, mode) { mascots: function(section, mode) {
var addoptions, batchmascots, categories, cb, keys, mascot, mascotEl, mascotHide, mascotoptions, menu, name, node, nodes, option, suboptions, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2; var addoptions, batchmascots, categories, cb, container, div, keys, mascot, mascotEl, mascotHide, mascotoptions, menu, name, node, option, suboptions, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1;
categories = {}; categories = {};
menu = [];
cb = Settings.cb.mascot; cb = Settings.cb.mascot;
if (typeof mode !== 'string') { if (typeof mode !== 'string') {
mode = 'default'; mode = 'default';
@ -14167,24 +14165,23 @@
} }
return $.add(this, mascotoptions); return $.add(this, mascotoptions);
}; };
nodes = {};
_ref = MascotTools.categories; _ref = MascotTools.categories;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
nodes[name] = []; menu = $('div', mascotHide);
categories[name] = $.el("div", { categories[name] = div = $.el("div", {
className: "mascots-container",
id: name, id: name,
innerHTML: "<h3 class=mascotHeader>" + name + "</h3>" className: "mascots-container",
innerHTML: "<h3 class=mascotHeader>" + name + "</h3>",
hidden: Conf["Hidden Categories"].contains(name)
}); });
if (Conf["Hidden Categories"].contains(name)) { option = $.el("label", {
categories[name].hidden = true;
}
menu.push(option = $.el("label", {
name: name, name: name,
innerHTML: "<input name='" + name + "' type=checkbox " + (Conf["Hidden Categories"].contains(name) ? 'checked' : '') + ">" + name innerHTML: "<input name='" + name + "' type=checkbox " + (Conf["Hidden Categories"].contains(name) ? 'checked' : '') + ">" + name
})); });
$.on($('input', option), 'change', cb.category); $.on($('input', option), 'change', cb.category);
$.add(suboptions, div);
$.add(menu, option);
} }
for (_j = 0, _len1 = keys.length; _j < _len1; _j++) { for (_j = 0, _len1 = keys.length; _j < _len1; _j++) {
name = keys[_j]; name = keys[_j];
@ -14193,35 +14190,24 @@
} }
mascot = Mascots[name]; mascot = Mascots[name];
mascotEl = $.el('div', { mascotEl = $.el('div', {
className: Conf[g.MASCOTSTRING].contains(name) ? 'mascot enabled' : 'mascot',
id: name, id: name,
className: Conf[g.MASCOTSTRING].contains(name) ? 'mascot enabled' : 'mascot',
innerHTML: "<div class='mascotname'>" + (name.replace(/_/g, " ")) + "</div><div class='mascotcontainer'><div class='mAlign " + mascot.category + "'><img class=mascotimg src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'></div></div>" innerHTML: "<div class='mascotname'>" + (name.replace(/_/g, " ")) + "</div><div class='mascotcontainer'><div class='mAlign " + mascot.category + "'><img class=mascotimg src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'></div></div>"
}); });
$.on(mascotEl, 'click', cb.select); $.on(mascotEl, 'click', cb.select);
$.on(mascotEl, 'mouseover', addoptions); $.on(mascotEl, 'mouseover', addoptions);
if (MascotTools.categories.contains(mascot.category)) { $.add(categories[mascot.category] || categories[MascotTools.categories[0]], mascotEl);
nodes[mascot.category].push(mascotEl);
} else {
nodes[MascotTools.categories[0]].push(mascotEl);
}
} }
_ref1 = MascotTools.categories;
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
name = _ref1[_k];
$.add(categories[name], nodes[name]);
$.add(suboptions, categories[name]);
}
$.add($('div', mascotHide), menu);
batchmascots = $.el('div', { batchmascots = $.el('div', {
id: "mascots_batch", id: "mascots_batch",
innerHTML: " <a href=\"javascript:;\" id=clear>Clear All</a>\n/\n<a href=\"javascript:;\" id=selectAll>Select All</a>\n/\n<a href=\"javascript:;\" id=createNew>Add Mascot</a>\n/\n<a href=\"javascript:;\" id=importMascot>Import Mascot</a><input id=importMascotButton type=file hidden>\n/\n<a href=\"javascript:;\" id=undelete>Undelete Mascots</a>\n/\n<a href=\"http://appchan.booru.org/\" target=_blank>Get More Mascots!</a>" innerHTML: " <a href=\"javascript:;\" id=clear>Clear All</a>\n/\n<a href=\"javascript:;\" id=selectAll>Select All</a>\n/\n<a href=\"javascript:;\" id=createNew>Add Mascot</a>\n/\n<a href=\"javascript:;\" id=importMascot>Import Mascot</a><input id=importMascotButton type=file hidden>\n/\n<a href=\"javascript:;\" id=undelete>Undelete Mascots</a>\n/\n<a href=\"http://appchan.booru.org/\" target=_blank>Get More Mascots!</a>"
}); });
$.on($('#clear', batchmascots), 'click', function() { $.on($('#clear', batchmascots), 'click', function() {
var enabledMascots, _l, _len3; var enabledMascots, _k, _len2;
enabledMascots = JSON.parse(JSON.stringify(Conf[g.MASCOTSTRING])); enabledMascots = JSON.parse(JSON.stringify(Conf[g.MASCOTSTRING]));
for (_l = 0, _len3 = enabledMascots.length; _l < _len3; _l++) { for (_k = 0, _len2 = enabledMascots.length; _k < _len2; _k++) {
name = enabledMascots[_l]; name = enabledMascots[_k];
$.rmClass($.id(name), 'enabled'); $.rmClass($.id(name), 'enabled');
} }
return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING] = []); return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING] = []);
@ -14260,12 +14246,11 @@
return Settings.openSection.apply(mascots, ['restore']); return Settings.openSection.apply(mascots, ['restore']);
}); });
} else { } else {
nodes = []; container = $.el("div", {
categories = $.el("div", {
className: "mascots" className: "mascots"
}); });
for (_l = 0, _len3 = keys.length; _l < _len3; _l++) { for (_k = 0, _len2 = keys.length; _k < _len2; _k++) {
name = keys[_l]; name = keys[_k];
if (!Conf["Deleted Mascots"].contains(name)) { if (!Conf["Deleted Mascots"].contains(name)) {
continue; continue;
} }
@ -14276,10 +14261,9 @@
innerHTML: "<div class='mascotname'>" + (name.replace(/_/g, " ")) + "</span><div class='container " + mascot.category + "'><img class=mascotimg src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'></div>" innerHTML: "<div class='mascotname'>" + (name.replace(/_/g, " ")) + "</span><div class='container " + mascot.category + "'><img class=mascotimg src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'></div>"
}); });
$.on(mascotEl, 'click', cb.restore); $.on(mascotEl, 'click', cb.restore);
nodes.push(mascotEl); $.add(container, mascotEl);
} }
$.add(categories, nodes); $.add(suboptions, container);
$.add(suboptions, categories);
batchmascots = $.el('div', { batchmascots = $.el('div', {
id: "mascots_batch", id: "mascots_batch",
innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>" innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>"
@ -14294,9 +14278,9 @@
return Settings.openSection.apply(mascots); return Settings.openSection.apply(mascots);
}); });
} }
_ref2 = [suboptions, batchmascots, mascotHide]; _ref1 = [suboptions, batchmascots, mascotHide];
for (_m = 0, _len4 = _ref2.length; _m < _len4; _m++) { for (_l = 0, _len3 = _ref1.length; _l < _len3; _l++) {
node = _ref2[_m]; node = _ref1[_l];
Rice.nodes(node); Rice.nodes(node);
} }
return $.add(section, [suboptions, batchmascots, mascotHide]); return $.add(section, [suboptions, batchmascots, mascotHide]);

View File

@ -7943,7 +7943,7 @@
if (response) { if (response) {
response = response.trim(); response = response.trim();
if (!/\s/.test(response)) { if (!/\s/.test(response)) {
response = "" + response + " " + response; response += " " + response;
} }
} }
return { return {
@ -10970,7 +10970,6 @@
editMascot = {}; editMascot = {};
} }
editMascot.name = key || ''; editMascot.name = key || '';
MascotTools.init(editMascot);
layout = { layout = {
name: ["Mascot Name", "", "text"], name: ["Mascot Name", "", "text"],
image: ["Image", "", "text"], image: ["Image", "", "text"],
@ -10990,6 +10989,7 @@
nodes = []; nodes = [];
for (name in layout) { for (name in layout) {
item = layout[name]; item = layout[name];
value = editMascot[name] || (editMascot[name] = item[1]);
switch (item[2]) { switch (item[2]) {
case "text": case "text":
div = this.input(item, name); div = this.input(item, name);
@ -11039,14 +11039,13 @@
}); });
break; break;
case "select": case "select":
value = editMascot[name] || item[1];
optionHTML = "<div class=optionlabel>" + item[0] + "</div><div class=option><select name='" + name + "' value='" + value + "'><br>"; optionHTML = "<div class=optionlabel>" + item[0] + "</div><div class=option><select name='" + name + "' value='" + value + "'><br>";
_ref = item[3]; _ref = item[3];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i]; option = _ref[_i];
optionHTML = optionHTML + ("<option value=\"" + option + "\">" + option + "</option>"); optionHTML += "<option value=\"" + option + "\">" + option + "</option>";
} }
optionHTML = optionHTML + "</select></div>"; optionHTML += "</select></div>";
div = $.el('div', { div = $.el('div', {
className: "mascotvar", className: "mascotvar",
innerHTML: optionHTML innerHTML: optionHTML
@ -11059,7 +11058,6 @@
}); });
break; break;
case "checkbox": case "checkbox":
value = editMascot[name] || item[1];
div = $.el("div", { div = $.el("div", {
className: "mascotvar", className: "mascotvar",
innerHTML: "<label><input type=" + item[2] + " class=field name='" + name + "' " + (value ? 'checked' : void 0) + ">" + item[0] + "</label>" innerHTML: "<label><input type=" + item[2] + " class=field name='" + name + "' " + (value ? 'checked' : void 0) + ">" + item[0] + "</label>"
@ -11071,6 +11069,7 @@
} }
nodes.push(div); nodes.push(div);
} }
MascotTools.init(editMascot);
$.add($("#mascotcontent", dialog), nodes); $.add($("#mascotcontent", dialog), nodes);
$.on($('#save > a', dialog), 'click', function() { $.on($('#save > a', dialog), 'click', function() {
return MascotTools.save(editMascot); return MascotTools.save(editMascot);
@ -11089,7 +11088,7 @@
value = editMascot[name][0]; value = editMascot[name][0];
} }
} else { } else {
value = editMascot[name] || item[1]; value = editMascot[name];
} }
editMascot[name] = value; editMascot[name] = value;
div = $.el("div", { div = $.el("div", {
@ -14122,10 +14121,9 @@
}); });
}, },
mascots: function(section, mode) { mascots: function(section, mode) {
var addoptions, batchmascots, categories, cb, keys, mascot, mascotEl, mascotHide, mascotoptions, menu, name, node, nodes, option, suboptions, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2; var addoptions, batchmascots, categories, cb, container, div, keys, mascot, mascotEl, mascotHide, mascotoptions, menu, name, node, option, suboptions, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1;
categories = {}; categories = {};
menu = [];
cb = Settings.cb.mascot; cb = Settings.cb.mascot;
if (typeof mode !== 'string') { if (typeof mode !== 'string') {
mode = 'default'; mode = 'default';
@ -14154,24 +14152,23 @@
} }
return $.add(this, mascotoptions); return $.add(this, mascotoptions);
}; };
nodes = {};
_ref = MascotTools.categories; _ref = MascotTools.categories;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
nodes[name] = []; menu = $('div', mascotHide);
categories[name] = $.el("div", { categories[name] = div = $.el("div", {
className: "mascots-container",
id: name, id: name,
innerHTML: "<h3 class=mascotHeader>" + name + "</h3>" className: "mascots-container",
innerHTML: "<h3 class=mascotHeader>" + name + "</h3>",
hidden: Conf["Hidden Categories"].contains(name)
}); });
if (Conf["Hidden Categories"].contains(name)) { option = $.el("label", {
categories[name].hidden = true;
}
menu.push(option = $.el("label", {
name: name, name: name,
innerHTML: "<input name='" + name + "' type=checkbox " + (Conf["Hidden Categories"].contains(name) ? 'checked' : '') + ">" + name innerHTML: "<input name='" + name + "' type=checkbox " + (Conf["Hidden Categories"].contains(name) ? 'checked' : '') + ">" + name
})); });
$.on($('input', option), 'change', cb.category); $.on($('input', option), 'change', cb.category);
$.add(suboptions, div);
$.add(menu, option);
} }
for (_j = 0, _len1 = keys.length; _j < _len1; _j++) { for (_j = 0, _len1 = keys.length; _j < _len1; _j++) {
name = keys[_j]; name = keys[_j];
@ -14180,35 +14177,24 @@
} }
mascot = Mascots[name]; mascot = Mascots[name];
mascotEl = $.el('div', { mascotEl = $.el('div', {
className: Conf[g.MASCOTSTRING].contains(name) ? 'mascot enabled' : 'mascot',
id: name, id: name,
className: Conf[g.MASCOTSTRING].contains(name) ? 'mascot enabled' : 'mascot',
innerHTML: "<div class='mascotname'>" + (name.replace(/_/g, " ")) + "</div><div class='mascotcontainer'><div class='mAlign " + mascot.category + "'><img class=mascotimg src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'></div></div>" innerHTML: "<div class='mascotname'>" + (name.replace(/_/g, " ")) + "</div><div class='mascotcontainer'><div class='mAlign " + mascot.category + "'><img class=mascotimg src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'></div></div>"
}); });
$.on(mascotEl, 'click', cb.select); $.on(mascotEl, 'click', cb.select);
$.on(mascotEl, 'mouseover', addoptions); $.on(mascotEl, 'mouseover', addoptions);
if (MascotTools.categories.contains(mascot.category)) { $.add(categories[mascot.category] || categories[MascotTools.categories[0]], mascotEl);
nodes[mascot.category].push(mascotEl);
} else {
nodes[MascotTools.categories[0]].push(mascotEl);
}
} }
_ref1 = MascotTools.categories;
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
name = _ref1[_k];
$.add(categories[name], nodes[name]);
$.add(suboptions, categories[name]);
}
$.add($('div', mascotHide), menu);
batchmascots = $.el('div', { batchmascots = $.el('div', {
id: "mascots_batch", id: "mascots_batch",
innerHTML: " <a href=\"javascript:;\" id=clear>Clear All</a>\n/\n<a href=\"javascript:;\" id=selectAll>Select All</a>\n/\n<a href=\"javascript:;\" id=createNew>Add Mascot</a>\n/\n<a href=\"javascript:;\" id=importMascot>Import Mascot</a><input id=importMascotButton type=file hidden>\n/\n<a href=\"javascript:;\" id=undelete>Undelete Mascots</a>\n/\n<a href=\"http://appchan.booru.org/\" target=_blank>Get More Mascots!</a>" innerHTML: " <a href=\"javascript:;\" id=clear>Clear All</a>\n/\n<a href=\"javascript:;\" id=selectAll>Select All</a>\n/\n<a href=\"javascript:;\" id=createNew>Add Mascot</a>\n/\n<a href=\"javascript:;\" id=importMascot>Import Mascot</a><input id=importMascotButton type=file hidden>\n/\n<a href=\"javascript:;\" id=undelete>Undelete Mascots</a>\n/\n<a href=\"http://appchan.booru.org/\" target=_blank>Get More Mascots!</a>"
}); });
$.on($('#clear', batchmascots), 'click', function() { $.on($('#clear', batchmascots), 'click', function() {
var enabledMascots, _l, _len3; var enabledMascots, _k, _len2;
enabledMascots = JSON.parse(JSON.stringify(Conf[g.MASCOTSTRING])); enabledMascots = JSON.parse(JSON.stringify(Conf[g.MASCOTSTRING]));
for (_l = 0, _len3 = enabledMascots.length; _l < _len3; _l++) { for (_k = 0, _len2 = enabledMascots.length; _k < _len2; _k++) {
name = enabledMascots[_l]; name = enabledMascots[_k];
$.rmClass($.id(name), 'enabled'); $.rmClass($.id(name), 'enabled');
} }
return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING] = []); return $.set(g.MASCOTSTRING, Conf[g.MASCOTSTRING] = []);
@ -14247,12 +14233,11 @@
return Settings.openSection.apply(mascots, ['restore']); return Settings.openSection.apply(mascots, ['restore']);
}); });
} else { } else {
nodes = []; container = $.el("div", {
categories = $.el("div", {
className: "mascots" className: "mascots"
}); });
for (_l = 0, _len3 = keys.length; _l < _len3; _l++) { for (_k = 0, _len2 = keys.length; _k < _len2; _k++) {
name = keys[_l]; name = keys[_k];
if (!Conf["Deleted Mascots"].contains(name)) { if (!Conf["Deleted Mascots"].contains(name)) {
continue; continue;
} }
@ -14263,10 +14248,9 @@
innerHTML: "<div class='mascotname'>" + (name.replace(/_/g, " ")) + "</span><div class='container " + mascot.category + "'><img class=mascotimg src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'></div>" innerHTML: "<div class='mascotname'>" + (name.replace(/_/g, " ")) + "</span><div class='container " + mascot.category + "'><img class=mascotimg src='" + (Array.isArray(mascot.image) ? (Style.lightTheme ? mascot.image[1] : mascot.image[0]) : mascot.image) + "'></div>"
}); });
$.on(mascotEl, 'click', cb.restore); $.on(mascotEl, 'click', cb.restore);
nodes.push(mascotEl); $.add(container, mascotEl);
} }
$.add(categories, nodes); $.add(suboptions, container);
$.add(suboptions, categories);
batchmascots = $.el('div', { batchmascots = $.el('div', {
id: "mascots_batch", id: "mascots_batch",
innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>" innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>"
@ -14281,9 +14265,9 @@
return Settings.openSection.apply(mascots); return Settings.openSection.apply(mascots);
}); });
} }
_ref2 = [suboptions, batchmascots, mascotHide]; _ref1 = [suboptions, batchmascots, mascotHide];
for (_m = 0, _len4 = _ref2.length; _m < _len4; _m++) { for (_l = 0, _len3 = _ref1.length; _l < _len3; _l++) {
node = _ref2[_m]; node = _ref1[_l];
Rice.nodes(node); Rice.nodes(node);
} }
return $.add(section, [suboptions, batchmascots, mascotHide]); return $.add(section, [suboptions, batchmascots, mascotHide]);

View File

@ -645,7 +645,6 @@ Settings =
mascots: (section, mode) -> mascots: (section, mode) ->
categories = {} categories = {}
menu = []
cb = Settings.cb.mascot cb = Settings.cb.mascot
if typeof mode isnt 'string' if typeof mode isnt 'string'
@ -676,45 +675,35 @@ Settings =
$.add @, mascotoptions $.add @, mascotoptions
# Create a keyed Unordered List Element and hide option for each mascot category. # Create a keyed Unordered List Element and hide option for each mascot category.
nodes = {}
for name in MascotTools.categories for name in MascotTools.categories
nodes[name] = [] menu = $ 'div', mascotHide
categories[name] = $.el "div", categories[name] = div = $.el "div",
id: name
className: "mascots-container" className: "mascots-container"
id: name
innerHTML: "<h3 class=mascotHeader>#{name}</h3>" innerHTML: "<h3 class=mascotHeader>#{name}</h3>"
hidden: Conf["Hidden Categories"].contains name
if Conf["Hidden Categories"].contains name option = $.el "label",
categories[name].hidden = true
menu.push option = $.el "label",
name: name name: name
innerHTML: "<input name='#{name}' type=checkbox #{if Conf["Hidden Categories"].contains(name) then 'checked' else ''}>#{name}" innerHTML: "<input name='#{name}' type=checkbox #{if Conf["Hidden Categories"].contains(name) then 'checked' else ''}>#{name}"
$.on $('input', option), 'change', cb.category $.on $('input', option), 'change', cb.category
for name in keys $.add suboptions, div
$.add menu, option
for name in keys
continue if Conf["Deleted Mascots"].contains name continue if Conf["Deleted Mascots"].contains name
mascot = Mascots[name] mascot = Mascots[name]
mascotEl = $.el 'div', mascotEl = $.el 'div',
id: name
className: if Conf[g.MASCOTSTRING].contains name then 'mascot enabled' else 'mascot' className: if Conf[g.MASCOTSTRING].contains name then 'mascot enabled' else 'mascot'
id: name
innerHTML: "<%= grunt.file.read('src/General/html/Settings/Mascot.html') %>" innerHTML: "<%= grunt.file.read('src/General/html/Settings/Mascot.html') %>"
$.on mascotEl, 'click', cb.select $.on mascotEl, 'click', cb.select
$.on mascotEl, 'mouseover', addoptions $.on mascotEl, 'mouseover', addoptions
if MascotTools.categories.contains mascot.category $.add (categories[mascot.category] or categories[MascotTools.categories[0]]), mascotEl
nodes[mascot.category].push mascotEl
else
nodes[MascotTools.categories[0]].push mascotEl
for name in MascotTools.categories
$.add categories[name], nodes[name]
$.add suboptions, categories[name]
$.add $('div', mascotHide), menu
batchmascots = $.el 'div', batchmascots = $.el 'div',
id: "mascots_batch" id: "mascots_batch"
@ -753,8 +742,7 @@ Settings =
Settings.openSection.apply mascots, ['restore'] Settings.openSection.apply mascots, ['restore']
else else
nodes = [] container = $.el "div",
categories = $.el "div",
className: "mascots" className: "mascots"
for name in keys for name in keys
@ -770,15 +758,13 @@ Settings =
$.on mascotEl, 'click', cb.restore $.on mascotEl, 'click', cb.restore
nodes.push mascotEl $.add container, mascotEl
$.add categories, nodes $.add suboptions, container
$.add suboptions, categories
batchmascots = $.el 'div', batchmascots = $.el 'div',
id: "mascots_batch" id: "mascots_batch"
innerHTML: "<a href=\"javascript:;\" id=\"return\">Return</a>" innerHTML: """<a href="javascript:;" id="return">Return</a>"""
$.on $('#return', batchmascots), 'click', -> $.on $('#return', batchmascots), 'click', ->
mascots = mascots =

View File

@ -827,7 +827,7 @@ QR =
response = response.trim() response = response.trim()
# one-word-captcha: # one-word-captcha:
# If there's only one word, duplicate it. # If there's only one word, duplicate it.
response = "#{response} #{response}" unless /\s/.test response response += " #{response}" unless /\s/.test response
{challenge, response} {challenge, response}
save: -> save: ->

View File

@ -9,9 +9,6 @@ MascotTools =
unless @el unless @el
@el = $.el 'div', @el = $.el 'div',
id: "mascot" id: "mascot"
# ><img>
# >not <img />
# >HTML5
innerHTML: "<img>" innerHTML: "<img>"
$.on @el, 'mousedown', MascotTools.click $.on @el, 'mousedown', MascotTools.click
@ -72,7 +69,6 @@ MascotTools =
else else
editMascot = {} editMascot = {}
editMascot.name = key or '' editMascot.name = key or ''
MascotTools.init editMascot
layout = layout =
name: [ name: [
"Mascot Name" "Mascot Name"
@ -142,6 +138,7 @@ MascotTools =
" "
nodes = [] nodes = []
for name, item of layout for name, item of layout
value = editMascot[name] or= item[1]
switch item[2] switch item[2]
@ -150,7 +147,6 @@ MascotTools =
input = $ 'input', div input = $ 'input', div
if name is 'image' if name is 'image'
$.on input, 'blur', -> $.on input, 'blur', ->
editMascot[@name] = @value editMascot[@name] = @value
MascotTools.init editMascot MascotTools.init editMascot
@ -192,11 +188,10 @@ MascotTools =
MascotTools.init editMascot MascotTools.init editMascot
when "select" when "select"
value = editMascot[name] or item[1]
optionHTML = "<div class=optionlabel>#{item[0]}</div><div class=option><select name='#{name}' value='#{value}'><br>" optionHTML = "<div class=optionlabel>#{item[0]}</div><div class=option><select name='#{name}' value='#{value}'><br>"
for option in item[3] for option in item[3]
optionHTML = optionHTML + "<option value=\"#{option}\">#{option}</option>" optionHTML += "<option value=\"#{option}\">#{option}</option>"
optionHTML = optionHTML + "</select></div>" optionHTML += "</select></div>"
div = $.el 'div', div = $.el 'div',
className: "mascotvar" className: "mascotvar"
innerHTML: optionHTML innerHTML: optionHTML
@ -208,7 +203,6 @@ MascotTools =
MascotTools.init editMascot MascotTools.init editMascot
when "checkbox" when "checkbox"
value = editMascot[name] or item[1]
div = $.el "div", div = $.el "div",
className: "mascotvar" className: "mascotvar"
innerHTML: "<label><input type=#{item[2]} class=field name='#{name}' #{if value then 'checked'}>#{item[0]}</label>" innerHTML: "<label><input type=#{item[2]} class=field name='#{name}' #{if value then 'checked'}>#{item[0]}</label>"
@ -217,23 +211,26 @@ MascotTools =
MascotTools.init editMascot MascotTools.init editMascot
nodes.push div nodes.push div
MascotTools.init editMascot
$.add $("#mascotcontent", dialog), nodes $.add $("#mascotcontent", dialog), nodes
$.on $('#save > a', dialog), 'click', -> $.on $('#save > a', dialog), 'click', ->
MascotTools.save editMascot MascotTools.save editMascot
$.on $('#close > a', dialog), 'click', MascotTools.close $.on $('#close > a', dialog), 'click', MascotTools.close
Rice.nodes(dialog) Rice.nodes dialog
$.add d.body, dialog $.add d.body, dialog
input: (item, name) -> input: (item, name) ->
if Array.isArray(editMascot[name]) if Array.isArray editMascot[name]
if Style.lightTheme if Style.lightTheme
value = editMascot[name][1] value = editMascot[name][1]
else else
value = editMascot[name][0] value = editMascot[name][0]
else else
value = editMascot[name] or item[1] value = editMascot[name]
editMascot[name] = value editMascot[name] = value