PageSourceSearch

https://www.transperth.wa.gov.au/DesktopModules/MySmartAccountRegi…/Js/MySmartAccountRegistration.js?cdv=2

js transperth.wa.gov.au collected 2026-10-01 10:41:50 UTC 29,827 bytes, 656 lines download raw bytes

1function onReCaptchaApiLoadCallback() {
2    if (msar && msar.onReCaptchaApiLoadCallback) {
3        msar.onReCaptchaApiLoadCallback();
4    }
5}
6
7function onReCaptchaVerifyCallback(response) {
8    if (msar && msar.onReCaptchaVerifyCallback) {
9        msar.onReCaptchaVerifyCallback(response);
10    }
11}
12
13function onReCaptchaExpired() {
14    if (msar && msar.onReCaptchaExpired) {
15        msar.onReCaptchaExpired();
16    }
17}
18
19function MySmartAccountRegistration() {
20    this.isApiLoading = false;
21    this.isApiLoaded = false;
22    this.isVerifyingEmail = false;
23    this.isVerifyingMobile = false;
24    this.verifiedMobile = '';
25}
26
27MySmartAccountRegistration.prototype.loadGoogleReCaptchaApi = function () {
28    var msarObj = this;
29
30    msarObj.isApiLoading = true;
31    var script = document.createElement('script');
32    script.type = 'text/javascript';
33    script.src = msarObj.msarSettings.reCaptchaApiUrl + '?onload=onReCaptchaApiLoadCallback&render=explicit';
34    script.async = true;
35    script.defer = true;
36    document.body.appendChild(script);
37}
38
39MySmartAccountRegistration.prototype.onReCaptchaApiLoadCallback = function () {
40    var msarObj = this;
41    msarObj.isApiLoading = false;
42    msarObj.isApiLoaded = true;
43    msarObj.isVerifyingEmail = false;
44    if (grecaptcha) {
45        var reCapSetting = {
46            'sitekey': msarObj.msarSettings.reCaptchaSiteKey,
47            'theme': 'light',
48            'callback': 'onReCaptchaVerifyCallback',
49            'expired-callback': 'onReCaptchaExpired',
50            'action': 'TP_REGISTRATION'
51        };
52        if (msarObj.msarSettings.reCaptchaUsingEnterpriseApi) {
53            grecaptcha.enterprise.render('divReCaptcha', reCapSetting);
54        }
55        else {
56            grecaptcha.render('divReCaptcha', reCapSetting);
57        }
58    }
59}
60
61MySmartAccountRegistration.prototype.onReCaptchaExpired = function () {
62    var msarObj = this;
63    if (msarObj.isVerifyingEmail) {
64        if (grecaptcha) {
65            if (msarObj.msarSettings.reCaptchaUsingEnterpriseApi) {
66                grecaptcha.enterprise.reset();
67            }
68            else {
69                grecaptcha.reset();
70            }
71        }
72    }
73    else {
74        $("#divReCaptchaRow [id$=_txtReCaptcha]").val('');
75    }
76}
77
78MySmartAccountRegistration.prototype.init = function (msarSettings) {
79    var msarObj = this;
80    var defaultMsarSettings = {
81        moduleId: '',
82        useCaptcha: false,
83        toSendEmailVerification: false,
84        toVerifyMobile: false,
85        reCaptchaSiteKey: '',
86        reCaptchaApiUrl: 'https://www.google.com/recaptcha/api.js',
87        privacyStatementUrl: '',
88        termsAndConditionsUrl: ''
89    };
90    msarObj.msarSettings = $.extend({}, defaultMsarSettings, msarSettings);
91    msarObj.msarSettings.reCaptchaUsingEnterpriseApi = msarObj.msarSettings.reCaptchaApiUrl.indexOf('enterprise.js') > -1;
92    msarObj.serviceFramework = $.ServicesFramework(msarObj.msarSettings.moduleId);
93    msarObj.msarServiceBase = msarObj.serviceFramework.getServiceRoot('MySmartAccountRegistration');
94    msarObj.commonServiceBase = msarObj.serviceFramework.getServiceRoot('PTA_Common');
95    msarObj.loginServiceBase = msarObj.serviceFramework.getServiceRoot('PTA_Login');
96
97    $('#divSmartAccountRegistration .pnl-phone-number .mobile-number #infoMsgMobileVerificationRequired').hide();
98    if (msarObj.msarSettings.toVerifyMobile) {
99        $('#divSmartAccountRegistration .pnl-phone-number').addClass('mobile-verification-required');
100        $('#divSmartAccountRegistration .pnl-phone-number .phone-number input[type=text]').removeClass('input-small');
101        msarObj.verifiedMobile = $('#divSmartAccountRegistration .pnl-phone-number .mobile-number [id$=_hdfVerifiedMobileNumber]').val();
102        var mobileNumber = $('#divSmartAccountRegistration .pnl-phone-number .mobile-number input[type=text]').val();
103        if (mobileNumber) {
104    		if (mobileNumber === msarObj.verifiedMobile) {
105        		$('#divSmartAccountRegistration .pnl-phone-number .mobile-number').addClass('number-verified');
106    		}
107    		else {
108        		$('#divSmartAccountRegistration .pnl-phone-number .mobile-number #infoMsgMobileVerificationRequired').show();
109    		}
110		}
111    }
112    $('#divReCaptchaRow [id$=_txtReCaptcha]').val('');
113    $('#divSmartAccountRegistration input[type=text]').attr("autocomplete", "off" + Date.now().toString());
114    $('#divSmartAccountRegistration #pnlErrorMessage').hide();
115    $('#divSmartAccountRegistration input[type=text][id$=_txtEmail]').on("focusout", function () {
116        var confirmedEmail = $('#divSmartAccountRegistration input[type=text][id$=_txt
116ConfirmEmail]').val();
117        if (confirmedEmail) {
118            msarObj.valConfirmedEmail();
119        }
120    });
121    $('#divSmartAccountRegistration input[type=text][id$=_txtConfirmEmail]').on("focusout", function () {
122        msarObj.valConfirmedEmail();
123    });
124    $('#divSmartAccountRegistration .pnl-phone-number.mobile-verification-required .mobile-number.number-verified input[type=text]').on('input', function () {
125        if ($(this).val() !== msarObj.verifiedMobile) {
126            $('#divSmartAccountRegistration .pnl-phone-number.mobile-verification-required .mobile-number').removeClass('number-verified');
127        }
128    });
129
130    $('#divSmartAccountRegistrationProgressBarModal').dialog({
131        autoOpen: false,
132        height: 200,
133        width: 200,
134        modal: true,
135        open: function (event, ui) {
136            $('.ui-dialog').css('z-index', 103);
137            $('.ui-widget-overlay').css('z-index', 102);
138            $(this).parent().find('.ui-dialog-titlebar-close').hide();
139            $('.ui-dialog-buttonpane button:contains("cancel")').button().hide();
140        }
141    });
142    $('#divSendVerificationCodeModal').dialog({
143        autoOpen: false,
144        //height: 200,
145        width: 280,
146        modal: true,
147        open: function (event, ui) {
148            $(this).parent().css({
149                'border-radius': '5px'
150            });
151            $('.ui-dialog').css('z-index', 103);
152            $('.ui-widget-overlay').css('z-index', 102);
153            $('.ui-dialog-content').css('background', 'white').css('padding', '8px');
154            $('.ui-dialog-content #msgVerificationCode').css('margin-bottom', '5px');
155            $(this).parent().find('.ui-dialog-titlebar-close').hide();
156            $('.ui-dialog-buttonpane button:contains("cancel")').button().hide();
157        }
158    });
159    $('#divMFALoginIptOutDialog').dialog({
160        autoOpen: false,
161        //height: 200,
162        width: '80%',
163        modal: true,
164        dialogClass: 'dnnFormPopup',
165        open: function (event, ui) {
166            $(this).parent().css({
167                'border-radius': '5px',
168                'max-width': '480px'
169            });
170            $(this).parent().css('left', ($(window).width() - $(this).parent().outerWidth()) / 2);
171            //$(this).parent().css('top', ($(window).height() - $(this).parent().outerHeight()) / 2);
172            $(this).parent().find('.ui-dialog-titlebar-close').hide();
173            $(this).parent().find('.ui-resizable-handle').hide();
174        },
175        buttons: [
176            {
177                text: 'Yes',
178                "class": "btn btn-small btn-green",
179                click: function () {
180                    $(this).dialog("close");
181                }
182            },
183            {
184                text: 'No',
185                "class": "btn btn-small",
186                click: function () {
187                    $('#divSmartAccountRegistration div[id$=_divMFALogin] input[type=radio][id$=_chkMFALoginYes]').prop("checked", true);
188                    $('#divSmartAccountRegistration div[id$=_divMFALogin] input[type=radio][id$=_chkMFALoginNo]').prop("checked", false);
189                    $(this).dialog("close");
190                }
191            }
192        ]
193    });
194  
195    $('#divSmartAccountRegistration input[type=text][id$=_txtPhoneNumberMobile]').on('change', function () {
196    	if ($(this).val()) {
197        	$('#divSmartAccountRegistration .pnl-phone-number .mobile-number #infoMsgMobileVerificationRequired').show();
198    	}
199    	else {
200        	$('#divSmartAccountRegistration .pnl-phone-number .mobile-number #infoMsgMobileVerificationRequired').hide();
201    	}
202	});
203
204    $('#divSendVerificationCodeModal .btn#btnSubmitVerificationCode').on('click', function (e) {
205        var code = $('#divSendVerificationCodeModal input#txtVerificationCode').val();
206        if (code) {
207            var isNewAccount = $('#divSmartAccountRegistration .form-actions .btn[id$=_btnCreateAccount]').is(':visible');
208            //verificationMethod - email : 0; sms : 1
209            if (msarObj.isVerifyingEmail) {
210                var email = $('#divSmartAccountRegistration input[type=text][id$=_txtEmail]').val();
211                if (email) {
212                    msarObj.checkVerificationCode(code, email, 0, isNewAccount);
213                }
214            }
215            else if (msarObj.isVerifyingMobile) {
216                var mobile = $('#divSmartAccountRegistration input[type=text][id$=_txtPhoneNumberMobile]').val();
217                if (mobile) {
218                    msarObj.checkVerificationCode(code, mobile, 1, isNewAccount);
219                }
220            }
221        }
222    });
223    $('#divSendVerificationCodeModal .btn#btnResendVerificationCode').on('click', function (e) {
224        var verificationMethod = -1;
225        if (msarObj.isVerifyingEmail) {
226            verificationMethod = 0;
227            $('#divSmartAccountRegistration .form-actions input[type=hidden][id$=_hdfVerificationCode]').val('');
228        }
229        else if (msarObj.isVerifyingMobile) {
230            verificationMethod = 1;
231        }
232        $('#divSendVerificationCodeModal input#txtVerificationCode').val('');
233        $('#divSendVerificationCodeModal').dialog('close');
234        if ($('#divSmartAccountRegistration .form-actions .btn[id$=_btnCreateAccount]').is(':visible')) {
235            var verificationToken = $('#divSmartAccountRegistration [id$=_hdfNewUserVerificationToken]').val();
236            msarObj.sendVerification(verificationMethod, true, verificationToken);
237        }
238        else if ($('#divSmartAccountRegistration .form-actions .btn[id$=_btnUpdateAccount]').is(':visible')) {
239            msarObj.sendVerification(verificationMethod, false);
240        }
241    });
242
243    $('#divSendVerificationCodeModal .btn#btnCancelVerifyCode').on('click', function (e) {
244        $('#divSendVerificationCodeModal input#txtVerificationCode').val('');
245        if (msarObj.isVerifyingEmail) {
246            msarObj.isVerifyingEmail = false;
247            $('#divSmartAccountRegistration .form-actions input[type=hidden][id$=_hdfVerificationCode]').val('');
248        }
249        else if (msarObj.isVerifyingMobile) {
250            msarObj.isVerifyingMobile = false;
251        }
252        $('#divSendVerificationCodeModal').dialog('close');
253    });
254
255    $('#divSmartAccountRegistration div[id$=_divMFALogin] input[type=radio][name$=chkMFALoginOption]').on('change', function () {
256        if ($(this).val() === 'out') {
257            $('#divMFALoginIptOutDialog').dialog('open');
258        }
259    });
260
261    $('#divSmartAccountRegistration .btn.btn-verify-mobile').on('click', function (e) {
262        e.preventDefault();
263        var mobileNumber = $('#divSmartAccountRegistration input[type=text][id$=_txtPhoneNumberMobile]').val();
264        if (mobileNumber && mobileNumber !== msarObj.verifiedMobile && msarObj.msarSettings.toVerifyMobile) {
265            var verificationToken = $('#divSmartAccountRegistration [id$=_hdfNewUserVerificationToken]').val();
266            msarObj.sendVerification(1, (verificationToken && verificationToken.length > 0), verificationToken);
267        }
268    });
269
270    $('#divSmartAccountRegistration .form-actions').on('click', '.btn[id$=_btnCreateAccount]', function (e, hasVerificationCode) {
271        if (!Page_ClientValidate()) {
272            e.preventDefault();
273        }
274        else if (msarObj.valPrivacyAndTerms() === false
275            || msarObj.valConfirmedEmail() === false) {
276            e.preventDefault();
277            //return false;
278        }
279        else if (msarObj.msarSettings.toVerifyMobile && $('#divSmartAccountRegistration input[type=text][id$=_txtPhoneNumberMobile]').val() && $('#divSmartAccountRegistration input[type=text][id$=_txtPhoneNumberMobile]').val() !== msarObj.verifiedMobile) {
280            $('#divSmartAccountRegistration .pnl-phone-number .mobile-number #infoMsgMobileVerificationRequired').addClass('error');
281            e.preventDefault();
282        }
283        else if (!hasVerificationCode && msarObj.msarSettings.toSendEmailVerification) {
284            e.preventDefault();
285            msarObj.verifyExistingUser(true, true);
286        }
287
288        if ($('.error.msg-block:visible').length > 0) {
289            msarObj.scrollToElement($('.error.msg-block:visible')[0]);
290        }
291    });
292
293    $('#divSmartAccountRegistration .form-actions').on('click', '.btn[id$=_btnUpdateAccount]', function (e, hasVerificationCode) {
294        if (msarObj.valPrivacyAndTerms() === false) {
295            e.preventDefault();
296            //return false;
297        }
298        else if (msarObj.msarSettings.toVerifyMobile && $('#divSmartAccountRegistration input[type=text][id$=_txtPhoneNumberMobile]').val() && $('#divSmartAccountRegistration input[type=text][id$=_txtPhoneNumberMobile]').val() !== msarObj.verifiedMobile) {
299            $('#divSmartAccountRegistration .pnl-phone-number .mobile-number #infoMsgMobileVerificationRequired').addClass('error');
300            e.preventDefault();
301        }
302        else {
303            var oldEmail = $('#divSmartAccountRegistration input[type=hidden][id$=_hdfOriginalEmail]').val();
304            var newEmail = $('#divSmartAccountRegistration input[type=text][id$=_txtEmail]').val();
305            if (oldEmail && newEmail && oldEmail.toUpperCase() !== newEmail.toUpperCase()) {
306                if (msarObj.valConfirmedEmail() === false) {
307                    e.preventDefault();
308                }
309                else if (!hasVerificationCode && msarObj.msarSettings.toSendEmailVerification) {
310                    e.preventDefault();
311                    msarObj.verifyExistingUser(true, false);
312                }
313            }
314        }
315
316        if ($('.error.msg-block:visible').length > 0) {
317            msarObj.scrollToElement($('.error.msg-block:visible')[0]);
318        }
319    });
320
321    $('#divPrivacyAndTerms').on('change', "input[type=checkbox][id$=_chkPrivacyAndTerms]", function (e) {
322        var $this = $(this);
323        if ($this.is(':checked')) {
324            $('#divPrivacyAndTerms #errMsgPrivacyAndTerms').hide();
325        }
326    });
327
328    $('#linkPrivacyStatement', '#divPrivacyAndTerms').click(function (e) {
329        if (msarObj.msarSettings.privacyStatementUrl.length > 0) {
330            var dialogWidth = 700;
331            var dialogHeight = 500;
332            var maxDialogWidth = $(window).width() - 46;
333            var maxDialogHeight = $(window).height() - 130;
334            if (dialogWidth > maxDialogWidth) {
335                dialogWidth = maxDialogWidth;
336            }
337            if (dialogHeight > maxDialogHeight) {
338                dialogHeight = maxDialogHeight;
339            }
340            dnnModal.show(msarObj.msarSettings.privacyStatementUrl + '?popUp=true', true, dialogHeight, dialogWidth, false);
341        }
342        e.preventDefault();
343    });
344
345    $('#linkTermsAndConditions', '#divPrivacyAndTerms').click(function (e) {
346        if (msarObj.msarSettings.termsAndConditionsUrl.length > 0) {
347            var dialogWidth = 700;
348            var dialogHeight = 500;
349            var maxDialogWidth = $(window).width() - 46;
350            var maxDialogHeight = $(window).height() - 130;
351            if (dialogWidth > maxDialogWidth) {
352                dialogWidth = maxDialogWidth;
353            }
354            if (dialogHeight > maxDialogHeight) {
355                dialogHeight = maxDialogHeight;
356            }
357            dnnModal.show(msarObj.msarSettings.termsAndConditionsUrl + '?popUp=true', true, dialogHeight, dialogWidth, false);
358        }
359        e.preventDefault();
360    });
361
362    if (msarObj.msarSettings.useCaptcha) {
363        msarObj.loadGoogleReCaptchaApi();
364    }
365}
366
367MySmartAccountRegistration.prototype.valPrivacyAndTerms = function () {
368    var chkPrivacyAndTermsStatus = $('#divPrivacyAndTerms input[type=checkbox][id$=_chkPrivacyAndTerms]').prop('checked');
369    if (chkPrivacyAndTermsStatus) { $('#errMsgPrivacyAndTerms').hide(); }
370    else { $('#errMsgPrivacyAndTerms').show(); }
371    return chkPrivacyAndTermsStatus;
372}
373
374MySmartAccountRegistration.prototype.valConfirmedEmail = function () {
375    var email = $('#divSmartAccountRegistration input[type=text][id$=_txtEmail]').val();
376    var confirmedEmail = $('#divSmartAccountRegistration input[type=text][id$=_txtConfirmEmail]').val();
377    if ((!email && !confirmedEmail)
378        || (email && confirmedEmail && email.toUpperCase() === confirmedEmail.toUpperCase())) {
379        $('#divSmartAccountRegistration #errMsgValidateConfirmedEmail').hide();
380        return true;
381    }
382    else {
383        $('#divSmartAccountRegistration #errMsgValidateConfirmedEmail').show();
384        return false;
385    }
386}
387
388MySmartAccountRegistration.prototype.verifyExistingUser = function (toSendVerificationCode, isNewAccount) {
389    var msarObj = this;
390    var verificationToken = null;
391    var emailField = $('#divSmartAccountRegistration input[type=text][id$=_txtEmail]');
392    if (emailField && emailField.val().length > 0) {
393        var postData = { Email: emailField.val() };
394        if (isNewAccount) {
395            verificationToken = $('#divSmartAccountRegistration [id$=_hdfNewUserVerificationToken]').val();
396            postData.VerificationToken = verificationToken;
397        }
398        //var postData = isNewAccount ? { VerificationStage: 0, AccountName: emailField.val() } : { VerificationStage: 2, AccountName: emailField.val() };
399        var api = isNewAccount ? 'VerifyNewUserEmail' : 'VerifyUserNewEmail';
400        $('#divSmartAccountRegistrationProgressBarModal').dialog('open');
401        $.ajax({
402            type: "POST",
403            beforeSend: msarObj.serviceFramework.setModuleHeaders,
404            url: msarObj.commonServiceBase + 'UserVerification/' + api,
405            data: postData,
406            success: function (data) {
407                $('#divSmartAccountRegistrationProgressBarModal').dialog('close');
408                if (data.result === 'success' && data.status === 'UserEmailVerified') {
409                    if (toSendVerificationCode) {
410                        msarObj.sendVerification(0, isNewAccount, verificationToken);
411                    }
412                }
413                else {
414                    //user exists, show error
415                    $('#divSmartAccountRegistration #divErrMsgEmailRegistered').show();
416                    $('html, body').animate({ scrollTop: $('#divSmartAccountRegistration #divErrMsgEmailRegistered').offset().top }, 400);
417                }
418            },
419            error: function (xhr, status, error) {
420                $('#divSmartAccountRegistrationProgressBarModal').dialog('close');
421                if (toSendVerificationCode) {
422                    msarObj.sendVerification(0, isNewAccount, verificationToken);
423                }
424            }
425        });
426    }
427}
428
429//verificationMethod - email : 0; sms : 1
430MySmartAccountRegistration.prototype.sendVerification = function (verificationMethod, isNewAccount, verificationToken) {
431    var msarObj = this;
432    var api = '';
433    var postData = { VerificationMethod: verificationMethod };
434    if (isNewAccount) {
435        api = 'SendNewUserVerificationCode';
436        postData.FirstName = $('#divSmartAccountRegistration input[type=text][id$=_txtFirstName]').val();
437        postData.LastName = $('#divSmartAccountRegistration input[type=text][id$=_txtLastName]').val();
438        postData.VerificationToken = verificationToken;
439    }
440    else {
441        api = 'SendNewContactVerificationCode';
442    }
443    if (verificationMethod == 0) {
444        var emailField = $('#divSmartAccountRegistration input[type=text][id$=_txtEmail]');
445        msarObj.isVerifyingEmail = true;
446        postData.CodeSentTo = emailField.val();
447    }
448    else if (verificationMethod == 1) {
449        var mobileField = $('#divSmartAccountRegistration input[type=text][id$=_txtPhoneNumberMobile]');
450        msarObj.isVerifyingMobile = true;
451        postData.CodeSentTo = mobileField.val();
452    }
453    if (api && api.length > 0) {
454        $('#divSmartAccountRegistrationProgressBarModal').dialog('open');
455        $.ajax({
456            type: "POST",
457            beforeSend: msarObj.serviceFramework.setModuleHeaders,
458            url: msarObj.commonServiceBase + 'UserVerification/' + api,
459            data: postData,
460            success: function (data) {
461                $('#divSmartAccountRegistrationProgressBarModal').dialog('close');
462                if (data.result === 'failed') {
463                    if (verificationMethod == 0) {
464                        msarObj.isVerifyingEmail = false;
465                    }
466                    else if (verificationMethod == 1) {
467                        msarObj.isVerifyingMobile = false;
468                    }
469                    $('#divSmartAccountRegistration #pnlErrorMessage').show();
470                    $('#divSmartAccountRegistration #pnlErrorMessage #msgVerificationError').html(data.message);
471                }
472                else if (data.result === 'success' && data.status === 'CodeSent') {
473                    //popup modal box for verification code.
474                    $('#divSendVerificationCodeModal input#txtVerificationCode').val('');
475                    $('#divSendVerificationCodeModal #msgVerificationSent').html(data.via);
476                    $('#divSendVerificationCodeModal #msgVerificationCode').html('');
477                    $('#divSendVerificationCodeModal #msgVerificationCode').hide();
478                    $('#divSendVerificationCodeModal').dialog('open');
479
480                }
481            },
482            error: function (xhr, status, error) {
483                if (verificationMethod == 0) {
484                    msarObj.isVerifyingEmail = false;
485                }
486                else if (verificationMethod == 1) {
487                    msarObj.isVerifyingMobile = false;
488                }
489                $('#divSmartAccountRegistrationProgressBarModal').dialog('close');
490                $('#divSmartAccountRegistration #pnlErrorMessage').show();
491                $('#divSmartAccountRegistration #msgVerificationError').html(error);
492            }
493        });
494    }
495}
496
497MySmartAccountRegistration.prototype.checkVerificationCode = function (code, codeSentTo, verificationMethod, isNewAccount) {
498    var msarObj = this;
499    //verificationMethod - email : 0; sms : 1
500    //var verificationMethod = /\S+@\S+\.\S+/.test(codeSentTo) ? 0 : 1;
501    var api = isNewAccount ? 'CheckNewUserVerificationCode' : 'CheckNewContactVerificationCode';
502    var postData = { Code: code, CodeSentTo: codeSentTo, VerificationMethod: verificationMethod };
503    if (isNewAccount) {
504        postData.VerificationToken = $('#divSmartAccountRegistration [id$=_hdfNewUserVerificationToken]').val();
505    }
506    else {
507        postData.VerificationStage = 2;
508    }
509    $.ajax({
510        type: "POST",
511        beforeSend: msarObj.serviceFramework.setModuleHeaders,
512        url: msarObj.commonServiceBase + 'UserVerification/' + api,
513        data: postData,
514        success: function (data) {
515            if (data.result === 'success' && data.status === 'CodeCheckSucceed') {
516                $('#divSmartAccountRegistration .form-actions input[type=hidden][id$=_hdfVerificationCode]').val(code);
517                if (verificationMethod == 0) {
518                    msarObj.isVerifyingEmail = false;
519                    if (isNewAccount) {
520                        $('#divSmartAccountRegistration .form-actions .btn[id$=_btnCreateAccount]').trigger('click', [true]);
521                    }
522                    else {
523                        $('#divSmartAccountRegistration .form-actions .btn[id$=_btnUpdateAccount]').trigger('click', [true]);
524                    }
525                }
526                else if (verificationMethod == 1) {
527                    msarObj.isVerifyingMobile = false;
528                    msarObj.verifiedMobile = codeSentTo;
529                    $('#divSmartAccountRegistration .pnl-phone-number .mobile-number').addClass('number-verified');
530                    $('#divSmartAccountRegistration .pnl-phone-number .mobile-number #infoMsgMobileVerificationRequired').removeClass('error');
531                }
532                $('#divSendVerificationCodeModal').dialog('close');
533            }
534            else {
535                //msarObj.isVerifyingEmail = false;
536                $('#divSendVerificationCodeModal #msgVerificationCode').show();
537                $('#divSendVerificationCodeModal #msgVerificationCode').html(data.message);
538                $('#divSendVerificationCodeModal input#txtVerificationCode').focus();
539            }
540        },
541        error: function (xhr, status, error) {
542            $('#divSendVerificationCodeModal #msgVerificationCode').show();
543            $('#divSendVerificationCodeModal #msgVerificationCode').html(error);
544            $('#divSendVerificationCodeModal input#txtVerificationCode').focus();
545        }
546    });
547}
548
549MySmartAccountRegistration.prototype.onReCaptchaVerifyCallback = function (response) {
550    if (response !== '') {
551        $("#divReCaptchaRow [id$=_txtReCaptcha]").val('true');
552        $("#divReCaptchaRow [id$=_rfvCaptcha]").hide();
553    }
554    else {
555        $("#divReCaptchaRow [id$=_txtReCaptcha]").val('');
556        $("#divReCaptchaRow [id$=_rfvCaptcha]").show();
557    }
558}
559
560MySmartAccountRegistration.prototype.setLocationAutoload = function (locId) {
561    var msarObj = this;
562    var val_NotFound = 'NOTFOUND';
563    var label_NotFound = 'No results found';
564    var val_Failed = 'FAILED';
565    var label_Failed = 'Please try again';
566    $('#' + locId).autocomplete({
567        autoFocus: true,
568        source: function (request, response) {
569            request.term = request.term.trim();
570            if (request.term == "") {
571                //when empty, returns empty result
572                response([]);
573            } else {
574                $.ajax({
575                    type: "POST",
576                    beforeSend: msarObj.serviceFramework.setModuleHeaders,
577                    url: msarObj.commonServiceBase + 'Location/GetLocationAsync',
578                    timeout: 10000,
579                    data: { location: request.term, type: 'national-gnaf' },
580                    dataType: "json",
581                    success: function (data) {
582                        if (data.locMatchList && data.locMatchList.length > 0) {
583                            response($.map(data.locMatchList, function (location) {
584                                return {
585                                    label: location.LocationName,
586                                    val: JSON.stringify(location)
587                                }
588                            }));
589                        }
590                        else {
591                            response([{ label: label_NotFound, val: val_NotFound }]);
592                        }
593                    },
594                    error: function (xhr, status, error) {
595                        response([{ label: label_Failed, val: val_Failed }]);
596                    }
597                });
598            }
599        },
600        minLength: 2,
601        select: function (event, ui) {
602            var street = ui.item.label;
603            var suburb = '';
604            var postcode = '';
605            if (ui.item.val !== val_NotFound) {
606                var locSelected;
607                try {
608                    locSelected = JSON.parse(ui.item.val);
609                } catch (e) {
610
611                }
612                if (locSelected && locSelected.LocationPostcode) {
613                    postcode = locSelected.LocationPostcode;
614                }
615                var index = street.lastIndexOf(',');
616                if (index > 1) {
617                    suburb = street.substring(index + 2);
618                    street = street.substring(0, index);
619                }
620                this.value = street;
621            }
622            $('#divSmartAccountRegistration input[id$=_txtSuburb]').val(suburb);
623            $('#divSmartAccountRegistration input[id$=_txtPostalCode]').val(postcode);
624            $(this).focus();
625
626            return false;
627        },
628        open: function () {
629            var width = $(this).width() + 30;
630            $('.ui-autocomplete:visible').css(
631                {
632                    'width': width + 'px',
633                    'max-width': width + 'px'
634                });
635        },
636        close: function () {
637            //if ($('#' + toSetField).val().length == 0) {
638            //    $('#' + errorField).show();
639            //    $(this).val("");
640            //}
641            //else {
642            //    $('#' + errorField).hide();
643            //}
644        }
645    });
646}
647
648MySmartAccountRegistration.prototype.scrollToElement = function (element) {
649    $('html, body').animate({
650        scrollTop: $(element).offset().top - 30
651    }, 300);
652}
653
654
655
656

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.