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.
HelenaExpressApp/www/assets/js/linkaccount.js

74 lines
2.7 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/.
*/
function setupNewAccount(name) {
app.dialog.preloader("Finishing up...");
apirequest(
SETTINGS.apis.registernew,
{
name: name
},
function (resp) {
app.dialog.close();
if (resp.status == "ERROR") {
app.dialog.alert(resp.msg, "Error");
return;
}
setStorage("client_uuid", resp.client_uuid);
setStorage("device_uuid", resp.device_uuid);
restartApplication();
},
function (xhr) {
app.dialog.close();
try {
var error = $.parseJSON(xhr.responseText);
if (error && typeof error.msg != 'undefined') {
app.dialog.alert(error.msg + " (NEWAC_XHR)", "Error");
} else {
app.dialog.alert("A server or network error occurred. Try again later. (NEWAC_XHRNOMSG)", "Error");
}
} catch (ex) {
app.dialog.alert("A server error occurred. Try again later. (NEWAC_XHRBADJSON)", "Error");
}
}, "POST");
}
function setupExistingAccount(email, phone, invoiceid) {
app.dialog.preloader("Finding your account...");
apirequest(
SETTINGS.apis.registerexisting,
{
email: email,
phone: phone,
invoiceid: invoiceid
},
function (resp) {
app.dialog.close();
if (resp.status == "ERROR") {
app.dialog.alert(resp.msg, "Error");
return;
}
setStorage("client_uuid", resp.client_uuid);
setStorage("device_uuid", resp.device_uuid);
restartApplication();
},
function (xhr) {
app.dialog.close();
try {
var error = $.parseJSON(xhr.responseText);
if (error && typeof error.msg != 'undefined') {
app.dialog.alert(error.msg + " (LINKAC_XHR)", "Error");
} else {
app.dialog.alert("A server or network error occurred. Try again later. (LINKAC_XHRNOMSG)", "Error");
}
} catch (ex) {
app.dialog.alert("A server error occurred. Try again later. (LINKAC_XHRBADJSON)", "Error");
}
}, "POST");
}