/* BetterDiscordApp Settings Panel JavaScript
* Version: 1.3
* Author: Jiiks | http://jiiks.net
* Date: 26/08/2015 - 11:54
* Last Update: 30/08/2015 - 12:16
* https://github.com/Jiiks/BetterDiscordApp
*/
var links = { "Jiiks.net": "http://jiiks.net", "Twitter": "http://twitter.com/jiiksi", "Github": "https://github.com/jiiks" };
function SettingsPanel() {
}
SettingsPanel.prototype.getPanel = function() {
return this.tcSettingsPanel;
}
SettingsPanel.prototype.init = function() {
var self = this;
this.tcSettingsPanel = $("
", { id: "tc-settings-panel", style: "display:none" });
this.getPanel().append($("", { id: "tc-settings-panel-header" }).append($("", { text: "BetterDiscord - Settings" })).append($("", { id: "tc-settings-close", text: "X", style:"cursor:pointer;" })));
var settingsList = $("");
this.getPanel().append($("", { id: "tc-settings-panel-body" }).append(settingsList));
$.each(settings, function(key, value) {
var son = "tc-switch-on";
var sof = "tc-switch-off";
if(settingsCookie[value.id]) {
son = "tc-switch-on active";
}else {
sof = "tc-switch-off active";
}
settingsList.append($("").append($("", { text: key})).append($("", { html: " - " + value.info + "" + (value.implemented == false ? ' Coming Soon' : "") })).append($("", { class: value.implemented ? "tc-switch" : "tc-switch disabled", id: value.id }).append($("", { class: sof, text: "OFF" })).append($("", { class: son, text: "ON" }))));
})
var settingsFooter = $("", { id: "tc-settings-panel-footer" });
settingsFooter.append($("", { id: "tc-about", text: "BDA v" + version + "(js "+jsVersion+") by Jiiks | Settings are automatically saved." } ));
var tcLinks = $("", { id: "tc-links" });
$.each(links, function(key, value) {
tcLinks.append($("", { href: value, text: key, target: "_blank" }));
tcLinks.append($("", { text: " | " }));
})
settingsFooter.append(tcLinks);
this.getPanel().append(settingsFooter);
$("body").append(this.getPanel());
$("#tc-settings-close").on("click", function(e) { self.show(); });
$(".tc-switch").on("click", function() { self.handler($(this)) });
if(settingsCookie["bda-es-0"]) {
$("#twitchcord-button-container").show();
} else {
$("#twitchcord-button-container").hide();
}
if(settingsCookie["bda-gs-2"]) {
$("body").addClass("bd-minimal");
} else {
$("body").removeClass("bd-minimal");
}
if(settingsCookie["bda-gs-3"]) {
$("body").addClass("bd-minimal-chan");
} else {
$("body").removeClass("bd-minimal-chan");
}
}
SettingsPanel.prototype.show = function() {
this.getPanel().toggle();
$("#tc-settings-li").removeClass();
if(this.getPanel().is(":visible")) {
$("#tc-settings-li").addClass("active");
}
}
SettingsPanel.prototype.handler = function(e){
var sid = e.attr("id");
var enabled = settingsCookie[sid];
enabled = !enabled;
settingsCookie[sid] = enabled;
var swoff = $("#" + sid + " .tc-switch-off");
var swon = $("#" + sid + " .tc-switch-on");
swoff.removeClass("active");
swon.removeClass("active");
if(enabled) {
swon.addClass("active");
} else {
swoff.addClass("active");
}
if(settingsCookie["bda-es-0"]) {
$("#twitchcord-button-container").show();
} else {
$("#twitchcord-button-container").hide();
}
if(settingsCookie["bda-gs-2"]) {
$("body").addClass("bd-minimal");
} else {
$("body").removeClass("bd-minimal");
}
if(settingsCookie["bda-gs-3"]) {
$("body").addClass("bd-minimal-chan");
} else {
$("body").removeClass("bd-minimal-chan");
}
mainCore.saveSettings();
}