From fa05e003b9e2015e8193085d167ab346eb8dc92c Mon Sep 17 00:00:00 2001 From: "Cathy J. Fitzpatrick" Date: Sun, 27 Jan 2013 23:03:55 -0700 Subject: [PATCH] Add shift+tab function for navigation After the introduction of the tab complete feature, the tab key can no longer be used to navigate away from the chatbox. This commit adds a shift+tab function to navigate away from the chatbox, rather than tab completing a name. --- js/sim.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/js/sim.js b/js/sim.js index f51507a0f..18dc07706 100644 --- a/js/sim.js +++ b/js/sim.js @@ -1229,13 +1229,13 @@ function Lobby(id, elem) { // Mark a user as active for the purpose of tab complete. this.markUserActive = function (userid) { var idx = selfR.userActivity.indexOf(userid); - if (idx != -1) { + if (idx !== -1) { selfR.userActivity.splice(idx, 1); } selfR.userActivity.push(userid); - if (selfR.userActivity.length > 400) { + if (selfR.userActivity.length > 100) { // Prune the list. - selfR.userActivity.splice(0, 200); + selfR.userActivity.splice(0, 20); } }; this.add = function (log) { @@ -1900,9 +1900,11 @@ function Lobby(id, elem) { this.formKeyDown = function (e) { hideTooltip(); // We only handle the tab key. - if (e.keyCode !== 9) return true; + // If shift is held down, then don't tab complete, and instead navigate + // away from the chatbox. + if ((e.keyCode !== 9) || e.shiftKey) return true; - // No matter what, we don't want to tab away from this box. + // We don't want to tab away from this box. e.preventDefault(); // Don't tab complete at the start of the text box. @@ -1940,8 +1942,8 @@ function Lobby(id, elem) { candidates.sort(function(a, b) { var aidx = selfR.userActivity.indexOf(a); var bidx = selfR.userActivity.indexOf(b); - if (aidx != -1) { - if (bidx != -1) { + if (aidx !== -1) { + if (bidx !== -1) { return bidx - aidx; } return -1; // a comes first