diff --git a/dev/js/00core.js b/dev/js/00core.js
index 0a4d19b5..45a4b92c 100644
--- a/dev/js/00core.js
+++ b/dev/js/00core.js
@@ -8,12 +8,6 @@
var BD;
-var settingsPanel, emoteModule, utils, quickEmoteMenu, opublicServers, voiceMode, pluginModule, themeModule, customCssEditor;
-
-var mainObserver;
-var mainCore;
-var settingsCookie = {};
-
function Core() {
BD = this;
}
@@ -21,30 +15,38 @@ function Core() {
Core.prototype.init = function () {
var self = this;
this.version = version;
- this.jsVersion = jsVersion;
- if (this.version < supportedVersion) {
- this.alert("Not Supported", "BetterDiscord v" + this.version + "(your version)" + " is not supported by the latest js(" + this.jsVersion + ").
Please download the latest version from BetterDiscord.net");
+
+ if (this.version < bdConfig.versionInfo.supportedVersion) {
+ this.alert("Not Supported", "BetterDiscord v" + this.version + "(your version)" + " is not supported by the latest js(" + bdConfig.versionInfo.version + ").
Please download the latest version from BetterDiscord.net");
return;
}
- this.utils = new Utils();
+ this.modules = {
+ emoteModule: new EmoteModule(),
+ publicServers: new PublicServers(),
+ emoteMenu: new QuickEmoteMenu(),
+ cssEditor: new customCssEditor(),
+ settingsPanel: new SettingsPanel(),
+ utils: new Utils(),
+ voiceMode: new VoiceMode(),
+ pluginModule: new pluginModule(),
+ themeModule: new ThemeModule()
+ }
- utils = new Utils();
- utils.getHash();
- emoteModule = new EmoteModule();
- quickEmoteMenu = new QuickEmoteMenu();
- voiceMode = new VoiceMode();
+ this.modules.utils.getHash();
- emoteModule.init();
+ this.modules.emoteModule.init();
this.initSettings();
this.initObserver();
+
//Incase were too fast
function gwDefer() {
- console.log(new Date().getTime() + " Defer");
+ self.modules.utils.log(new Date().getTime() + " Defer");
+
if ($(".guilds-wrapper .guilds").children().length > 0) {
- console.log(new Date().getTime() + " Defer Loaded");
+ self.modules.utils.log(new Date().getTime() + " Defer Loaded");
var guilds = $(".guilds>li:first-child");
var showChannelsButton = $("", {
@@ -55,7 +57,7 @@ Core.prototype.init = function () {
"cursor": "pointer"
},
click: function () {
- settingsCookie["bda-gs-3"] = false;
+ self.settingsCookie["bda-gs-3"] = false;
$("body").removeClass("bd-minimal-chan");
self.saveSettings();
}
@@ -63,39 +65,29 @@ Core.prototype.init = function () {
$(".guilds-wrapper").prepend(showChannelsButton);
- opublicServers = new PublicServers();
- customCssEditor = new CustomCssEditor();
- pluginModule = new PluginModule();
- pluginModule.loadPlugins();
+ self.modules.pluginModule.loadPlugins();
+
if (typeof (themesupport2) !== "undefined") {
- themeModule = new ThemeModule();
- themeModule.loadThemes();
+ self.modules.themeModule.loadThemes();
}
- settingsPanel = new SettingsPanel();
- settingsPanel.init();
+ self.modules.settingsPanel.init();
- quickEmoteMenu.init(false);
-
- $("#tc-settings-button").on("click", function () {
- settingsPanel.show();
- });
+ self.modules.quickEmoteMenu.init(false);
window.addEventListener("beforeunload", function(){
- if(settingsCookie["bda-dc-0"]){
+ if(self.settingsCookie["bda-dc-0"]){
$('.btn.btn-disconnect').click();
}
});
-
- opublicServers.init();
-
- emoteModule.autoCapitalize();
+ self.modules.publicServers.init();
+ self.modules.emoteModule.autoCapitalize();
/*Display new features in BetterDiscord*/
- if (settingsCookie["version"] < jsVersion) {
+ if (self.settingsCookie["version"] < bdConfig.versionInfo.version) {
var cl = self.constructChangelog();
$("body").append(cl);
- settingsCookie["version"] = jsVersion;
+ self.settingsCookie["version"] = bdConfig.versionInfo.version;
self.saveSettings();
}
@@ -115,14 +107,14 @@ Core.prototype.init = function () {
Core.prototype.initSettings = function () {
if ($.cookie("better-discord") == undefined) {
- settingsCookie = defaultCookie;
+ this.settingsCookie = bdConfig.defaults;
this.saveSettings();
} else {
this.loadSettings();
for (var setting in defaultCookie) {
- if (settingsCookie[setting] == undefined) {
- settingsCookie[setting] = defaultCookie[setting];
+ if (this.settingsCookie[setting] == undefined) {
+ this.settingsCookie[setting] = bdConfig.defaults[setting];
this.saveSettings();
}
}
@@ -130,38 +122,39 @@ Core.prototype.initSettings = function () {
};
Core.prototype.saveSettings = function () {
- $.cookie("better-discord", JSON.stringify(settingsCookie), {
+ $.cookie("better-discord", JSON.stringify(this.settingsCookie), {
expires: 365,
path: '/'
});
};
Core.prototype.loadSettings = function () {
- settingsCookie = JSON.parse($.cookie("better-discord"));
+ this.settingsCookie = JSON.parse($.cookie("better-discord"));
};
Core.prototype.initObserver = function () {
- mainObserver = new MutationObserver(function (mutations) {
+ var self = this;
+ this.observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if($(mutation.target).find(".emoji-picker").length) {
var fc = mutation.target.firstChild;
if(fc.classList.contains("popout")) {
- quickEmoteMenu.obsCallback($(fc));
+ self.modules.quickEmoteMenu.obsCallback($(fc));
}
}
- if (typeof pluginModule !== "undefined") pluginModule.rawObserver(mutation);
+ if (typeof pluginModule !== "undefined") self.modules.pluginModule.rawObserver(mutation);
if (mutation.target.getAttribute('class') != null) {
//console.log(mutation.target)
if(mutation.target.classList.contains('title-wrap') || mutation.target.classList.contains('chat')){
// quickEmoteMenu.obsCallback();
- voiceMode.obsCallback();
- if (typeof pluginModule !== "undefined") pluginModule.channelSwitch();
+ self.modules.voiceMode.obsCallback();
+ if (typeof pluginModule !== "undefined") self.modules.pluginModule.channelSwitch();
}
if (mutation.target.getAttribute('class').indexOf('scroller messages') != -1) {
- if (typeof pluginModule !== "undefined") pluginModule.newMessage();
+ if (typeof self.modules.pluginModule !== "undefined") self.modules.pluginModule.newMessage();
}
}
- emoteModule.obsCallback(mutation);
+ self.modules.emoteModule.obsCallback(mutation);
});
});
@@ -184,15 +177,15 @@ Core.prototype.constructChangelog = function () {
'