Cleaning up of index with some fixes

This commit is contained in:
MathMan05 2024-06-24 11:00:49 -05:00
parent 73e5856d01
commit d1ce9f780a
4 changed files with 99 additions and 99 deletions

View file

@ -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}

View file

@ -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)=>{

View file

@ -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;
})
}
}

View file

@ -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})