compiled JS
This commit is contained in:
parent
2c068a7978
commit
ebce7c0099
5 changed files with 161 additions and 111 deletions
|
@ -246,7 +246,6 @@ class Localuser {
|
|||
break;
|
||||
case "READY":
|
||||
this.gottenReady(temp);
|
||||
this.genusersettings();
|
||||
break;
|
||||
case "MESSAGE_UPDATE":
|
||||
const message = SnowFlake.getSnowFlakeFromID(temp.d.id, Message).getObject();
|
||||
|
@ -806,99 +805,82 @@ class Localuser {
|
|||
});
|
||||
}
|
||||
}
|
||||
settings.show();
|
||||
}
|
||||
/**
|
||||
@deprecated
|
||||
This should be made to not be used anymore
|
||||
**/
|
||||
genusersettings() {
|
||||
const connectionContainer = document.createElement("div");
|
||||
connectionContainer.id = "connection-container";
|
||||
this.userConnections = new Dialog(["html",
|
||||
connectionContainer
|
||||
], () => { }, async () => {
|
||||
connectionContainer.innerHTML = "";
|
||||
const res = await fetch(this.info.api + "/connections", {
|
||||
{
|
||||
const connections = settings.addButton("Connections");
|
||||
const connectionContainer = document.createElement("div");
|
||||
connectionContainer.id = "connection-container";
|
||||
fetch(this.info.api + "/connections", {
|
||||
headers: this.headers
|
||||
});
|
||||
const json = await res.json();
|
||||
Object.keys(json).sort(key => json[key].enabled ? -1 : 1).forEach(key => {
|
||||
const connection = json[key];
|
||||
const container = document.createElement("div");
|
||||
container.textContent = key.charAt(0).toUpperCase() + key.slice(1);
|
||||
if (connection.enabled) {
|
||||
container.addEventListener("click", async () => {
|
||||
const connectionRes = await fetch(this.info.api + "/connections/" + key + "/authorize", {
|
||||
headers: this.headers
|
||||
}).then(r => r.json()).then(json => {
|
||||
Object.keys(json).sort(key => json[key].enabled ? -1 : 1).forEach(key => {
|
||||
const connection = json[key];
|
||||
const container = document.createElement("div");
|
||||
container.textContent = key.charAt(0).toUpperCase() + key.slice(1);
|
||||
if (connection.enabled) {
|
||||
container.addEventListener("click", async () => {
|
||||
const connectionRes = await fetch(this.info.api + "/connections/" + key + "/authorize", {
|
||||
headers: this.headers
|
||||
});
|
||||
const connectionJSON = await connectionRes.json();
|
||||
window.open(connectionJSON.url, "_blank", "noopener noreferrer");
|
||||
});
|
||||
const connectionJSON = await connectionRes.json();
|
||||
window.open(connectionJSON.url, "_blank", "noopener noreferrer");
|
||||
});
|
||||
}
|
||||
else {
|
||||
container.classList.add("disabled");
|
||||
container.title = "This connection has been disabled server-side.";
|
||||
}
|
||||
connectionContainer.appendChild(container);
|
||||
});
|
||||
});
|
||||
let appName = "";
|
||||
const appListContainer = document.createElement("div");
|
||||
appListContainer.id = "app-list-container";
|
||||
this.devPortal = new Dialog(["vdiv",
|
||||
["hdiv",
|
||||
["textbox", "Name:", appName, event => {
|
||||
appName = event.target.value;
|
||||
}],
|
||||
["button",
|
||||
"",
|
||||
"Create application",
|
||||
async () => {
|
||||
if (appName.trim().length == 0)
|
||||
return alert("Please enter a name for the application.");
|
||||
const res = await fetch(this.info.api + "/applications", {
|
||||
method: "POST",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify({
|
||||
name: appName
|
||||
})
|
||||
});
|
||||
const json = await res.json();
|
||||
this.manageApplication(json.id);
|
||||
this.devPortal.hide();
|
||||
}
|
||||
]
|
||||
],
|
||||
["html",
|
||||
appListContainer
|
||||
]
|
||||
], () => { }, async () => {
|
||||
appListContainer.innerHTML = "";
|
||||
const res = await fetch(this.info.api + "/applications", {
|
||||
headers: this.headers
|
||||
});
|
||||
const json = await res.json();
|
||||
json.forEach(application => {
|
||||
const container = document.createElement("div");
|
||||
if (application.cover_image) {
|
||||
const cover = document.createElement("img");
|
||||
cover.crossOrigin = "anonymous";
|
||||
cover.src = this.info.cdn + "/app-icons/" + application.id + "/" + application.cover_image + ".png?size=256";
|
||||
cover.alt = "";
|
||||
cover.loading = "lazy";
|
||||
container.appendChild(cover);
|
||||
}
|
||||
const name = document.createElement("h2");
|
||||
name.textContent = application.name + (application.bot ? " (Bot)" : "");
|
||||
container.appendChild(name);
|
||||
container.addEventListener("click", async () => {
|
||||
this.devPortal.hide();
|
||||
this.manageApplication(application.id);
|
||||
else {
|
||||
container.classList.add("disabled");
|
||||
container.title = "This connection has been disabled server-side.";
|
||||
}
|
||||
connectionContainer.appendChild(container);
|
||||
});
|
||||
appListContainer.appendChild(container);
|
||||
});
|
||||
});
|
||||
connections.addHTMLArea(connectionContainer);
|
||||
}
|
||||
{
|
||||
const devPortal = settings.addButton("Developer Portal");
|
||||
let appName = "";
|
||||
devPortal.addTextInput("Name:", value => {
|
||||
appName = value;
|
||||
});
|
||||
devPortal.addButtonInput("", "Create application", async () => {
|
||||
if (appName.trim().length == 0) {
|
||||
return alert("Please enter a name for the application.");
|
||||
}
|
||||
const res = await fetch(this.info.api + "/applications", {
|
||||
method: "POST",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify({
|
||||
name: appName
|
||||
})
|
||||
});
|
||||
const json = await res.json();
|
||||
this.manageApplication(json.id);
|
||||
});
|
||||
const appListContainer = document.createElement("div");
|
||||
appListContainer.id = "app-list-container";
|
||||
fetch(this.info.api + "/applications", {
|
||||
headers: this.headers
|
||||
}).then(r => r.json()).then(json => {
|
||||
json.forEach(application => {
|
||||
const container = document.createElement("div");
|
||||
if (application.cover_image) {
|
||||
const cover = document.createElement("img");
|
||||
cover.crossOrigin = "anonymous";
|
||||
cover.src = this.info.cdn + "/app-icons/" + application.id + "/" + application.cover_image + ".png?size=256";
|
||||
cover.alt = "";
|
||||
cover.loading = "lazy";
|
||||
container.appendChild(cover);
|
||||
}
|
||||
const name = document.createElement("h2");
|
||||
name.textContent = application.name + (application.bot ? " (Bot)" : "");
|
||||
container.appendChild(name);
|
||||
container.addEventListener("click", async () => {
|
||||
this.manageApplication(application.id);
|
||||
});
|
||||
appListContainer.appendChild(container);
|
||||
});
|
||||
});
|
||||
devPortal.addHTMLArea(appListContainer);
|
||||
}
|
||||
settings.show();
|
||||
}
|
||||
async manageApplication(appId = "") {
|
||||
const res = await fetch(this.info.api + "/applications/" + appId, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue