diff --git a/www/js/ui.js b/www/js/ui.js index 79fd47df..581b640b 100644 --- a/www/js/ui.js +++ b/www/js/ui.js @@ -122,12 +122,11 @@ CyTube.chatTabCompleteData = { context: {} }; -function chatTabComplete() { +function chatTabComplete(chatline) { if (!CyTube.tabCompleteMethods) { console.error('Missing CyTube.tabCompleteMethods!'); return; } - var chatline = document.getElementById("chatline"); var currentText = chatline.value; var currentPosition = chatline.selectionEnd; if (typeof currentPosition !== 'number' || !chatline.setSelectionRange) { @@ -199,7 +198,7 @@ $("#chatline").keydown(function(ev) { } else if(ev.keyCode == 9) { // Tab completion try { - chatTabComplete(); + chatTabComplete(ev.target); } catch (error) { console.error(error); } diff --git a/www/js/util.js b/www/js/util.js index f28bb01c..34e32dd1 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -776,7 +776,7 @@ function applyOpts() { else { USEROPTS.notifications = "never"; } - } + } } function parseTimeout(t) { @@ -2814,6 +2814,14 @@ function initPm(user) { meta: meta }); input.val(""); + } else if(ev.keyCode == 9) { // Tab completion + try { + chatTabComplete(ev.target); + } catch (error) { + console.error(error); + } + ev.preventDefault(); + return false; } });