Cleaning up of index with some fixes
This commit is contained in:
parent
73e5856d01
commit
d1ce9f780a
4 changed files with 99 additions and 99 deletions
|
@ -475,7 +475,7 @@ class channel{
|
||||||
return "default";
|
return "default";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async sendMessage(content,{attatchmenets=[],embeds=[],replyingto=false}){
|
async sendMessage(content,{attachments=[],embeds=[],replyingto=false}){
|
||||||
let replyjson=false;
|
let replyjson=false;
|
||||||
if(replyingto){
|
if(replyingto){
|
||||||
replyjson=
|
replyjson=
|
||||||
|
@ -485,7 +485,7 @@ class channel{
|
||||||
"message_id": replyingto.id,
|
"message_id": replyingto.id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if(attatchmenets.length===0){
|
if(attachments.length===0){
|
||||||
const body={
|
const body={
|
||||||
content:content,
|
content:content,
|
||||||
nonce:Math.floor(Math.random()*1000000000)
|
nonce:Math.floor(Math.random()*1000000000)
|
||||||
|
@ -494,7 +494,7 @@ class channel{
|
||||||
body.message_reference=replyjson;
|
body.message_reference=replyjson;
|
||||||
}
|
}
|
||||||
console.log(body)
|
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",
|
method:"POST",
|
||||||
headers:this.headers,
|
headers:this.headers,
|
||||||
body:JSON.stringify(body)
|
body:JSON.stringify(body)
|
||||||
|
@ -509,11 +509,11 @@ class channel{
|
||||||
body.message_reference=replyjson;
|
body.message_reference=replyjson;
|
||||||
}
|
}
|
||||||
formData.append('payload_json', JSON.stringify(body));
|
formData.append('payload_json', JSON.stringify(body));
|
||||||
for(const i in attatchmenets){
|
for(const i in attachments){
|
||||||
console.log(attatchmenets[i])
|
console.log(attachments[i])
|
||||||
formData.append("files["+i+"]",attatchmenets[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',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
headers:{"Authorization":this.headers.Authorization}
|
headers:{"Authorization":this.headers.Authorization}
|
||||||
|
|
|
@ -127,7 +127,7 @@ let replyingto=null;
|
||||||
function createchannels(fincall){
|
function createchannels(fincall){
|
||||||
let name="";
|
let name="";
|
||||||
let category=0;
|
let category=0;
|
||||||
console.log(fincall)
|
console.log(fincall);
|
||||||
channelselect=new fullscreen(
|
channelselect=new fullscreen(
|
||||||
["vdiv",
|
["vdiv",
|
||||||
["radio","select channel type",
|
["radio","select channel type",
|
||||||
|
@ -153,7 +153,7 @@ function createchannels(fincall){
|
||||||
function createcategory(fincall){
|
function createcategory(fincall){
|
||||||
let name="";
|
let name="";
|
||||||
let category=4;
|
let category=4;
|
||||||
console.log(fincall)
|
console.log(fincall);
|
||||||
channelselect=new fullscreen(
|
channelselect=new fullscreen(
|
||||||
["vdiv",
|
["vdiv",
|
||||||
["textbox","Name of category","",function(){
|
["textbox","Name of category","",function(){
|
||||||
|
@ -235,7 +235,7 @@ function buildprofile(x,y,user,type="author"){
|
||||||
function profileclick(obj,author){
|
function profileclick(obj,author){
|
||||||
obj.onclick=function(e){
|
obj.onclick=function(e){
|
||||||
console.log(e.clientX,e.clientY,author);
|
console.log(e.clientX,e.clientY,author);
|
||||||
buildprofile(e.clientX,e.clientY,author)
|
buildprofile(e.clientX,e.clientY,author);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ async function enter(event){
|
||||||
}
|
}
|
||||||
replyingto=false;
|
replyingto=false;
|
||||||
thisuser.channelfocus.sendMessage(typebox.value,{
|
thisuser.channelfocus.sendMessage(typebox.value,{
|
||||||
attatchmenets:images,
|
attachments:images,
|
||||||
replyingto:replying,
|
replyingto:replying,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -356,79 +356,11 @@ document.addEventListener('paste', async (e) => {
|
||||||
console.log(file.type)
|
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();
|
setTheme();
|
||||||
|
|
||||||
function userSettings(){
|
function userSettings(){
|
||||||
usersettings.show();
|
thisuser.usersettings.show();
|
||||||
}
|
}
|
||||||
let triggered=false;
|
let triggered=false;
|
||||||
document.getElementById("messagecontainer").addEventListener("scroll",(e)=>{
|
document.getElementById("messagecontainer").addEventListener("scroll",(e)=>{
|
||||||
|
|
|
@ -7,6 +7,7 @@ class localuser{
|
||||||
this.headers={"Content-type": "application/json; charset=UTF-8",Authorization:this.userinfo.token};
|
this.headers={"Content-type": "application/json; charset=UTF-8",Authorization:this.userinfo.token};
|
||||||
}
|
}
|
||||||
gottenReady(ready){
|
gottenReady(ready){
|
||||||
|
this.usersettings;
|
||||||
this.initialized=true;
|
this.initialized=true;
|
||||||
this.ready=ready;
|
this.ready=ready;
|
||||||
this.guilds=[];
|
this.guilds=[];
|
||||||
|
@ -105,7 +106,7 @@ class localuser{
|
||||||
case "READY":
|
case "READY":
|
||||||
this.gottenReady(temp);
|
this.gottenReady(temp);
|
||||||
READY=temp;
|
READY=temp;
|
||||||
genusersettings();
|
this.genusersettings();
|
||||||
returny();
|
returny();
|
||||||
break;
|
break;
|
||||||
case "MESSAGE_UPDATE":
|
case "MESSAGE_UPDATE":
|
||||||
|
@ -459,5 +460,72 @@ class localuser{
|
||||||
typingtext.classList.add("hidden");
|
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;
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ class cmessage{
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
async edit(content){
|
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",
|
method: "PATCH",
|
||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
body:JSON.stringify({content:content})
|
body:JSON.stringify({content:content})
|
||||||
|
@ -245,25 +245,25 @@ class cmessage{
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTime(date) {
|
function formatTime(date) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const sameDay = date.getDate() === now.getDate() &&
|
const sameDay = date.getDate() === now.getDate() &&
|
||||||
date.getMonth() === now.getMonth() &&
|
date.getMonth() === now.getMonth() &&
|
||||||
date.getFullYear() === now.getFullYear();
|
date.getFullYear() === now.getFullYear();
|
||||||
|
|
||||||
const yesterday = new Date(now);
|
const yesterday = new Date(now);
|
||||||
yesterday.setDate(now.getDate() - 1);
|
yesterday.setDate(now.getDate() - 1);
|
||||||
const isYesterday = date.getDate() === yesterday.getDate() &&
|
const isYesterday = date.getDate() === yesterday.getDate() &&
|
||||||
date.getMonth() === yesterday.getMonth() &&
|
date.getMonth() === yesterday.getMonth() &&
|
||||||
date.getFullYear() === yesterday.getFullYear();
|
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) {
|
if (sameDay) {
|
||||||
return `Today at ${formatTime(date)}`;
|
return `Today at ${formatTime(date)}`;
|
||||||
} else if (isYesterday) {
|
} else if (isYesterday) {
|
||||||
return `Yesterday at ${formatTime(date)}`;
|
return `Yesterday at ${formatTime(date)}`;
|
||||||
} else {
|
} else {
|
||||||
return `${date.toLocaleDateString()} at ${formatTime(date)}`;
|
return `${date.toLocaleDateString()} at ${formatTime(date)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmessage.setupcmenu();
|
cmessage.setupcmenu();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue