]> git.mar77i.info Git - chat/commitdiff
disable textarea before any channel is selected
authormar77i <mar77i@protonmail.ch>
Mon, 30 Sep 2024 21:52:35 +0000 (23:52 +0200)
committermar77i <mar77i@protonmail.ch>
Mon, 30 Sep 2024 22:09:13 +0000 (00:09 +0200)
chat/static/chat/chat.css
chat/static/chat/chat.js

index 33d11219a79dc551cbbbaabae620ec44257257c2..271f979606391fb400d50783ece3d3558057ee0e 100644 (file)
@@ -39,4 +39,4 @@ nav > div {
 
 .input > textarea {
     resize: none;
-}
\ No newline at end of file
+}
index 27122735d38348fb5ac50a85c65b125abdfe62d9..5d9172049260fd4602f84c25d5be8d29b575b422 100644 (file)
         fetch_data(
             "/api/privatemessage/?other=" + user_id.toString(), add_privatemessages
         );
+        document.getElementsByClassName("input")[0].children[0].removeAttribute(
+            "disabled"
+        );
     }
 
     function setup_user_callback() {
         fetch_data(
             "/api/channelmessage/?channel=" + channel_id.toString(), add_channelmessages
         );
+        document.getElementsByClassName("input")[0].children[0].removeAttribute(
+            "disabled"
+        );
     }
 
     function setup_channel_callback() {
                 data[name] = current_channel.data[name];
             }
         }
-        post_data(current_channel.url, JSON.stringify(data), null);
-        ta.value = "";
+        if (current_channel.url) {
+            post_data(current_channel.url, JSON.stringify(data), null);
+            ta.value = "";
+        }
     }
 
     function input_onkeydown(event) {
         function (event) {
             var ws, schema, input;
             event = event || window.event;
+            input = document.getElementsByClassName("input")[0];
+            if (!current_channel.url) {
+                input.children[0].setAttribute("disabled", "");
+            }
             if (event.target.readyState !== "complete") {
                 return;
             }
             schema = {"http:": "ws:", "https:": "wss:"}[window.location.protocol];
             ws = new WebSocket(schema + "//" + window.location.host + "/");
             ws.addEventListener("message", ws_receive);
-            input = document.getElementsByClassName("input")[0];
             input.children[0].addEventListener("keydown", input_onkeydown);
             input.children[0].value = "";
             input.children[1].addEventListener("click", send);