add "noImplicitThis":true

This commit is contained in:
MathMan05 2024-08-19 12:19:42 -05:00
parent ec2fc491d9
commit ce3ea3a271
17 changed files with 58 additions and 59 deletions

View file

@ -58,7 +58,7 @@ class Channel {
this.deleteChannel(); this.deleteChannel();
}, null, _ => { console.log(_); return _.isAdmin(); }); }, null, _ => { console.log(_); return _.isAdmin(); });
this.contextmenu.addbutton("Edit channel", function () { this.contextmenu.addbutton("Edit channel", function () {
this.editChannel(this); this.editChannel();
}, null, _ => { return _.isAdmin(); }); }, null, _ => { return _.isAdmin(); });
this.contextmenu.addbutton("Make invite", function () { this.contextmenu.addbutton("Make invite", function () {
this.createInvite(); this.createInvite();
@ -346,9 +346,9 @@ class Channel {
addchannel.textContent = "+"; addchannel.textContent = "+";
addchannel.classList.add("addchannel"); addchannel.classList.add("addchannel");
caps.appendChild(addchannel); caps.appendChild(addchannel);
addchannel.onclick = function () { addchannel.onclick = _ => {
this.guild.createchannels(this.createChannel.bind(this)); this.guild.createchannels(this.createChannel.bind(this));
}.bind(this); };
this.coatDropDiv(decdiv, childrendiv); this.coatDropDiv(decdiv, childrendiv);
} }
div.appendChild(caps); div.appendChild(caps);
@ -552,8 +552,7 @@ class Channel {
}); });
console.log(full); console.log(full);
full.hide(); full.hide();
}] }]]
]
]); ]);
full.show(); full.show();
console.log(full); console.log(full);

View file

@ -238,7 +238,7 @@ class Dialog {
this.background.classList.add("background"); this.background.classList.add("background");
document.body.appendChild(this.background); document.body.appendChild(this.background);
document.body.appendChild(this.html); document.body.appendChild(this.html);
this.background.onclick = function () { this.hide(); }.bind(this); this.background.onclick = _ => { this.hide(); };
} }
hide() { hide() {
document.body.removeChild(this.background); document.body.removeChild(this.background);

View file

@ -446,8 +446,7 @@ class Guild {
console.log(name, category); console.log(name, category);
func(name, category); func(name, category);
channelselect.hide(); channelselect.hide();
}.bind(this)] }.bind(this)]]);
]);
channelselect.show(); channelselect.show();
} }
createcategory() { createcategory() {
@ -458,12 +457,11 @@ class Guild {
console.log(this); console.log(this);
name = this.value; name = this.value;
}], }],
["button", "", "submit", function () { ["button", "", "submit", () => {
console.log(name, category); console.log(name, category);
this.createChannel(name, category); this.createChannel(name, category);
channelselect.hide(); channelselect.hide();
}] }]]);
]);
channelselect.show(); channelselect.show();
} }
delChannel(json) { delChannel(json) {

View file

@ -153,11 +153,13 @@ typebox.addEventListener("keydown", event => {
}); });
console.log(typebox); console.log(typebox);
typebox.onclick = console.log; typebox.onclick = console.log;
function getguildinfo() { /*
const path = window.location.pathname.split("/"); function getguildinfo(){
const channel = path[3]; const path=window.location.pathname.split("/");
this.ws.send(JSON.stringify({ op: 14, d: { guild_id: path[2], channels: { [channel]: [[0, 99]] } } })); const channel=path[3];
this.ws.send(JSON.stringify({op: 14, d: {guild_id: path[2], channels: {[channel]: [[0, 99]]}}}));
} }
*/
const images = []; const images = [];
const imageshtml = []; const imageshtml = [];
import { File } from "./file.js"; import { File } from "./file.js";

View file

@ -917,8 +917,7 @@ class Localuser {
this.mfa_enabled = true; this.mfa_enabled = true;
} }
}); });
}] }]]);
]);
console.log("here :3"); console.log("here :3");
addmodel.show(); addmodel.show();
}); });

View file

@ -17,7 +17,7 @@ class Member {
this.contextmenu.addbutton("Message user", function () { this.contextmenu.addbutton("Message user", function () {
fetch(this.info.api + "/users/@me/channels", { method: "POST", fetch(this.info.api + "/users/@me/channels", { method: "POST",
body: JSON.stringify({ "recipients": [this.id] }), body: JSON.stringify({ "recipients": [this.id] }),
headers: this.headers headers: this.localuser.headers
}); });
}); });
} }

View file

@ -70,7 +70,7 @@ class Message {
Message.contextmenu.addbutton("Edit", function () { Message.contextmenu.addbutton("Edit", function () {
this.channel.editing = this; this.channel.editing = this;
const markdown = (document.getElementById("typebox"))["markdown"]; const markdown = (document.getElementById("typebox"))["markdown"];
markdown.txt = this.content.rawString; markdown.txt = this.content.rawString.split('');
markdown.boxupdate(document.getElementById("typebox")); markdown.boxupdate(document.getElementById("typebox"));
}, null, _ => { return _.author.id === _.localuser.user.id; }); }, null, _ => { return _.author.id === _.localuser.user.id; });
Message.contextmenu.addbutton("Delete message", function () { Message.contextmenu.addbutton("Delete message", function () {

View file

@ -6,7 +6,8 @@
"strict": false, "strict": false,
"esModuleInterop": true, "esModuleInterop": true,
"outDir": "./.dist", "outDir": "./.dist",
"removeComments": false "removeComments": false,
"noImplicitThis":true
}, },
"include": [ "include": [
"./webpage/*.ts" "./webpage/*.ts"

View file

@ -51,30 +51,30 @@ class Channel{
return this.snowflake.id; return this.snowflake.id;
} }
static setupcontextmenu(){ static setupcontextmenu(){
this.contextmenu.addbutton("Copy channel id",function(){ this.contextmenu.addbutton("Copy channel id",function(this:Channel){
console.log(this) console.log(this)
navigator.clipboard.writeText(this.id); navigator.clipboard.writeText(this.id);
}); });
this.contextmenu.addbutton("Mark as read",function(){ this.contextmenu.addbutton("Mark as read",function(this:Channel){
console.log(this) console.log(this)
this.readbottom(); this.readbottom();
}); });
this.contextmenu.addbutton("Settings[temp]",function(){ this.contextmenu.addbutton("Settings[temp]",function(this:Channel){
this.generateSettings(); this.generateSettings();
}); });
this.contextmenu.addbutton("Delete channel",function(){ this.contextmenu.addbutton("Delete channel",function(this:Channel){
console.log(this) console.log(this)
this.deleteChannel(); this.deleteChannel();
},null,_=>{console.log(_);return _.isAdmin()}); },null,_=>{console.log(_);return _.isAdmin()});
this.contextmenu.addbutton("Edit channel",function(){ this.contextmenu.addbutton("Edit channel",function(this:Channel){
this.editChannel(this); this.editChannel();
},null,_=>{return _.isAdmin()}); },null,_=>{return _.isAdmin()});
this.contextmenu.addbutton("Make invite",function(){ this.contextmenu.addbutton("Make invite",function(this:Channel){
this.createInvite(); this.createInvite();
},null,(_:Channel)=>{ },null,(_:Channel)=>{
return _.hasPermission("CREATE_INSTANT_INVITE")&&_.type!==4 return _.hasPermission("CREATE_INSTANT_INVITE")&&_.type!==4
@ -356,9 +356,9 @@ class Channel{
addchannel.textContent="+"; addchannel.textContent="+";
addchannel.classList.add("addchannel"); addchannel.classList.add("addchannel");
caps.appendChild(addchannel); caps.appendChild(addchannel);
addchannel.onclick=function(){ addchannel.onclick=_=>{
this.guild.createchannels(this.createChannel.bind(this)); this.guild.createchannels(this.createChannel.bind(this));
}.bind(this); }
this.coatDropDiv(decdiv,childrendiv); this.coatDropDiv(decdiv,childrendiv);
} }
div.appendChild(caps) div.appendChild(caps)
@ -537,9 +537,9 @@ class Channel{
const full=new Dialog( const full=new Dialog(
["hdiv", ["hdiv",
["vdiv", ["vdiv",
["textbox","Channel name:",this.name,function(){name=this.value}], ["textbox","Channel name:",this.name,function(this:HTMLInputElement){name=this.value}],
["mdbox","Channel topic:",this.topic,function(){topic=this.value}], ["mdbox","Channel topic:",this.topic,function(this:HTMLTextAreaElement){topic=this.value}],
["checkbox","NSFW Channel",this.nsfw,function(){nsfw=this.checked}], ["checkbox","NSFW Channel",this.nsfw,function(this:HTMLInputElement){nsfw=this.checked}],
["button","","submit",()=>{ ["button","","submit",()=>{
fetch(this.info.api+"/channels/"+thisid,{ fetch(this.info.api+"/channels/"+thisid,{
method:"PATCH", method:"PATCH",

View file

@ -241,7 +241,7 @@ class Dialog{
this.background.classList.add("background"); this.background.classList.add("background");
document.body.appendChild(this.background); document.body.appendChild(this.background);
document.body.appendChild(this.html); document.body.appendChild(this.html);
this.background.onclick = function(){this.hide();}.bind(this); this.background.onclick = _=>{this.hide()};
} }
hide(){ hide(){
document.body.removeChild(this.background); document.body.removeChild(this.background);

View file

@ -31,33 +31,33 @@ class Guild{
} }
static contextmenu=new Contextmenu("guild menu"); static contextmenu=new Contextmenu("guild menu");
static setupcontextmenu(){ static setupcontextmenu(){
Guild.contextmenu.addbutton("Copy Guild id",function(){ Guild.contextmenu.addbutton("Copy Guild id",function(this:Guild){
console.log(this) console.log(this)
navigator.clipboard.writeText(this.id); navigator.clipboard.writeText(this.id);
}); });
Guild.contextmenu.addbutton("Mark as read",function(){ Guild.contextmenu.addbutton("Mark as read",function(this:Guild){
console.log(this) console.log(this)
this.markAsRead(); this.markAsRead();
}); });
Guild.contextmenu.addbutton("Notifications",function(){ Guild.contextmenu.addbutton("Notifications",function(this:Guild){
console.log(this) console.log(this)
this.setnotifcation(); this.setnotifcation();
}); });
Guild.contextmenu.addbutton("Leave guild",function(){ Guild.contextmenu.addbutton("Leave guild",function(this:Guild){
this.confirmleave(); this.confirmleave();
},null,function(_){return _.properties.owner_id!==_.member.user.id}); },null,function(_){return _.properties.owner_id!==_.member.user.id});
Guild.contextmenu.addbutton("Delete guild",function(){ Guild.contextmenu.addbutton("Delete guild",function(this:Guild){
this.confirmDelete(); this.confirmDelete();
},null,function(_){return _.properties.owner_id===_.member.user.id}); },null,function(_){return _.properties.owner_id===_.member.user.id});
Guild.contextmenu.addbutton("Create invite",function(){ Guild.contextmenu.addbutton("Create invite",function(this:Guild){
console.log(this); console.log(this);
},null,_=>true,_=>false); },null,_=>true,_=>false);
Guild.contextmenu.addbutton("Settings[temp]",function(){ Guild.contextmenu.addbutton("Settings[temp]",function(this:Guild){
this.generateSettings(); this.generateSettings();
}); });
/* -----things left for later----- /* -----things left for later-----
@ -296,7 +296,7 @@ class Guild{
["textbox", ["textbox",
"Name of server:", "Name of server:",
"", "",
function(){ function(this:HTMLInputElement){
confirmname=this.value; confirmname=this.value;
} }
] ]
@ -447,7 +447,7 @@ class Guild{
}, },
1 1
], ],
["textbox","Name of channel","",function(){ ["textbox","Name of channel","",function(this:HTMLInputElement){
console.log(this) console.log(this)
name=this.value name=this.value
}], }],
@ -464,11 +464,11 @@ class Guild{
let category=4; let category=4;
const channelselect=new Dialog( const channelselect=new Dialog(
["vdiv", ["vdiv",
["textbox","Name of category","",function(){ ["textbox","Name of category","",function(this:HTMLInputElement){
console.log(this); console.log(this);
name=this.value; name=this.value;
}], }],
["button","","submit",function(){ ["button","","submit",()=>{
console.log(name,category) console.log(name,category)
this.createChannel(name,category); this.createChannel(name,category);
channelselect.hide(); channelselect.hide();

View file

@ -166,13 +166,13 @@ typebox.addEventListener("keydown",event=>{
console.log(typebox) console.log(typebox)
typebox.onclick=console.log; typebox.onclick=console.log;
/*
function getguildinfo(){ function getguildinfo(){
const path=window.location.pathname.split("/"); const path=window.location.pathname.split("/");
const channel=path[3]; const channel=path[3];
this.ws.send(JSON.stringify({op: 14, d: {guild_id: path[2], channels: {[channel]: [[0, 99]]}}})); this.ws.send(JSON.stringify({op: 14, d: {guild_id: path[2], channels: {[channel]: [[0, 99]]}}}));
} }
*/
const images:Blob[]=[]; const images:Blob[]=[];
const imageshtml=[]; const imageshtml=[];

View file

@ -534,7 +534,7 @@ class Localuser{
["textbox", ["textbox",
"Invite Link/Code", "Invite Link/Code",
"", "",
function(){ function(this:HTMLInputElement){
inviteurl=this.value; inviteurl=this.value;
} }
], ],
@ -916,8 +916,8 @@ class Localuser{
["title","2FA set up"], ["title","2FA set up"],
["text","Copy this secret into your totp(time-based one time password) app"], ["text","Copy this secret into your totp(time-based one time password) app"],
["text",`Your secret is: ${secret} and it's 6 digits, with a 30 second token period`], ["text",`Your secret is: ${secret} and it's 6 digits, with a 30 second token period`],
["textbox","Account password:","",function(){password=this.value}], ["textbox","Account password:","",function(this:HTMLInputElement){password=this.value}],
["textbox","Code:","",function(){code=this.value}], ["textbox","Code:","",function(this:HTMLInputElement){code=this.value}],
["button","","Submit",()=>{ ["button","","Submit",()=>{
fetch(this.info.api+"/users/@me/mfa/totp/enable/",{ fetch(this.info.api+"/users/@me/mfa/totp/enable/",{
method:"POST", method:"POST",

View file

@ -263,7 +263,7 @@ async function login(username:string, password:string, captcha:string){
console.log(response); console.log(response);
if(response.ticket){ if(response.ticket){
let onetimecode=""; let onetimecode="";
new Dialog(["vdiv",["title","2FA code:"],["textbox","","",function(){onetimecode=this.value}],["button","","Submit",function(){ new Dialog(["vdiv",["title","2FA code:"],["textbox","","",function(this:HTMLInputElement){onetimecode=this.value}],["button","","Submit",function(){
fetch(api+"/auth/mfa/totp",{ fetch(api+"/auth/mfa/totp",{
method:"POST", method:"POST",
headers:{ headers:{

View file

@ -14,14 +14,14 @@ class Member{
nick:string; nick:string;
static contextmenu:Contextmenu=new Contextmenu("User Menu"); static contextmenu:Contextmenu=new Contextmenu("User Menu");
static setUpContextMenu(){ static setUpContextMenu(){
this.contextmenu.addbutton("Copy user id",function(){ this.contextmenu.addbutton("Copy user id",function(this:Member){
navigator.clipboard.writeText(this.id); navigator.clipboard.writeText(this.id);
}); });
this.contextmenu.addbutton("Message user",function(){ this.contextmenu.addbutton("Message user",function(this:Member){
fetch(this.info.api+"/users/@me/channels", fetch(this.info.api+"/users/@me/channels",
{method:"POST", {method:"POST",
body:JSON.stringify({"recipients":[this.id]}), body:JSON.stringify({"recipients":[this.id]}),
headers: this.headers headers: this.localuser.headers
}); });
}); });
} }

View file

@ -57,13 +57,13 @@ class Message{
this.del=new Promise(_=>{this.resolve=_}) this.del=new Promise(_=>{this.resolve=_})
} }
static setupcmenu(){ static setupcmenu(){
Message.contextmenu.addbutton("Copy raw text",function(){ Message.contextmenu.addbutton("Copy raw text",function(this:Message){
navigator.clipboard.writeText(this.content.rawString); navigator.clipboard.writeText(this.content.rawString);
}); });
Message.contextmenu.addbutton("Reply",function(this:Message,div:HTMLDivElement){ Message.contextmenu.addbutton("Reply",function(this:Message,div:HTMLDivElement){
this.channel.setReplying(this); this.channel.setReplying(this);
}); });
Message.contextmenu.addbutton("Copy message id",function(){ Message.contextmenu.addbutton("Copy message id",function(this:Message){
navigator.clipboard.writeText(this.id); navigator.clipboard.writeText(this.id);
}); });
Message.contextmenu.addsubmenu("Add reaction",function(this:Message,e){ Message.contextmenu.addsubmenu("Add reaction",function(this:Message,e){
@ -72,13 +72,13 @@ class Message{
this.reactionToggle(_); this.reactionToggle(_);
}); });
}); });
Message.contextmenu.addbutton("Edit",function(){ Message.contextmenu.addbutton("Edit",function(this:Message){
this.channel.editing=this; this.channel.editing=this;
const markdown=(document.getElementById("typebox"))["markdown"] as MarkDown; const markdown=(document.getElementById("typebox"))["markdown"] as MarkDown;
markdown.txt=this.content.rawString; markdown.txt=this.content.rawString.split('');
markdown.boxupdate(document.getElementById("typebox")); markdown.boxupdate(document.getElementById("typebox"));
},null,_=>{return _.author.id===_.localuser.user.id}); },null,_=>{return _.author.id===_.localuser.user.id});
Message.contextmenu.addbutton("Delete message",function(){ Message.contextmenu.addbutton("Delete message",function(this:Message){
this.delete(); this.delete();
},null,_=>{return _.canDelete()}) },null,_=>{return _.canDelete()})
} }

View file

@ -71,7 +71,7 @@ class User{
this.contextmenu.addbutton("Copy user id",function(this:User){ this.contextmenu.addbutton("Copy user id",function(this:User){
navigator.clipboard.writeText(this.id); navigator.clipboard.writeText(this.id);
}); });
this.contextmenu.addbutton("Message user",function(){ this.contextmenu.addbutton("Message user",function(this:User){
fetch(this.info.api+"/users/@me/channels", fetch(this.info.api+"/users/@me/channels",
{method:"POST", {method:"POST",
body:JSON.stringify({"recipients":[this.id]}), body:JSON.stringify({"recipients":[this.id]}),