Guild context menu plus prep for guild creation
This commit is contained in:
parent
0e34ddcacb
commit
01970f336b
4 changed files with 83 additions and 5 deletions
|
@ -4,8 +4,8 @@ class contextmenu{
|
||||||
this.buttons=[]
|
this.buttons=[]
|
||||||
|
|
||||||
}
|
}
|
||||||
addbutton(text,onclick,img=null,shown=_=>{return true}){
|
addbutton(text,onclick,img=null,shown=_=>true,enabled=_=>true){
|
||||||
this.buttons.push([text,onclick,img,shown])
|
this.buttons.push([text,onclick,img,shown,enabled])
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
makemenu(x,y,addinfo,obj){
|
makemenu(x,y,addinfo,obj){
|
||||||
|
@ -15,6 +15,7 @@ class contextmenu{
|
||||||
if(!thing[3](addinfo)){continue;}
|
if(!thing[3](addinfo)){continue;}
|
||||||
const textb=document.createElement("tr");
|
const textb=document.createElement("tr");
|
||||||
const intext=document.createElement("button")
|
const intext=document.createElement("button")
|
||||||
|
intext.disabled=!thing[4]();
|
||||||
textb.button=intext;
|
textb.button=intext;
|
||||||
intext.classList.add("contextbutton")
|
intext.classList.add("contextbutton")
|
||||||
intext.innerText=thing[0]
|
intext.innerText=thing[0]
|
||||||
|
|
|
@ -1,4 +1,30 @@
|
||||||
class guild{
|
class guild{
|
||||||
|
static contextmenu=new contextmenu("channel menu");
|
||||||
|
static setupcontextmenu(){
|
||||||
|
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(){
|
||||||
|
console.log(this);
|
||||||
|
},null,_=>true,_=>false);
|
||||||
|
/* -----things left for later-----
|
||||||
|
guild.contextmenu.addbutton("Leave Guild",function(){
|
||||||
|
console.log(this)
|
||||||
|
this.deleteChannel();
|
||||||
|
},null,_=>{return thisuser.isAdmin()})
|
||||||
|
|
||||||
|
guild.contextmenu.addbutton("Mute Guild",function(){
|
||||||
|
editchannelf(this);
|
||||||
|
},null,_=>{return thisuser.isAdmin()})
|
||||||
|
*/
|
||||||
|
}
|
||||||
constructor(JSON,owner){
|
constructor(JSON,owner){
|
||||||
if(JSON===-1){
|
if(JSON===-1){
|
||||||
return;
|
return;
|
||||||
|
@ -131,6 +157,22 @@ class guild{
|
||||||
isAdmin(){
|
isAdmin(){
|
||||||
return this.member.isAdmin()
|
return this.member.isAdmin()
|
||||||
}
|
}
|
||||||
|
async markAsRead(){
|
||||||
|
const build={read_states:[]};
|
||||||
|
for(const thing of this.channels){
|
||||||
|
if(thing.hasunreads){
|
||||||
|
build.read_states.push({channel_id:thing.id,message_id:thing.lastmessageid,read_state_type:0});
|
||||||
|
thing.lastreadmessageid=thing.lastmessageid;
|
||||||
|
thing.myhtml.classList.remove("cunread");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.unreads();
|
||||||
|
fetch(info.api.toString()+"/v9/read-states/ack-bulk",{
|
||||||
|
method:"POST",
|
||||||
|
headers:{"Content-type": "application/json; charset=UTF-8",Authorization:token},
|
||||||
|
body:JSON.stringify(build)
|
||||||
|
})
|
||||||
|
}
|
||||||
fillMember(member){
|
fillMember(member){
|
||||||
member.guild=this;
|
member.guild=this;
|
||||||
const realroles=[];
|
const realroles=[];
|
||||||
|
@ -221,3 +263,4 @@ class guild{
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
guild.setupcontextmenu();
|
||||||
|
|
|
@ -120,7 +120,7 @@ class localuser{
|
||||||
this.guildhtml[thing.id]=divy;
|
this.guildhtml[thing.id]=divy;
|
||||||
if(thing.properties.icon!=null){
|
if(thing.properties.icon!=null){
|
||||||
const img=document.createElement("img");
|
const img=document.createElement("img");
|
||||||
img.classList.add("pfp","servericon")
|
img.classList.add("pfp","servericon");
|
||||||
img.src=info.cdn.toString()+"icons/"+thing.properties.id+"/"+thing.properties.icon+".png";
|
img.src=info.cdn.toString()+"icons/"+thing.properties.id+"/"+thing.properties.icon+".png";
|
||||||
divy.appendChild(img)
|
divy.appendChild(img)
|
||||||
img.all=thing;
|
img.all=thing;
|
||||||
|
@ -129,6 +129,7 @@ class localuser{
|
||||||
this.all.loadGuild();
|
this.all.loadGuild();
|
||||||
this.all.loadChannel();
|
this.all.loadChannel();
|
||||||
}
|
}
|
||||||
|
guild.contextmenu.bind(img,thing);
|
||||||
}else{
|
}else{
|
||||||
const div=document.createElement("div");
|
const div=document.createElement("div");
|
||||||
let build="";
|
let build="";
|
||||||
|
@ -143,9 +144,24 @@ class localuser{
|
||||||
this.all.loadGuild();
|
this.all.loadGuild();
|
||||||
this.all.loadChannel();
|
this.all.loadChannel();
|
||||||
}
|
}
|
||||||
|
guild.contextmenu.bind(div,thing)
|
||||||
}
|
}
|
||||||
serverlist.append(divy);
|
serverlist.append(divy);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const br=document.createElement("hr")
|
||||||
|
br.classList.add("lightbr");
|
||||||
|
serverlist.appendChild(br);
|
||||||
|
|
||||||
|
const div=document.createElement("div");
|
||||||
|
div.innerText="+";
|
||||||
|
div.classList.add("addserver","servericon")
|
||||||
|
serverlist.appendChild(div)
|
||||||
|
div.onclick=function(){
|
||||||
|
console.log("clicked :3")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
this.unreads();
|
this.unreads();
|
||||||
}
|
}
|
||||||
messageCreate(messagep){
|
messageCreate(messagep){
|
||||||
|
|
|
@ -86,7 +86,13 @@ 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;
|
||||||
|
@ -285,6 +291,7 @@ p {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
word-break:normal;
|
||||||
}
|
}
|
||||||
.username:hover {
|
.username:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
@ -397,7 +404,18 @@ p {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
.addserver{
|
||||||
|
border-radius: 50%;
|
||||||
|
width: .5in;
|
||||||
|
height: .5in;
|
||||||
|
background-color: var(--blank-bg);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 200%;
|
||||||
|
user-select: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
#channelw {
|
#channelw {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue