$(document).ready(function() { $("#username").keypress(function(e) { if(e.which == 13) $("#password").focus(); }); $("#password").keypress(function(e) { if(e.which == 13) $("#btnLogin").click(); }); $("#btnLogin").click(function() { const username = $("#username").val(); const password = $("#password").val(); const errorDiv = $("#loginError"); const createdDiv = $("#accountCreated"); const stayLoggedIn = $("#stayLoggedIn").is(":checked"); const btn = $(this); errorDiv.hide(); btn.prop("disabled", true); btn.html("Logging in… "); jsCore.apiCall("/user/login", {"username": username, "password": password, "stayLoggedIn": stayLoggedIn }, function(data) { window.location.reload(); }, function(err) { btn.html("Login"); btn.prop("disabled", false); $("#password").val(""); createdDiv.hide(); errorDiv.html(err); errorDiv.show(); }); }); $("#toggleSidebar").click(function() { $(".main-wrapper").toggleClass("sidebar-collapsed"); $(".main-sidebar").toggleClass("collapsed"); }); });