lint and merge

This commit is contained in:
MathMan05 2024-09-19 12:49:50 -05:00
parent 49f2234e81
commit e12b99c38b
34 changed files with 10323 additions and 10330 deletions

View file

@ -267,8 +267,8 @@ module.exports = [
parser: tsParser,
globals: global,
},
files: ["webpage/*.ts"],
ignores: ["!*.js", "!*.ts"],
files: ["src/*.ts","src/**/*.ts",],
ignores: ["dist/", "node_modules/"],
plugins: {
unicorn,
sonarjs,

View file

@ -37,6 +37,6 @@
"gulp-copy": "^5.0.0",
"gulp-typescript": "^6.0.0-alpha.1",
"typescript": "^5.6.2",
"typescript-eslint": "^7.18.0"
"typescript-eslint": "^8.6.0"
}
}

View file

@ -4,10 +4,10 @@ import compression from "compression";
import express, { Request, Response }from"express";
import fs from"node:fs";
import fetch from"node-fetch";
import path from "path";
import path from"node:path";
import{ observe, uptime }from"./stats.js";
import{ getApiUrls, inviteResponse }from"./utils.js";
import { fileURLToPath } from "url";
import{ fileURLToPath }from"node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

View file

@ -1,8 +1,8 @@
import fs from"node:fs";
import path from "path";
import path from"node:path";
import fetch from"node-fetch";
import{ getApiUrls }from"./utils.js";
import { fileURLToPath } from "url";
import{ fileURLToPath }from"node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@ -28,7 +28,7 @@ interface Instance {
};
}
let uptimeObject: UptimeObject = loadUptimeObject();
const uptimeObject: UptimeObject = loadUptimeObject();
export{ uptimeObject as uptime };
function loadUptimeObject(): UptimeObject{
@ -48,7 +48,7 @@ function saveUptimeObject(): void {
fs.writeFile(
path.join(__dirname, "..", "uptime.json"),
JSON.stringify(uptimeObject),
(error) => {
error=>{
if(error){
console.error("Error saving uptime.json:", error);
}
@ -67,8 +67,7 @@ removeUndefinedKey();
export async function observe(instances: Instance[]): Promise<void>{
const activeInstances = new Set<string>();
const instancePromises = instances.map((instance) =>
resolveInstance(instance, activeInstances)
const instancePromises = instances.map(instance=>resolveInstance(instance, activeInstances)
);
await Promise.allSettled(instancePromises);
updateInactiveInstances(activeInstances);

View file

@ -26,7 +26,7 @@ export async function getApiUrls(url: string): Promise<ApiUrls | null> {
}
try{
const info: ApiUrls = await fetch(`${url}.well-known/spacebar`).then(
(res) => res.json() as Promise<ApiUrls>
res=>res.json() as Promise<ApiUrls>
);
const api = info.api;
const apiUrl = new URL(api);
@ -34,7 +34,7 @@ export async function getApiUrls(url: string): Promise<ApiUrls | null> {
`${api}${
apiUrl.pathname.includes("api") ? "" : "api"
}/policies/instance/domains`
).then((res) => res.json());
).then(res=>res.json());
return{
api: policies.apiEndpoint,
gateway: policies.gateway,
@ -76,7 +76,7 @@ export async function getApiUrls(url: string): Promise<ApiUrls | null> {
}
const invite = await fetch(`${urls.api}/invites/${code}`).then(
(res) => res.json() as Promise<Invite>
res=>res.json() as Promise<Invite>
);
const title = invite.guild.name;
const description = invite.inviter

View file

@ -97,13 +97,13 @@ switch (noise) {
case"three": {
const voicy = new Voice("sin", 800);
voicy.play();
setTimeout((_) => {
setTimeout(_=>{
voicy.freq = 1000;
}, 50);
setTimeout((_) => {
setTimeout(_=>{
voicy.freq = 1300;
}, 100);
setTimeout((_) => {
setTimeout(_=>{
voicy.stop();
}, 150);
break;
@ -113,7 +113,7 @@ const voicy = new Voice((t: number, freq: number) => {
return Math.sin((t + 2) ** Math.cos(t * 4) * Math.PI * 2 * freq);
}, 700);
voicy.play();
setTimeout((_) => {
setTimeout(_=>{
voicy.stop();
}, 150);
break;
@ -121,13 +121,13 @@ break;
case"square": {
const voicy = new Voice("square", 600, 0.4);
voicy.play();
setTimeout((_) => {
setTimeout(_=>{
voicy.freq = 800;
}, 50);
setTimeout((_) => {
setTimeout(_=>{
voicy.freq = 1000;
}, 100);
setTimeout((_) => {
setTimeout(_=>{
voicy.stop();
}, 150);
break;
@ -135,13 +135,13 @@ break;
case"beep": {
const voicy = new Voice("sin", 800);
voicy.play();
setTimeout((_) => {
setTimeout(_=>{
voicy.stop();
}, 50);
setTimeout((_) => {
setTimeout(_=>{
voicy.play();
}, 100);
setTimeout((_) => {
setTimeout(_=>{
voicy.stop();
}, 150);
break;

View file

@ -131,7 +131,7 @@ permission_overwrites!: Map<string, Permissions>;
const copy = document.createElement("span");
copy.classList.add("copybutton", "svgtheme", "svg-copy");
copycontainer.append(copy);
copycontainer.onclick = (_) => {
copycontainer.onclick = _=>{
if(text.textContent){
navigator.clipboard.writeText(text.textContent);
}
@ -150,8 +150,8 @@ permission_overwrites!: Map<string, Permissions>;
temporary: uses !== 0,
}),
})
.then((_) => _.json())
.then((json) => {
.then(_=>_.json())
.then(json=>{
const params = new URLSearchParams("");
params.set("instance", this.info.wellknown);
const encoded = params.toString();
@ -177,7 +177,6 @@ permission_overwrites!: Map<string, Permissions>;
"Never",
],
function(e: Event){
expires = [1800, 3600, 21600, 43200, 86400, 604800, 2592000, 0,][(e.srcElement as HTMLSelectElement).selectedIndex];
update();
@ -224,8 +223,8 @@ permission_overwrites!: Map<string, Permissions>;
sortPerms(){
this.permission_overwritesar.sort((a, b)=>{
return(
this.guild.roles.findIndex((_) => _ === a[0]) -
this.guild.roles.findIndex((_) => _ === b[0])
this.guild.roles.indexOf(a[0]) -
this.guild.roles.indexOf(b[0])
);
});
}
@ -246,7 +245,7 @@ permission_overwrites!: Map<string, Permissions>;
await this.grabAfter(id);
return this.idToNext.get(id);
}else{
return;
}
}
},
@ -366,7 +365,7 @@ permission_overwrites!: Map<string, Permissions>;
return false;
}
return(
!!this.lastmessageid &&
Boolean(this.lastmessageid) &&
(!this.lastreadmessageid ||
SnowFlake.stringToUnixTime(this.lastmessageid) >
SnowFlake.stringToUnixTime(this.lastreadmessageid)) &&
@ -378,7 +377,7 @@ permission_overwrites!: Map<string, Permissions>;
return true;
}
for(const thing of member.roles){
let premission = this.permission_overwrites.get(thing.id);
const premission = this.permission_overwrites.get(thing.id);
if(premission){
const perm = premission.getPermission(name);
if(perm){
@ -396,7 +395,7 @@ permission_overwrites!: Map<string, Permissions>;
this.permission_overwritesar.length === 0 &&
this.hasPermission("MANAGE_CHANNELS")
){
const role = this.guild.roles.find((_) => _.name === "@everyone");
const role = this.guild.roles.find(_=>_.name === "@everyone");
if(role){
this.addRoleToPerms(role);
}
@ -467,9 +466,9 @@ permission_overwrites!: Map<string, Permissions>;
}
}
// @ts-ignore I dont wanna deal with this
div["all"] = this;
div.all = this;
div.draggable = admin;
div.addEventListener("dragstart", (e) => {
div.addEventListener("dragstart", e=>{
Channel.dragged = [this, div];
e.stopImmediatePropagation();
});
@ -495,7 +494,7 @@ permission_overwrites!: Map<string, Permissions>;
addchannel.textContent = "+";
addchannel.classList.add("addchannel");
caps.appendChild(addchannel);
addchannel.onclick = (_) => {
addchannel.onclick = _=>{
this.guild.createchannels(this.createChannel.bind(this));
};
this.coatDropDiv(decdiv, childrendiv);
@ -505,9 +504,9 @@ permission_overwrites!: Map<string, Permissions>;
decdiv.classList.add("channeleffects");
decdiv.classList.add("channel");
Channel.contextmenu.bindContextmenu(decdiv, this, undefined);
Channel.contextmenu.bindContextmenu(decdiv, this);
// @ts-ignore I dont wanna deal with this
decdiv["all"] = this;
decdiv.all = this;
for(const channel of this.children){
childrendiv.appendChild(channel.createguildHTML(admin));
@ -541,12 +540,12 @@ permission_overwrites!: Map<string, Permissions>;
if(this.hasunreads){
div.classList.add("cunread");
}
Channel.contextmenu.bindContextmenu(div, this, undefined);
Channel.contextmenu.bindContextmenu(div, this);
if(admin){
this.coatDropDiv(div);
}
// @ts-ignore I dont wanna deal with this
div["all"] = this;
div.all = this;
const myhtml = document.createElement("span");
myhtml.textContent = this.name;
if(this.type === 0){
@ -567,7 +566,7 @@ permission_overwrites!: Map<string, Permissions>;
console.log(this.type);
}
div.appendChild(myhtml);
div.onclick = (_) => {
div.onclick = _=>{
this.getHTML();
};
}
@ -577,7 +576,7 @@ permission_overwrites!: Map<string, Permissions>;
if(this.html){
return this.html.deref();
}else{
return undefined;
}
}
readbottom(){
@ -604,16 +603,16 @@ permission_overwrites!: Map<string, Permissions>;
}
}
coatDropDiv(div: HTMLDivElement, container: HTMLElement | boolean = false){
div.addEventListener("dragenter", (event) => {
div.addEventListener("dragenter", event=>{
console.log("enter");
event.preventDefault();
});
div.addEventListener("dragover", (event) => {
div.addEventListener("dragover", event=>{
event.preventDefault();
});
div.addEventListener("drop", (event) => {
div.addEventListener("drop", event=>{
const that = Channel.dragged[0];
if(!that)return;
event.preventDefault();
@ -764,7 +763,7 @@ permission_overwrites!: Map<string, Permissions>;
const span = document.createElement("span");
span.textContent = "Replying to " + this.replyingto.author.username;
const X = document.createElement("button");
X.onclick = (_) => {
X.onclick = _=>{
if(this.replyingto?.div){
this.replyingto.div.classList.remove("replying");
}
@ -977,10 +976,10 @@ permission_overwrites!: Map<string, Permissions>;
headers: this.headers,
}
)
.then((j) => {
.then(j=>{
return j.json();
})
.then((response) => {
.then(response=>{
let previd: string = id;
for(const i in response){
let messager: Message;
@ -1018,7 +1017,7 @@ permission_overwrites!: Map<string, Permissions>;
headers: this.headers,
}
)
.then((j) => {
.then(j=>{
return j.json();
})
.then((response: messagejson[])=>{
@ -1115,7 +1114,7 @@ permission_overwrites!: Map<string, Permissions>;
}
messages.append(await this.infinite.getDiv(id));
this.infinite.updatestuff();
this.infinite.watchForChange().then(async (_) => {
this.infinite.watchForChange().then(async _=>{
//await new Promise(resolve => setTimeout(resolve, 0));
this.infinite.focus(id, false); //if someone could figure out how to make this work correctly without this, that's be great :P
loading.classList.remove("loading");
@ -1353,7 +1352,7 @@ permission_overwrites!: Map<string, Permissions>;
icon: message.author.getpfpsrc(),
image: imgurl,
});
notification.addEventListener("click", (_) => {
notification.addEventListener("click", _=>{
window.focus();
this.getHTML();
});

View file

@ -12,7 +12,7 @@ class Contextmenu<x, y> {
div!: HTMLDivElement;
static setup(){
Contextmenu.currentmenu = "";
document.addEventListener("click", (event) => {
document.addEventListener("click", event=>{
if(Contextmenu.currentmenu === ""){
return;
}
@ -30,8 +30,8 @@ class Contextmenu<x, y> {
text: string,
onclick: (this: x, arg: y, e: MouseEvent) => void,
img: null | string = null,
shown: (this: x, arg: y) => boolean = (_) => true,
enabled: (this: x, arg: y) => boolean = (_) => true
shown: (this: x, arg: y) => boolean = _=>true,
enabled: (this: x, arg: y) => boolean = _=>true
){
this.buttons.push([text, onclick, img, shown, enabled, "button"]);
return{};
@ -40,8 +40,8 @@ class Contextmenu<x, y> {
text: string,
onclick: (this: x, arg: y, e: MouseEvent) => void,
img = null,
shown: (this: x, arg: y) => boolean = (_) => true,
enabled: (this: x, arg: y) => boolean = (_) => true
shown: (this: x, arg: y) => boolean = _=>true,
enabled: (this: x, arg: y) => boolean = _=>true
){
this.buttons.push([text, onclick, img, shown, enabled, "submenu"]);
return{};

View file

@ -235,7 +235,7 @@ shown = html;
}else{
html.style.display = "none";
}
button.addEventListener("click", (_) => {
button.addEventListener("click", _=>{
if(shown){
shown.style.display = "none";
}
@ -261,7 +261,7 @@ this.background = document.createElement("div");
this.background.classList.add("background");
document.body.appendChild(this.background);
document.body.appendChild(this.html);
this.background.onclick = (_) => {
this.background.onclick = _=>{
this.hide();
};
}

View file

@ -150,15 +150,15 @@ static contextmenu = new Contextmenu<Group, undefined>("channel menu");
}
createguildHTML(){
const div = document.createElement("div");
Group.contextmenu.bindContextmenu(div, this, undefined);
Group.contextmenu.bindContextmenu(div, this);
this.html = new WeakRef(div);
div.classList.add("channeleffects");
const myhtml = document.createElement("span");
myhtml.textContent = this.name;
div.appendChild(this.user.buildpfp());
div.appendChild(myhtml);
(div as any)["myinfo"] = this;
div.onclick = (_) => {
(div as any).myinfo = this;
div.onclick = _=>{
this.getHTML();
};
@ -286,7 +286,7 @@ static contextmenu = new Contextmenu<Group, undefined>("channel menu");
buildpfp.classList.add("mentioned");
div.append(buildpfp);
sentdms.append(div);
div.onclick = (_) => {
div.onclick = _=>{
this.guild.loadGuild();
this.getHTML();
};

View file

@ -312,22 +312,20 @@ h2.textContent = `You've been invited by ${json.inviter.username}`;
div.append(h2);
const button = document.createElement("button");
button.textContent = "Accept";
if (this.localuser.info.api.startsWith(info.api)) {
if (this.localuser.guildids.has(guild.id)) {
if(this.localuser.info.api.startsWith(info.api) && this.localuser.guildids.has(guild.id)){
button.textContent = "Already joined";
button.disabled = true;
}
}
button.classList.add("acceptinvbutton");
div.append(button);
button.onclick = (_) => {
button.onclick = _=>{
if(this.localuser.info.api.startsWith(info.api)){
fetch(this.localuser.info.api + "/invites/" + json.code, {
method: "POST",
headers: this.localuser.headers,
})
.then((r) => r.json())
.then((_) => {
.then(r=>r.json())
.then(_=>{
if(_.message){
alert(_.message);
}

View file

@ -18,7 +18,6 @@ class Emoji {
if(this.owner instanceof Guild){
return this.owner;
}
return;
}
get localuser(){
if(this.owner instanceof Guild){
@ -118,10 +117,10 @@ class Emoji {
}
static grabEmoji(){
fetch("/emoji.bin")
.then((e) => {
.then(e=>{
return e.arrayBuffer();
})
.then((e) => {
.then(e=>{
Emoji.decodeEmojiList(e);
});
}
@ -131,7 +130,7 @@ class Emoji {
localuser: Localuser
): Promise<Emoji | string>{
let res: (r: Emoji | string) => void;
const promise: Promise<Emoji | string> = new Promise((r) => {
const promise: Promise<Emoji | string> = new Promise(r=>{
res = r;
});
const menu = document.createElement("div");
@ -150,8 +149,8 @@ class Emoji {
let isFirst = true;
localuser.guilds
.filter((guild) => guild.id != "@me" && guild.emojis.length > 0)
.forEach((guild) => {
.filter(guild=>guild.id != "@me" && guild.emojis.length > 0)
.forEach(guild=>{
const select = document.createElement("div");
select.classList.add("emojiSelect");
@ -172,7 +171,7 @@ class Emoji {
const div = document.createElement("span");
div.textContent = guild.properties.name
.replace(/'s /g, " ")
.replace(/\w+/g, (word) => word[0])
.replace(/\w+/g, word=>word[0])
.replace(/\s/g, "");
select.append(div);
}
@ -236,7 +235,7 @@ class Emoji {
emoji.classList.add("emojiSelect");
emoji.textContent = emojit.emoji;
body.append(emoji);
emoji.onclick = (_) => {
emoji.onclick = _=>{
res(emojit.emoji);
if(Contextmenu.currentmenu !== ""){
Contextmenu.currentmenu.remove();

View file

@ -84,7 +84,7 @@ div.append(contained);
const controls = document.createElement("div");
const garbage = document.createElement("button");
garbage.textContent = "🗑";
garbage.onclick = (_) => {
garbage.onclick = _=>{
div.remove();
files.splice(files.indexOf(file), 1);
};

View file

@ -72,10 +72,10 @@ roleids!: Map<string, Role>;
Guild.contextmenu.addbutton(
"Create invite",
function (this: Guild) {},
(this: Guild)=>{},
null,
(_) => true,
(_) => false
_=>true,
_=>false
);
Guild.contextmenu.addbutton("Settings", function(this: Guild){
this.generateSettings();
@ -95,7 +95,7 @@ roleids!: Map<string, Role>;
const settings = new Settings("Settings for " + this.properties.name);
{
const overview = settings.addButton("Overview");
const form = overview.addForm("", (_) => {}, {
const form = overview.addForm("", _=>{}, {
headers: this.headers,
traditionalSubmit: true,
fetchURL: this.info.api + "/guilds/" + this.id,
@ -153,7 +153,7 @@ roleids!: Map<string, Role>;
this.roleids.set(roleh.id, roleh);
}
if(member instanceof User){
Member.resolveMember(member, this).then((_) => {
Member.resolveMember(member, this).then(_=>{
if(_){
this.member = _;
}else{
@ -161,7 +161,7 @@ roleids!: Map<string, Role>;
}
});
}else{
Member.new(member, this).then((_) => {
Member.new(member, this).then(_=>{
if(_){
this.member = _;
}
@ -248,7 +248,7 @@ roleids!: Map<string, Role>;
"",
"Yes, I'm sure",
(_: any)=>{
this.leave().then((_) => {
this.leave().then(_=>{
full.hide();
});
},
@ -377,7 +377,7 @@ roleids!: Map<string, Role>;
guild.loadGuild();
guild.loadChannel();
};
Guild.contextmenu.bindContextmenu(img, guild, undefined);
Guild.contextmenu.bindContextmenu(img, guild);
}
}else{
const div = document.createElement("div");
@ -389,7 +389,7 @@ roleids!: Map<string, Role>;
}
const build = name
.replace(/'s /g, " ")
.replace(/\w+/g, (word) => word[0])
.replace(/\w+/g, word=>word[0])
.replace(/\s/g, "");
div.textContent = build;
div.classList.add("blankserver", "servericon");
@ -399,7 +399,7 @@ roleids!: Map<string, Role>;
guild.loadGuild();
guild.loadChannel();
};
Guild.contextmenu.bindContextmenu(div, guild, undefined);
Guild.contextmenu.bindContextmenu(div, guild);
}
}
return divy;
@ -434,7 +434,7 @@ roleids!: Map<string, Role>;
if(confirmname !== this.properties.name){
return;
}
this.delete().then((_) => {
this.delete().then(_=>{
full.hide();
});
},

View file

@ -3,7 +3,7 @@ console.log(mobile);
const serverbox = document.getElementById("instancebox") as HTMLDivElement;
fetch("/instances.json")
.then((_) => _.json())
.then(_=>_.json())
.then(
(
json: {
@ -75,7 +75,7 @@ stats.append(span);
statbox.append(stats);
}
div.append(statbox);
div.onclick = (_) => {
div.onclick = _=>{
if(instance.online){
window.location.href =
"/register.html?instance=" + encodeURI(instance.name);

View file

@ -7,8 +7,8 @@ import { File } from "./file.js";
(async ()=>{
async function waitForLoad(): Promise<void>{
return new Promise((resolve) => {
document.addEventListener("DOMContentLoaded", (_) => resolve());
return new Promise(resolve=>{
document.addEventListener("DOMContentLoaded", _=>resolve());
});
}
@ -88,7 +88,7 @@ async function waitForLoad(): Promise<void> {
}
const userInfoElement = document.getElementById("userinfo") as HTMLDivElement;
userInfoElement.addEventListener("click", (event) => {
userInfoElement.addEventListener("click", event=>{
event.stopImmediatePropagation();
showAccountSwitcher();
});
@ -96,7 +96,7 @@ async function waitForLoad(): Promise<void> {
const switchAccountsElement = document.getElementById(
"switchaccounts"
) as HTMLDivElement;
switchAccountsElement.addEventListener("click", (event) => {
switchAccountsElement.addEventListener("click", event=>{
event.stopImmediatePropagation();
showAccountSwitcher();
});
@ -204,7 +204,7 @@ async function waitForLoad(): Promise<void> {
const markdown = new MarkDown("", thisUser);
typebox.markdown = markdown;
typebox.addEventListener("keyup", handleEnter);
typebox.addEventListener("keydown", (event) => {
typebox.addEventListener("keydown", event=>{
if(event.key === "Enter" && !event.shiftKey) event.preventDefault();
});
markdown.giveBox(typebox);

View file

@ -235,7 +235,7 @@ offset: number
this.watchtime = false;
}
this.changePromise = new Promise<boolean>(async (res) => {
this.changePromise = new Promise<boolean>(async res=>{
try{
if(!this.div){
res(false);
@ -281,9 +281,9 @@ offset: number
behavior: "smooth",
block: "center",
});
await new Promise((resolve) => setTimeout(resolve, 1000));
await new Promise(resolve=>setTimeout(resolve, 1000));
element.classList.remove("jumped");
await new Promise((resolve) => setTimeout(resolve, 100));
await new Promise(resolve=>setTimeout(resolve, 100));
element.classList.add("jumped");
}else{
element.scrollIntoView();
@ -296,7 +296,7 @@ offset: number
await this.firstElement(id);
this.updatestuff();
await this.watchForChange();
await new Promise((resolve) => setTimeout(resolve, 100));
await new Promise(resolve=>setTimeout(resolve, 100));
await this.focus(id, true);
}
}

View file

@ -50,8 +50,8 @@ let guildinfo: any;
fetch(`${urls!.api}/invites/${code}`, {
method: "GET",
})
.then((response) => response.json())
.then((json) => {
.then(response=>response.json())
.then(json=>{
const guildjson = json.guild;
guildinfo = guildjson;
document.getElementById("invitename")!.textContent = guildjson.name;

View file

@ -164,9 +164,9 @@ class Localuser {
r = ds.readable.getReader();
arr = new Uint8Array();
}
const promise = new Promise<void>((res) => {
const promise = new Promise<void>(res=>{
returny = res;
ws.addEventListener("open", (_event) => {
ws.addEventListener("open", _event=>{
console.log("WebSocket connected");
ws.send(
JSON.stringify({
@ -211,11 +211,11 @@ class Localuser {
}
});
let order = new Promise<void>((res) => res());
let order = new Promise<void>(res=>res());
ws.addEventListener("message", async (event) => {
ws.addEventListener("message", async event=>{
const temp2 = order;
order = new Promise<void>(async (res) => {
order = new Promise<void>(async res=>{
await temp2;
let temp: { op: number; t: string };
try{
@ -257,7 +257,7 @@ class Localuser {
});
});
ws.addEventListener("close", async (event) => {
ws.addEventListener("close", async event=>{
this.ws = undefined;
console.log("WebSocket closed with code " + event.code);
@ -604,7 +604,7 @@ class Localuser {
div.classList.add("home", "servericon");
home.classList.add("svgtheme", "svgicon", "svg-home");
home["all"] = this.guildids.get("@me");
home.all = this.guildids.get("@me");
(this.guildids.get("@me") as Guild).html = outdiv;
const unread = document.createElement("div");
unread.classList.add("unread");
@ -615,8 +615,8 @@ class Localuser {
outdiv.classList.add("servernoti");
serverlist.append(outdiv);
home.onclick = function(){
this["all"].loadGuild();
this["all"].loadChannel();
this.all.loadGuild();
this.all.loadChannel();
};
const sentdms = document.createElement("div");
sentdms.classList.add("sentdms");
@ -644,7 +644,7 @@ class Localuser {
div.textContent = "+";
div.classList.add("home", "servericon");
serverlist.appendChild(div);
div.onclick = (_) => {
div.onclick = _=>{
this.createGuild();
};
const guilddsdiv = document.createElement("div");
@ -702,8 +702,8 @@ class Localuser {
method: "POST",
headers: this.headers,
})
.then((r) => r.json())
.then((_) => {
.then(r=>r.json())
.then(_=>{
if(_.message){
error.textContent = _.message;
}
@ -744,7 +744,7 @@ class Localuser {
"",
"submit",
()=>{
this.makeGuild(fields).then((_) => {
this.makeGuild(fields).then(_=>{
if(_.message){
alert(_.errors.name._errors[0].message);
}else{
@ -934,14 +934,14 @@ class Localuser {
const finput = settingsLeft.addFileInput(
"Upload pfp:",
(_) => {
_=>{
if(file){
this.updatepfp(file);
}
},
{ clear: true }
);
finput.watchForChange((_) => {
finput.watchForChange(_=>{
if(!_){
file = null;
hypouser.avatar = null;
@ -960,14 +960,14 @@ class Localuser {
let bfile: undefined | File | null;
const binput = settingsLeft.addFileInput(
"Upload banner:",
(_) => {
_=>{
if(bfile !== undefined){
this.updatebanner(bfile);
}
},
{ clear: true }
);
binput.watchForChange((_) => {
binput.watchForChange(_=>{
if(!_){
bfile = null;
hypouser.banner = undefined;
@ -986,7 +986,7 @@ class Localuser {
let changed = false;
const pronounbox = settingsLeft.addTextInput(
"Pronouns",
(_) => {
_=>{
if(newpronouns || newbio || changed){
this.updateProfile({
pronouns: newpronouns,
@ -997,15 +997,15 @@ class Localuser {
},
{ initText: this.user.pronouns }
);
pronounbox.watchForChange((_) => {
pronounbox.watchForChange(_=>{
hypouser.pronouns = _;
newpronouns = _;
regen();
});
const bioBox = settingsLeft.addMDInput("Bio:", (_) => {}, {
const bioBox = settingsLeft.addMDInput("Bio:", _=>{}, {
initText: this.user.bio.rawString,
});
bioBox.watchForChange((_) => {
bioBox.watchForChange(_=>{
newbio = _;
hypouser.bio = new MarkDown(_, this);
regen();
@ -1018,10 +1018,10 @@ class Localuser {
}
const colorPicker = settingsLeft.addColorInput(
"Profile color",
(_) => {},
_=>{},
{ initColor: color }
);
colorPicker.watchForChange((_) => {
colorPicker.watchForChange(_=>{
console.log();
color = _;
hypouser.accent_color = Number.parseInt("0x" + _.substr(1), 16);
@ -1035,7 +1035,7 @@ class Localuser {
const themes = ["Dark", "WHITE", "Light"];
tas.addSelect(
"Theme:",
(_) => {
_=>{
localStorage.setItem("theme", themes[_]);
setTheme();
},
@ -1052,13 +1052,13 @@ class Localuser {
tas
.addSelect(
"Notification sound:",
(_) => {
_=>{
Voice.setNotificationSound(sounds[_]);
},
sounds,
{ defaultIndex: sounds.indexOf(Voice.getNotificationSound()) }
)
.watchForChange((_) => {
.watchForChange(_=>{
Voice.noises(sounds[_]);
});
}
@ -1067,7 +1067,7 @@ class Localuser {
const userinfos = getBulkInfo();
tas.addColorInput(
"Accent color:",
(_) => {
_=>{
userinfos.accent_color = _;
localStorage.setItem("userinfos", JSON.stringify(userinfos));
document.documentElement.style.setProperty(
@ -1155,7 +1155,7 @@ class Localuser {
security.addButtonInput("", "Change discriminator", ()=>{
const form = security.addSubForm(
"Change Discriminator",
(_) => {
_=>{
security.returnFromSub();
},
{
@ -1169,7 +1169,7 @@ class Localuser {
security.addButtonInput("", "Change email", ()=>{
const form = security.addSubForm(
"Change Email",
(_) => {
_=>{
security.returnFromSub();
},
{
@ -1187,7 +1187,7 @@ class Localuser {
security.addButtonInput("", "Change username", ()=>{
const form = security.addSubForm(
"Change Username",
(_) => {
_=>{
security.returnFromSub();
},
{
@ -1205,7 +1205,7 @@ class Localuser {
security.addButtonInput("", "Change password", ()=>{
const form = security.addSubForm(
"Change Password",
(_) => {
_=>{
security.returnFromSub();
},
{
@ -1220,11 +1220,11 @@ class Localuser {
}
let in1 = "";
let in2 = "";
form.addTextInput("New password:", "").watchForChange((text) => {
form.addTextInput("New password:", "").watchForChange(text=>{
in1 = text;
});
const copy = form.addTextInput("New password again:", "");
copy.watchForChange((text) => {
copy.watchForChange(text=>{
in2 = text;
});
form.setValue("new_password", ()=>{
@ -1246,11 +1246,11 @@ class Localuser {
fetch(this.info.api + "/connections", {
headers: this.headers,
})
.then((r) => r.json())
.then((json) => {
.then(r=>r.json())
.then(json=>{
Object.keys(json)
.sort((key) => (json[key].enabled ? -1 : 1))
.forEach((key) => {
.sort(key=>(json[key].enabled ? -1 : 1))
.forEach(key=>{
const connection = json[key];
const container = document.createElement("div");
@ -1324,8 +1324,8 @@ class Localuser {
fetch(this.info.api + "/applications", {
headers: this.headers,
})
.then((r) => r.json())
.then((json) => {
.then(r=>r.json())
.then(json=>{
json.forEach(
(application: {
cover_image: any;
@ -1414,7 +1414,7 @@ class Localuser {
[
"fileupload",
"Application icon:",
(event) => {
event=>{
const reader = new FileReader();
const files = (event.target as HTMLInputElement).files;
if(files){
@ -1566,7 +1566,7 @@ class Localuser {
[
"fileupload",
"Bot avatar:",
(event) => {
event=>{
const reader = new FileReader();
const files = (event.target as HTMLInputElement).files;
if(files){
@ -1668,7 +1668,7 @@ class Localuser {
guildmap = new Map();
this.waitingmembers.set(guildid, guildmap);
}
const promise: Promise<memberjson | undefined> = new Promise((res) => {
const promise: Promise<memberjson | undefined> = new Promise(res=>{
guildmap.set(id, res);
this.getmembers();
});
@ -1707,7 +1707,7 @@ class Localuser {
}
}
async getmembers(){
const promise = new Promise((res) => {
const promise = new Promise(res=>{
setTimeout(res, 10);
});
await promise; //allow for more to be sent at once :P
@ -1729,7 +1729,7 @@ class Localuser {
return;
}
const promise: Promise<[memberjson[], string[]]> = new Promise(
(res) => {
res=>{
const nonce = "" + Math.floor(Math.random() * 100000000000);
this.noncemap.set(nonce, res);
this.noncebuild.set(nonce, [[], [], []]);
@ -1769,7 +1769,7 @@ class Localuser {
value.delete(thing);
continue;
}
func(undefined);
func();
value.delete(thing);
}
}

View file

@ -1,24 +1,24 @@
<body class="Dark-theme">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jank Client</title>
<meta content="Jank Client" property="og:title" />
<meta content="Jank Client" property="og:title">
<meta
content="A spacebar client that has DMs, replying and more"
property="og:description"
/>
<meta content="/logo.webp" property="og:image" />
<meta content="#4b458c" data-react-helmet="true" name="theme-color" />
<link href="/style.css" rel="stylesheet" />
<link href="/themes.css" rel="stylesheet" id="lightcss" />
>
<meta content="/logo.webp" property="og:image">
<meta content="#4b458c" data-react-helmet="true" name="theme-color">
<link href="/style.css" rel="stylesheet">
<link href="/themes.css" rel="stylesheet" id="lightcss">
</head>
<div id="logindiv">
<h1>Login</h1>
<br />
<br >
<form id="form" submit="check(e)">
<label for="instance"><b>Instance:</b></label
><br />
><br >
<p id="verify"></p>
<input
type="search"
@ -29,27 +29,27 @@
value=""
id="instancein"
required
/><br /><br />
><br ><br >
<label for="uname"><b>Email:</b></label
><br />
><br >
<input
type="text"
placeholder="Enter email address"
name="uname"
id="uname"
required
/><br /><br />
><br ><br >
<label for="psw"><b>Password:</b></label
><br />
><br >
<input
type="password"
placeholder="Enter Password"
name="psw"
id="psw"
required
/><br /><br /><br /><br />
><br ><br ><br ><br >
<p class="wrongred" id="wrong"></p>
<div id="h-captcha"></div>

View file

@ -261,8 +261,7 @@ const stringURLMap = new Map<string, string>();
}
let api: string;
try{
const info = await fetch(`${str}/.well-known/spacebar`).then((x) =>
x.json()
const info = await fetch(`${str}/.well-known/spacebar`).then(x=>x.json()
);
api = info.api;
}catch{
@ -274,7 +273,7 @@ const stringURLMap = new Map<string, string>();
`${api}${
url.pathname.includes("api") ? "" : "api"
}/policies/instance/domains`
).then((x) => x.json());
).then(x=>x.json());
return{
api: info.apiEndpoint,
gateway: info.gateway,
@ -349,7 +348,7 @@ const stringURLMap = new Map<string, string>();
if(instancein){
console.log(instancein);
instancein.addEventListener("keydown", (_) => {
instancein.addEventListener("keydown", _=>{
const verify = document.getElementById("verify");
verify!.textContent = "Waiting to check Instance";
clearTimeout(timeout);
@ -387,8 +386,8 @@ const stringURLMap = new Map<string, string>();
const info = JSON.parse(localStorage.getItem("instanceinfo")!);
const api = info.login + (info.login.startsWith("/") ? "/" : "");
return await fetch(api + "/auth/login", options)
.then((response) => response.json())
.then((response) => {
.then(response=>response.json())
.then(response=>{
console.log(response, response.message);
if(response.message === "Invalid Form Body"){
return response.errors.login._errors[0].message;
@ -441,8 +440,8 @@ const stringURLMap = new Map<string, string>();
ticket: response.ticket,
}),
})
.then((r) => r.json())
.then((response) => {
.then(r=>r.json())
.then(response=>{
if(response.message){
alert(response.message);
}else{
@ -568,7 +567,7 @@ const stringURLMap = new Map<string, string>();
}
fetch("/instances.json")
.then((_) => _.json())
.then(_=>_.json())
.then(
(
json: {

View file

@ -480,14 +480,14 @@ if (!keep) {
user.bind(mention, guild);
}
if(guild){
Member.resolveMember(user, guild).then((member) => {
Member.resolveMember(user, guild).then(member=>{
if(member){
mention.textContent = `@${member.name}`;
}
});
}
}else{
mention.textContent = `@unknown`;
mention.textContent = "@unknown";
}
break;
case"#":
@ -495,12 +495,12 @@ const channel = this.localuser.channelids.get(id);
if(channel){
mention.textContent = `#${channel.name}`;
if(!keep){
mention.onclick = (_) => {
mention.onclick = _=>{
this.localuser.goToChannel(id);
};
}
}else{
mention.textContent = `#unknown`;
mention.textContent = "#unknown";
}
break;
}
@ -693,11 +693,11 @@ const parts = build
e.target.classList.add("unspoiled");
}
giveBox(box: HTMLDivElement){
box.onkeydown = (_) => {
box.onkeydown = _=>{
//console.log(_);
};
let prevcontent = "";
box.onkeyup = (_) => {
box.onkeyup = _=>{
const content = MarkDown.gatherBoxText(box);
if(content !== prevcontent){
prevcontent = content;
@ -705,7 +705,7 @@ const parts = build
this.boxupdate(box);
}
};
box.onpaste = (_) => {
box.onpaste = _=>{
if(!_.clipboardData)return;
console.log(_.clipboardData.types);
const data = _.clipboardData.getData("text");
@ -760,7 +760,7 @@ const parts = build
elm.target = "_blank";
return;
}
elm.onmouseup = (_) => {
elm.onmouseup = _=>{
if(_.button === 2)return;
console.log(":3");
function open(){
@ -811,7 +811,7 @@ const parts = build
}
};
}else{
throw Error(url + " is not a valid URL");
throw new Error(url + " is not a valid URL");
}
}
/*
@ -839,7 +839,7 @@ const parts = build
len--;
}
}
len += +(text[text.length - 1] === "\n");
len += Number(text.at(-1) === "\n");
return function restore(){
if(!selection)return;
@ -853,7 +853,7 @@ const parts = build
function getTextNodeAtPosition(root: Node, index: number){
const NODE_TYPE = NodeFilter.SHOW_TEXT;
const treeWalker = document.createTreeWalker(root, NODE_TYPE, (elem) => {
const treeWalker = document.createTreeWalker(root, NODE_TYPE, elem=>{
if(!elem.textContent)return 0;
if(index > elem.textContent.length){
index -= elem.textContent.length;

View file

@ -91,10 +91,10 @@ owner: Guild
const maybe = user.members.get(guild);
if(!user.members.has(guild)){
const membpromise = guild.localuser.resolvemember(user.id, guild.id);
const promise = new Promise<Member | undefined>(async (res) => {
const promise = new Promise<Member | undefined>(async res=>{
const membjson = await membpromise;
if(membjson === undefined){
return res(undefined);
return res();
}else{
const member = new Member(membjson, guild);
const map = guild.localuser.presences;

View file

@ -46,7 +46,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
member: Member | undefined;
reactions!: messagejson["reactions"];
static setup(){
this.del = new Promise((_) => {
this.del = new Promise(_=>{
this.resolve = _;
});
Message.setupcmenu();
@ -64,7 +64,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
Message.contextmenu.addsubmenu(
"Add reaction",
function(this: Message, _, e: MouseEvent){
Emoji.emojiPicker(e.x, e.y, this.localuser).then((_) => {
Emoji.emojiPicker(e.x, e.y, this.localuser).then(_=>{
this.reactionToggle(_);
});
}
@ -96,7 +96,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
document.getElementById("typebox") as HTMLDivElement & {
markdown: MarkDown;
}
)["markdown"] as MarkDown;
).markdown as MarkDown;
markdown.txt = this.content.rawString.split("");
markdown.boxupdate(document.getElementById("typebox") as HTMLDivElement);
}
@ -144,7 +144,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
}else if(thing === "id"){
continue;
}else if(thing === "member"){
Member.new(messagejson.member as memberjson, this.guild).then((_) => {
Member.new(messagejson.member as memberjson, this.guild).then(_=>{
this.member = _ as Member;
});
continue;
@ -169,7 +169,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
);
}
if(!this.member && this.guild.id !== "@me"){
this.author.resolvemember(this.guild).then((_) => {
this.author.resolvemember(this.guild).then(_=>{
this.member = _;
});
}
@ -223,7 +223,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
}else if(userd instanceof Member){
return this.mentions.includes(userd.user);
}else{
return;
}
}
getimages(){
@ -341,7 +341,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
"You have this user blocked, click to hide these messages.";
div.append(span);
span.classList.add("blocked");
span.onclick = (_) => {
span.onclick = _=>{
const scroll = this.channel.infinite.scrollTop;
let next: Message | undefined = this;
while(next?.author === this.author){
@ -377,7 +377,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
}
span.textContent = `You have this user blocked, click to see the ${count} blocked messages.`;
build.append(span);
span.onclick = (_) => {
span.onclick = _=>{
const scroll = this.channel.infinite.scrollTop;
const func = this.channel.infinite.snapBottom();
let next: Message | undefined = this;
@ -417,7 +417,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
line.classList.add("startreply");
replyline.classList.add("replyflex");
// TODO: Fix this
this.channel.getmessage(this.message_reference.id).then((message) => {
this.channel.getmessage(this.message_reference.id).then(message=>{
if(message.author.relationshipType === 2){
username.textContent = "Blocked user";
return;
@ -429,7 +429,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
username.textContent = author.username;
author.bind(username, this.guild);
});
reply.onclick = (_) => {
reply.onclick = _=>{
// TODO: FIX this
this.channel.infinite.focus(this.message_reference.id);
};
@ -457,7 +457,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
this.author.bind(pfp, this.guild, false);
pfpRow.appendChild(pfp);
}else{
div["pfpparent"] = pfpparent;
div.pfpparent = pfpparent;
}
pfpRow.classList.add("pfprow");
build.appendChild(pfpRow);
@ -491,7 +491,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
div.classList.remove("topMessage");
}
const messaged = this.content.makeHTML();
(div as any)["txt"] = messaged;
(div as any).txt = messaged;
const messagedwrap = document.createElement("div");
messagedwrap.classList.add("flexttb");
messagedwrap.appendChild(messaged);
@ -524,7 +524,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
build.appendChild(text);
texttxt.classList.add("flexltr");
const messaged = document.createElement("span");
div["txt"] = messaged;
div.txt = messaged;
messaged.textContent = "welcome: ";
texttxt.appendChild(messaged);
@ -552,7 +552,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
bindButtonEvent(){
if(this.div){
let buttons: HTMLDivElement | undefined;
this.div.onmouseenter = (_) => {
this.div.onmouseenter = _=>{
if(buttons){
buttons.remove();
buttons = undefined;
@ -566,7 +566,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
reply.classList.add("svgtheme", "svg-reply", "svgicon");
container.append(reply);
buttons.append(container);
container.onclick = (_) => {
container.onclick = _=>{
this.channel.setReplying(this);
};
}
@ -576,7 +576,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
edit.classList.add("svgtheme", "svg-edit", "svgicon");
container.append(edit);
buttons.append(container);
container.onclick = (_) => {
container.onclick = _=>{
this.setEdit();
};
}
@ -586,7 +586,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
reply.classList.add("svgtheme", "svg-delete", "svgicon");
container.append(reply);
buttons.append(container);
container.onclick = (_) => {
container.onclick = _=>{
if(_.shiftKey){
this.delete();
return;
@ -620,7 +620,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
}
}
};
this.div.onmouseleave = (_) => {
this.div.onmouseleave = _=>{
if(buttons){
buttons.remove();
buttons = undefined;
@ -659,7 +659,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
reaction.append(emoji);
reactdiv.append(reaction);
reaction.onclick = (_) => {
reaction.onclick = _=>{
this.reactionToggle(thing.emoji.name);
};
}
@ -742,8 +742,7 @@ static contextmenu = new Contextmenu<Message, undefined>("message menu");
function formatTime(date: Date){
updateTimes();
const datestring = date.toLocaleDateString();
const formatTime = (date: Date) =>
date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
const formatTime = (date: Date)=>date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
if(datestring === now){
return`Today at ${formatTime(date)}`;

View file

@ -136,7 +136,7 @@ const tosPage = data.instance.tosPage;
if(tosPage){
document.getElementById("TOSbox")!.innerHTML =
'I agree to the <a href="" id="TOSa">Terms of Service</a>:';
"I agree to the <a href=\"\" id=\"TOSa\">Terms of Service</a>:";
TOSa = document.getElementById("TOSa") as HTMLAnchorElement;
TOSa.href = tosPage;
}else{
@ -149,4 +149,4 @@ console.log(tosPage);
tosLogic();
(checkInstance as any)["alt"] = tosLogic;
(checkInstance as any).alt = tosLogic;

View file

@ -87,7 +87,7 @@ class PermissionToggle implements OptionsElement<number> {
if(state === 1){
on.checked = true;
}
on.onclick = (_) => {
on.onclick = _=>{
this.permissions.setPermission(this.rolejson.name, 1);
this.owner.changed();
};
@ -99,7 +99,7 @@ class PermissionToggle implements OptionsElement<number> {
if(state === 0){
no.checked = true;
}
no.onclick = (_) => {
no.onclick = _=>{
this.permissions.setPermission(this.rolejson.name, 0);
this.owner.changed();
};
@ -111,7 +111,7 @@ class PermissionToggle implements OptionsElement<number> {
if(state === -1){
off.checked = true;
}
off.onclick = (_) => {
off.onclick = _=>{
this.permissions.setPermission(this.rolejson.name, -1);
this.owner.changed();
};
@ -160,12 +160,12 @@ class PermissionToggle implements OptionsElement<number> {
}
handleString(str: string): HTMLElement{
this.curid = str;
const arr = this.permissions.find((_) => _[0].id === str);
const arr = this.permissions.find(_=>_[0].id === str);
if(arr){
const perm = arr[1];
this.permission.deny = perm.deny;
this.permission.allow = perm.allow;
const role = this.permissions.find((e) => e[0].id === str);
const role = this.permissions.find(e=>e[0].id === str);
if(role){
this.options.name = role[0].name;
this.options.haschanged = false;

View file

@ -29,7 +29,7 @@ if (promise) {
lastcache = await promise.text();
}
console.log(lastcache);
fetch("/getupdates").then(async (data) => {
fetch("/getupdates").then(async data=>{
const text = await data.clone().text();
console.log(text, lastcache);
if(lastcache !== text){

View file

@ -36,7 +36,7 @@ interface OptionsElement<x> {
const button = document.createElement("button");
button.classList.add("SettingsButton");
button.textContent = thing[0];
button.onclick = (_) => {
button.onclick = _=>{
this.generateHTMLArea(thing[1], htmlarea);
if(this.warndiv){
this.warndiv.remove();
@ -118,7 +118,7 @@ interface OptionsElement<x> {
this.value = value;
}
}
onchange: (str: string) => void = (_) => {};
onchange: (str: string) => void = _=>{};
watchForChange(func: (str: string) => void){
this.onchange = func;
}
@ -196,7 +196,7 @@ interface OptionsElement<x> {
this.value = value;
}
}
onchange: (str: boolean) => void = (_) => {};
onchange: (str: boolean) => void = _=>{};
watchForChange(func: (str: boolean) => void){
this.onchange = func;
}
@ -282,7 +282,7 @@ interface OptionsElement<x> {
this.colorContent = value;
}
}
onchange: (str: string) => void = (_) => {};
onchange: (str: string) => void = _=>{};
watchForChange(func: (str: string) => void){
this.onchange = func;
}
@ -341,7 +341,7 @@ interface OptionsElement<x> {
this.index = value;
}
}
onchange: (str: number) => void = (_) => {};
onchange: (str: number) => void = _=>{};
watchForChange(func: (str: number) => void){
this.onchange = func;
}
@ -388,7 +388,7 @@ interface OptionsElement<x> {
this.value = value;
}
}
onchange: (str: string) => void = (_) => {};
onchange: (str: string) => void = _=>{};
watchForChange(func: (str: string) => void){
this.onchange = func;
}
@ -427,7 +427,7 @@ interface OptionsElement<x> {
if(this.clear){
const button = document.createElement("button");
button.textContent = "Clear";
button.onclick = (_) => {
button.onclick = _=>{
if(this.onchange){
this.onchange(null);
}
@ -761,7 +761,7 @@ interface OptionsElement<x> {
this.haschanged = true;
this.owner.changed(div);
button.onclick = (_) => {
button.onclick = _=>{
if(this.owner instanceof Buttons){
this.owner.save();
}
@ -835,7 +835,7 @@ interface OptionsElement<x> {
selections: string[],
{ defaultIndex = 0, required = false } = {}
){
const select = this.options.addSelect(label, (_) => {}, selections, {
const select = this.options.addSelect(label, _=>{}, selections, {
defaultIndex,
});
this.names.set(formName, select);
@ -850,7 +850,7 @@ interface OptionsElement<x> {
formName: string,
{ required = false, files = "one", clear = false } = {}
){
const FI = this.options.addFileInput(label, (_) => {}, { clear });
const FI = this.options.addFileInput(label, _=>{}, { clear });
if(files !== "one" && files !== "multi")
throw new Error("files should equal one or multi");
this.fileOptions.set(FI, { files });
@ -866,7 +866,7 @@ interface OptionsElement<x> {
formName: string,
{ initText = "", required = false, password = false } = {}
){
const textInput = this.options.addTextInput(label, (_) => {}, {
const textInput = this.options.addTextInput(label, _=>{}, {
initText,
password,
});
@ -881,7 +881,7 @@ interface OptionsElement<x> {
formName: string,
{ initColor = "", required = false } = {}
){
const colorInput = this.options.addColorInput(label, (_) => {}, {
const colorInput = this.options.addColorInput(label, _=>{}, {
initColor,
});
this.names.set(formName, colorInput);
@ -896,7 +896,7 @@ interface OptionsElement<x> {
formName: string,
{ initText = "", required = false } = {}
){
const mdInput = this.options.addMDInput(label, (_) => {}, { initText });
const mdInput = this.options.addMDInput(label, _=>{}, { initText });
this.names.set(formName, mdInput);
if(required){
this.required.add(mdInput);
@ -909,7 +909,7 @@ interface OptionsElement<x> {
formName: string,
{ initState = false, required = false } = {}
){
const box = this.options.addCheckboxInput(label, (_) => {}, { initState });
const box = this.options.addCheckboxInput(label, _=>{}, { initState });
this.names.set(formName, box);
if(required){
this.required.add(box);
@ -928,7 +928,7 @@ interface OptionsElement<x> {
div.classList.add("FormSettings");
if(!this.traditionalSubmit){
const button = document.createElement("button");
button.onclick = (_) => {
button.onclick = _=>{
this.submit();
};
button.textContent = this.submitText;
@ -987,7 +987,7 @@ interface OptionsElement<x> {
if(input.value){
const reader = new FileReader();
reader.readAsDataURL(input.value[0]);
const promise = new Promise<void>((res) => {
const promise = new Promise<void>(res=>{
reader.onload = ()=>{
(build as any)[thing] = reader.result;
res();
@ -1008,8 +1008,8 @@ interface OptionsElement<x> {
body: JSON.stringify(build),
headers: this.headers,
})
.then((_) => _.json())
.then((json) => {
.then(_=>_.json())
.then(json=>{
if(json.errors && this.errors(json.errors))return;
this.onSubmit(json);
});
@ -1032,7 +1032,7 @@ interface OptionsElement<x> {
const ref = this.options.html.get(elm);
if(ref && ref.deref()){
const html = ref.deref() as HTMLDivElement;
this.makeError(html, errors["errors"][error]._errors.message);
this.makeError(html, errors.errors[error]._errors.message);
return true;
}
}
@ -1062,7 +1062,7 @@ interface OptionsElement<x> {
element = div;
}else{
element.classList.remove("suberror");
setTimeout((_) => {
setTimeout(_=>{
element.classList.add("suberror");
}, 100);
}
@ -1096,7 +1096,7 @@ interface OptionsElement<x> {
exit.textContent = "✖";
exit.classList.add("exitsettings");
background.append(exit);
exit.onclick = (_) => {
exit.onclick = _=>{
this.hide();
};
document.body.append(background);

View file

@ -103,8 +103,8 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
body: JSON.stringify({ recipients: [this.id] }),
headers: this.localuser.headers,
})
.then((res) => res.json())
.then((json) => {
.then(res=>res.json())
.then(json=>{
this.localuser.goToChannel(json.id);
});
});
@ -140,11 +140,11 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
});
this.contextmenu.addbutton(
"Kick member",
function (this: User, member: Member | undefined) {
(this: User, member: Member | undefined)=>{
member?.kick();
},
null,
(member) => {
member=>{
if(!member)return false;
const us = member.guild.member;
if(member.id === us.id){
@ -158,11 +158,11 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
);
this.contextmenu.addbutton(
"Ban member",
function (this: User, member: Member | undefined) {
(this: User, member: Member | undefined)=>{
member?.ban();
},
null,
(member) => {
member=>{
if(!member)return false;
const us = member.guild.member;
if(member.id === us.id){
@ -211,7 +211,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
{
headers: this.localuser.headers,
}
).then((res) => res.json());
).then(res=>res.json());
}
async getBadge(id: string): Promise<any>{
@ -272,7 +272,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
bind(html: HTMLElement, guild: Guild | null = null, error = true): void{
if(guild && guild.id !== "@me"){
Member.resolveMember(this, guild)
.then((member) => {
.then(member=>{
User.contextmenu.bindContextmenu(html, this, member);
if(member === undefined && error){
const errorSpan = document.createElement("span");
@ -285,7 +285,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
member.bind(html);
}
})
.catch((err) => {
.catch(err=>{
console.log(err);
});
}
@ -300,7 +300,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
const json = await fetch(
localuser.info.api.toString() + "/users/" + id + "/profile",
{ headers: localuser.headers }
).then((res) => res.json());
).then(res=>res.json());
return new User(json, localuser);
}
@ -309,7 +309,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
this.hypotheticalpfp = false;
const src = this.getpfpsrc();
Array.from(document.getElementsByClassName("userid:" + this.id)).forEach(
(element) => {
element=>{
(element as HTMLImageElement).src = src;
}
);
@ -447,7 +447,7 @@ members: WeakMap<Guild, Member | undefined | Promise<Member | undefined>> =
const biohtml = this.bio.makeHTML();
userbody.appendChild(biohtml);
if(guild){
Member.resolveMember(this, guild).then((member) => {
Member.resolveMember(this, guild).then(member=>{
if(!member)return;
const roles = document.createElement("div");
roles.classList.add("rolesbox");