Spaces:
Sleeping
Sleeping
jacobinathanialpeterson
commited on
Commit
•
b0a736a
1
Parent(s):
21681f7
Update static/script.js
Browse files- static/script.js +18 -18
static/script.js
CHANGED
@@ -54,6 +54,24 @@ function getMessages(roomId=myRoomId, url="https://jacobinathanialpeterson-chatb
|
|
54 |
})
|
55 |
.then(response => { if (!response.ok) { throw new Error('Network response was not ok.') } return response.json() })
|
56 |
.then(data => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
// Get the keys of the object
|
58 |
const keys = Object.keys(data);
|
59 |
|
@@ -105,24 +123,6 @@ function updateUI() {
|
|
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 |
|
|
|
54 |
})
|
55 |
.then(response => { if (!response.ok) { throw new Error('Network response was not ok.') } return response.json() })
|
56 |
.then(data => {
|
57 |
+
if (data) {
|
58 |
+
// Get the button element you want to preserve
|
59 |
+
const preserveButton = document.getElementById('createRoom');
|
60 |
+
|
61 |
+
// Get the parent element containing all the elements you want to remove
|
62 |
+
const parentElement = document.body; // Change this selector according to your DOM structure
|
63 |
+
|
64 |
+
// Get all children of the parent element
|
65 |
+
const children = parentElement.children;
|
66 |
+
|
67 |
+
// Loop through the children and remove elements that are not the preserveButton
|
68 |
+
for (let i = 0; i < children.length; i++) {
|
69 |
+
const element = children[i];
|
70 |
+
if (element !== preserveButton) {
|
71 |
+
element.remove(); // Remove the element from the DOM
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
// Get the keys of the object
|
76 |
const keys = Object.keys(data);
|
77 |
|
|
|
123 |
<div class="msg">${value.message}</div>
|
124 |
</div>`;
|
125 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
messagesContainer.innerHTML = elementValue;
|
128 |
|