Automatically clear command history
This commit is contained in:
parent
1cc2223724
commit
c0630dcffc
|
@ -53,4 +53,10 @@ Available commands:
|
||||||
/clear Clear on-screen buffer
|
/clear Clear on-screen buffer
|
||||||
/mute Toggle notification sounds
|
/mute Toggle notification sounds
|
||||||
/help This
|
/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 = [],
|
||||||
history_pos = -1,
|
history_pos = -1,
|
||||||
history_keep = 4,
|
history_keep = 4,
|
||||||
|
history_timer,
|
||||||
|
|
||||||
// Collection of DOM components
|
// Collection of DOM components
|
||||||
components = {
|
components = {
|
||||||
|
@ -54,7 +55,7 @@ define('cryptalk', {
|
||||||
components.chat.html('');
|
components.chat.html('');
|
||||||
|
|
||||||
// Clear command history on clearing buffer
|
// Clear command history on clearing buffer
|
||||||
history = []; history_pos = -1;
|
clearHistory();
|
||||||
},
|
},
|
||||||
|
|
||||||
leave: function () {
|
leave: function () {
|
||||||
|
@ -129,7 +130,7 @@ define('cryptalk', {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Push input buffer to command history
|
// Push input buffer to history
|
||||||
pushHistory = function (b) {
|
pushHistory = function (b) {
|
||||||
history.push(b);
|
history.push(b);
|
||||||
|
|
||||||
|
@ -137,6 +138,12 @@ define('cryptalk', {
|
||||||
if( history.length > history_keep ) history.shift();
|
if( history.length > history_keep ) history.shift();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Clear input buffer history
|
||||||
|
clearHistory = function() {
|
||||||
|
history = [];
|
||||||
|
history_pos = -1;
|
||||||
|
},
|
||||||
|
|
||||||
// Handler for the document`s keyDown-event.
|
// Handler for the document`s keyDown-event.
|
||||||
onKeyDown = function (e) {
|
onKeyDown = function (e) {
|
||||||
var buffer,
|
var buffer,
|
||||||
|
@ -151,6 +158,10 @@ define('cryptalk', {
|
||||||
return components.input.focus();
|
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
|
// Check for escape key, this does nothing but clear the input buffer and reset history position
|
||||||
if ( e.keyCode == 27 ) {
|
if ( e.keyCode == 27 ) {
|
||||||
history_pos = -1;
|
history_pos = -1;
|
||||||
|
@ -252,7 +263,7 @@ define('cryptalk', {
|
||||||
post('info', $.template(templates.messages.left_room, { roomName: room }));
|
post('info', $.template(templates.messages.left_room, { roomName: room }));
|
||||||
|
|
||||||
// Clear history on leaving room
|
// Clear history on leaving room
|
||||||
history = []; history_pos = -1;
|
clearHistory();
|
||||||
|
|
||||||
room = false;
|
room = false;
|
||||||
})
|
})
|
||||||
|
|
|
@ -28,13 +28,18 @@ define({
|
||||||
' /join RoomId Join a room \n' +
|
' /join RoomId Join a room \n' +
|
||||||
' /count Count participants of room \n' +
|
' /count Count participants of room \n' +
|
||||||
' /nick NickName Sets an optional nick \n' +
|
' /nick NickName Sets an optional nick \n' +
|
||||||
' /mute Toggle notification sounds \n' +
|
' /mute Toggle notification sounds \n' +
|
||||||
' /key OurStrongPassphrase Sets encryption key \n' +
|
' /key OurStrongPassphrase Sets encryption key \n' +
|
||||||
' /leave Leave the room \n' +
|
' /leave Leave the room \n' +
|
||||||
' /clear Clear on-screen buffer \n' +
|
' /clear Clear on-screen buffer \n' +
|
||||||
' /help This \n' +
|
' /help This \n' +
|
||||||
' \n' +
|
' \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' +
|
'<strong>It is highly recommended to use incognito mode while chatting, \n' +
|
||||||
'to prevent browsers from keeping history or cache.</strong> \n' +
|
'to prevent browsers from keeping history or cache.</strong> \n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
|
|
Loading…
Reference in New Issue