@ -29,10 +29,12 @@ function checkAccountStatus(callback) {
// the user wants to try a different one.
// the user wants to try a different one.
removeFromStorage ( "accountnumber" ) ;
removeFromStorage ( "accountnumber" ) ;
app . dialog . alert ( resp . msg , "Error" ) ;
app . dialog . alert ( resp . msg , "Error" ) ;
sendErrorReport ( "Account" , "Couldn't check account status" , resp . msg ) ;
}
}
} , function ( err) {
} , function ( xhr, status , erro r) {
router . back ( ) ;
router . back ( ) ;
app . dialog . alert ( "Something went wrong. Try again later." , "Error" ) ;
app . dialog . alert ( "Something went wrong. Try again later." , "Error" ) ;
sendErrorReport ( "Account" , "Couldn't check account status" , "Server/network problem: " + xhr . status + ": " + xhr . statusText ) ;
} ) ;
} ) ;
} else {
} else {
callback ( false ) ;
callback ( false ) ;
@ -85,13 +87,16 @@ function verifyCode(code) {
if ( resp . status == "OK" ) {
if ( resp . status == "OK" ) {
setStorage ( "accountkey" , resp . authkey ) ;
setStorage ( "accountkey" , resp . authkey ) ;
app . dialog . alert ( "This device has been successfully linked to your Helena Express account." , "Account verified!" ) ;
app . dialog . alert ( "This device has been successfully linked to your Helena Express account." , "Account verified!" ) ;
sendActionReport ( "Account" , "Device linked OK" ) ;
displayAccountInfo ( ) ;
displayAccountInfo ( ) ;
} else if ( resp . status == "ERROR" ) {
} else if ( resp . status == "ERROR" ) {
app . dialog . alert ( resp . msg , "Error" ) ;
app . dialog . alert ( resp . msg , "Error" ) ;
sendErrorReport ( "Account" , "Device linking" , resp . msg ) ;
}
}
} , function ( error) {
} , function ( xhr, status , error) {
app . dialog . close ( ) ;
app . dialog . close ( ) ;
app . dialog . alert ( "There's a server or network problem. Check your Internet connection or try again later." , "Error" ) ;
app . dialog . alert ( "There's a server or network problem. Check your Internet connection or try again later." , "Error" ) ;
sendErrorReport ( "Account" , "Couldn't verify account code" , "Server/network problem: " + xhr . status + ": " + xhr . statusText ) ;
} ) ;
} ) ;
}
}
@ -129,8 +134,9 @@ function displayAccountInfo() {
$ ( "#loyaltyBalanceBox" ) . addClass ( "display-none" ) ;
$ ( "#loyaltyBalanceBox" ) . addClass ( "display-none" ) ;
$ ( "#loyaltyErrorMessage" ) . text ( "Error: " + success . msg ) ;
$ ( "#loyaltyErrorMessage" ) . text ( "Error: " + success . msg ) ;
}
}
} , function ( error) {
} , function ( xhr, status , error) {
$ ( "#loyaltyErrorMessage" ) . text ( "Error: Couldn't get your account info. Try again later." ) ;
$ ( "#loyaltyErrorMessage" ) . text ( "Error: Couldn't get your account info. Try again later." ) ;
sendErrorReport ( "Account" , "Couldn't display account info" , "Server/network problem: " + xhr . status + ": " + xhr . statusText ) ;
} , "GET" ) ;
} , "GET" ) ;
}
}
@ -167,14 +173,17 @@ $("body").on("click", "#setupAccountBtn", function () {
if ( resp . status == "ERROR" ) {
if ( resp . status == "ERROR" ) {
app . dialog . alert ( resp . msg , "Error" ) ;
app . dialog . alert ( resp . msg , "Error" ) ;
sendErrorReport ( "Account" , "Couldn't register account" , resp . msg ) ;
return ;
return ;
} else {
} else {
setStorage ( "accountnumber" , resp . accountnumber ) ;
setStorage ( "accountnumber" , resp . accountnumber ) ;
sendActionReport ( "Account" , "Account created" ) ;
router . refreshPage ( ) ;
router . refreshPage ( ) ;
}
}
} , function ( error) {
} , function ( xhr, status , error) {
app . dialog . close ( ) ;
app . dialog . close ( ) ;
app . dialog . alert ( "There's a server or network problem. Check your Internet connection or try again later." , "Error" ) ;
app . dialog . alert ( "There's a server or network problem. Check your Internet connection or try again later." , "Error" ) ;
sendErrorReport ( "Account" , "Couldn't register account" , "Server/network problem: " + xhr . status + ": " + xhr . statusText ) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -209,16 +218,19 @@ $("body").on("click", "#updateAccountBtn", function () {
if ( resp . status == "ERROR" ) {
if ( resp . status == "ERROR" ) {
app . dialog . alert ( resp . msg , "Error" ) ;
app . dialog . alert ( resp . msg , "Error" ) ;
sendErrorReport ( "Account" , "Couldn't update account" , resp . msg ) ;
return ;
return ;
} else {
} else {
app . popup . close ( "#accountUpdatePopup" , true ) ;
app . popup . close ( "#accountUpdatePopup" , true ) ;
setStorage ( "accountnumber" , resp . accountnumber ) ;
setStorage ( "accountnumber" , resp . accountnumber ) ;
sendActionReport ( "Account" , "Account updated" ) ;
router . refreshPage ( ) ;
router . refreshPage ( ) ;
app . dialog . alert ( "Account details updated." , "Account Updated" ) ;
app . dialog . alert ( "Account details updated." , "Account Updated" ) ;
}
}
} , function ( error) {
} , function ( xhr, status , error) {
app . dialog . close ( ) ;
app . dialog . close ( ) ;
app . dialog . alert ( "There's a server or network problem. Check your Internet connection or try again later." , "Error" ) ;
app . dialog . alert ( "There's a server or network problem. Check your Internet connection or try again later." , "Error" ) ;
sendErrorReport ( "Account" , "Couldn't update account" , "Server/network problem: " + xhr . status + ": " + xhr . statusText ) ;
} ) ;
} ) ;
} ) ;
} ) ;
@ -292,4 +304,6 @@ function openCheckoutWindowToSaveCard(onaccountpage) {
setTimeout ( initAccountPage , 1000 * 40 ) ;
setTimeout ( initAccountPage , 1000 * 40 ) ;
setTimeout ( initAccountPage , 1000 * 50 ) ;
setTimeout ( initAccountPage , 1000 * 50 ) ;
setTimeout ( initAccountPage , 1000 * 60 ) ;
setTimeout ( initAccountPage , 1000 * 60 ) ;
setTimeout ( initAccountPage , 1000 * 90 ) ;
setTimeout ( initAccountPage , 1000 * 120 ) ;
}
}