diff --git a/www/js/api.js b/www/js/api.js index 3bb1eab..3ef5d20 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -87,16 +87,16 @@ function callAPIRawResponse(action, data, success, failure) { } switch (textStatus) { case "timeout": - failure("Couldn't connect to the server (timeout)."); + failure("Couldn't connect to the server (timeout).", xhr); break; case "error": - failure("Couldn't connect to the server (error)."); + failure("Couldn't connect to the server (error).", xhr); break; case "parseerror": - failure("The server sent a malformed response."); + failure("The server sent a malformed response.", xhr); break; default: - failure("Couldn't connect to the server."); + failure("Couldn't connect to the server.", xhr); } } }); diff --git a/www/js/signin.js b/www/js/signin.js index 0b6b024..06ad619 100644 --- a/www/js/signin.js +++ b/www/js/signin.js @@ -11,7 +11,7 @@ $('#username').on("keyup", function () { function checkAndSave(username, password) { app.preloader.show(); - callAPI("ping", { + callAPIRawResponse("ping", { username: username, password: password }, function (data) { @@ -32,9 +32,13 @@ function checkAndSave(username, password) { app.preloader.hide(); app.dialog.alert(msg, "Error"); }); - }, function (msg) { + }, function (msg, xhr) { app.preloader.hide(); - app.dialog.alert(msg, "Error"); + if (xhr.status == 401) { + app.dialog.alert("Login incorrect.", "Error"); + } else { + app.dialog.alert(msg, "Error"); + } }); } @@ -43,4 +47,10 @@ function setupAccount() { var password = $("#password").val(); checkAndSave(username, password); -} \ No newline at end of file +} + +$("#password").on("keyup", function (evt) { + if (evt.keyCode == 13) { + setupAccount(); + } +}) \ No newline at end of file