/* BetterDiscordApp Settings Panel JavaScript * Version: 2.0 * Author: Jiiks | http://jiiks.net * Date: 26/08/2015 - 11:54 * Last Update: 10/04/2016 * https://github.com/Jiiks/BetterDiscordApp */ function SettingsPanel() { utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/codemirror.min.js"); utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/mode/css/css.min.js"); utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.4.2/Sortable.min.js"); } SettingsPanel.prototype.init = function () { var self = this; self.constructPanel(); var body = $("body"); 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"); } if (settingsCookie["bda-gs-4"]) { voiceMode.enable(); } if(settingsCookie["bda-gs-5"]) { $("#app-mount").addClass("bda-dark"); } if (settingsCookie["bda-es-6"]) { //Pretty emote titles emoteNamePopup = $("
"); $(document).off("mouseover.etitles").on("mouseover.etitles", ".emote", function () { var x = $(this).offset(); var title = $(this).attr("alt"); $(emoteNamePopup).find(".tipsy-inner").text(title); $(emoteNamePopup).css('left', x.left - 25); $(emoteNamePopup).css('top', x.top - 32); $("div[data-reactid='.0.1.1']").append($(emoteNamePopup)); }); $(document).off("mouseleave.etitles").on("mouseleave.etitles", ".emote", function () { $(".tipsy").remove(); }); } else { $(document).off("mouseover.etitles"); $(document).off("mouseleave.etitles"); } }; SettingsPanel.prototype.changeTab = function(tab) { this.lastTab = tab; tab = $(tab).prop("id"); $(".bd-tab").removeClass("selected"); $(".bd-pane").hide(); $("#" + tab).addClass("selected"); $("#" + tab.replace("tab", "pane")).show(); switch(tab) { case "bd-customcss-tab": if(!this.customCssInitialized) { customCssEditor.init(); this.customCssInitialized = true; } break; } }; SettingsPanel.prototype.updateSetting = function(checkbox) { console.log("Working?"); }; SettingsPanel.prototype.constructPanel = function() { var self = this; self.lastTab = ""; panel = $("
", { id: "bd-pane", class: "settings-inner", css: { "display": "none" } }); var panelHtml = '\
\
\
\
Core
\
Emotes
\
Custom CSS
\
Plugins
\
Themes
\
\
\
\
    \ '; //Core settings for(var setting in bdConfig.options) { var sett = bdConfig.options[setting]; var id = sett["id"]; if(sett["cat"] != "core" || !sett["implemented"] || sett["hidden"]) continue; panelHtml += '\
  • \
    \
    \ \ \
    \ \ '+setting+' - '+sett["info"]+'\ \
    \
  • \ '; } panelHtml += '\
\
\ \ \ \ \
\
\
BetterDiscord v'+BdApi.getCore().version+'(JSv'+BdApi.getCore().jsVersion+') by Jiiks BetterDiscord.net
\
\ '; panel.html(panelHtml); function showSettings() { $(".tab-bar-item").removeClass("selected"); settingsButton.addClass("selected"); $(".form .settings-right .settings-inner").first().hide(); panel.show(); if (self.lastTab == "") { self.changeTab({id:"bd-settings-tab"}); } else { self.changeTab(self.lastTab); } } settingsButton = $("
", { class: "tab-bar-item", text: "BetterDiscord", id: "bd-settings-new", click: showSettings }); (function defer() { if($(".btn.btn-settings").length < 1) { setTimeout(defer, 100); return; } $(".btn.btn-settings").first().off("click.bda").on("click.bda", function() { (function defer() { if(!$(".modal-inner").first().is(":visible")) { setTimeout(defer, 100); return; } panel.hide(); var tabBar = $(".tab-bar.SIDE").first(); $(".tab-bar.SIDE .tab-bar-item").click(function () { $(".form .settings-right .settings-inner").first().show(); $("#bd-settings-new").removeClass("selected"); panel.hide(); }); tabBar.append(settingsButton); $(".form .settings-right .settings-inner").last().after(panel); $("#bd-settings-new").removeClass("selected"); })(); }); })(); };