+
+
+
+ |
+
+ Server Name
+ |
+
+ Channel
+ |
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
|
+
+ ⚙
+ |
+
+
+
+ |
+
+
+
+
+
+
+ typing
+
+ .
+ .
+ .
+
+
+
+ |
+
+
+
+
+
+
diff --git a/webpage/index.js b/webpage/index.js
new file mode 100644
index 0000000..3529952
--- /dev/null
+++ b/webpage/index.js
@@ -0,0 +1,662 @@
+function setDynamicHeight() {
+ var servertdHeight = document.getElementById('servertd').offsetHeight+document.getElementById('typebox').offsetHeight+document.getElementById('pasteimage').offsetHeight;
+ document.documentElement.style.setProperty('--servertd-height', servertdHeight + 'px');
+}
+const resizeObserver = new ResizeObserver(() => {
+ setDynamicHeight();
+});
+resizeObserver.observe(document.getElementById('servertd'));
+resizeObserver.observe(document.getElementById('typebox'));
+resizeObserver.observe(document.getElementById('pasteimage'));
+setDynamicHeight();
+
+
+let token=gettoken();
+let ws
+initwebsocket();
+let READY;
+
+/*
+fetch("https://old.server.spacebar.chat/api/v9/channels/1243314160814653069/messages/1244097259492795763/ack",{
+ method:"POST",
+ headers:{"Content-type": "application/json; charset=UTF-8",Authorization:token},
+ body:JSON.stringify({})
+})
+*/
+function createbutton(text,img,clickevent=function(){}){
+ const textb=document.createElement("tr");
+ const intext=document.createElement("button")
+ textb.button=intext;
+ intext.classList.add("contextbutton")
+ intext.innerText=text
+ textb.appendChild(intext)
+ intext.onclick=clickevent;
+ return textb
+
+}
+
+var currentmenu="";
+document.addEventListener('click', function(event) {
+ if(currentmenu==""){
+ return;
+ }
+ if (!currentmenu.contains(event.target)) {
+ currentmenu.remove();
+ currentmenu="";
+ }
+});
+let replyingto=null;
+lacechannel(document.getElementById("channels"));
+function lacechannel(c){
+ c.addEventListener("contextmenu", (event) => {
+ event.preventDefault();
+ event.stopImmediatePropagation();
+ makemenuc.bind(c)(event.currentTarget,event.clientX,event.clientY);
+ });
+}
+
+function createchannels(fincall){
+ let name="";
+ let catagory=1;
+ console.log(fincall)
+ channelselect=new fullscreen(
+ ["vdiv",
+ ["radio","select channel type",
+ ["voice","text","announcement"],
+ function(e){
+ console.log(e)
+ catagory={"text":0,"voice":2,"announcement":5,"catagory":4}[e]
+ }
+ ],
+ ["textbox","Name of channel","",function(){
+ console.log(this)
+ name=this.value
+ }],
+ ["button","","submit",function(){
+ console.log(name,catagory)
+ fincall(name,catagory);
+ channelselect.hide();
+ }]
+ ]);
+ channelselect.show();
+}
+function createcatagory(fincall){
+ let name="";
+ let catagory=4;
+ console.log(fincall)
+ channelselect=new fullscreen(
+ ["vdiv",
+ ["textbox","Name of catagory","",function(){
+ console.log(this)
+ name=this.value
+ }],
+ ["button","","submit",function(){
+ console.log(name,catagory)
+ fincall(name,catagory);
+ channelselect.hide();
+ }]
+ ]);
+ channelselect.show();
+}
+function editchannelf(channel){channel.editChannel();}
+function makemenuc(divmessage,x,y){
+ if(currentmenu!=""){
+ currentmenu.remove();
+ }
+ const build = document.createElement('table');
+ if(x!==-1){
+ build.classList.add("contextmenu");
+ }
+ console.log(divmessage,divmessage.classList.contains("Channel"));
+ if(divmessage.classList.contains("Channel")){
+ const channel=this.all;
+ const copyidbutton=createbutton("copy channel id",null,function(){
+ console.log(this)
+ navigator.clipboard.writeText(channel.id);
+ })
+ copyidbutton.button.all=divmessage.all;
+ build.appendChild(copyidbutton);
+ if(thisuser.isAdmin()){
+ const deleteChannel=createbutton("Delete channel",null,function(){
+ console.log(channel)
+ channel.deleteChannel();
+ })
+ deleteChannel.button.all=divmessage.all;
+ build.appendChild(deleteChannel);
+
+ const editchannel=createbutton("edit channel",null,function(){
+ editchannelf(channel);
+ })
+ editchannel.button.all=divmessage.all;
+ build.appendChild(editchannel);
+ }
+ }else{
+ if(thisuser.isAdmin()){
+ const createchannel=createbutton("create channel",null,function(){
+ createchannels(thisuser.lookingguild.createChannel.bind(thisuser.lookingguild));
+ })
+ createchannel.button.all=divmessage.all;
+ build.appendChild(createchannel);
+
+ const createcat=createbutton("create catagory",null,function(){
+ createcatagory(thisuser.lookingguild.createChannel.bind(thisuser.lookingguild));
+ })
+ createcat.button.all=divmessage.all;
+ build.appendChild(createcat);
+ //createcatagory
+ }
+ }
+
+ if(divmessage.userid==READY.d.user.id){
+ const editbut=createbutton("edit",null,function(){
+ console.log(this)
+ editing=this.all.id;
+ document.getElementById("typebox").value=this.all.content;
+ })
+ editbut.button.all=divmessage.all;
+ console.log(editbut)
+ build.appendChild(editbut);
+ }
+ if(x!==-1){
+ build.style.top = y+'px';
+ build.style.left = x+'px';
+ }
+ document.body.appendChild(build)
+ currentmenu=build;
+}
+function makemenu(divmessage,x,y){
+ if(currentmenu!=""){
+ currentmenu.remove();
+ }
+ const build = document.createElement('table');
+ if(x!==-1){
+ build.classList.add("contextmenu");
+ }
+ const copybutton=createbutton("copy raw text",null,function(){
+ console.log(this)
+ navigator.clipboard.writeText(this.all.content);
+ })
+ copybutton.button.all=divmessage.all;
+ build.appendChild(copybutton);
+ const replybutton=createbutton("reply",null,function(){
+ console.log(this)
+ if(replyingto){
+ replyingto.classList.remove("replying");
+ }
+ replyingto=divmessage;
+ replyingto.classList.add("replying");
+ })
+ replybutton.button.all=divmessage.all;
+ build.appendChild(replybutton);
+ const copyidbutton=createbutton("copy message id",null,function(){
+ console.log(this)
+ navigator.clipboard.writeText(this.all.id);
+ })
+ copyidbutton.button.all=divmessage.all;
+ build.appendChild(copyidbutton);
+
+ const dmbutton=createbutton("Message user",null,function(){
+ console.log(this)
+ fetch("https://old.server.spacebar.chat/api/v9/users/@me/channels",
+ {method:"POST",
+ body:JSON.stringify({"recipients":[this.all.author.id]}),
+ headers: {"Content-type": "application/json; charset=UTF-8",Authorization:token}
+ });
+ })
+ dmbutton.button.all=divmessage.all;
+ build.appendChild(dmbutton);
+
+ if(divmessage.userid==READY.d.user.id){
+ const editbut=createbutton("edit",null,function(){
+ console.log(this)
+ editing=this.all.id;
+ document.getElementById("typebox").value=this.all.content;
+ })
+ editbut.button.all=divmessage.all;
+ console.log(editbut)
+ build.appendChild(editbut);
+ }
+ if(x!==-1){
+ build.style.top = y+'px';
+ build.style.left = x+'px';
+ }
+ document.body.appendChild(build)
+ currentmenu=build;
+}
+let messagelist=[];
+function buildprofile(x,y,user,type="author"){
+ if(currentmenu!=""){
+ currentmenu.remove();
+ }
+ let nickname, username, discriminator, bio, bot, pronouns, id, avatar
+ if(type=="author"){
+ console.log(user)
+ username=nickname=user.username;
+ bio=user.bio;
+ id=user.id;
+ discriminator=user.discriminator;
+ pronouns=user.pronouns;
+ bot=user.bot;
+ avatar=user.avatar;
+ }
+
+ const div=document.createElement("table");
+ if(x!==-1){
+ div.style.left=x+"px";
+ div.style.top=y+"px";
+ div.classList.add("profile");
+ }else{
+ div.classList.add("hypoprofile");
+ }
+
+ {
+ const pfp=user.buildpfp();
+ const pfprow=document.createElement("tr");
+ div.appendChild(pfprow);
+ pfprow.appendChild(pfp);
+ }
+ {
+ const userbody=document.createElement("tr");
+ userbody.classList.add("infosection");
+ div.appendChild(userbody);
+ const usernamehtml=document.createElement("h2");
+ usernamehtml.innerText=nickname;
+ userbody.appendChild(usernamehtml);
+
+ const discrimatorhtml=document.createElement("h3");
+ discrimatorhtml.classList.add("tag");
+ discrimatorhtml.innerText=username+"#"+discriminator;
+ userbody.appendChild(discrimatorhtml)
+
+ const pronounshtml=document.createElement("p");
+ pronounshtml.innerText=pronouns;
+ pronounshtml.classList.add("pronouns");
+ userbody.appendChild(pronounshtml)
+
+ const rule=document.createElement("hr");
+ userbody.appendChild(rule);
+ const biohtml=markdown(bio);
+ userbody.appendChild(biohtml);
+ }
+ console.log(div);
+ if(x!==-1){
+ currentmenu=div;
+ document.body.appendChild(div)
+ }
+ return div
+}
+function profileclick(obj,author){
+ obj.onclick=function(e){
+ console.log(e.clientX,e.clientY,author);
+ buildprofile(e.clientX,e.clientY,author)
+ e.stopPropagation();
+ }
+}
+
+var editing=false;
+document.getElementById("typebox").addEventListener("keyup",enter);
+console.log(document.getElementById("typebox"))
+document.getElementById("typebox").onclick=console.log;
+async function enter(event){
+ thisuser.lookingguild.prevchannel.typingstart();
+ const tis=document.getElementById("typebox");
+ if(event.key === "Enter"&&!event.shiftKey){
+ event.preventDefault();
+ if(editing){
+ fetch("https://api.old.server.spacebar.chat/api/channels/"+window.location.pathname.split("/")[3]+"/messages/"+editing,{
+ method: "PATCH",
+ headers: {
+ "Content-type": "application/json; charset=UTF-8",
+ Authorization:token
+ },
+ body:JSON.stringify({content:tis.value})
+
+ })
+ tis.value="";
+ editing=false;
+ }else{
+ let replyjson=false;
+ if(replyingto){
+ replyjson=
+ {
+ "guild_id":replyingto.all.guild_id,
+ "channel_id": replyingto.all.channel_id,
+ "message_id": replyingto.all.id,
+ };
+ replyingto.classList.remove("replying");
+ }
+
+ replyingto=false;
+ if(images.length==0){
+
+ const body={
+ content:tis.value,
+ nonce:Math.floor(Math.random()*1000000000)
+ };
+ if(replyjson){
+ body.message_reference=replyjson;
+ }
+ console.log(body)
+ fetch("https://api.old.server.spacebar.chat/api/channels/"+window.location.pathname.split("/")[3]+"/messages",{
+ method:"POST",
+ headers:{
+ "Content-type": "application/json; charset=UTF-8",
+ Authorization:token,
+ },
+ body:JSON.stringify(body)
+ }).then(
+ function(out){
+ console.log(out,"here it is")
+ }
+ )
+ tis.value="";
+ }else{
+ let formData = new FormData();
+ const body={
+ content:tis.value,
+ nonce:Math.floor(Math.random()*1000000000),
+ }
+ if(replyjson){
+ body.message_reference=replyjson;
+ }
+ formData.append('payload_json', JSON.stringify(body));
+ for(i in images){
+ console.log(images[i])
+ formData.append("files["+i+"]",images[i]);
+ }
+ const data=formData.entries()
+ console.log(data.next(),data.next(),data.next())
+ console.log((await fetch("https://api.old.server.spacebar.chat/api/channels/"+window.location.pathname.split("/")[3]+"/messages", {
+ method: 'POST',
+ body: formData,
+ headers:{
+ "Authorization":token,
+ }
+ })));
+ //fetch("/sendimagemessage",{body:formData,method:"POST"})
+
+ while(images.length!=0){
+ images.pop()
+ pasteimage.removeChild(imageshtml.pop())
+ }
+ tis.value="";
+ }
+ }
+ }
+}
+
+let packets=1;
+let serverz=0;
+let serverid=[];
+let thisuser=null;
+
+
+function initwebsocket(){
+ ws = new WebSocket('wss://gateway.old.server.spacebar.chat/?v=9&encoding=json');
+
+ ws.addEventListener('open', (event) => {
+ console.log('WebSocket connected');
+ ws.send(JSON.stringify({
+ "op": 2,
+ "d": {
+ "token":token,
+ "capabilities": 16381,
+ "properties": {
+ "browser": "Harmony",
+ "client_build_number": 0,
+ "release_channel": "Custom",
+ "browser_user_agent": navigator.userAgent
+ },
+ "compress": false,
+ "presence": {
+ "status": "online",
+ "since": new Date().getTime(),
+ "activities": [],
+ "afk": false
+ }
+ }
+ }))
+ });
+
+ ws.addEventListener('message', (event) => {
+
+
+ try{
+ const temp=JSON.parse(event.data);
+ console.log(temp)
+ if(temp.op==0){
+ switch(temp.t){
+ case "MESSAGE_CREATE":
+ thisuser.messageCreate(temp);
+ break;
+ case "READY":
+ thisuser=new localuser(temp);
+ console.log(temp.d.read_state.entries)
+ thisuser.loaduser();
+ READY=temp;
+ thisuser.init();
+ genusersettings();
+ document.getElementById("loading").classList.add("doneloading");
+ document.getElementById("loading").classList.remove("loading")
+ break;
+ case "MESSAGE_UPDATE":
+ if(window.location.pathname.split("/")[3]==temp.d.channel_id){
+ const find=temp.d.id;
+ for(const message of messagelist){
+ if(message.all.id===find){
+ message.all.content=temp.d.content;
+ message.txt.innerHTML=markdown(temp.d.content).innerHTML;
+ break;
+ }
+ }
+ }
+ break;
+ case "TYPING_START":
+ thisuser.typeingStart(temp);
+ break;
+ case "USER_UPDATE":
+ const users=user.userids[temp.d.id];
+ console.log(users,temp.d.id)
+
+ if(users){
+ users.userupdate(temp.d);
+ console.log("in here");
+ }
+ break
+ case "CHANNEL_UPDATE":
+ thisuser.updateChannel(temp.d);
+ break;
+ case "CHANNEL_CREATE":
+ thisuser.createChannel(temp.d);
+ break;
+ case "CHANNEL_DELETE":
+ thisuser.delChannel(temp.d);
+ break;
+ }
+
+ }else if(temp.op===10){
+ console.log("heartbeat down")
+ setInterval(function(){
+ ws.send(JSON.stringify({op:1,d:packets}))
+ },temp.d.heartbeat_interval)
+ packets=1;
+ }else if(temp.op!=11){
+ packets++
+ }
+ }catch(error){
+ console.error(error)
+ }
+
+ });
+
+ ws.addEventListener('close', (event) => {
+ console.log('WebSocket closed');
+ });
+}
+
+let cchanel=0;
+
+
+function getguildinfo(){
+ const path=window.location.pathname.split("/");
+ const channel=path[3];
+ ws.send(JSON.stringify({op: 14, d: {guild_id: path[2], channels: {[channel]: [[0, 99]]}}}));
+}
+
+
+const images=[];
+const imageshtml=[];
+function createunknown(fname,fsize,src){
+ const div=document.createElement("table");
+ div.classList.add("unkownfile");
+ const nametr=document.createElement("tr");
+ div.append(nametr);
+ const fileicon=document.createElement("td");
+ nametr.append(fileicon);
+ fileicon.append("🗎");
+ fileicon.classList.add("fileicon");
+ fileicon.rowSpan="2";
+ const nametd=document.createElement("td");
+ if(src){
+ const a=document.createElement("a");
+ a.href=src;
+ a.innerText=fname;
+ nametd.append(a);
+ }else{
+ nametd.innerText=fname;
+ }
+
+ nametd.classList.add("filename");
+ nametr.append(nametd);
+ const sizetr=document.createElement("tr");
+ const size=document.createElement("td");
+ sizetr.append(size);
+ size.innerText="Size:"+filesizehuman(fsize);
+ size.classList.add("filesize");
+ div.appendChild(sizetr)
+ return div;
+}
+function filesizehuman(fsize){
+ var i = fsize == 0 ? 0 : Math.floor(Math.log(fsize) / Math.log(1024));
+ return +((fsize / Math.pow(1024, i)).toFixed(2)) * 1 + ' ' + ['Bytes', 'Kilobytes', 'Megabytes', 'Gigabytes', 'Terabytes'][i];
+}
+function createunknownfile(file){
+ return createunknown(file.name,file.size)
+}
+function filetohtml(file){
+ if (file.type.startsWith('image/')) {
+ const img = document.createElement('img');
+ const blob = URL.createObjectURL(file);
+ img.src = blob;
+ return img;
+ }else{
+ console.log(file.name);
+
+ return createunknownfile(file);
+ }
+}
+document.addEventListener('paste', async (e) => {
+ Array.from(e.clipboardData.files).forEach(async (file) => {
+ e.preventDefault();
+ const html=filetohtml(file);
+ pasteimage.appendChild(html);
+ const blob = URL.createObjectURL(file);
+ images.push(file)
+ imageshtml.push(html);
+
+ console.log(file.type)
+ });
+});
+let usersettings
+function genusersettings(){
+ const hypothetcialprofie=document.createElement("div");
+ let file=null;
+ let newprouns=null;
+ let newbio=null;
+ let hypouser=new user(thisuser.user,true);
+ function regen(){
+ hypothetcialprofie.textContent="";
+ const hypoprofile=buildprofile(-1,-1,hypouser);
+
+ hypothetcialprofie.appendChild(hypoprofile)
+ console.log(hypothetcialprofie,hypoprofile)
+ }
+ regen();
+ usersettings=new fullscreen(
+ ["hdiv",
+ ["vdiv",
+ ["fileupload","upload pfp:",function(e){
+ console.log(this.files[0])
+ file=this.files[0];
+ const blob = URL.createObjectURL(this.files[0]);
+ hypouser.avatar = blob;
+ hypouser.hypotheticalpfp=true;
+ regen();
+ }],
+ ["textbox","Pronouns:",thisuser.user.pronouns,function(e){
+ console.log(this.value);
+ hypouser.pronouns=this.value;
+ newprouns=this.value;
+ regen();
+ }],
+ ["mdbox","Bio:",thisuser.user.bio,function(e){
+ console.log(this.value);
+ hypouser.bio=this.value;
+ newbio=this.value;
+ regen();
+ }],
+ ["button","update user content:","submit",function(){
+ if(file!==null){
+ thisuser.updatepfp(file);
+ }
+ if(newprouns!==null){
+ thisuser.updatepronouns(newprouns);
+ }
+ if(newbio!==null){
+ thisuser.updatebio(newbio);
+ }
+ }]
+ ],
+ ["vdiv",
+ ["html",hypothetcialprofie]
+ ]
+ ],_=>{},function(){
+ hypouser=new user(thisuser.user);
+ regen();
+ file=null;
+ newprouns=null;
+ newbio=null;
+ })
+}
+function userSettings(){
+ usersettings.show();
+}
+let triggered=false;
+document.getElementById("messagecontainer").addEventListener("scroll",(e)=>{
+ if(document.getElementById("messagecontainer").scrollTop<2000){
+ if(!triggered){
+ thisuser.lookingguild.prevchannel.grabmoremessages();
+ }
+ triggered=true;
+ }else{
+ triggered=false;
+ }
+ //
+})
+/*
+{
+ const messages=document.getElementById("messages");
+ let height=messages.clientHeight;
+ //
+ const resizeObserver=new ResizeObserver(()=>{
+ console.log(messages.scrollTop,messages.clientHeight-height-messages.scrollHeight);
+ messages.scrollTop-=height-messages.scrollHeight;
+ console.log(messages.scrollTop)
+ //if(shouldsnap){
+ // document.getElementById("messagecontainer").scrollTop = document.getElementById("messagecontainer").scrollHeight;
+ //}
+ height=messages.scrollHeight;
+ })
+ resizeObserver.observe(messages)
+}
+*/
diff --git a/webpage/localuser.js b/webpage/localuser.js
new file mode 100644
index 0000000..1c90564
--- /dev/null
+++ b/webpage/localuser.js
@@ -0,0 +1,227 @@
+class localuser{
+ constructor(ready){
+ this.ready=ready;
+ this.guilds=[];
+ this.guildids={};
+ this.user=new user(ready.d.user);
+ this.status=this.ready.d.user_settings.status;
+ this.channelfocus=null;
+ this.lookingguild=null;
+ for(const thing of ready.d.guilds){
+ const temp=new guild(thing,this);
+ this.guilds.push(temp);
+ this.guildids[temp.id]=temp;
+ }
+ {
+ const temp=new dirrect(ready.d.private_channels,this);
+ this.guilds.push(temp);
+ this.guildids[temp.id]=temp;
+ }
+ for(const thing of ready.d.merged_members){
+ const temp=new member(thing[0]);
+ this.guildids[temp.guild_id].giveMember(temp);
+ }
+ this.typing=[];
+ }
+ updateChannel(JSON){
+ this.guildids[JSON.guild_id].updateChannel(JSON);
+ if(JSON.guild_id===this.lookingguild.id){
+ this.loadGuild(JSON.guild_id);
+ }
+ }
+ createChannel(JSON){
+ JSON.guild_id??="@me";
+ this.guildids[JSON.guild_id].createChannelpac(JSON);
+ if(JSON.guild_id===this.lookingguild.id){
+ this.loadGuild(JSON.guild_id);
+ }
+ }
+ delChannel(JSON){
+ JSON.guild_id??="@me";
+ this.guildids[JSON.guild_id].delChannel(JSON);
+ if(JSON.guild_id===this.lookingguild.id){
+ this.loadGuild(JSON.guild_id);
+ }
+ }
+ init(){
+ const location=window.location.href.split("/");
+ if(location[3]==="channels"){
+ const guild=this.loadGuild(location[4]);
+ console.log(guild);
+ guild.loadChannel(location[5]);
+ console.log(location[5])
+ this.channelfocus=location[5];
+ }
+ this.buildservers();
+ }
+ loaduser(){
+ document.getElementById("username").innerText=this.user.username
+ document.getElementById("userpfp").src=this.user.getpfpsrc()
+ document.getElementById("status").innerText=this.status;
+ }
+ isAdmin(){
+ return this.lookingguild.isAdmin();
+ }
+ loadGuild(id){
+ const guild=this.guildids[id];
+ this.lookingguild=guild;
+ document.getElementById("serverName").innerText=guild.properties.name;
+ //console.log(this.guildids,id)
+ document.getElementById("channels").innerHTML="";
+ document.getElementById("channels").appendChild(guild.getHTML());
+ return guild;
+ }
+ buildservers(){
+ const serverlist=document.getElementById("servers");//
+
+ const div=document.createElement("div");
+ div.innerText="⌂";
+ div.classList.add("Home","servericon")
+ div.all=this.guildids["@me"];
+ serverlist.appendChild(div)
+ div.onclick=function(){
+ this.all.loadGuild();
+ this.all.loadChannel();
+ }
+ const br=document.createElement("hr")
+ br.classList.add("lightbr")
+ serverlist.appendChild(br)
+ for(const thing of this.guilds){
+ if(thing instanceof dirrect){
+ continue;
+ }
+ if(thing.properties.icon!=null){
+ const img=document.createElement("img");
+ img.classList.add("pfp","servericon")
+ img.src="https://cdn.old.server.spacebar.chat/icons/"+thing.properties.id+"/"+thing.properties.icon+".png";
+ serverlist.appendChild(img)
+ img.all=thing;
+ img.onclick=function(){
+ console.log(this.all.loadGuild)
+ this.all.loadGuild();
+ this.all.loadChannel();
+ }
+ }else{
+ const div=document.createElement("div");
+ let build="";
+ for(const char of thing.properties.name.split(" ")){
+ build+=char[0];
+ }
+ div.innerText=build;
+ div.classList.add("blankserver","servericon")
+ serverlist.appendChild(div)
+ div.all=thing;
+ div.onclick=function(){
+ this.all.loadGuild();
+ this.all.loadChannel();
+ }
+ }
+ }
+ }
+ messageCreate(messagep){
+ messagep.d.guild_id??="@me";
+ this.guildids[messagep.d.guild_id].channelids[messagep.d.channel_id].messageCreate(messagep,this.channelfocus===messagep.d.channel_id);
+ }
+ typeingStart(typing){
+ if(this.channelfocus===typing.d.channel_id){
+ const memb=typing.d.member;
+ let name;
+ if(memb.id===this.user.id){
+ console.log("you is typing")
+ return;
+ }
+ console.log("user is typing and you should see it");
+ if(memb.nick){
+ name=memb.nick;
+ }else{
+ name=memb.user.username;
+ }
+ let already=false;
+ for(const thing of this.typing){
+ if(thing[0]===name){
+ thing[1]=new Date().getTime();
+ already=true;
+ break;
+ }
+ }
+ if(!already){
+ this.typing.push([name,new Date().getTime()]);
+ }
+ setTimeout(this.rendertyping.bind(this),10000);
+ this.rendertyping();
+ }
+ }
+ updatepfp(file){
+ var reader = new FileReader();
+ reader.readAsDataURL(file);
+ reader.onload = function () {
+ fetch("https://old.server.spacebar.chat/api/v9/users/@me",{
+ method:"PATCH",
+ headers:{
+ "Content-type": "application/json; charset=UTF-8",
+ Authorization:token
+ },
+ body:JSON.stringify({
+ avatar:reader.result,
+ })
+ });
+ console.log(reader.result);
+ };
+
+ }
+ updatepronouns(pronouns){
+ fetch("https://old.server.spacebar.chat/api/v9/users/@me/profile",{
+ method:"PATCH",
+ headers:{
+ "Content-type": "application/json; charset=UTF-8",
+ Authorization:token
+ },
+ body:JSON.stringify({
+ pronouns:pronouns,
+ })
+ });
+ }
+ updatebio(bio){
+ fetch("https://old.server.spacebar.chat/api/v9/users/@me/profile",{
+ method:"PATCH",
+ headers:{
+ "Content-type": "application/json; charset=UTF-8",
+ Authorization:token
+ },
+ body:JSON.stringify({
+ bio:bio,
+ })
+ });
+ }
+ rendertyping(){
+ const typingtext=document.getElementById("typing")
+ let build="";
+ const array2=[];
+ let showing=false;
+ let i=0;
+ for(const thing of this.typing){
+ i++;
+ if(thing[1]>new Date().getTime()-5000){
+ build+=thing[0];
+ array2.push(thing);
+ showing=true;
+ if(i!==this.typing.length){
+ build+=",";
+ }
+ }
+ }
+ if(i>1){
+ build+=" are typing";
+ }else{
+ build+=" is typing";
+ }
+ console.log(typingtext.classList);
+ if(showing){
+ typingtext.classList.remove("hidden");
+ document.getElementById("typingtext").innerText=build;
+ }else{
+ typingtext.classList.add("hidden");
+ }
+ }
+
+}
diff --git a/webpage/login.html b/webpage/login.html
new file mode 100644
index 0000000..98304d2
--- /dev/null
+++ b/webpage/login.html
@@ -0,0 +1,18 @@
+
+
+