//============================================================================== // // Purpose: Sign-Up and confirm support. // //============================================================================== /* eslint no-unused-vars: "off", eqeqeq: "off", no-useless-assignment: "off", no-empty: "off", no-dupe-else-if: "off", no-use-before-define: "off", no-eval: "off", no-alert: "off", no-global-assign: "off", no-self-assign: "off", no-useless-escape: "off", no-dupe-keys: "off", no-constant-condition: "off", no-unreachable: "off" */ /*global // ClientDialogs.js cdBuildMnemonicLabelHTML ClientDialogBuilder showInfoDialog // ClientFunctions.js hideDialog hideDialogP jsrsExecuteWithErrorP rsCallbackHandleStandardJSONResponse rsCallbackHandleStandardJSONResponseWithHideAndRefresh // SharedClientFunctions.js FormValidator trim // SharedFunctions.js htmlEncode // Found in ShopSharedFullFunctions.js displayTimedMessageP // ShopSharedFunctions.js getObj // Generated pageConfirmAccount pageHomepage */ //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ function rsCallbackSignUp(json_) { hideDialog(); var strFormId = 'frmSignUpResults', objCDBuilder = new ClientDialogBuilder({ formId: strFormId, formTitle: 'ShopaZulu Sign-Up Results', fnCancelOrClose: function () { hideDialog(); displayTimedMessageP({ msgHTML: 'Navigating to ShopaZulu Account Confirmation Page' }); window.location = pageConfirmAccount; } }); objCDBuilder.addFlexibleRow({ rawValue: "Congratulations! You're account has been created!" }); // objCDBuilder.addFlexibleRow({ // rawValue: JSON.stringify(json_, null, 2), // additionalCellClasses: 'JSONViewer' // }); objCDBuilder.showClientDialog(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ function shopazuluSignUp() { var strFormId = 'frmSignUp', theForm = getObj(strFormId), objEmail = theForm.txtEmailAddress, objPassword = theForm.txtPassword, strPassword = objPassword.value, objConfirmPassword = theForm.txtConfirmPassword, validator = new FormValidator(); if (!validator.CSValidateRequiredField(objEmail, 'Please enter an Email Address')) { return; } if (!validator.CSValidateRequiredField(objPassword, 'Please enter a Password')) { return; } if (strPassword !== objConfirmPassword.value) { showInfoDialog( "Passwords Don't Match", "Passwords Don't Match", 1, 'txtPassword'); return; } jsrsExecuteWithErrorP( 'Admin_SignUp', // commandString_ rsCallbackHandleStandardJSONResponse, // fnCallback_ 'Initializing Account', // doingWhat_ { emailAddress: trim(objEmail.value), password: strPassword }, // payload_ { fnOnSuccess: rsCallbackSignUp }); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ function showSignUpDialog() { var strFormId = 'frmSignUp', objCDBuilder = new ClientDialogBuilder({ formId: strFormId, formTitle: 'ShopaZulu Sign-Up', focusFieldName: 'txtEmailAddress', okButtonDisplayText: cdBuildMnemonicLabelHTML({ mnemonicActionJS: 'shopazuluSignUp()', mnemonicChar: 's', rawLabel: 'Sign-Up!' }), fnSubmit: shopazuluSignUp }); objCDBuilder.addTextFieldRow( 'txtEmailAddress', { rawLabel: 'Email Address', isEmail: 1 }); objCDBuilder.addSectionHeaderRow(); objCDBuilder.addTextFieldRow( 'txtPassword', { rawLabel: 'Password', isPasswordField: 1 }); objCDBuilder.addTextFieldRow( 'txtConfirmPassword', { rawLabel: 'Confirm Password', isPasswordField: 1 }); objCDBuilder.showClientDialog(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ function rsCallbackConfirmAccount(json_) { hideDialog(); var strFormId = 'frmConfirmationResults', objCDBuilder = new ClientDialogBuilder({ formId: strFormId, formTitle: 'ShopaZulu Confirmation Results', fnCancelOrClose: function () { hideDialog(); displayTimedMessageP({ msgHTML: 'Navigating to ShopaZulu Homepage' }); window.location = pageHomepage; } }); objCDBuilder.addFlexibleRow({ rawValue: "Congratulations! You're account has been confirmed!" }); objCDBuilder.addFlexibleRow({ rawValue: JSON.stringify(json_, null, 2), additionalCellClasses: 'JSONViewer' }); objCDBuilder.showClientDialog(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ function confirmAccount() { var strFormId = 'frmConfirmAccount', theForm = getObj(strFormId), objEmail = theForm.txtEmailAddress, objConfirmationCode = theForm.txtConfirmationCode, strConfirmationCode = objConfirmationCode.value, validator = new FormValidator(); if (!validator.CSValidateRequiredField(objEmail, 'Please enter an Email Address')) { return; } if (!validator.CSValidateRequiredField(objConfirmationCode, 'Please enter your Confirmation Code')) { return; } jsrsExecuteWithErrorP( 'Admin_ConfirmAccount', // commandString_ rsCallbackHandleStandardJSONResponse, // fnCallback_ 'Confirming Account', // doingWhat_ { emailAddress: trim(objEmail.value), confirmationCode: strConfirmationCode }, // payload_ { fnOnSuccess: rsCallbackSignUp }); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ function showConfirmAccountDialog() { var strFormId = 'frmConfirmAccount', objCDBuilder = new ClientDialogBuilder({ formId: strFormId, formTitle: 'ShopaZulu Confirm Account', focusFieldName: 'txtEmailAddress', okButtonDisplayText: cdBuildMnemonicLabelHTML({ mnemonicActionJS: 'confirmAccount()', mnemonicChar: 'c', rawLabel: 'Confirm Account!' }), fnSubmit: confirmAccount }); objCDBuilder.addFlexibleRow({ rawValue: 'Enter the Confirmation Code you were sent' }); objCDBuilder.addTextFieldRow( 'txtEmailAddress', { rawLabel: 'Email Address', isEmail: 1 }); objCDBuilder.addTextFieldRow( 'txtConfirmationCode', { rawLabel: 'Confirmation Code' }); objCDBuilder.showClientDialog(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ function rsCallbackResetPassword(json_) { hideDialog(); var strFormId = 'frmResetRestults', objCDBuilder = new ClientDialogBuilder({ formId: strFormId, formTitle: 'ShopaZulu Password Reset', fnCancelOrClose: function () { hideDialog(); displayTimedMessageP({ msgHTML: 'Navigating to ShopaZulu Homepage' }); window.location = pageHomepage; } }); objCDBuilder.addFlexibleRow({ rawValue: json_.message }); // objCDBuilder.addFlexibleRow({ // rawValue: JSON.stringify(json_, null, 2), // additionalCellClasses: 'JSONViewer' // }); objCDBuilder.showClientDialog(); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ function resetPassword() { var strFormId = 'frmResetPassword', theForm = getObj(strFormId), objEmail = theForm.txtEmailAddress, validator = new FormValidator(); if (!validator.CSValidateRequiredField(objEmail, 'Please enter an Email Address')) { return; } jsrsExecuteWithErrorP( 'Admin_ResetPassword', // commandString_ rsCallbackHandleStandardJSONResponse, // fnCallback_ 'Resetting your password', // doingWhat_ { emailAddress: trim(objEmail.value) }, // payload_ { fnOnSuccess: rsCallbackResetPassword }); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ function showResetPasswordDialog() { var strFormId = 'frmResetPassword', objCDBuilder = new ClientDialogBuilder({ formId: strFormId, formTitle: 'ShopaZulu Reset Password', focusFieldName: 'txtEmailAddress', okButtonDisplayText: cdBuildMnemonicLabelHTML({ mnemonicActionJS: 'resetPassword()', mnemonicChar: 'r', rawLabel: 'Reset Password!' }), fnSubmit: resetPassword }); objCDBuilder.addFlexibleRow({ rawValue: 'Enter the email address for the account whose password needs to be reset' }); objCDBuilder.addTextFieldRow( 'txtEmailAddress', { rawLabel: 'Email Address', isEmail: 1 }); objCDBuilder.showClientDialog(); }