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=[]
|
||||
|
||||
}
|
||||
addbutton(text,onclick,img=null,shown=_=>{return true}){
|
||||
this.buttons.push([text,onclick,img,shown])
|
||||
addbutton(text,onclick,img=null,shown=_=>true,enabled=_=>true){
|
||||
this.buttons.push([text,onclick,img,shown,enabled])
|
||||
return {};
|
||||
}
|
||||
makemenu(x,y,addinfo,obj){
|
||||
|
@ -15,6 +15,7 @@ class contextmenu{
|
|||
if(!thing[3](addinfo)){continue;}
|
||||
const textb=document.createElement("tr");
|
||||
const intext=document.createElement("button")
|
||||
intext.disabled=!thing[4]();
|
||||
textb.button=intext;
|
||||
intext.classList.add("contextbutton")
|
||||
intext.innerText=thing[0]
|
||||
|
|
|
@ -1,4 +1,30 @@
|
|||
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){
|
||||
if(JSON===-1){
|
||||
return;
|
||||
|
@ -131,6 +157,22 @@ class guild{
|
|||
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){
|
||||
member.guild=this;
|
||||
const realroles=[];
|
||||
|
@ -221,3 +263,4 @@ class guild{
|
|||
})
|
||||
}
|
||||
}
|
||||
guild.setupcontextmenu();
|
||||
|
|
|
@ -120,7 +120,7 @@ class localuser{
|
|||
this.guildhtml[thing.id]=divy;
|
||||
if(thing.properties.icon!=null){
|
||||
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";
|
||||
divy.appendChild(img)
|
||||
img.all=thing;
|
||||
|
@ -129,6 +129,7 @@ class localuser{
|
|||
this.all.loadGuild();
|
||||
this.all.loadChannel();
|
||||
}
|
||||
guild.contextmenu.bind(img,thing);
|
||||
}else{
|
||||
const div=document.createElement("div");
|
||||
let build="";
|
||||
|
@ -143,9 +144,24 @@ class localuser{
|
|||
this.all.loadGuild();
|
||||
this.all.loadChannel();
|
||||
}
|
||||
guild.contextmenu.bind(div,thing)
|
||||
}
|
||||
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();
|
||||
}
|
||||
messageCreate(messagep){
|
||||
|
|
|
@ -86,7 +86,13 @@ 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;
|
||||
|
@ -285,6 +291,7 @@ p {
|
|||
width: fit-content;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
word-break:normal;
|
||||
}
|
||||
.username:hover {
|
||||
text-decoration: underline;
|
||||
|
@ -397,7 +404,18 @@ p {
|
|||
user-select: none;
|
||||
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 {
|
||||
width: 100%;
|
||||
display: inline-block;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue