FumesAI commited on
Commit
cf9e277
1 Parent(s): bbc1e9b

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +18 -14
index.html CHANGED
@@ -162,20 +162,24 @@
162
  document.getElementById('userCount').innerText = `Online Users: ${onlineUsersCount}`
163
  });
164
  function sendMessage() {
165
- document.getElementById('btn').disabled = true
166
- var message = userInput.value;
167
- if(message.length>1200){
168
- alert('messsage lenght exceeds 1200 chracters!!')
169
- }
170
- else{
171
- var data = {
172
- user: user,
173
- message: message
174
- };
175
- socket.emit('message', data);
176
- userInput.value = '';
177
- }
178
- }
 
 
 
 
179
  userInput.addEventListener("keypress", function(event) {
180
  if (event.keyCode === 13) {
181
  if(!document.getElementById('btn').disabled){
 
162
  document.getElementById('userCount').innerText = `Online Users: ${onlineUsersCount}`
163
  });
164
  function sendMessage() {
165
+ document.getElementById('btn').disabled = true;
166
+ setTimeout(function(){
167
+ document.getElementById('btn').disabled = false;
168
+ }, 5000); // 5000 milliseconds = 5 seconds
169
+
170
+ var message = userInput.value;
171
+ if (message.length > 1200) {
172
+ alert('Message length exceeds 1200 characters!!');
173
+ } else {
174
+ var data = {
175
+ user: user,
176
+ message: message
177
+ };
178
+ socket.emit('message', data);
179
+ userInput.value = '';
180
+ }
181
+ }
182
+
183
  userInput.addEventListener("keypress", function(event) {
184
  if (event.keyCode === 13) {
185
  if(!document.getElementById('btn').disabled){