Add tabcompletion for PMs

This commit is contained in:
kr4ssi@tuta.io 2020-03-14 01:43:25 +01:00 committed by Calvin Montgomery
parent 106065184f
commit d2358924a4
2 changed files with 11 additions and 4 deletions

View File

@ -122,12 +122,11 @@ CyTube.chatTabCompleteData = {
context: {} context: {}
}; };
function chatTabComplete() { function chatTabComplete(chatline) {
if (!CyTube.tabCompleteMethods) { if (!CyTube.tabCompleteMethods) {
console.error('Missing CyTube.tabCompleteMethods!'); console.error('Missing CyTube.tabCompleteMethods!');
return; return;
} }
var chatline = document.getElementById("chatline");
var currentText = chatline.value; var currentText = chatline.value;
var currentPosition = chatline.selectionEnd; var currentPosition = chatline.selectionEnd;
if (typeof currentPosition !== 'number' || !chatline.setSelectionRange) { if (typeof currentPosition !== 'number' || !chatline.setSelectionRange) {
@ -199,7 +198,7 @@ $("#chatline").keydown(function(ev) {
} }
else if(ev.keyCode == 9) { // Tab completion else if(ev.keyCode == 9) { // Tab completion
try { try {
chatTabComplete(); chatTabComplete(ev.target);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }

View File

@ -776,7 +776,7 @@ function applyOpts() {
else { else {
USEROPTS.notifications = "never"; USEROPTS.notifications = "never";
} }
} }
} }
function parseTimeout(t) { function parseTimeout(t) {
@ -2814,6 +2814,14 @@ function initPm(user) {
meta: meta meta: meta
}); });
input.val(""); input.val("");
} else if(ev.keyCode == 9) { // Tab completion
try {
chatTabComplete(ev.target);
} catch (error) {
console.error(error);
}
ev.preventDefault();
return false;
} }
}); });