Changes including leaving and deleting servers
This commit is contained in:
parent
c794ae46c7
commit
68de802a4d
6 changed files with 221 additions and 70 deletions
2
index.js
2
index.js
|
@ -11,7 +11,7 @@ app.use("/getupdates",(req, res) => {
|
||||||
let debugging=true;
|
let debugging=true;
|
||||||
app.use('/', (req, res) => {
|
app.use('/', (req, res) => {
|
||||||
if(debugging&&req.path.startsWith("/service.js")){
|
if(debugging&&req.path.startsWith("/service.js")){
|
||||||
res.send("console.log(\"Hi :3\")");
|
res.send("console.log(\"Hi :3\");");
|
||||||
}
|
}
|
||||||
if(fs.existsSync(`${__dirname}/webpage${req.path}`)) {
|
if(fs.existsSync(`${__dirname}/webpage${req.path}`)) {
|
||||||
res.sendFile(`./webpage${req.path}`, {root: __dirname});
|
res.sendFile(`./webpage${req.path}`, {root: __dirname});
|
||||||
|
|
|
@ -118,6 +118,12 @@ class fullscreen{
|
||||||
span.innerText=array[1];
|
span.innerText=array[1];
|
||||||
return span;
|
return span;
|
||||||
}
|
}
|
||||||
|
case "title":{
|
||||||
|
const span =document.createElement("span");
|
||||||
|
span.classList.add("title")
|
||||||
|
span.innerText=array[1];
|
||||||
|
return span;
|
||||||
|
}
|
||||||
case "radio":{
|
case "radio":{
|
||||||
const div=document.createElement("div");
|
const div=document.createElement("div");
|
||||||
const fieldset=document.createElement("fieldset");
|
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(){
|
guild.contextmenu.addbutton("Copy Guild id",function(){
|
||||||
console.log(this)
|
console.log(this)
|
||||||
navigator.clipboard.writeText(this.id);
|
navigator.clipboard.writeText(this.id);
|
||||||
})
|
});
|
||||||
|
|
||||||
guild.contextmenu.addbutton("Mark as read",function(){
|
guild.contextmenu.addbutton("Mark as read",function(){
|
||||||
console.log(this)
|
console.log(this)
|
||||||
this.markAsRead();
|
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);
|
console.log(this);
|
||||||
},null,_=>true,_=>false);
|
},null,_=>true,_=>false);
|
||||||
/* -----things left for later-----
|
/* -----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(){
|
printServers(){
|
||||||
let build=""
|
let build=""
|
||||||
for(const thing of this.headchannels){
|
for(const thing of this.headchannels){
|
||||||
|
@ -124,6 +166,89 @@ class guild{
|
||||||
sortchannels(){
|
sortchannels(){
|
||||||
this.headchannels.sort((a,b)=>{return a.position-b.position;});
|
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){
|
unreads(html){
|
||||||
if(html){
|
if(html){
|
||||||
this.html=html;
|
this.html=html;
|
||||||
|
|
|
@ -149,6 +149,23 @@ class localuser{
|
||||||
this.delChannel(temp.d);
|
this.delChannel(temp.d);
|
||||||
}
|
}
|
||||||
break;
|
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){
|
}else if(temp.op===10){
|
||||||
|
@ -267,47 +284,14 @@ class localuser{
|
||||||
thing.unreaddms();
|
thing.unreaddms();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const divy=document.createElement("div");
|
const divy=thing.generateGuildIcon();
|
||||||
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)
|
|
||||||
}
|
|
||||||
serverlist.append(divy);
|
serverlist.append(divy);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const br=document.createElement("hr")
|
const br=document.createElement("hr");
|
||||||
br.classList.add("lightbr");
|
br.classList.add("lightbr");
|
||||||
serverlist.appendChild(br);
|
serverlist.appendChild(br);
|
||||||
|
br.id="bottomseperator";
|
||||||
|
|
||||||
const div=document.createElement("div");
|
const div=document.createElement("div");
|
||||||
div.innerText="+";
|
div.innerText="+";
|
||||||
|
|
|
@ -32,6 +32,7 @@ body {
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-radius: .1in;
|
border-radius: .1in;
|
||||||
border-color: var(--dialog-border);
|
border-color: var(--dialog-border);
|
||||||
|
padding:.03in;
|
||||||
}
|
}
|
||||||
|
|
||||||
th {
|
th {
|
||||||
|
@ -78,6 +79,14 @@ samp {
|
||||||
.contextbutton:active{
|
.contextbutton:active{
|
||||||
border-width: 0px;
|
border-width: 0px;
|
||||||
}
|
}
|
||||||
|
.contextbutton:disabled{
|
||||||
|
cursor:not-allowed;
|
||||||
|
border-width:0px;
|
||||||
|
}
|
||||||
|
.contextbutton:disabled:hover{
|
||||||
|
background-color: var(--channels-bg);
|
||||||
|
}
|
||||||
|
|
||||||
.infosection {
|
.infosection {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
background-color: var(--profile-info-bg);
|
background-color: var(--profile-info-bg);
|
||||||
|
@ -86,13 +95,7 @@ samp {
|
||||||
width: calc(100% - .6cm);
|
width: calc(100% - .6cm);
|
||||||
height: calc(100% - .75in);
|
height: calc(100% - .75in);
|
||||||
}
|
}
|
||||||
.contextbutton:disabled{
|
|
||||||
cursor:not-allowed;
|
|
||||||
border-width:0px;
|
|
||||||
}
|
|
||||||
.contextbutton:disabled:hover{
|
|
||||||
background-color: var(--channels-bg);
|
|
||||||
}
|
|
||||||
.profile {
|
.profile {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -266,6 +269,9 @@ input {
|
||||||
color: var(--primary-text);
|
color: var(--primary-text);
|
||||||
height: .4in;
|
height: .4in;
|
||||||
width: 97.5%;
|
width: 97.5%;
|
||||||
|
border-color: var(--settings-hover);
|
||||||
|
border-width:0 0 .04in 0;
|
||||||
|
border-radius:.05in;
|
||||||
}
|
}
|
||||||
|
|
||||||
div {
|
div {
|
||||||
|
@ -591,22 +597,57 @@ textarea {
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
transition: background .1s ease-in-out;
|
||||||
|
background-color: var(--textarea-bg);
|
||||||
color: var(--primary-text);
|
color: var(--primary-text);
|
||||||
background-color: var(--button-bg);
|
font-weight: bold;
|
||||||
border-radius: .05in;
|
text-align: left;
|
||||||
height: .3in;
|
font-size: .45cm;
|
||||||
min-width: 1.3in;
|
cursor: pointer;
|
||||||
font-size: .175in;
|
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 {
|
input::file-selector-button {
|
||||||
|
transition: background .1s ease-in-out;
|
||||||
|
background-color: var(--textarea-bg);
|
||||||
color: var(--primary-text);
|
color: var(--primary-text);
|
||||||
background-color: var(--button-bg);
|
font-weight: bold;
|
||||||
border-radius: .05in;
|
text-align: left;
|
||||||
height: .25in;
|
font-size: .45cm;
|
||||||
min-width: 1in;
|
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 {
|
#logindiv {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
@ -767,7 +808,7 @@ span {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.tabbed-head{
|
.tabbed-head{
|
||||||
background: var(--textarea-bg);
|
background: var(--settings-hover);
|
||||||
}
|
}
|
||||||
.tabbed-content td{
|
.tabbed-content td{
|
||||||
/* border-color: var(--textarea-bg); */
|
/* border-color: var(--textarea-bg); */
|
||||||
|
@ -804,3 +845,8 @@ span {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
font-size: .125in;
|
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*/
|
.Dark-theme { /* thanks to TomatoCake for the updated CSS vars and such*/
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
|
|
||||||
--primary-text: #FFF;
|
--primary-text: #FFF;
|
||||||
--primary-bg: #282832;
|
--primary-bg: #282832;
|
||||||
--black: #000;
|
--black: #000;
|
||||||
|
|
||||||
--message-bg-hover: #1e1e28;
|
--message-bg-hover: #1e1e28;
|
||||||
--typing-bg: #161616;
|
--typing-bg: #161616;
|
||||||
--timestamp-color: #a2a2a2;
|
--timestamp-color: #a2a2a2;
|
||||||
|
@ -18,7 +16,7 @@
|
||||||
--channels-bg: #32323c;
|
--channels-bg: #32323c;
|
||||||
--channel-hover: #1c1b25;
|
--channel-hover: #1c1b25;
|
||||||
--blank-bg: #1b1b1b;
|
--blank-bg: #1b1b1b;
|
||||||
--light-border: #929292;
|
--light-border: #92929B;
|
||||||
--settings-hover: #0e0d10;
|
--settings-hover: #0e0d10;
|
||||||
--quote-bg: #7a798e;
|
--quote-bg: #7a798e;
|
||||||
--button-bg: #1b1b28;
|
--button-bg: #1b1b28;
|
||||||
|
@ -26,29 +24,21 @@
|
||||||
--filename: #47bbff;
|
--filename: #47bbff;
|
||||||
--mention-bg: #F00;
|
--mention-bg: #F00;
|
||||||
--pronouns: #797979;
|
--pronouns: #797979;
|
||||||
|
|
||||||
--profile-bg: #2e2d33;
|
--profile-bg: #2e2d33;
|
||||||
--profile-info-bg: #1a1a1e;
|
--profile-info-bg: #1a1a1e;
|
||||||
|
|
||||||
--server-border: #1b1b24;
|
--server-border: #1b1b24;
|
||||||
--server-bg: #252530;
|
--server-bg: #252530;
|
||||||
|
|
||||||
--reply-border: #474b76;
|
--reply-border: #474b76;
|
||||||
--reply-bg: #0b0d20;
|
--reply-bg: #0b0d20;
|
||||||
--reply-text: #acacac;
|
--reply-text: #acacac;
|
||||||
|
|
||||||
--spoiler-hover: #111111;
|
--spoiler-hover: #111111;
|
||||||
--spoiler-open-bg: #1e1e1e;
|
--spoiler-open-bg: #1e1e1e;
|
||||||
|
|
||||||
--unknown-file-bg: #141316;
|
--unknown-file-bg: #141316;
|
||||||
--unknown-file-border: #474555;
|
--unknown-file-border: #474555;
|
||||||
|
|
||||||
--login-border: #131315;
|
--login-border: #131315;
|
||||||
--loading-bg: #22232c;
|
--loading-bg: #22232c;
|
||||||
|
|
||||||
--dialog-bg: #33363d;
|
--dialog-bg: #33363d;
|
||||||
--dialog-border: #1c1b31;
|
--dialog-border: #1c1b31;
|
||||||
|
|
||||||
--scrollbar-track: #34313c;
|
--scrollbar-track: #34313c;
|
||||||
--scrollbar-thumb: #201f29;
|
--scrollbar-thumb: #201f29;
|
||||||
--scrollbar-thumb-hover: #16161f;
|
--scrollbar-thumb-hover: #16161f;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue