diff --git a/.dist/channel.js b/.dist/channel.js index 38410c1..4bc2f27 100644 --- a/.dist/channel.js +++ b/.dist/channel.js @@ -404,6 +404,38 @@ class Channel { headers: this.headers }); } + setReplying(message) { + if (this.replyingto) { + this.replyingto.div.classList.remove("replying"); + } + this.replyingto = message; + console.log(message); + this.replyingto.div.classList.add("replying"); + this.makereplybox(); + } + makereplybox() { + const replybox = document.getElementById("replybox"); + if (this.replyingto) { + replybox.innerHTML = ""; + const span = document.createElement("span"); + span.textContent = "Replying to " + this.replyingto.author.username; + const X = document.createElement("button"); + X.onclick = _ => { + this.replyingto.div.classList.remove("replying"); + replybox.classList.add("hideReplyBox"); + this.replyingto = null; + replybox.innerHTML = ""; + }; + replybox.classList.remove("hideReplyBox"); + X.textContent = "⦻"; + X.classList.add("cancelReply"); + replybox.append(span); + replybox.append(X); + } + else { + replybox.classList.add("hideReplyBox"); + } + } async getmessage(id) { if (this.messageids[id]) { return this.messageids[id]; @@ -427,6 +459,7 @@ class Channel { const prom = Message.wipeChanel(); await this.putmessages(); await prom; + this.makereplybox(); this.buildmessages(); history.pushState(null, null, "/channels/" + this.guild_id + "/" + this.id); document.getElementById("channelname").textContent = "#" + this.name; diff --git a/.dist/index.js b/.dist/index.js index 4f3b858..a7aaf5b 100644 --- a/.dist/index.js +++ b/.dist/index.js @@ -11,14 +11,14 @@ async function waitforload() { } await waitforload(); function setDynamicHeight() { - var servertdHeight = document.getElementById('servertd').offsetHeight + document.getElementById('typebox').offsetHeight + document.getElementById('pasteimage').offsetHeight; + var servertdHeight = document.getElementById('servertd').offsetHeight + document.getElementById('typediv').offsetHeight + document.getElementById('pasteimage').offsetHeight; document.documentElement.style.setProperty('--servertd-height', servertdHeight + 'px'); } const resizeObserver = new ResizeObserver(() => { setDynamicHeight(); }); resizeObserver.observe(document.getElementById('servertd')); -resizeObserver.observe(document.getElementById('typebox')); +resizeObserver.observe(document.getElementById('replybox')); resizeObserver.observe(document.getElementById('pasteimage')); setDynamicHeight(); const users = getBulkUsers(); @@ -129,15 +129,16 @@ async function enter(event) { } else { replyingto = thisuser.channelfocus.replyingto; - let replying = replyingto?.all; + let replying = replyingto; if (replyingto) { - replyingto.classList.remove("replying"); + replyingto.div.classList.remove("replying"); } thisuser.channelfocus.replyingto = null; channel.sendMessage(typebox.value, { attachments: images, replyingto: replying, }); + thisuser.channelfocus.makereplybox(); } while (images.length != 0) { images.pop(); diff --git a/.dist/message.js b/.dist/message.js index 19aef46..121a872 100644 --- a/.dist/message.js +++ b/.dist/message.js @@ -36,12 +36,7 @@ class Message { navigator.clipboard.writeText(this.content); }); Message.contextmenu.addbutton("Reply", function (div) { - if (this.channel.replyingto) { - this.channel.replyingto.classList.remove("replying"); - } - this.channel.replyingto = div; - console.log(div); - this.channel.replyingto.classList.add("replying"); + this.channel.setReplying(this); }); Message.contextmenu.addbutton("Copy message id", function () { navigator.clipboard.writeText(this.id); @@ -163,6 +158,9 @@ class Message { premessage = this.channel.messages[this.channel.messages.indexOf(this) + 1]; } const div = this.div; + if (this === this.channel.replyingto) { + div.classList.add("replying"); + } div.innerHTML = ""; const build = document.createElement('table'); if (this.message_reference) { diff --git a/webpage/channel.ts b/webpage/channel.ts index 6b4c546..5c9b330 100644 --- a/webpage/channel.ts +++ b/webpage/channel.ts @@ -39,7 +39,7 @@ class Channel{ message_notifications:number; allthewayup:boolean; static contextmenu=new Contextmenu("channel menu"); - replyingto:HTMLDivElement; + replyingto:Message; static setupcontextmenu(){ Channel.contextmenu.addbutton("Copy channel id",function(){ console.log(this) @@ -412,6 +412,38 @@ class Channel{ headers:this.headers }) } + setReplying(message:Message){ + if(this.replyingto){ + this.replyingto.div.classList.remove("replying"); + } + this.replyingto=message; + console.log(message); + this.replyingto.div.classList.add("replying"); + this.makereplybox(); + + } + makereplybox(){ + const replybox=document.getElementById("replybox"); + if(this.replyingto){ + replybox.innerHTML=""; + const span=document.createElement("span"); + span.textContent="Replying to "+this.replyingto.author.username; + const X=document.createElement("button"); + X.onclick=_=>{ + this.replyingto.div.classList.remove("replying"); + replybox.classList.add("hideReplyBox"); + this.replyingto=null; + replybox.innerHTML=""; + } + replybox.classList.remove("hideReplyBox"); + X.textContent="⦻"; + X.classList.add("cancelReply"); + replybox.append(span); + replybox.append(X); + }else{ + replybox.classList.add("hideReplyBox"); + } + } async getmessage(id:string):Promise{ if(this.messageids[id]){ return this.messageids[id]; @@ -434,6 +466,7 @@ class Channel{ const prom=Message.wipeChanel(); await this.putmessages(); await prom; + this.makereplybox(); this.buildmessages(); history.pushState(null, null,"/channels/"+this.guild_id+"/"+this.id); document.getElementById("channelname").textContent="#"+this.name; diff --git a/webpage/index.html b/webpage/index.html index 2dab8f6..8f3689d 100644 --- a/webpage/index.html +++ b/webpage/index.html @@ -57,6 +57,7 @@
+