Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <script>
  2. var chatTimer;
  3. var chatThrottled = false;
  4. var chatTimeout = 2000;
  5.  
  6. function chatThrottleDisable() {
  7. chatThrottled = false;
  8. }
  9.  
  10. function sendChat() {
  11. if (chatThrottled == false) {
  12. text = $('#text').val();
  13. $('#text').val('');
  14. socket.emit('text', {msg: text, room: '{{channel.channelLoc}}'});
  15. chatThrottled = true;
  16. chatTimer = setTimeout(chatThrottleDisable, chatTimeout);
  17. }
  18.  
  19. };
  20.  
  21. $('#text').keypress(function(e) {
  22. var code = e.keyCode || e.which;
  23. if (code == 13) {
  24. sendChat();
  25. }
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement