/* BetterDiscordApp Settings Panel JavaScript
* Version: 1.2
* Author: Jiiks | http://jiiks.net
* Date: 26/08/2015 - 11:54
* Last Update: 29/08/2015 - 11:47
* https://github.com/Jiiks/BetterDiscordApp
*/
var links = { "Check for updates": "#", "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" });
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($("", { text: " - " + value.info })).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 }));
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)) });
}
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();
}
core.saveSettings();
}