Changes including leaving and deleting servers
This commit is contained in:
parent
c794ae46c7
commit
68de802a4d
6 changed files with 221 additions and 70 deletions
|
@ -118,6 +118,12 @@ class fullscreen{
|
|||
span.innerText=array[1];
|
||||
return span;
|
||||
}
|
||||
case "title":{
|
||||
const span =document.createElement("span");
|
||||
span.classList.add("title")
|
||||
span.innerText=array[1];
|
||||
return span;
|
||||
}
|
||||
case "radio":{
|
||||
const div=document.createElement("div");
|
||||
const fieldset=document.createElement("fieldset");
|
||||
|
|
131
webpage/guild.js
131
webpage/guild.js
|
@ -4,14 +4,22 @@ class guild{
|
|||
guild.contextmenu.addbutton("Copy Guild id",function(){
|
||||
console.log(this)
|
||||
navigator.clipboard.writeText(this.id);
|
||||
})
|
||||
});
|
||||
|
||||
guild.contextmenu.addbutton("Mark as read",function(){
|
||||
console.log(this)
|
||||
this.markAsRead();
|
||||
})
|
||||
});
|
||||
|
||||
guild.contextmenu.addbutton("Create Invite",function(){
|
||||
guild.contextmenu.addbutton("Leave guild",function(){
|
||||
this.confirmleave();
|
||||
},null,function(_){return _.properties.owner_id!==_.member.user.id});
|
||||
|
||||
guild.contextmenu.addbutton("Delete guild",function(){
|
||||
this.confirmDelete();
|
||||
},null,function(_){return _.properties.owner_id===_.member.user.id});
|
||||
|
||||
guild.contextmenu.addbutton("Create invite",function(){
|
||||
console.log(this);
|
||||
},null,_=>true,_=>false);
|
||||
/* -----things left for later-----
|
||||
|
@ -59,6 +67,40 @@ class guild{
|
|||
}
|
||||
}
|
||||
}
|
||||
confirmleave(){
|
||||
const full= new fullscreen([
|
||||
"vdiv",
|
||||
["title",
|
||||
"Are you sure you want to leave?"
|
||||
],
|
||||
["hdiv",
|
||||
["button",
|
||||
"",
|
||||
"Yes, I'm sure",
|
||||
_=>{
|
||||
this.leave().then(_=>{
|
||||
full.hide();
|
||||
});
|
||||
}
|
||||
],
|
||||
["button",
|
||||
"",
|
||||
"Nevermind",
|
||||
_=>{
|
||||
full.hide();
|
||||
}
|
||||
]
|
||||
|
||||
]
|
||||
]);
|
||||
full.show();
|
||||
}
|
||||
async leave(){
|
||||
return fetch(info.api.toString()+"/users/@me/guilds/"+this.id,{
|
||||
method:"DELETE",
|
||||
headers:this.headers
|
||||
})
|
||||
}
|
||||
printServers(){
|
||||
let build=""
|
||||
for(const thing of this.headchannels){
|
||||
|
@ -124,6 +166,89 @@ class guild{
|
|||
sortchannels(){
|
||||
this.headchannels.sort((a,b)=>{return a.position-b.position;});
|
||||
}
|
||||
generateGuildIcon(){
|
||||
const divy=document.createElement("div");
|
||||
divy.classList.add("servernoti");
|
||||
|
||||
const noti=document.createElement("div");
|
||||
noti.classList.add("unread");
|
||||
divy.append(noti);
|
||||
this.owner.guildhtml[this.id]=divy;
|
||||
if(this.properties.icon!=null){
|
||||
const img=document.createElement("img");
|
||||
img.classList.add("pfp","servericon");
|
||||
img.src=info.cdn.toString()+"icons/"+this.properties.id+"/"+this.properties.icon+".png";
|
||||
divy.appendChild(img)
|
||||
img.onclick=()=>{
|
||||
console.log(this.loadGuild)
|
||||
this.loadGuild();
|
||||
this.loadChannel();
|
||||
}
|
||||
guild.contextmenu.bind(img,this);
|
||||
}else{
|
||||
const div=document.createElement("div");
|
||||
let build="";
|
||||
for(const char of this.properties.name.split(" ")){
|
||||
build+=char[0];
|
||||
}
|
||||
div.innerText=build;
|
||||
div.classList.add("blankserver","servericon")
|
||||
divy.appendChild(div)
|
||||
div.onclick=()=>{
|
||||
this.loadGuild();
|
||||
this.loadChannel();
|
||||
}
|
||||
guild.contextmenu.bind(div,this)
|
||||
}
|
||||
return divy;
|
||||
}
|
||||
confirmDelete(){
|
||||
let confirmname="";
|
||||
const full= new fullscreen([
|
||||
"vdiv",
|
||||
["title",
|
||||
"Are you sure you want to delete "+this.properties.name+"?"
|
||||
],
|
||||
["textbox",
|
||||
"Name of server:",
|
||||
"",
|
||||
function(){
|
||||
confirmname=this.value;
|
||||
}
|
||||
]
|
||||
,
|
||||
["hdiv",
|
||||
["button",
|
||||
"",
|
||||
"Yes, I'm sure",
|
||||
_=>{
|
||||
console.log(confirmname)
|
||||
if(confirmname!==this.properties.name){
|
||||
return;
|
||||
}
|
||||
this.delete().then(_=>{
|
||||
full.hide();
|
||||
});
|
||||
}
|
||||
],
|
||||
["button",
|
||||
"",
|
||||
"Nevermind",
|
||||
_=>{
|
||||
full.hide();
|
||||
}
|
||||
]
|
||||
|
||||
]
|
||||
]);
|
||||
full.show();
|
||||
}
|
||||
async delete(){
|
||||
return fetch(info.api.toString()+"/guilds/"+this.id+"/delete",{
|
||||
method:"POST",
|
||||
headers:this.headers,
|
||||
})
|
||||
}
|
||||
unreads(html){
|
||||
if(html){
|
||||
this.html=html;
|
||||
|
|
|
@ -149,6 +149,23 @@ class localuser{
|
|||
this.delChannel(temp.d);
|
||||
}
|
||||
break;
|
||||
case "GUILD_DELETE":
|
||||
{
|
||||
const guildy=this.guildids[temp.d.id];
|
||||
delete this.guildids[temp.d.id];
|
||||
this.guilds.splice(this.guilds.indexOf(guildy),1);
|
||||
guildy.html.remove();
|
||||
break;
|
||||
}
|
||||
case "GUILD_CREATE":
|
||||
{
|
||||
const guildy=new guild(temp.d,this);
|
||||
this.guilds.push(guildy);
|
||||
this.guildids[guildy.id]=guildy;
|
||||
console.log("test1")
|
||||
document.getElementById("servers").insertBefore(guildy.generateGuildIcon(),document.getElementById("bottomseperator"));
|
||||
console.log("test2")
|
||||
}
|
||||
}
|
||||
|
||||
}else if(temp.op===10){
|
||||
|
@ -267,47 +284,14 @@ class localuser{
|
|||
thing.unreaddms();
|
||||
continue;
|
||||
}
|
||||
const divy=document.createElement("div");
|
||||
divy.classList.add("servernoti");
|
||||
|
||||
const noti=document.createElement("div");
|
||||
noti.classList.add("unread");
|
||||
divy.append(noti);
|
||||
this.guildhtml[thing.id]=divy;
|
||||
if(thing.properties.icon!=null){
|
||||
const img=document.createElement("img");
|
||||
img.classList.add("pfp","servericon");
|
||||
img.src=info.cdn.toString()+"icons/"+thing.properties.id+"/"+thing.properties.icon+".png";
|
||||
divy.appendChild(img)
|
||||
img.all=thing;
|
||||
img.onclick=function(){
|
||||
console.log(this.all.loadGuild)
|
||||
this.all.loadGuild();
|
||||
this.all.loadChannel();
|
||||
}
|
||||
guild.contextmenu.bind(img,thing);
|
||||
}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")
|
||||
divy.appendChild(div)
|
||||
div.all=thing;
|
||||
div.onclick=function(){
|
||||
this.all.loadGuild();
|
||||
this.all.loadChannel();
|
||||
}
|
||||
guild.contextmenu.bind(div,thing)
|
||||
}
|
||||
const divy=thing.generateGuildIcon();
|
||||
serverlist.append(divy);
|
||||
}
|
||||
{
|
||||
const br=document.createElement("hr")
|
||||
const br=document.createElement("hr");
|
||||
br.classList.add("lightbr");
|
||||
serverlist.appendChild(br);
|
||||
br.id="bottomseperator";
|
||||
|
||||
const div=document.createElement("div");
|
||||
div.innerText="+";
|
||||
|
|
|
@ -32,6 +32,7 @@ body {
|
|||
border-style: solid;
|
||||
border-radius: .1in;
|
||||
border-color: var(--dialog-border);
|
||||
padding:.03in;
|
||||
}
|
||||
|
||||
th {
|
||||
|
@ -78,6 +79,14 @@ samp {
|
|||
.contextbutton:active{
|
||||
border-width: 0px;
|
||||
}
|
||||
.contextbutton:disabled{
|
||||
cursor:not-allowed;
|
||||
border-width:0px;
|
||||
}
|
||||
.contextbutton:disabled:hover{
|
||||
background-color: var(--channels-bg);
|
||||
}
|
||||
|
||||
.infosection {
|
||||
display: inline-block;
|
||||
background-color: var(--profile-info-bg);
|
||||
|
@ -86,13 +95,7 @@ samp {
|
|||
width: calc(100% - .6cm);
|
||||
height: calc(100% - .75in);
|
||||
}
|
||||
.contextbutton:disabled{
|
||||
cursor:not-allowed;
|
||||
border-width:0px;
|
||||
}
|
||||
.contextbutton:disabled:hover{
|
||||
background-color: var(--channels-bg);
|
||||
}
|
||||
|
||||
.profile {
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
|
@ -266,6 +269,9 @@ input {
|
|||
color: var(--primary-text);
|
||||
height: .4in;
|
||||
width: 97.5%;
|
||||
border-color: var(--settings-hover);
|
||||
border-width:0 0 .04in 0;
|
||||
border-radius:.05in;
|
||||
}
|
||||
|
||||
div {
|
||||
|
@ -591,22 +597,57 @@ textarea {
|
|||
}
|
||||
|
||||
button {
|
||||
transition: background .1s ease-in-out;
|
||||
background-color: var(--textarea-bg);
|
||||
color: var(--primary-text);
|
||||
background-color: var(--button-bg);
|
||||
border-radius: .05in;
|
||||
height: .3in;
|
||||
min-width: 1.3in;
|
||||
font-size: .175in;
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
font-size: .45cm;
|
||||
cursor: pointer;
|
||||
border-width: 0px .00in .03in 0;
|
||||
border-radius:.03in;
|
||||
margin: .02in .05in;
|
||||
}
|
||||
button:active{
|
||||
border-width: 0px;
|
||||
}
|
||||
button:disabled{
|
||||
cursor:not-allowed;
|
||||
border-width:0px;
|
||||
}
|
||||
button:disabled:hover{
|
||||
background-color: var(--textarea-bg);
|
||||
}
|
||||
button:hover {
|
||||
background-color: var(--primary-bg);
|
||||
}
|
||||
|
||||
input::file-selector-button {
|
||||
transition: background .1s ease-in-out;
|
||||
background-color: var(--textarea-bg);
|
||||
color: var(--primary-text);
|
||||
background-color: var(--button-bg);
|
||||
border-radius: .05in;
|
||||
height: .25in;
|
||||
min-width: 1in;
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
font-size: .45cm;
|
||||
cursor: pointer;
|
||||
border-width: 0px .00in .03in 0;
|
||||
border-radius:.03in;
|
||||
margin: .02in .05in;
|
||||
}
|
||||
input[type="file"] {
|
||||
background:transparent;
|
||||
}
|
||||
select{
|
||||
transition: background .1s ease-in-out;
|
||||
background-color: var(--textarea-bg);
|
||||
color: var(--primary-text);
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
font-size: .45cm;
|
||||
cursor: pointer;
|
||||
border-width: 0px .00in .03in 0;
|
||||
border-radius:.03in;
|
||||
margin: .02in .05in;
|
||||
}
|
||||
|
||||
#logindiv {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
|
@ -767,7 +808,7 @@ span {
|
|||
position: relative;
|
||||
}
|
||||
.tabbed-head{
|
||||
background: var(--textarea-bg);
|
||||
background: var(--settings-hover);
|
||||
}
|
||||
.tabbed-content td{
|
||||
/* border-color: var(--textarea-bg); */
|
||||
|
@ -804,3 +845,8 @@ span {
|
|||
white-space: nowrap;
|
||||
font-size: .125in;
|
||||
}
|
||||
.title{
|
||||
font-size:.25in;
|
||||
font-weight:bold;
|
||||
text-shadow: .01in .01in .02in var(--black);
|
||||
}
|
|
@ -4,11 +4,9 @@
|
|||
}
|
||||
.Dark-theme { /* thanks to TomatoCake for the updated CSS vars and such*/
|
||||
color-scheme: dark;
|
||||
|
||||
--primary-text: #FFF;
|
||||
--primary-bg: #282832;
|
||||
--black: #000;
|
||||
|
||||
--message-bg-hover: #1e1e28;
|
||||
--typing-bg: #161616;
|
||||
--timestamp-color: #a2a2a2;
|
||||
|
@ -18,7 +16,7 @@
|
|||
--channels-bg: #32323c;
|
||||
--channel-hover: #1c1b25;
|
||||
--blank-bg: #1b1b1b;
|
||||
--light-border: #929292;
|
||||
--light-border: #92929B;
|
||||
--settings-hover: #0e0d10;
|
||||
--quote-bg: #7a798e;
|
||||
--button-bg: #1b1b28;
|
||||
|
@ -26,29 +24,21 @@
|
|||
--filename: #47bbff;
|
||||
--mention-bg: #F00;
|
||||
--pronouns: #797979;
|
||||
|
||||
--profile-bg: #2e2d33;
|
||||
--profile-info-bg: #1a1a1e;
|
||||
|
||||
--server-border: #1b1b24;
|
||||
--server-bg: #252530;
|
||||
|
||||
--reply-border: #474b76;
|
||||
--reply-bg: #0b0d20;
|
||||
--reply-text: #acacac;
|
||||
|
||||
--spoiler-hover: #111111;
|
||||
--spoiler-open-bg: #1e1e1e;
|
||||
|
||||
--unknown-file-bg: #141316;
|
||||
--unknown-file-border: #474555;
|
||||
|
||||
--login-border: #131315;
|
||||
--loading-bg: #22232c;
|
||||
|
||||
--dialog-bg: #33363d;
|
||||
--dialog-border: #1c1b31;
|
||||
|
||||
--scrollbar-track: #34313c;
|
||||
--scrollbar-thumb: #201f29;
|
||||
--scrollbar-thumb-hover: #16161f;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue