diff --git a/cli/onionshare_cli/resources/static/js/chat.js b/cli/onionshare_cli/resources/static/js/chat.js index 258b020b..de64c094 100644 --- a/cli/onionshare_cli/resources/static/js/chat.js +++ b/cli/onionshare_cli/resources/static/js/chat.js @@ -88,7 +88,7 @@ var emitMessage = function (socket) { var updateUsername = function (socket) { var username = $('#username').val(); - if (!checkUsernameExists(username)) { + if (!checkUsernameExists(username) && !checkUsernameTooLong(username)) { $.ajax({ method: 'POST', url: `http://${document.domain}:${location.port}/update-session-username`, @@ -133,6 +133,15 @@ var checkUsernameExists = function (username) { return false; } +var checkUsernameTooLong = function (username) { + $('#username-error').text(''); + if (username.length > 128) { + $('#username-error').text('Please choose a shorter username.'); + return true; + } + return false; +} + var getScrollDiffBefore = function () { return $('#chat').scrollTop() - ($('#chat')[0].scrollHeight - $('#chat')[0].offsetHeight); } diff --git a/cli/onionshare_cli/resources/templates/500.html b/cli/onionshare_cli/resources/templates/500.html new file mode 100644 index 00000000..9f6727d2 --- /dev/null +++ b/cli/onionshare_cli/resources/templates/500.html @@ -0,0 +1,21 @@ + + + +
+Sorry, an unexpected error seems to have occurred, and your request didn't succeed.
+