You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB
JavaScript

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
$('#username').on("keyup", function () {
$('#username').val($('#username').val().toLowerCase());
});
function checkAndSave(username, password) {
app.preloader.show();
var url = SETTINGS["server"] + "/getkey";
$.ajax({
url: url,
dataType: "json",
cache: false,
method: "POST",
data: {
username: username,
password: password
},
success: function (data) {
app.preloader.hide();
if (data.status == "OK") {
localStorage.setItem("username", username);
localStorage.setItem("password", password);
localStorage.setItem("configured", true);
// Restart the app to re-read the config
restartApplication();
} else if (data.status == "ERROR") {
app.dialog.alert(data.msg, "Error");
} else {
app.dialog.alert("", "Error");
}
}, error: function () {
app.preloader.hide();
app.dialog.alert("Could not sign in. Check your credentials and connection.", "Error");
}
});
}
function setupAccount() {
var type = $("#accttype").val();
var username = $("#username").val();
var password = $("#password").val();
checkAndSave(username, password);
}