Remove new message and change username buttons (user just presses enter instead) and update a bunch of css

This commit is contained in:
Micah Lee 2020-08-19 20:22:15 -04:00
parent 0d4d5b773c
commit 06d2b75f3e
3 changed files with 23 additions and 21 deletions

View file

@ -41,27 +41,16 @@ $(function () {
emitMessage(socket);
}
});
$('#send-button').on('click', function (e) {
emitMessage(socket);
});
// Keep buttons disabled unless changed or not empty
$('#username').on('keyup', function (event) {
if ($('#username').val() !== '' && $('#username').val() !== current_username) {
$('#update-username').removeAttr('disabled');
if (event.keyCode == 13) {
current_username = updateUsername(socket);
}
} else {
$('#update-username').attr('disabled', true);
}
});
// Update username
$('#update-username').on('click', function () {
current_username = updateUsername(socket);
});
// Show warning of losing data
$(window).on('beforeunload', function (e) {
e.preventDefault();
@ -103,7 +92,6 @@ var updateUsername = function (socket) {
}).done(function (response) {
console.log(response);
});
$('#update-username').attr('disabled', true);
return username;
}
@ -138,7 +126,7 @@ var scrollBottomMaybe = function (scrollDiff) {
var addStatusMessage = function (message) {
$('#chat').append(
`<p><small><i>${sanitizeHTML(message)}</i></small></p>`
`<p class="status">${sanitizeHTML(message)}</p>`
);
}