From ac7a328e4d3ebc18822ee198fe389c59249eafb8 Mon Sep 17 00:00:00 2001 From: Albert Feng Date: Fri, 9 Jun 2017 14:35:36 -0700 Subject: [PATCH 1/4] bug added --- public/js/chat.js | 37 +++++++++++++++++++------------------ views/index.ejs | 7 ++----- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/public/js/chat.js b/public/js/chat.js index 56fd3f1..5339902 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -78,9 +78,9 @@ var connect = function() { if(dev) { console.log(data); } - - - + + + if(data.type == 'delete') { return $('div[data-mid="' + data.message + '"]').remove(); } @@ -95,7 +95,7 @@ var connect = function() { } } - + if(usersTyping.length == 1) { string = usersTyping + ' is writing...'; } else if(usersTyping.length > 4) { @@ -198,7 +198,7 @@ var connect = function() { textToSpeech.text = data.message; speechSynthesis.speak(textToSpeech); } - + showChat(data.type, data.user, data.message, data.subtxt, data.mid); } @@ -298,11 +298,11 @@ function showChat(type, user, message, subtxt, mid) { } else { $('#panel').append('
' + user + '(' + subtxt + ') ' + getTime() + '' + message + '
'); } - + $('#panel').animate({scrollTop: $('#panel').prop('scrollHeight')}, 500); updateStyle(); nmr++; - + if(settings.inline) { var m = message.match(/(https?|ftp):\/\/[^\s/$.?#].[^\s]*/gmi); @@ -408,7 +408,7 @@ function handleInput() { showChat('light', 'Error', 'Use /' + command[0] + variables); } - break; + break; case 'clear': nmr = 0; @@ -447,13 +447,13 @@ function handleInput() { function getTime() { var now = new Date(); var time = [now.getHours(), now.getMinutes(), now.getSeconds()]; - + for(var i = 0; i < 3; i++) { if(time[i] < 10) { time[i] = '0' + time[i]; } } - + return time.join(':'); } @@ -491,7 +491,7 @@ $(document).ready(function() { if(clients[i].role === 0) { admin = ''; } - + if(clients[i].role === 1) { admin = ' - Helper'; } @@ -594,12 +594,12 @@ $(document).ready(function() { settings.synthesis = document.getElementById('synthesis').checked; localStorage.settings = JSON.stringify(settings); }); - + $('#inline').bind('change', function() { settings.inline = document.getElementById('inline').checked; localStorage.settings = JSON.stringify(settings); }); - + $('#desktop').bind('change', function() { settings.desktop = document.getElementById('desktop').checked; localStorage.settings = JSON.stringify(settings); @@ -651,7 +651,8 @@ $(document).ready(function() { .autocomplete({ minLength: 0, source: function(request, response) { - var term = request.term; + var term = request.termError; + // var term = request.term; var results = []; term = term.split(/ \s*/).pop(); @@ -697,7 +698,7 @@ if('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) { if(speechToText) { speechToText.onresult = function(event) { $('#message').val(''); - + for (var i = event.resultIndex; i < event.results.length; ++i) { if (event.results[i].isFinal) { $('#message').val(event.results[i][0].transcript); @@ -710,11 +711,11 @@ if(speechToText) { } } } - + speechToText.onerror = function(event) { updateBar('mdi-content-send', 'Enter your message here', false); } - + } function desktopNotif(message) { @@ -756,4 +757,4 @@ window.onfocus = function() { window.onblur = function() { focus = false; -}; \ No newline at end of file +}; diff --git a/views/index.ejs b/views/index.ejs index 9e65169..6c0bb6f 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -24,8 +24,6 @@
- Fork me on GitHub -

@@ -94,7 +92,6 @@
-

Created by Igor Antun

@@ -215,7 +212,7 @@

- +