This commit is contained in:
Zack Rauen 2017-10-29 19:00:14 -04:00
parent 01875813f1
commit 87ea70c7eb
1 changed files with 0 additions and 436 deletions

View File

@ -1526,7 +1526,6 @@ function SettingsPanel() {
SettingsPanel.prototype.init = function () {
var self = this;
self.v2SettingsPanel = new V2_SettingsPanel();
//self.construct();
var body = $("body");
if (settingsCookie["bda-es-0"]) {
@ -1588,131 +1587,6 @@ SettingsPanel.prototype.init = function () {
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":
$(".bda-slist-top").show();
break;
case "bd-emotes-tab":
$(".bda-slist-top").show();
break;
case "bd-customcss-tab":
$(".bda-slist-top").show();
if (!customCssInitialized) {
customCssEditor.init();
customCssInitialized = true;
}
break;
case "bd-themes-tab":
$(".bda-slist-top:first").hide();
break;
case "bd-plugins-tab":
$(".bda-slist-top:first").hide();
break;
default:
$(".bda-slist-top").show();
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")
}
}
if(id == "bda-gs-8" && enabled) {
mainCore.alert("Developer Mode Enabled", "Use F8 to break/resume execution<br>More coming soon")
}
settingsCookie[id] = enabled;
this.updateSettings();
};
SettingsPanel.prototype.updateSettings = function() {
if (settingsCookie["bda-es-0"]) {
$("#twitchcord-button-container").show();
} else {
$("#twitchcord-button-container").hide();
}
if(settingsCookie["bda-gs-b"]) {
$("body").addClass("bd-blue");
} else {
$("body").removeClass("bd-blue");
}
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 = $("<div class='tipsy tipsy-se' style='display: block; top: 82px; left: 1630.5px; visibility: visible; opacity: 0.8;'><div class='tipsy-inner'></div></div>");
$(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');
}
if(settingsCookie["bda-gs-8"]) {
dMode.enable();
} else {
dMode.disable();
}
mainCore.saveSettings();
};
SettingsPanel.prototype.inject = function(mutation) {
let self = this;
if(!mutation.target.classList.contains("layers")) return;
@ -1746,316 +1620,6 @@ SettingsPanel.prototype.versionInfo = function() {
return element;
}
SettingsPanel.prototype.tabBarNew = function() {
let self = this;
let _tabBar = $("<div/>", {
class: 'tab-bar TOP',
style: 'border-bottom:none'
});
let items = [
{ 'id': 'bd-core', 'text': 'Core' },
{ 'id': 'bd-emotes', 'text': 'Emotes' },
{ 'id': 'bd-customcss', 'text': 'Custom CSS' },
{ 'id': 'bd-plugins', 'text': 'Plugins' },
{ 'id': 'bd-themes', 'text': 'Themes' }
];
items.map(value => {
_tabBar.append($("<div/>", {
class: 'tab-bar-item bd-tab',
text: value.text,
id: value.id,
click: () => self.changeTabNew(value.id)
}));
});
return _tabBar;
}
SettingsPanel.prototype.changeTabNew = function(id) {
$(".bd-tab").removeClass("selected");
$(`#${id}`).addClass("selected");
$(".bd-pane").hide();
$(`#${id}-pane`).show();
if(id === 'bd-customcss') {
if (!customCssInitialized) {
customCssEditor.init();
customCssInitialized = true;
}
}
}
SettingsPanel.prototype.updateSettingNew = function (id, checked) {
if(id == "bda-css-2") {
$("#app-mount").removeClass("bd-hide-bd");
customCssEditor.hideBackdrop = checked;
if(checked) {
$("#app-mount").addClass("bd-hide-bd")
}
}
if(id == "bda-gs-8" && checked) {
mainCore.alert("Developer Mode Enabled", "Use F8 to break/resume execution<br>More coming soon")
}
settingsCookie[id] = checked;
this.updateSettings();
};
SettingsPanel.prototype.settingsSwitch = function(key) {
let self = this;
let setting = settings[key];
return $("<div/>", {
class: 'ui-flex flex-vertical flex-justify-start flex-align-stretch flex-nowrap ui-switch-item'
}).append($("<div/>", {
class: 'ui-flex flex-horizontal flex-justify-start flex-align-stretch flex-nowrap'
}).append($("<h3/>", {
class: 'ui-form-title h3 margin-reset margin-reset ui-flex-child',
text: key
})).append($("<label/>", {
class: 'ui-switch-wrapper ui-flex-child',
style: 'flex: 0 0 auto'
}).append($("<input/>", {
class: 'ui-switch-checkbox',
type: 'checkbox',
change: function() { self.updateSettingNew(setting.id, this.checked) },
checked: settingsCookie[setting.id]
})).append($("<div/>", {
class: 'ui-switch'
})))).append($("<div/>", {
class: 'ui-form-text style-description margin-top-4',
style: 'flex: 1 1 auto',
text: setting.info
}));
}
SettingsPanel.prototype.corePaneNew = function() {
let self = this;
let _pane = $("<div/>", {
class: 'ui-form-item bd-pane',
id: 'bd-core-pane',
style: 'display:none'
});
Object.keys(settings).map(value => {
let setting = settings[value];
if(setting.cat !== 'core' || !setting.implemented || setting.hidden) return false;
_pane.append(self.settingsSwitch(value))
});
return _pane;
}
SettingsPanel.prototype.emotesPaneNew = function() {
let self = this;
let _pane = $("<div/>", {
class: 'ui-form-item bd-pane',
id: 'bd-emotes-pane',
style: 'display:none'
});
Object.keys(settings).map(value => {
let setting = settings[value];
if(setting.cat !== 'emote' || !setting.implemented || setting.hidden) return false;
_pane.append(self.settingsSwitch(value))
});
return _pane;
}
SettingsPanel.prototype.customCssPaneNew = function() {
let self = this;
let _pane = $("<div/>", {
class: 'ui-form-item bd-pane',
id: 'bd-customcss-pane',
style: 'display:none'
});
let attachBtn = $("<div/>", {
id: 'editor-detached',
style: 'display:none'
}).append($("<h3/>", {
text: 'Editor Detached'
})).append($("<button/>", {
class: 'btn btn-primary',
text: 'Attach',
click: () => { customCssEditor.attach(); }
}));
_pane.append(attachBtn);
let _ccss = window.bdStorage.get("bdcustomcss");
let ccss = "";
if(_ccss !== null && _ccss !== "") {
ccss = atob(_ccss);
}
let innerPane = $("<div/>", {
id: 'bd-customcss-innerpane'
}).append($("<textarea/>", {
id: 'bd-custom-css-ta',
text: ccss
}));
_pane.append(innerPane);
return _pane;
}
SettingsPanel.prototype.pluginTemp = function(plugin, cb) {
let item = $("<li/>", {
}).append($("<div/>", {
class: 'bda-left'
}).append($("<span/>", {
class: 'bda-name',
text: `${plugin.getName()} v${plugin.getVersion()} by ${plugin.getAuthor()}`
})).append($("<div/>", {
class: 'scroller-wrap fade'
}).append($("<div/>", {
class: 'scroller bda-description',
text: plugin.getDescription()
})))).append($("<div/>", {
class: 'bda-right'
}).append($("<label/>", {
class: 'ui-switch-wrapper ui-flex-child',
style: 'flex: 0 0 auto'
}).append($("<input/>", {
class: 'ui-switch-checkbox',
type: 'checkbox',
change: function() { pluginModule.handlePluginT(plugin.getName(), this.checked) },
checked: pluginCookie[plugin.getName()]
})).append($("<div/>", {
class: 'ui-switch'
}))).append($("<button/>", {
text: 'Reload',
disabled: true,
enabled: false,
click: () => { return false; }
})).append($("<button/>", {
text: 'Settings',
click: () => { pluginModule.showSettingsT(plugin.getName()) }
})));
return item;
}
SettingsPanel.prototype.pluginsPaneNew = function() {
let self = this;
let list = $("<ul/>", {
class: 'bda-slist'
});
$.each(bdplugins, function() {
let plugin = this["plugin"];
list.append(self.pluginTemp(plugin));
});
return $("<div/>", {
class: 'ui-form-item bd-pane',
id: 'bd-plugins-pane',
style: 'display:none'
}).append(list);
}
SettingsPanel.prototype.themeTemp = function(theme) {
let item = $("<li/>", {
}).append($("<div/>", {
class: 'bda-left'
}).append($("<span/>", {
class: 'bda-name',
text: `${theme["name"].replace(/_/g, " ")} v${theme["version"]} by ${theme["author"]}`
})).append($("<div/>", {
class: 'scroller-wrap fade'
}).append($("<div/>", {
class: 'scroller bda-description',
text: theme["description"]
})))).append($("<div/>", {
class: 'bda-right'
}).append($("<label/>", {
class: 'ui-switch-wrapper ui-flex-child',
style: 'flex: 0 0 auto'
}).append($("<input/>", {
class: 'ui-switch-checkbox',
type: 'checkbox',
change: function() { themeModule.handleThemeT(theme["name"], this.checked) },
checked: themeCookie[theme["name"]]
})).append($("<div/>", {
class: 'ui-switch'
}))).append($("<button/>", {
text: 'Reload',
disabled: true,
enabled: false,
click: () => { return false; }
})));
return item;
}
SettingsPanel.prototype.themesPaneNew = function() {
let self = this;
let list = $("<ul/>", {
class: 'bda-slist'
});
$.each(bdthemes, function() {
let theme = this;
list.append(self.themeTemp(theme));
});
return $("<div/>", {
class: 'ui-form-item bd-pane',
id: 'bd-themes-pane',
style: 'display:none'
}).append(list);
}
SettingsPanel.prototype.panesNew = function() {
let self = this;
let _panes = $("<div/>", {
class: 'bd-settings-panes'
});
_panes.append(self.corePaneNew());
_panes.append(self.emotesPaneNew());
_panes.append(self.customCssPaneNew());
_panes.append(self.pluginsPaneNew());
_panes.append(self.themesPaneNew());
return _panes;
}
SettingsPanel.prototype.settingsPaneNew = function() {
let self = this;
if(self.constructed) return self.constructed;
let tools = $(".tools").clone();
tools.find(".btn-close").on("click", () => { $(".tools").first().find(".btn-close").click(); });
self.constructed = $("<div/>", {
class: 'content-region',
id: 'bd-settingspane',
style: 'display:none'
}).append($("<div/>", {
class: 'scroller-wrap fade dark'
}).append($("<div/>", {
class: 'scroller'
}).append($("<div/>", {
class: 'content-column'
}).append(self.tabBarNew()).append(self.panesNew())).append(tools)));
return self.constructed;
};
SettingsPanel.prototype.showBdSettingsPane = function() {
$(".ui-standard-sidebar-view .content-region").first().hide();
$("#bd-settingspane").show();
};
SettingsPanel.prototype.hideBdSettingsPane = function() {
$(".ui-standard-sidebar-view .content-region").first().show();
$("#bd-settingspane").hide();
};
/* BetterDiscordApp Utilities JavaScript
* Version: 1.0
* Author: Jiiks | http://jiiks.net