FumesAI
commited on
Commit
•
df4aaf4
1
Parent(s):
596a8a3
Update index.html
Browse files- index.html +8 -4
index.html
CHANGED
@@ -109,14 +109,14 @@
|
|
109 |
|
110 |
<div class="bg-gray-200 px-4 py-3 flex items-center" id="ic">
|
111 |
<input id="user-input" type="text" autocomplete="off" placeholder="Type your message..." class="flex-1 py-2 px-2 rounded-lg focus:outline-none focus:ring focus:ring-cyan-400 bg-gray-200 text-gray-300">
|
112 |
-
<button onclick="sendMessage()" class="ml-4 bg-blue-600 text-white px-4 py-2 rounded-lg">Send</button>
|
113 |
</div>
|
114 |
|
115 |
|
116 |
<script src="https://cdn.socket.io/4.1.3/socket.io.min.js"></script>
|
117 |
|
118 |
<script>
|
119 |
-
var socket = io.connect('https://
|
120 |
var messages = document.getElementById('chat-messages');
|
121 |
let user = localStorage.getItem("userName")
|
122 |
console.log(user)
|
@@ -138,6 +138,7 @@
|
|
138 |
document.getElementById('userCount').innerText = `Online Users: ${onlineUsersCount}`
|
139 |
});
|
140 |
function sendMessage() {
|
|
|
141 |
var message = userInput.value;
|
142 |
if(message.length>1200){
|
143 |
alert('messsage lenght exceeds 1200 chracters!!')
|
@@ -152,8 +153,10 @@
|
|
152 |
}
|
153 |
}
|
154 |
userInput.addEventListener("keypress", function(event) {
|
155 |
-
if (event.keyCode === 13) {
|
156 |
-
|
|
|
|
|
157 |
}
|
158 |
});
|
159 |
|
@@ -180,6 +183,7 @@ socket.on('response', function(data) {
|
|
180 |
var currentMessage = messages.lastChild;
|
181 |
if (data.response === 'complete') {
|
182 |
currentMessage = null;
|
|
|
183 |
} else {
|
184 |
if (!currentMessage || !currentMessage.classList.contains('ai-response')) {
|
185 |
currentMessage = document.createElement('p');
|
|
|
109 |
|
110 |
<div class="bg-gray-200 px-4 py-3 flex items-center" id="ic">
|
111 |
<input id="user-input" type="text" autocomplete="off" placeholder="Type your message..." class="flex-1 py-2 px-2 rounded-lg focus:outline-none focus:ring focus:ring-cyan-400 bg-gray-200 text-gray-300">
|
112 |
+
<button onclick="sendMessage()" class="ml-4 bg-blue-600 text-white px-4 py-2 rounded-lg" id='btn'>Send</button>
|
113 |
</div>
|
114 |
|
115 |
|
116 |
<script src="https://cdn.socket.io/4.1.3/socket.io.min.js"></script>
|
117 |
|
118 |
<script>
|
119 |
+
var socket = io.connect('https://apix-30ox.onrender.com');
|
120 |
var messages = document.getElementById('chat-messages');
|
121 |
let user = localStorage.getItem("userName")
|
122 |
console.log(user)
|
|
|
138 |
document.getElementById('userCount').innerText = `Online Users: ${onlineUsersCount}`
|
139 |
});
|
140 |
function sendMessage() {
|
141 |
+
document.getElementById('btn').disabled = true
|
142 |
var message = userInput.value;
|
143 |
if(message.length>1200){
|
144 |
alert('messsage lenght exceeds 1200 chracters!!')
|
|
|
153 |
}
|
154 |
}
|
155 |
userInput.addEventListener("keypress", function(event) {
|
156 |
+
if (event.keyCode === 13) {
|
157 |
+
if(!document.getElementById('btn').disabled){
|
158 |
+
sendMessage();
|
159 |
+
}
|
160 |
}
|
161 |
});
|
162 |
|
|
|
183 |
var currentMessage = messages.lastChild;
|
184 |
if (data.response === 'complete') {
|
185 |
currentMessage = null;
|
186 |
+
document.getElementById('btn').disabled = false
|
187 |
} else {
|
188 |
if (!currentMessage || !currentMessage.classList.contains('ai-response')) {
|
189 |
currentMessage = document.createElement('p');
|