This commit is contained in:
Mirco Wittrien 2018-12-27 14:37:35 +01:00
parent 84fc67f38a
commit c52ff0914c
2 changed files with 23 additions and 26 deletions

View File

@ -258,7 +258,7 @@ class PluginRepo {
.on("click", ".btn-addplugin", () => {this.addPluginToOwnList(settingspanel);}) .on("click", ".btn-addplugin", () => {this.addPluginToOwnList(settingspanel);})
.on("keyup", "#input-pluginurl", (e) => {if (e.which == 13) this.addPluginToOwnList(settingspanel);}) .on("keyup", "#input-pluginurl", (e) => {if (e.which == 13) this.addPluginToOwnList(settingspanel);})
.on("click", ".remove-plugin", (e) => {this.removePluginFromOwnList(e);}) .on("click", ".remove-plugin", (e) => {this.removePluginFromOwnList(e);})
.on("click", ".remove-all", () => {this.removeAllFromOwnList(settingspanel);}) .on("click", ".remove-all", () => {this.removeAllFromOwnList();})
.on("click", ".refresh-button", () => { .on("click", ".refresh-button", () => {
this.loading = {is:false, timeout:null, amount:0}; this.loading = {is:false, timeout:null, amount:0};
this.loadPlugins(); this.loadPlugins();
@ -353,9 +353,8 @@ class PluginRepo {
if (typeof BDFDB === "object") { if (typeof BDFDB === "object") {
clearInterval(this.updateInterval); clearInterval(this.updateInterval);
clearTimeout(this.loading.timeout); clearTimeout(this.loading.timeout);
$("webview[webview-pluginrepo], .pluginrepo-modal, .pluginrepo-notice, .bd-pluginrepobutton, .pluginrepo-loadingicon").remove(); BDFDB.removeEles("webview[webview-pluginrepo]",".pluginrepo-modal",".pluginrepo-notice",".bd-pluginrepobutton",".pluginrepo-loadingicon",BDFDB.dotCN.app + " > .repo-loadingwrapper:empty");
$(BDFDB.dotCN.app + " > .repo-loadingwrapper:empty").remove();
BDFDB.unloadMessage(this); BDFDB.unloadMessage(this);
} }
@ -422,10 +421,10 @@ class PluginRepo {
BDFDB.saveData("ownlist", ownlist, this, "ownlist"); BDFDB.saveData("ownlist", ownlist, this, "ownlist");
} }
removeAllFromOwnList (settingspanel) { removeAllFromOwnList () {
if (confirm("Are you sure you want to remove all added Plugins from your own list?")) { if (confirm("Are you sure you want to remove all added Plugins from your own list?")) {
BDFDB.saveData("ownlist", [], this, "ownlist"); BDFDB.saveData("ownlist", [], this, "ownlist");
settingspanel.querySelectorAll(BDFDB.dotCN.hovercard).forEach(ele => {ele.remove();}); BDFDB.removeEles(this.getName() + "-settings " + BDFDB.dotCN.hovercard);
} }
} }
@ -686,18 +685,17 @@ class PluginRepo {
getPluginInfo(() => { getPluginInfo(() => {
if (!this.started) { if (!this.started) {
clearTimeout(this.loading.timeout); clearTimeout(this.loading.timeout);
if (typeof webview != "undefined") webview.remove(); BDFDB.removeEles(webview);
return; return;
} }
var finishCounter = 0, finishInterval = setInterval(() => { var finishCounter = 0, finishInterval = setInterval(() => {
if ((webviewqueue.length == 0 && !webviewrunning) || finishCounter > 300 || !this.loading.is) { if ((webviewqueue.length == 0 && !webviewrunning) || finishCounter > 300 || !this.loading.is) {
clearInterval(finishInterval); clearInterval(finishInterval);
if (typeof webview != "undefined") webview.remove(); BDFDB.removeEles(webview, ".pluginrepo-loadingicon");
$(".pluginrepo-loadingicon").remove(); if (!loadingiconwrapper.firstChild) BDFDB.removeEles(loadingiconwrapper);
if (!loadingiconwrapper.firstChild) loadingiconwrapper.remove();
clearTimeout(this.loading.timeout); clearTimeout(this.loading.timeout);
this.loading = {is:false, timeout:null, amount:this.loading.amount}; this.loading = {is:false, timeout:null, amount:this.loading.amount};
console.log("PluginRepo: Finished fetching Plugins."); console.log(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Finished fetching Plugins.");
if (document.querySelector(".bd-pluginrepobutton")) BDFDB.showToast(`Finished fetching Plugins.`, {type:"success"}); if (document.querySelector(".bd-pluginrepobutton")) BDFDB.showToast(`Finished fetching Plugins.`, {type:"success"});
if (outdated > 0) { if (outdated > 0) {
var text = `${outdated} of your Plugins ${outdated == 1 ? "is" : "are"} outdated. Check:`; var text = `${outdated} of your Plugins ${outdated == 1 ? "is" : "are"} outdated. Check:`;
@ -897,7 +895,7 @@ class PluginRepo {
bdplugins[name].plugin.start(); bdplugins[name].plugin.start();
pluginCookie[name] = true; pluginCookie[name] = true;
pluginModule.savePluginData(); pluginModule.savePluginData();
console.log("PluginRepo: started Plugin " + name); console.log(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Started Plugin " + name + ".");
} }
} }
@ -924,7 +922,7 @@ class PluginRepo {
pluginCookie[name] = false; pluginCookie[name] = false;
delete bdplugins[name]; delete bdplugins[name];
pluginModule.savePluginData(); pluginModule.savePluginData();
console.log("PluginRepo: stopped Plugin " + name); console.log(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Stopped Plugin " + name + ".");
} }
} }
} }

View File

@ -304,7 +304,7 @@ class ThemeRepo {
.on("click", ".btn-addtheme", () => {this.addThemeToOwnList(settingspanel);}) .on("click", ".btn-addtheme", () => {this.addThemeToOwnList(settingspanel);})
.on("keyup", "#input-themeurl", (e) => {if (e.which == 13) this.addThemeToOwnList(settingspanel);}) .on("keyup", "#input-themeurl", (e) => {if (e.which == 13) this.addThemeToOwnList(settingspanel);})
.on("click", ".remove-theme", (e) => {this.removeThemeFromOwnList(e);}) .on("click", ".remove-theme", (e) => {this.removeThemeFromOwnList(e);})
.on("click", ".remove-all", () => {this.removeAllFromOwnList(settingspanel);}) .on("click", ".remove-all", () => {this.removeAllFromOwnList();})
.on("click", ".refresh-button", () => { .on("click", ".refresh-button", () => {
this.loading = {is:false, timeout:null, amount:0}; this.loading = {is:false, timeout:null, amount:0};
this.loadThemes(); this.loadThemes();
@ -403,8 +403,7 @@ class ThemeRepo {
clearInterval(this.updateInterval); clearInterval(this.updateInterval);
clearTimeout(this.loading.timeout); clearTimeout(this.loading.timeout);
$(".discordPreview, .themerepo-modal, .themerepo-notice, .bd-themerepobutton, .themerepo-loadingicon").remove(); BDFDB.removeEles(".discordPreview",".themerepo-modal",".themerepo-notice",".bd-themerepobutton",".themerepo-loadingicon",BDFDB.dotCN.app + " > .repo-loadingwrapper:empty");
$(BDFDB.dotCN.app + " > .repo-loadingwrapper:empty").remove();
BDFDB.unloadMessage(this); BDFDB.unloadMessage(this);
} }
@ -467,10 +466,10 @@ class ThemeRepo {
BDFDB.saveData("ownlist", ownlist, this, "ownlist"); BDFDB.saveData("ownlist", ownlist, this, "ownlist");
} }
removeAllFromOwnList (settingspanel) { removeAllFromOwnList () {
if (confirm("Are you sure you want to remove all added Themes from your own list?")) { if (confirm("Are you sure you want to remove all added Themes from your own list?")) {
BDFDB.saveData("ownlist", [], this, "ownlist"); BDFDB.saveData("ownlist", [], this, "ownlist");
settingspanel.querySelectorAll(BDFDB.dotCN.hovercard).forEach(ele => {ele.remove();}); BDFDB.removeEles(this.getName() + "-settings " + BDFDB.dotCN.hovercard);
} }
} }
@ -520,7 +519,7 @@ class ThemeRepo {
themeRepoModal.find("#input-hideupdated").prop("checked", hiddenSettings.updated || showOnlyOutdated); themeRepoModal.find("#input-hideupdated").prop("checked", hiddenSettings.updated || showOnlyOutdated);
themeRepoModal.find("#input-hideoutdated").prop("checked", hiddenSettings.outdated && !showOnlyOutdated); themeRepoModal.find("#input-hideoutdated").prop("checked", hiddenSettings.outdated && !showOnlyOutdated);
themeRepoModal.find("#input-hidedownloadable").prop("checked", hiddenSettings.downloadable || showOnlyOutdated); themeRepoModal.find("#input-hidedownloadable").prop("checked", hiddenSettings.downloadable || showOnlyOutdated);
if (!BDFDB.isRestartNoMoreEnabled()) themeRepoModal.find("#RNMoption").remove(); if (!BDFDB.isRestartNoMoreEnabled()) BDFDB.removeEles(".themerepo-modal #RNMoption");
else themeRepoModal.find("#input-rnmstart").prop("checked", BDFDB.loadData("RNMstart", this, "settings")); else themeRepoModal.find("#input-rnmstart").prop("checked", BDFDB.loadData("RNMstart", this, "settings"));
themeRepoModal themeRepoModal
.on("keyup." + this.getName(), BDFDB.dotCN.searchbarinput, () => { .on("keyup." + this.getName(), BDFDB.dotCN.searchbarinput, () => {
@ -799,11 +798,11 @@ class ThemeRepo {
clearTimeout(this.loading.timeout); clearTimeout(this.loading.timeout);
return; return;
} }
$(".themerepo-loadingicon").remove(); BDFDB.removeEles(".themerepo-loadingicon");
if (!loadingiconwrapper.firstChild) loadingiconwrapper.remove(); if (!loadingiconwrapper.firstChild) BDFDB.removeEles(loadingiconwrapper);
clearTimeout(this.loading.timeout); clearTimeout(this.loading.timeout);
this.loading = {is:false, timeout:null, amount:this.loading.amount}; this.loading = {is:false, timeout:null, amount:this.loading.amount};
console.log("ThemeRepo: Finished fetching Themes."); console.log(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Finished fetching Themes.");
if (document.querySelector(".bd-themerepobutton")) BDFDB.showToast(`Finished fetching Themes.`, {type:"success"}); if (document.querySelector(".bd-themerepobutton")) BDFDB.showToast(`Finished fetching Themes.`, {type:"success"});
if (outdated > 0) { if (outdated > 0) {
var text = `${outdated} of your Themes ${outdated == 1 ? "is" : "are"} outdated. Check:`; var text = `${outdated} of your Themes ${outdated == 1 ? "is" : "are"} outdated. Check:`;
@ -909,11 +908,11 @@ class ThemeRepo {
applyTheme (entry) { applyTheme (entry) {
var name = entry.name; var name = entry.name;
if (BDFDB.isThemeEnabled(name) == false) { if (BDFDB.isThemeEnabled(name) == false) {
$(`style#${name}`).remove(); BDFDB.removeEles(`style#${name}`);
$("head").append(`<style id=${name}>${entry.css}</style>`); $("head").append(`<style id=${name}>${entry.css}</style>`);
themeCookie[name] = true; themeCookie[name] = true;
themeModule.saveThemeData(); themeModule.saveThemeData();
console.log("ThemeRepo: applied Theme " + name); console.log(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Applied Theme " + name + ".");
} }
} }
@ -936,11 +935,11 @@ class ThemeRepo {
removeTheme (entry) { removeTheme (entry) {
var name = entry.name; var name = entry.name;
if (BDFDB.isThemeEnabled(name) == true) { if (BDFDB.isThemeEnabled(name) == true) {
$(`style#${name}`).remove(); BDFDB.removeEles(`style#${name}`);
themeCookie[name] = false; themeCookie[name] = false;
delete bdthemes[name]; delete bdthemes[name];
themeModule.saveThemeData(); themeModule.saveThemeData();
console.log("ThemeRepo: removed Theme " + name); console.log(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Removed Theme " + name + ".");
} }
} }
} }