/* BetterDiscordApp Settings Panel JavaScript * Version: 2.0 * Author: Jiiks | http://jiiks.net * Date: 26/08/2015 - 11:54 * Last Update: 27/11/2015 - 00:50 * https://github.com/Jiiks/BetterDiscordApp */ var settingsButton = null; var panel = null; 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.construct(); 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).on("mouseover", ".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).on("mouseleave", ".emote", function () { $(".tipsy").remove(); }); } else { $(document).off('mouseover', '.emote'); } }; var customCssInitialized = false; var lastTab = ""; SettingsPanel.prototype.changeTab = function (tab) { var self = this; lastTab = tab; var controlGroups = $("#bd-control-groups"); $(".bd-tab").removeClass("selected"); $(".bd-pane").hide(); $("#" + tab).addClass("selected"); $("#" + tab.replace("tab", "pane")).show(); switch (tab) { case "bd-settings-tab": break; case "bd-customcss-tab": if (!customCssInitialized) { customCssEditor.init(); customCssInitialized = true; } break; } }; SettingsPanel.prototype.updateSetting = function (checkbox) { var cb = $(checkbox).children().find('input[type="checkbox"]'); var enabled = !cb.is(":checked"); var id = cb.attr("id"); cb.prop("checked", enabled); if(id == "bda-css-2") { $("#app-mount").removeClass("bd-hide-bd"); customCssEditor.hideBackdrop = enabled; if(enabled) { $("#app-mount").addClass("bd-hide-bd") } } settingsCookie[id] = enabled; 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-1"]) { $("#bd-pub-li").show(); } else { $("#bd-pub-li").hide(); } if (settingsCookie["bda-gs-4"]) { voiceMode.enable(); } else { voiceMode.disable(); } $("#app-mount").removeClass("bda-dark"); if(settingsCookie["bda-gs-5"]) { $("#app-mount").addClass("bda-dark"); } if (settingsCookie["bda-es-6"]) { //Pretty emote titles emoteNamePopup = $("
"); $(document).on("mouseover", ".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).on("mouseleave", ".emote", function () { $(".tipsy").remove(); }); } else { $(document).off('mouseover', '.emote'); } mainCore.saveSettings(); }; SettingsPanel.prototype.construct = function () { var self = this; panel = $("
", { id: "bd-pane", class: "settings-inner", css: { "display": "none" } }); var settingsInner = '' + '
' + '
' + '
' + '
Core
' + '
Emotes
' + '
Custom CSS
' + '
Plugins
' + '
Themes
' + '
' + '
' + ' '; settingsInner += ''; var ccss = atob(localStorage.getItem("bdcustomcss")); customCssEditor.applyCustomCss(ccss, true, false); settingsInner += '' + ' ' + '' + ' ' + ' ' + '' + '
' + '
' + '
' + ' BetterDiscord v' + version + '(JSv' + jsVersion + ') by Jiiks' + ' BetterDiscord.net' + '
' + '
'; function showSettings() { $(".tab-bar-item").removeClass("selected"); settingsButton.addClass("selected"); $(".form .settings-right .settings-inner").first().hide(); panel.show(); if (lastTab == "") { self.changeTab("bd-settings-tab"); } else { self.changeTab(lastTab); } } settingsButton = $("
", { class: "tab-bar-item", text: "BetterDiscord", id: "bd-settings-new", click: showSettings }); panel.html(settingsInner); function defer() { if ($(".btn.btn-settings").length < 1) { setTimeout(defer, 100); } else { $(".btn.btn-settings").first().on("click", function () { function innerDefer() { if ($(".modal-inner").first().is(":visible")) { 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"); } else { setTimeout(innerDefer, 100); } } innerDefer(); }); } } defer(); };