Automatically clear command history
This commit is contained in:
parent
1cc2223724
commit
c0630dcffc
|
@ -53,4 +53,10 @@ Available commands:
|
|||
/clear Clear on-screen buffer
|
||||
/mute Toggle notification sounds
|
||||
/help This
|
||||
|
||||
You can select any of the five last commands/messages with up/down key.
|
||||
|
||||
Due to security reasons, /key command is not saved, and command
|
||||
history is automatically cleared after one minute of inactivity.
|
||||
|
||||
```
|
||||
|
|
|
@ -16,6 +16,7 @@ define('cryptalk', {
|
|||
history = [],
|
||||
history_pos = -1,
|
||||
history_keep = 4,
|
||||
history_timer,
|
||||
|
||||
// Collection of DOM components
|
||||
components = {
|
||||
|
@ -54,7 +55,7 @@ define('cryptalk', {
|
|||
components.chat.html('');
|
||||
|
||||
// Clear command history on clearing buffer
|
||||
history = []; history_pos = -1;
|
||||
clearHistory();
|
||||
},
|
||||
|
||||
leave: function () {
|
||||
|
@ -129,7 +130,7 @@ define('cryptalk', {
|
|||
}
|
||||
},
|
||||
|
||||
// Push input buffer to command history
|
||||
// Push input buffer to history
|
||||
pushHistory = function (b) {
|
||||
history.push(b);
|
||||
|
||||
|
@ -137,6 +138,12 @@ define('cryptalk', {
|
|||
if( history.length > history_keep ) history.shift();
|
||||
},
|
||||
|
||||
// Clear input buffer history
|
||||
clearHistory = function() {
|
||||
history = [];
|
||||
history_pos = -1;
|
||||
},
|
||||
|
||||
// Handler for the document`s keyDown-event.
|
||||
onKeyDown = function (e) {
|
||||
var buffer,
|
||||
|
@ -151,6 +158,10 @@ define('cryptalk', {
|
|||
return components.input.focus();
|
||||
}
|
||||
|
||||
// Reset command history clear timer
|
||||
clearTimeout(history_timer);
|
||||
history_timer = setTimeout(function(){clearHistory()}, 60000);
|
||||
|
||||
// Check for escape key, this does nothing but clear the input buffer and reset history position
|
||||
if ( e.keyCode == 27 ) {
|
||||
history_pos = -1;
|
||||
|
@ -252,7 +263,7 @@ define('cryptalk', {
|
|||
post('info', $.template(templates.messages.left_room, { roomName: room }));
|
||||
|
||||
// Clear history on leaving room
|
||||
history = []; history_pos = -1;
|
||||
clearHistory();
|
||||
|
||||
room = false;
|
||||
})
|
||||
|
|
|
@ -35,6 +35,11 @@ define({
|
|||
' /help This \n' +
|
||||
' \n' +
|
||||
' \n' +
|
||||
'You can select any of the five last commands/messages with up/down key.\n' +
|
||||
' \n' +
|
||||
'Due to security reasons, /key command is not saved, and command \n' +
|
||||
'history is automatically cleared after one minute of inactivity. \n' +
|
||||
' \n' +
|
||||
'<strong>It is highly recommended to use incognito mode while chatting, \n' +
|
||||
'to prevent browsers from keeping history or cache.</strong> \n' +
|
||||
' \n' +
|
||||
|
|
Loading…
Reference in New Issue