|
|
|
@ -8,7 +8,7 @@ $('#username').on("keyup", function () {
|
|
|
|
|
$('#username').val($('#username').val().toLowerCase());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function checkAndSave(username, password) {
|
|
|
|
|
function checkAndSave(username, password, type) {
|
|
|
|
|
app.preloader.show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -21,13 +21,15 @@ function checkAndSave(username, password) {
|
|
|
|
|
method: "POST",
|
|
|
|
|
data: {
|
|
|
|
|
username: username,
|
|
|
|
|
password: password
|
|
|
|
|
password: password,
|
|
|
|
|
type: type
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
app.preloader.hide();
|
|
|
|
|
if (data.status == "OK") {
|
|
|
|
|
localStorage.setItem("username", username);
|
|
|
|
|
localStorage.setItem("password", password);
|
|
|
|
|
localStorage.setItem("accttype", type);
|
|
|
|
|
localStorage.setItem("configured", true);
|
|
|
|
|
// Restart the app to re-read the config
|
|
|
|
|
restartApplication();
|
|
|
|
@ -45,9 +47,43 @@ function checkAndSave(username, password) {
|
|
|
|
|
|
|
|
|
|
function setupAccount() {
|
|
|
|
|
var type = $("#accttype").val();
|
|
|
|
|
var username = $("#username").val();
|
|
|
|
|
var password = $("#password").val();
|
|
|
|
|
|
|
|
|
|
checkAndSave(username, password, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createAccount() {
|
|
|
|
|
var type = $("#accttype").val();
|
|
|
|
|
var username = $("#username").val();
|
|
|
|
|
var password = $("#password").val();
|
|
|
|
|
|
|
|
|
|
checkAndSave(username, password);
|
|
|
|
|
app.preloader.show();
|
|
|
|
|
|
|
|
|
|
var url = SETTINGS["server"] + "/signup";
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
dataType: "json",
|
|
|
|
|
cache: false,
|
|
|
|
|
method: "POST",
|
|
|
|
|
data: {
|
|
|
|
|
username: username,
|
|
|
|
|
password: password,
|
|
|
|
|
accttype: type
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
app.preloader.hide();
|
|
|
|
|
if (data.status == "OK") {
|
|
|
|
|
checkAndSave(username, password, type);
|
|
|
|
|
} 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 create account. Check your connection.", "Error");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|