From e13f5d18a1937992f3cdc20c5427fb710025d496 Mon Sep 17 00:00:00 2001 From: Hexagon Date: Sun, 21 Sep 2014 16:33:52 +0200 Subject: [PATCH] Opera and firefox fixes --- public/css/default.css | 1 + public/js/cryptalk_modules/cryptalk.js | 17 ++++++++++++----- public/js/cryptalk_modules/sound.js | 4 +++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/public/css/default.css b/public/css/default.css index ad44118..810c5ad 100644 --- a/public/css/default.css +++ b/public/css/default.css @@ -81,4 +81,5 @@ body, html { color: #FFFFFF; background-color:#141414; + height:30px; } \ No newline at end of file diff --git a/public/js/cryptalk_modules/cryptalk.js b/public/js/cryptalk_modules/cryptalk.js index 9ac1967..9668172 100644 --- a/public/js/cryptalk_modules/cryptalk.js +++ b/public/js/cryptalk_modules/cryptalk.js @@ -40,7 +40,7 @@ define('cryptalk', { // Always clear the input after a post if (clearBuffer) { - components.input[0].value = ''; + clearInput(); } // Append the post to the chat DOM element @@ -145,6 +145,11 @@ define('cryptalk', { history = []; history_pos = -1; }, + + // Clear input buffer + clearInput = function() { + setTimeout(function(){components.input[0].value = '';},0); + }, // Handler for the document`s keyDown-event. onKeyDown = function (e) { @@ -168,7 +173,9 @@ define('cryptalk', { // Check for escape key, this does nothing but clear the input buffer and reset history position if ( e.keyCode == 27 ) { history_pos = -1; - components.input[0].value = ''; + clearInput(); + + return; } // Check for up or down-keys, they handle the history position @@ -210,7 +217,7 @@ define('cryptalk', { commands[command](payload); // Clear input field - components.input[0].value = ''; + clearInput(); // Save to history if(command !== 'key') { @@ -221,7 +228,7 @@ define('cryptalk', { if (!room || !key) { // Push buffer to history and clear input field - pushHistory(buffer); components.input[0].value = ''; + pushHistory(buffer); clearInput(); // Make sure that the user has joined a room and the key is set return (!room) ? post('error', templates.messages.msg_no_room) : post('error', templates.messages.msg_no_key); @@ -236,7 +243,7 @@ define('cryptalk', { }); // And clear the the buffer - components.input[0].value = ''; + clearInput(); // Save to history pushHistory(buffer); diff --git a/public/js/cryptalk_modules/sound.js b/public/js/cryptalk_modules/sound.js index 8d11570..9c87249 100644 --- a/public/js/cryptalk_modules/sound.js +++ b/public/js/cryptalk_modules/sound.js @@ -4,7 +4,9 @@ define('sound',{requires: ['queue']}, function (requires) { var exports = { messages: {} }, queue = requires.queue, - ac = new (window.AudioContext || window.webkitAudioContext || false); + ac = false; + + if( window.AudioContext || window.webkitAudioContext ) ac = new ( window.AudioContext || window.webkitAudioContext ); // Recursive function for playing tones, takes an array of [tone,start_ms,duration_ms] - entries // i is only used for recursion