diff --git a/webpage/channel.js b/webpage/channel.js index c2f5fc7..c70140d 100644 --- a/webpage/channel.js +++ b/webpage/channel.js @@ -475,7 +475,7 @@ class channel{ return "default"; } } - async sendMessage(content,{attatchmenets=[],embeds=[],replyingto=false}){ + async sendMessage(content,{attachments=[],embeds=[],replyingto=false}){ let replyjson=false; if(replyingto){ replyjson= @@ -485,7 +485,7 @@ class channel{ "message_id": replyingto.id, }; } - if(attatchmenets.length===0){ + if(attachments.length===0){ const body={ content:content, nonce:Math.floor(Math.random()*1000000000) @@ -494,7 +494,7 @@ class channel{ body.message_reference=replyjson; } console.log(body) - return await fetch(info.api.toString()+"/channels/"+window.location.pathname.split("/")[3]+"/messages",{ + return await fetch(info.api.toString()+"/channels/"+this.id+"/messages",{ method:"POST", headers:this.headers, body:JSON.stringify(body) @@ -509,11 +509,11 @@ class channel{ body.message_reference=replyjson; } formData.append('payload_json', JSON.stringify(body)); - for(const i in attatchmenets){ - console.log(attatchmenets[i]) - formData.append("files["+i+"]",attatchmenets[i]); + for(const i in attachments){ + console.log(attachments[i]) + formData.append("files["+i+"]",attachments[i]); } - return await fetch(info.api.toString()+"/channels/"+window.location.pathname.split("/")[3]+"/messages", { + return await fetch(info.api.toString()+"/channels/"+this.id+"/messages", { method: 'POST', body: formData, headers:{"Authorization":this.headers.Authorization} diff --git a/webpage/index.js b/webpage/index.js index 98fcbad..a87981b 100644 --- a/webpage/index.js +++ b/webpage/index.js @@ -127,7 +127,7 @@ let replyingto=null; function createchannels(fincall){ let name=""; let category=0; - console.log(fincall) + console.log(fincall); channelselect=new fullscreen( ["vdiv", ["radio","select channel type", @@ -153,7 +153,7 @@ function createchannels(fincall){ function createcategory(fincall){ let name=""; let category=4; - console.log(fincall) + console.log(fincall); channelselect=new fullscreen( ["vdiv", ["textbox","Name of category","",function(){ @@ -235,7 +235,7 @@ function buildprofile(x,y,user,type="author"){ function profileclick(obj,author){ obj.onclick=function(e){ console.log(e.clientX,e.clientY,author); - buildprofile(e.clientX,e.clientY,author) + buildprofile(e.clientX,e.clientY,author); e.stopPropagation(); } } @@ -263,7 +263,7 @@ async function enter(event){ } replyingto=false; thisuser.channelfocus.sendMessage(typebox.value,{ - attatchmenets:images, + attachments:images, replyingto:replying, }) } @@ -356,79 +356,11 @@ document.addEventListener('paste', async (e) => { 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); - } - }], - ["select","Theme:",["Dark","Light","WHITE"],e=>{ - localStorage.setItem("theme",["Dark","Light","WHITE"][e.target.selectedIndex]); - setTheme(); - },["Dark","Light","WHITE"].indexOf(localStorage.getItem("theme"))], - ["select","Notification sound:",voice.sounds,e=>{ - voice.setNotificationSound(voice.sounds[e.target.selectedIndex]); - voice.noises(voice.sounds[e.target.selectedIndex]); - },voice.sounds.indexOf(voice.getNotificationSound())] - ], - ["vdiv", - ["html",hypothetcialprofie] - ] - ],_=>{},function(){ - hypouser=new user(thisuser.user); - regen(); - file=null; - newprouns=null; - newbio=null; - }) -} setTheme(); function userSettings(){ - usersettings.show(); + thisuser.usersettings.show(); } let triggered=false; document.getElementById("messagecontainer").addEventListener("scroll",(e)=>{ diff --git a/webpage/localuser.js b/webpage/localuser.js index 89b76da..df36c1e 100644 --- a/webpage/localuser.js +++ b/webpage/localuser.js @@ -7,6 +7,7 @@ class localuser{ this.headers={"Content-type": "application/json; charset=UTF-8",Authorization:this.userinfo.token}; } gottenReady(ready){ + this.usersettings; this.initialized=true; this.ready=ready; this.guilds=[]; @@ -105,7 +106,7 @@ class localuser{ case "READY": this.gottenReady(temp); READY=temp; - genusersettings(); + this.genusersettings(); returny(); break; case "MESSAGE_UPDATE": @@ -459,5 +460,72 @@ class localuser{ typingtext.classList.add("hidden"); } } + 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(); + this.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); + } + }], + ["select","Theme:",["Dark","Light","WHITE"],e=>{ + localStorage.setItem("theme",["Dark","Light","WHITE"][e.target.selectedIndex]); + setTheme(); + },["Dark","Light","WHITE"].indexOf(localStorage.getItem("theme"))], + ["select","Notification sound:",voice.sounds,e=>{ + voice.setNotificationSound(voice.sounds[e.target.selectedIndex]); + voice.noises(voice.sounds[e.target.selectedIndex]); + },voice.sounds.indexOf(voice.getNotificationSound())] + ], + ["vdiv", + ["html",hypothetcialprofie] + ] + ],_=>{},function(){ + hypouser=new user(thisuser.user); + regen(); + file=null; + newprouns=null; + newbio=null; + }) + } } diff --git a/webpage/message.js b/webpage/message.js index e923554..e17433b 100644 --- a/webpage/message.js +++ b/webpage/message.js @@ -87,7 +87,7 @@ class cmessage{ return build; } async edit(content){ - return await fetch(info.api.toString()+"/channels/"+window.location.pathname.split("/")[3]+"/messages/"+this.id,{ + return await fetch(info.api.toString()+"/channels/"+this.channel.id+"/messages/"+this.id,{ method: "PATCH", headers: this.headers, body:JSON.stringify({content:content}) @@ -245,25 +245,25 @@ class cmessage{ } function formatTime(date) { - const now = new Date(); - const sameDay = date.getDate() === now.getDate() && - date.getMonth() === now.getMonth() && - date.getFullYear() === now.getFullYear(); + const now = new Date(); + const sameDay = date.getDate() === now.getDate() && + date.getMonth() === now.getMonth() && + date.getFullYear() === now.getFullYear(); - const yesterday = new Date(now); - yesterday.setDate(now.getDate() - 1); - const isYesterday = date.getDate() === yesterday.getDate() && - date.getMonth() === yesterday.getMonth() && - date.getFullYear() === yesterday.getFullYear(); + const yesterday = new Date(now); + yesterday.setDate(now.getDate() - 1); + const isYesterday = date.getDate() === yesterday.getDate() && + date.getMonth() === yesterday.getMonth() && + date.getFullYear() === yesterday.getFullYear(); - const formatTime = date => date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); + const formatTime = date => date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); - if (sameDay) { - return `Today at ${formatTime(date)}`; - } else if (isYesterday) { - return `Yesterday at ${formatTime(date)}`; - } else { - return `${date.toLocaleDateString()} at ${formatTime(date)}`; - } + if (sameDay) { + return `Today at ${formatTime(date)}`; + } else if (isYesterday) { + return `Yesterday at ${formatTime(date)}`; + } else { + return `${date.toLocaleDateString()} at ${formatTime(date)}`; + } } cmessage.setupcmenu();