jacobinathanialpeterson commited on
Commit
e8a9de2
·
1 Parent(s): 7a99f51

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +19 -1
static/script.js CHANGED
@@ -95,7 +95,7 @@ let atBottom = true;
95
  function updateUI() {
96
  const messagesContainer = document.getElementById("messages");
97
  const isAtBottom = messagesContainer.scrollHeight - messagesContainer.scrollTop === messagesContainer.clientHeight;
98
-
99
  let elementValue = '';
100
  if (DATA) {
101
  Object.entries(DATA).forEach(([key, value]) => {
@@ -105,6 +105,24 @@ function updateUI() {
105
  <div class="msg">${value.message}</div>
106
  </div>`;
107
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
  messagesContainer.innerHTML = elementValue;
110
 
 
95
  function updateUI() {
96
  const messagesContainer = document.getElementById("messages");
97
  const isAtBottom = messagesContainer.scrollHeight - messagesContainer.scrollTop === messagesContainer.clientHeight;
98
+
99
  let elementValue = '';
100
  if (DATA) {
101
  Object.entries(DATA).forEach(([key, value]) => {
 
105
  <div class="msg">${value.message}</div>
106
  </div>`;
107
  });
108
+ } else {
109
+ // Get the button element you want to preserve
110
+ const preserveButton = document.getElementById('createRoom');
111
+
112
+ // Get the parent element containing all the elements you want to remove
113
+ const parentElement = document.body; // Change this selector according to your DOM structure
114
+
115
+ // Get all children of the parent element
116
+ const children = parentElement.children;
117
+
118
+ // Loop through the children and remove elements that are not the preserveButton
119
+ for (let i = 0; i < children.length; i++) {
120
+ const element = children[i];
121
+ if (element !== preserveButton) {
122
+ element.remove(); // Remove the element from the DOM
123
+ }
124
+ }
125
+
126
  }
127
  messagesContainer.innerHTML = elementValue;
128