From 84719ea18063e981322201c92f7e3d54b8df7c36 Mon Sep 17 00:00:00 2001 From: mim Armand Date: Tue, 29 Nov 2016 13:38:09 -0600 Subject: [PATCH] just added a checkbox to make the extention to console.log instead of alerting in case of onError trigerer since the alerting is annoying and specially since the event.data object can be undefined making it even more annoying --- index.html | 6 ++++++ index.js | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 63094a4..6639d91 100644 --- a/index.html +++ b/index.html @@ -35,6 +35,12 @@ Message Log
+
+ Options +
+ +
diff --git a/index.js b/index.js index 71dbc21..ecbe94a 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,7 @@ new function() { var serverUrl; var connectionStatus; var sendMessage; + var logInstead; var connectButton; var disconnectButton; @@ -17,6 +18,7 @@ new function() { ws.onclose = onClose; ws.onmessage = onMessage; ws.onerror = onError; + logInstead = $('#logInstead').is(':checked'); connectionStatus.text('OPENING ...'); serverUrl.attr('disabled', 'disabled'); @@ -62,7 +64,12 @@ new function() { }; var onError = function(event) { - alert(event.data); + console.log(event); + if(logInstead){ + console.error('Error! ', event); + }else{ + alert(event.data); + } } var addMessage = function(data, type) { @@ -101,6 +108,7 @@ new function() { sendButton.click(function(e) { var msg = $('#sendMessage').val(); + logInstead = $('#logInstead').is(':checked'); addMessage(msg, 'SENT'); ws.send(msg); });