diff --git a/appchan-x.user.js b/appchan-x.user.js
index 3a8a754dd..d1a901cad 100644
--- a/appchan-x.user.js
+++ b/appchan-x.user.js
@@ -4999,6 +4999,7 @@
});
Settings.addSection('Style', Settings.style);
Settings.addSection('Themes', Settings.themes);
+ Settings.addSection('Mascots', Settings.mascots);
Settings.addSection('Script', Settings.main);
Settings.addSection('Filter', Settings.filter);
Settings.addSection('Sauce', Settings.sauce);
@@ -5769,6 +5770,201 @@
},
close: true
});
+ },
+ mascots: function(section, mode) {
+ var batchmascots, categories, category, header, keys, li, mascot, mascotHide, name, option, parentdiv, suboptions, ul, _i, _j, _k, _len, _len1, _len2, _ref;
+
+ ul = {};
+ categories = [];
+ if (typeof mode !== 'string') {
+ mode = 'default';
+ }
+ parentdiv = $.el("div", {
+ id: "mascotContainer"
+ });
+ suboptions = $.el("div", {
+ className: "suboptions"
+ });
+ mascotHide = $.el("div", {
+ id: "mascot_hide",
+ className: "reply",
+ innerHTML: "Hide Categories
" + (name.replace(/_/g, " ")) + "
"
+ });
+ $.on(li, 'click', function() {
+ if (confirm("Are you sure you want to undelete \"" + this.id + "\"?")) {
+ Conf["Deleted Mascots"].remove(this.id);
+ $.set("Deleted Mascots", Conf["Deleted Mascots"]);
+ return $.rm(this);
+ }
+ });
+ $.add(ul, li);
+ }
+ }
+ $.add(suboptions, ul);
+ batchmascots = $.el('div', {
+ id: "mascots_batch",
+ innerHTML: "
Return"
+ });
+ $.on($('#return', batchmascots), 'click', function() {
+ $.rm($.id("mascotContainer"));
+ return Settings.section('mascots');
+ });
+ }
+ $.add(parentdiv, [suboptions, batchmascots, mascotHide]);
+ Rice.nodes(parentdiv);
+ return $.add(section, parentdiv);
}
};
@@ -12800,7 +12996,8 @@
'Enabled Mascots': [],
'Enabled Mascots sfw': [],
'Enabled Mascots nsfw': [],
- 'Deleted Mascots': []
+ 'Deleted Mascots': [],
+ 'Hidden Categories': ["Questionable"]
});
return $.get(Conf, Main.initFeatures);
},
diff --git a/src/main.coffee b/src/main.coffee
index 8e4587cc2..64cc45442 100644
--- a/src/main.coffee
+++ b/src/main.coffee
@@ -304,6 +304,8 @@ Main =
flatten null, Config
for db in DataBoards
Conf[db] = boards: {}
+
+ # Unflattened Config.
$.extend Conf,
'userThemes': []
'userMascots': []
@@ -311,6 +313,7 @@ Main =
'Enabled Mascots sfw': []
'Enabled Mascots nsfw': []
'Deleted Mascots': []
+ 'Hidden Categories': ["Questionable"]
$.get Conf, Main.initFeatures
diff --git a/src/settings.coffee b/src/settings.coffee
index f3740c79e..e1daa08c9 100644
--- a/src/settings.coffee
+++ b/src/settings.coffee
@@ -35,7 +35,7 @@ Settings =
Settings.addSection 'Style', Settings.style
Settings.addSection 'Themes', Settings.themes
- # Settings.addSection 'Mascots', Settings.mascots
+ Settings.addSection 'Mascots', Settings.mascots
Settings.addSection 'Script', Settings.main
Settings.addSection 'Filter', Settings.filter
Settings.addSection 'Sauce', Settings.sauce
@@ -856,4 +856,191 @@ Settings =
asapTest: -> true
close: true
- return
\ No newline at end of file
+ return
+
+
+ mascots: (section, mode) ->
+ ul = {}
+ categories = []
+
+ if typeof mode isnt 'string'
+ mode = 'default'
+
+ parentdiv = $.el "div",
+ id: "mascotContainer"
+
+ suboptions = $.el "div",
+ className: "suboptions"
+
+ mascotHide = $.el "div",
+ id: "mascot_hide"
+ className: "reply"
+ innerHTML: "Hide Categories
"
+
+ keys = Object.keys Mascots
+ keys.sort()
+
+ if mode is 'default'
+ # Create a keyed Unordered List Element and hide option for each mascot category.
+ for category in MascotTools.categories
+ ul[category] = $.el "ul",
+ className: "mascots"
+ id: category
+
+ if Conf["Hidden Categories"].contains category
+ ul[category].hidden = true
+
+ header = $.el "h3",
+ className: "mascotHeader"
+ textContent: category
+
+ categories.push option = $.el "label",
+ name: category
+ innerHTML: "
#{category}"
+
+ $.on $('input', option), 'change', ->
+ Settings.mascotTab.toggle.call @
+
+ $.add ul[category], header
+ $.add suboptions, ul[category]
+
+ for name in keys
+ unless Conf["Deleted Mascots"].contains name
+ mascot = Mascots[name]
+ li = $.el 'li',
+ className: 'mascot'
+ id: name
+ innerHTML: "
+
#{name.replace /_/g, " "}
+
+
"
+
+ if Conf[g.MASCOTSTRING].contains name
+ $.addClass li, 'enabled'
+
+ $.on $('a.edit', li), 'click', (e) ->
+ e.stopPropagation()
+ MascotTools.dialog @name
+ Settings.close()
+
+ $.on $('a.delete', li), 'click', (e) ->
+ e.stopPropagation()
+ if confirm "Are you sure you want to delete \"#{@name}\"?"
+ if Conf['mascot'] is @name
+ MascotTools.init()
+ for type in ["Enabled Mascots", "Enabled Mascots sfw", "Enabled Mascots nsfw"]
+ Conf[type].remove @name
+ $.set type, Conf[type]
+ Conf["Deleted Mascots"].push @name
+ $.set "Deleted Mascots", Conf["Deleted Mascots"]
+ $.rm $.id @name
+
+ # Mascot Exporting
+ $.on $('a.export', li), 'click', (e) ->
+ e.stopPropagation()
+ exportMascot = Mascots[@name]
+ exportMascot['Mascot'] = @name
+ exportedMascot = "data:application/json," + encodeURIComponent(JSON.stringify(exportMascot))
+
+ if window.open exportedMascot, "_blank"
+ return
+ else if confirm "Your popup blocker is preventing Appchan X from exporting this theme. Would you like to open the exported theme in this window?"
+ window.location exportedMascot
+
+ $.on li, 'click', ->
+ if Conf[g.MASCOTSTRING].remove @id
+ if Conf['mascot'] is @id
+ MascotTools.init()
+ else
+ Conf[g.MASCOTSTRING].push @id
+ MascotTools.init @id
+ $.toggleClass @, 'enabled'
+ $.set g.MASCOTSTRING, Conf[g.MASCOTSTRING]
+
+ if MascotTools.categories.contains mascot.category
+ $.add ul[mascot.category], li
+ else
+ $.add ul[MascotTools.categories[0]], li
+
+ $.add $('div', mascotHide), categories
+
+ batchmascots = $.el 'div',
+ id: "mascots_batch"
+ innerHTML: "
+
Clear All /
+
Select All /
+
Add Mascot /
+
Import Mascot /
+
Undelete Mascots /
+
Get More Mascots!
+ "
+
+ $.on $('#clear', batchmascots), 'click', ->
+ enabledMascots = JSON.parse(JSON.stringify(Conf[g.MASCOTSTRING]))
+ for name in enabledMascots
+ $.rmClass $.id(name), 'enabled'
+ $.set g.MASCOTSTRING, Conf[g.MASCOTSTRING] = []
+
+ $.on $('#selectAll', batchmascots), 'click', ->
+ for name, mascot of Mascots
+ unless Conf["Hidden Categories"].contains(mascot.category) or Conf[g.MASCOTSTRING].contains(name) or Conf["Deleted Mascots"].contains(name)
+ $.addClass $.id(name), 'enabled'
+ Conf[g.MASCOTSTRING].push name
+ $.set g.MASCOTSTRING, Conf[g.MASCOTSTRING]
+
+ $.on $('#createNew', batchmascots), 'click', ->
+ MascotTools.dialog()
+ Settings.close()
+
+ $.on $("#importMascot", batchmascots), 'click', ->
+ @nextSibling.click()
+
+ $.on $("#importMascotButton", batchmascots), 'change', (evt) ->
+ MascotTools.importMascot evt
+
+ $.on $('#undelete', batchmascots), 'click', ->
+ unless Conf["Deleted Mascots"].length > 0
+ alert "No mascots have been deleted."
+ return
+ $.rm $.id "mascotContainer"
+ Settings.mascotTab.dialog Settings.el, 'undelete'
+
+ else
+ ul = $.el "ul",
+ className: "mascots"
+ id: category
+
+ for name in keys
+ if Conf["Deleted Mascots"].contains name
+ mascot = Mascots[name]
+ li = $.el 'li',
+ className: 'mascot'
+ id: name
+ innerHTML: "
+
#{name.replace /_/g, " "}
+
+ "
+
+ $.on li, 'click', ->
+ if confirm "Are you sure you want to undelete \"#{@id}\"?"
+ Conf["Deleted Mascots"].remove @id
+ $.set "Deleted Mascots", Conf["Deleted Mascots"]
+ $.rm @
+
+ $.add ul, li
+
+ $.add suboptions, ul
+
+ batchmascots = $.el 'div',
+ id: "mascots_batch"
+ innerHTML: "
Return"
+
+ $.on $('#return', batchmascots), 'click', ->
+ $.rm $.id "mascotContainer"
+ Settings.section 'mascots'
+
+ $.add parentdiv, [suboptions, batchmascots, mascotHide]
+
+ Rice.nodes parentdiv
+
+ $.add section, parentdiv
\ No newline at end of file