Update public/index.html
Browse files- public/index.html +23 -22
public/index.html
CHANGED
|
@@ -152,31 +152,32 @@
|
|
| 152 |
}
|
| 153 |
|
| 154 |
async function submitKey() {
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
alert("Invalid key. Please try again.");
|
| 171 |
-
}
|
| 172 |
-
} catch (error) {
|
| 173 |
-
console.error('Error verifying key:', error);
|
| 174 |
-
alert("Error verifying the key.");
|
| 175 |
-
}
|
| 176 |
} else {
|
| 177 |
-
alert("
|
| 178 |
}
|
|
|
|
|
|
|
|
|
|
| 179 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
socket.on('new_message', (newMessage) => {
|
| 182 |
const currentChats = Array.from(chatList.children).map(chat => ({
|
|
|
|
| 152 |
}
|
| 153 |
|
| 154 |
async function submitKey() {
|
| 155 |
+
const userKey = document.getElementById("keyInput").value;
|
| 156 |
+
console.log("Key Sent to Server:", userKey); // Debugging line
|
| 157 |
+
if (userKey) {
|
| 158 |
+
// Send the key to the server to validate
|
| 159 |
+
try {
|
| 160 |
+
const res = await fetch('/validate-key', {
|
| 161 |
+
method: 'POST',
|
| 162 |
+
headers: { 'Content-Type': 'application/json' },
|
| 163 |
+
body: JSON.stringify({ key: userKey })
|
| 164 |
+
});
|
| 165 |
+
|
| 166 |
+
if (res.ok) {
|
| 167 |
+
// Key is valid, hide the input form and load chat list
|
| 168 |
+
keyInputContainer.style.display = 'none'; // Hide key input
|
| 169 |
+
loadChatList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
} else {
|
| 171 |
+
alert("Invalid key. Please try again.");
|
| 172 |
}
|
| 173 |
+
} catch (error) {
|
| 174 |
+
console.error('Error verifying key:', error);
|
| 175 |
+
alert("Error verifying the key.");
|
| 176 |
}
|
| 177 |
+
} else {
|
| 178 |
+
alert("Please enter a valid key.");
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
|
| 182 |
socket.on('new_message', (newMessage) => {
|
| 183 |
const currentChats = Array.from(chatList.children).map(chat => ({
|