web-base/js/admin.js

29 lines
1005 B
JavaScript
Raw Normal View History

2020-02-10 00:52:25 +01:00
$(document).ready(function() {
2020-04-04 01:15:59 +02:00
// Login
2020-06-21 15:43:26 +02:00
$("#username").keypress(function(e) { if(e.which === 13) $("#password").focus(); });
$("#password").keypress(function(e) { if(e.which === 13) $("#btnLogin").click(); });
2020-02-10 00:52:25 +01:00
$("#btnLogin").click(function() {
2020-04-03 22:10:21 +02:00
const username = $("#username").val();
const password = $("#password").val();
const errorDiv = $("#loginError");
const createdDiv = $("#accountCreated");
const stayLoggedIn = $("#stayLoggedIn").is(":checked");
const btn = $(this);
2020-02-10 00:52:25 +01:00
errorDiv.hide();
btn.prop("disabled", true);
btn.html("Logging in… <i class=\"fa fa-spin fa-circle-notch\"></i>");
2020-04-03 22:10:21 +02:00
jsCore.apiCall("/user/login", {"username": username, "password": password, "stayLoggedIn": stayLoggedIn }, function(data) {
2020-06-23 01:03:35 +02:00
document.location.reload();
2020-02-10 00:52:25 +01:00
}, function(err) {
btn.html("Login");
btn.prop("disabled", false);
$("#password").val("");
createdDiv.hide();
errorDiv.html(err);
errorDiv.show();
});
});
});