CMD+K clears chat, or /clear, or CTRL+K

This commit is contained in:
Dan Seripap 2016-02-25 23:37:45 -05:00
parent 0d9b41bb3a
commit 6b7994442d
2 changed files with 23 additions and 2 deletions

View File

@ -17,6 +17,11 @@ export default class Chat {
this.bindEvents();
}
clear() {
let chatArea = $('.messages');
return chatArea.fadeOut(200, () => { chatArea.empty().show(); });
}
// Log a message
log(message, options) {
let html = options && options.html === true || false;
@ -226,6 +231,15 @@ export default class Chat {
console.log(err);
});
}
}, {
command: 'clear',
description: 'Clears the chat screen',
paramaters: [],
multiple: true,
usage: '/clear',
action: () => {
this.clear();
}
}];
const color = () => {

View File

@ -15,6 +15,7 @@ $(function() {
let $window = $(window);
let $participants = $('#participants');
let keyMapping = [];
let roomId = window.location.pathname.length ? window.location.pathname : null;
@ -68,16 +69,22 @@ $(function() {
}
// Keyboard events
$window.keydown(function(event) {
$window.keydown((event) => {
// When the client hits ENTER on their keyboard and chat message input is focused
if (event.which === 13 && !event.shiftKey && $('.inputMessage').is(':focus')) {
handleMessageSending();
socket.emit('stop typing');
chat.typing = false;
event.preventDefault();
} else {
keyMapping[event.keyCode] = event.type === 'keydown';
}
}).keyup((event) => {
if ((keyMapping[17] || keyMapping[91] || keyMapping[93]) && keyMapping[75]) {
chat.clear();
}
keyMapping = [];
});
// Select message input when closing modal