/* The following errors were found when attempting to minify this file: - Line 22: Parse error. syntax error - Line 23: Parse error. syntax error - Line 25: Parse error. missing ) after argument list - Line 25: Parse error. missing ; before statement - Line 26: Parse error. syntax error - Line 27: Parse error. syntax error - Line 28: Parse error. syntax error */ /// /// /// var subInfo = null; var phoneFieldDirty = false; var profileEditor = false; var ALT_ENABLED_SMS = "Subscribe via text messaging"; var ALT_ENABLED_EMAIL = "Subscribe via email"; var ALT_SUBBED_SMS = "Unsubscribe from text messages"; var ALT_SUBBED_EMAIL = "Unsubscribe email"; var listFilter = ''; var isProfileAvailable = false; var savedMailListID = 0; var listID = 0; var phoneNumberPlainText = ''; var profileAddressDetails = {}; // Add handler to fix IE bug. $addHandler(window, 'load', function () { invalidateNMLists(); }); $(document).ready(function () { const phoneNumberField = document.querySelector("#phoneNumber"); if (phoneNumberField?.value) { ysnSMS.checked = true; } if (phoneNumberField) { NotifyMeAjax.GetMinProfileInfo(document.aspnetForm.EMAIL.value, getMinInfoSuccess, function () { }); } }); function inflateUIHtml(html) { if (html == null) return ''; else return (html + '') .replace(/%T1%/g, "\"You must sign in to subscribe to or unsubscribe from lists.\"") .replace(/%T2%/g, "\"Please enter a phone number and click save to be able to receive text messages from this list.\"") .replace(/%T3%/g, "\"Subscribe via text messaging\"") .replace(/%T4%/g, "\"Subscribe via email\"") .replace(/%T5%/g, "\"Unsubscribe from text messages\"") .replace(/%T6%/g, "\"Unsubscribe email\"") .replace(/%T7%/g, " height=\"16\" width=\"16\" src=\"/Common/images/NotifyMe/") .replace(/%T8%/g, " href=\"/List.aspx\" onclick=\"subUnsub(") .replace(/%T9%/g, ");return false;\">IE work-around. Invoked when operations that affect image visibility are made through AJAX callbacks. var nmLists = document.getElementById('nmLists'); // Hack to fix IE vanishing images bug. if (nmLists) { nmLists.style.display = 'none'; nmLists.style.display = 'block'; } } function setListFilter(filter) { /// Sets list section visiblity filter, updates UI. /// The ID of the section to show. All other sections are hidden. listFilter = filter; processFilter(); } function clearListFilter() { /// Clears list section visiblity filter, updates UI. listFilter = ''; processFilter(); } function processFilter() { /// Applies list section visiblity filter. var nmLists = document.getElementById('nmLists'); var section = nmLists.firstChild; while (section != null) { if (section.nodeType == 1) { if (listFilter == '' || section.id == listFilter) section.style.display = 'block'; else section.style.display = 'none'; } section = section.nextSibling; } } function refreshLists() { /// Refreshes Notify Me lists section. NotifyMeAjax.UpdateSubscriberListsUI(document.aspnetForm.EMAIL.value, document.aspnetForm.NID.value, listID, refreshListsSuccess, refreshListsFailure); } function hideAvailableListsMenu() { /// Hides available lists menu with a short delay (100ms). setTimeout(hideAvailableListsMenuNow, 300); } function hideAvailableListsMenuNow() { /// Hides available lists menu with immediatly. document.getElementById('availableLists').style.display = 'none'; } function refreshListsSuccess(result, userContext) { /// Callback for refresh list success. /// Result from call to server. /// An arbitrary string passed to the server request routine. // Update markup, run JavaScript to update client state. var contactInfo = document.getElementById('fstContactInfo'); var nmLists = document.getElementById('nmLists'); nmLists.innerHTML = inflateUIHtml(result[0]); // HTML from server. processFilter(); // Apply view filter. eval(result[1]); // JavaScript from server. // Hack for Internet Explorer. var nmLists = document.getElementById('nmLists'); if (nmLists) nmLists.style.clear = 'left'; if (savedMailListID > 0) { subUnsub(savedMailListID, true); savedMailListID = 0; } } function refreshListsFailure(error, userContext) { /// Callback for refresh list failure. /// Error object from server. /// An arbitrary string passed to the server request routine. // Error occurred updating through AJAX, try postback. document.aspnetForm.submit(); } function emailAddressSignIn_KeyDown(event) { /// Event handler for emailAddressSignIn element when a key is pressed down. /// Stores information on event. var keyCode = (event.which ? event.which : event.keyCode); switch (keyCode) { case 13: case 10: signIn(); break; } } function phoneNumber_KeyUp(event) { /// Event handler for phoneNumber element when a key is pressed down. /// Stores information on event. var keyCode = (event.which ? event.which : event.keyCode); switch (keyCode) { case 13: case 10: saveSMSProfile(); break; } var phoneField = document.getElementById('phoneNumber'); phoneFieldDirty = !isObfuscatedMobileNumber(phoneField.value); toggleSaveMobileNumberButton(true); } function updateEmailPrefSuccess(result, userContext) { /// Callback for email preference update success. /// Result from call to server. /// An arbitrary string passed to the server request routine. if (!result) { var htmlEmailPref = document.getElementById('HTMLEmailPref'); htmlEmailPref.checked = !htmlEmailPref.checked; alert('Your HTML email preference could not be updated.'); } updateEmailPref = this._updateEmailPref; } function updateEmailPrefFailure(error, userContext) { /// Callback for email preference update failure. /// Error object from server. /// An arbitrary string passed to the server request routine. var htmlEmailPref = document.getElementById('HTMLEmailPref'); htmlEmailPref.checked = !htmlEmailPref.checked; alert('Your HTML email preference could not be updated due to error.'); updateEmailPref = this._updateEmailPref; } function updateEmailPref(event) { /// Event fired when user clicks email format checkbox. Sends preference to server. /// Stores information on event. this._updateEmailPref = updateEmailPref; updateEmailPref = function () { alert('Your email preference is being updated. Please wait...'); } var emailAddress = document.aspnetForm.EMAIL.value; var target = (event.srcElement ? event.srcElement : event.target); NotifyMeAjax.UpdateEmailPreference(emailAddress, (target.checked ? 'HTML' : 'Text'), updateEmailPrefSuccess, updateEmailPrefFailure); } function updateBusinessPrefSuccess(result, userContext) { /// Callback for business account update success. /// Result from call to server. /// An arbitrary string passed to the server request routine. if (!result) { var personalPref = document.getElementById('PersonalPref'); personalPref.checked = !personalPref.checked; alert('Your personal/business account type could not be updated.'); } updateBusinessPref = this._updateBusinessPref; } function updateBusinessPrefFailure(error, userContext) { /// Callback for business account update failure. /// Error object from server. /// An arbitrary string passed to the server request routine. var personalPref = document.getElementById('PersonalPref'); personalPref.checked = !personalPref.checked; alert('Your personal/business account type could not be updated due to error.'); updateBusinessPref = this._updateBusinessPref; } function updateBusinessPref(event) { /// Event fired when user clicks business account checkbox. Sends SMS mobile number type (personal, business) to server. /// Stores information on event. this._updateBusinessPref = updateBusinessPref; updateBusinessPref = function () { alert('Your personal/business account type is being updated. Please wait...'); } var emailAddress = document.aspnetForm.EMAIL.value; var target = (event.srcElement ? event.srcElement : event.target); NotifyMeAjax.UpdateBusinessPreference(emailAddress, target.checked, updateBusinessPrefSuccess, updateBusinessPrefFailure); } function ToggleSMSDetails(event, checked, dirty) { /// Event fired when user clicks "I would like to be able to receive..." checkbox. Hides/shows SMS details DIV /// Stores information on event. var $SMS = $('.SMS'); var mobilenumber = document.getElementById('phoneNumber').value; if (checked) { //$SMS.slideDown(300); divSMSDetails.style.display = "block"; if (event != null) {//If checkbox check event is fired then pull already saved number if any. var email = $('#emailAddressManage').val(); NotifyMeAjax.GetMinProfileInfo(email, SmsCheckbox_CheckedSuccess, function () { }); } } else { if (event != null) { if (dirty && mobilenumber != '' && !isObfuscatedMobileNumber(mobilenumber)) { saveSMSProfile(); } } divSMSDetails.style.display = "none"; //else { // divSMSDetails.style.display = "none"; // if (dirty && mobilenumber != '' && !isObfuscatedMobileNumber(mobilenumber)) { // saveSMSProfile(); // } //} document.getElementById('phoneNumber').value = ''; phoneFieldDirty = dirty; phoneNumberPlainText = ''; } //Enable-Disable save button when user signs in , when event is null if(event==null) { if (mobilenumber != '') { toggleSaveMobileNumberButton(false); } else { toggleSaveMobileNumberButton(true); } } } function getMinInfoSuccess(result, userContext) { var OBFUSC_SMS_NUMBER = 0; var BUSINESS_PREF = 1; var SHOW_PROFILE_EDITOR = 2; var HTML_EMAIL_PREFERED = 3; var ACTUAL_SMS_NUMBER = 4; var FIRST_NAME = 6; var LAST_NAME = 7; var ADDRESS_LINE1 = 8; var ADDRESS_LINE2 = 9; var CITY = 10; var STATE = 11; var POSTAL_CODE = 12; var OBFUSC_ADDRESS_LINE1 = 13; var OBFUSC_ADDRESS_LINE2 = 14; var OBFUSC_CITY = 15; var OBFUSC_STATE = 16; var OBFUSC_POSTAL_CODE = 17; if (document.getElementById('phoneNumber') != null) { document.getElementById('phoneNumber').value = result[OBFUSC_SMS_NUMBER]; document.aspnetForm.SMS.value = result[OBFUSC_SMS_NUMBER]; if (document.getElementById('phoneNumber').value != '') { ysnSMS.checked = true; ToggleSMSDetails(null, true, false); } else { ysnSMS.checked = false; ToggleSMSDetails(null, false, false); } } if (result[SHOW_PROFILE_EDITOR] == 'true') { document.getElementById('firstName').value = profileAddressDetails.FirstName = result[FIRST_NAME]; document.getElementById('lastName').value = profileAddressDetails.LastName = result[LAST_NAME]; document.getElementById('addressLine1').value = result[OBFUSC_ADDRESS_LINE1]; document.getElementById('addressLine2').value = result[OBFUSC_ADDRESS_LINE2]; document.getElementById('city').value = result[OBFUSC_CITY]; document.getElementById('txtState').value = result[OBFUSC_STATE]; document.getElementById('postalCode').value = result[OBFUSC_POSTAL_CODE]; document.getElementById('how').value = ''; profileAddressDetails.AddressLine1 = result[ADDRESS_LINE1]; profileAddressDetails.AddressLine2 = result[ADDRESS_LINE2]; profileAddressDetails.City = result[CITY]; profileAddressDetails.State = result[STATE]; profileAddressDetails.PostalCode = result[POSTAL_CODE]; profileAddressDetails.How = ''; isProfileAvailable = true; document.getElementById('fstFullProfile').style.display = ''; profileEditor = true; } else { document.getElementById('fstFullProfile').style.display = 'none'; profileEditor = false; } var personalPref = document.getElementById('PersonalPref'); if (personalPref) personalPref.checked = (result[BUSINESS_PREF] == 'true'); if (result[HTML_EMAIL_PREFERED] != "TEXT") { //the result was cast ToUpper() document.aspnetForm.HTMLEmailPref.checked = true; } else { //this will catch HTML prefered and no selection having been made document.aspnetForm.HTMLEmailPref.checked = false; } if (result[ACTUAL_SMS_NUMBER] != null && result[ACTUAL_SMS_NUMBER] != undefined) { phoneNumberPlainText = result[ACTUAL_SMS_NUMBER]; } refreshLists(); } function tryConfirmAgainSuccess(result, userContext) { /// Callback for reconfirmation success. /// Result from call to server. /// An arbitrary string passed to the server request routine. if (result > 0) showSubscriptionModal(false, false); } function tryConfirmAgainFailure(error, userContext) { /// Callback for reconfirmation failure. /// Error object from server. /// An arbitrary string passed to the server request routine. // Error occurred updating through AJAX, try postback. document.aspnetForm.submit(); } function tryConfirmAgain(emailAddress) { /// Gives user a chance to re-confirm their unconfirmed subscriptions. /// Email address. NotifyMeAjax.ReactivateEmail(emailAddress, tryConfirmAgainSuccess, tryConfirmAgainFailure); } function getBounceNoticeSuccess(result, userContext) { /// Callback for GetBounceNotice() success. /// Result from call to server. /// An arbitrary string passed to the server request routine. var numResults = result.length; if (numResults > 0) { // Prepare markup for bounced lists display. var spnBounce = document.getElementById('spnBounce'); var listsText = []; for (var i = 0; i < numResults; i++) listsText.push(result[i].Name); var messageWrapperEm = document.createElement('em'); messageWrapperEm.innerHTML = 'Due to delivery issues for your account, you are no longer subscribed to the lists below:
' + listsText.join(', ') + '
'; var lnkReactivate = document.createElement('a'); lnkReactivate.href = '#'; lnkReactivate.style.fontStyle = 'normal'; lnkReactivate.innerHTML = 'Reactivate Your Subscriptions'; messageWrapperEm.appendChild(lnkReactivate); // Show bounced lists. spnBounce.appendChild(messageWrapperEm); spnBounce.style.display = ''; // Attach event handler to reactivation link. $(lnkReactivate).click(function (event) { event.preventDefault(); tryConfirmAgain(userContext); }); } } function signInSuccess(result, userContext) { /// Callback for sign-in success. /// Result from call to server. /// An arbitrary string passed to the server request routine. if (result > 0) { document.aspnetForm.EMAIL.value = userContext; document.aspnetForm.ACCTID.value = result; document.getElementById('divSignIn').style.display = 'none'; document.getElementById('divManage').style.display = 'block'; document.getElementById('emailAddressManage').value = userContext; NotifyMeAjax.GetBounceNotice(userContext, getBounceNoticeSuccess, function () { }, userContext); NotifyMeAjax.GetMinProfileInfo(userContext, getMinInfoSuccess, function () { }); refreshLists(); signIn = this._signIn; } else { alert('Could not sign in to Notify Me.'); signIn = this._signIn; } } function signInFailure(error, userContext) { /// Callback for sign-in failure. /// Error object from server. /// An arbitrary string passed to the server request routine. signIn = this._signIn; handleServiceMethodError(error); return; } function subUnsubSuccess(result, userContext) { /// Callback for subscription/unsubscription success. /// Result from call to server. /// Contains state information (type of action, mailing list ID). See subUnsub() NotifyMeAjax calls. subUnsubWorkDone(userContext, (result == 0 ? 1 : 0), null); invalidateNMLists(); } function subUnsubFailure(error, userContext) { /// Callback for subscription/unsubscription failure. /// Error object from server. /// Contains state information (type of action, mailing list ID). See subUnsub() NotifyMeAjax calls. subUnsubWorkDone(userContext, false, error); invalidateNMLists(); } function closeHelpAndSavePref(isUserHidingHelp) { closeModalDialog('editItemBehavior'); if (isUserHidingHelp) { document.aspnetForm.SHOWHELP.value = 'false'; NotifyMeAjax.SetShowSubHelp(false); } } function closeHelpAndSavePhone(mobilePhone) { closeModalDialog('editItemBehavior'); if (mobilePhone != '') { document.getElementById('phoneNumber').value = mobilePhone; ysnSMS.checked = true; phoneFieldDirty = true; saveSMSProfile(); ToggleSMSDetails(null, true, true); } } function closeHelp() { closeModalDialog('editItemBehavior'); } function subUnsubWorkDone(userContext, success, error) { /// Called by callbacks when their work is complete. Allows subsequent requests and finishes request processing. /// Contains state information (type of action, mailing list ID). See subUnsub() NotifyMeAjax calls. /// Whether or not the action was successful. /// Error object from server. var isSMS = false, isSub = false, mailListID = 0; var mailListDesc = null; if (userContext) { isSMS = (userContext.charAt(1) == 's'); isSub = (userContext.charAt(0) == '+'); mailListID = userContext.substr(2); mailListDesc = subInfo[mailListID]; } if (success) { var clickedImg; if (isSMS) { clickedImg = document.getElementById('imgSMS' + mailListID); clickedImg.src = "/Common/images/NotifyMe/NotifyMeSMS" + (isSub ? "Selected" : "") + ".png"; clickedImg.alt = (isSub ? ALT_SUBBED_SMS : ALT_ENABLED_SMS); clickedImg.title = clickedImg.alt; mailListDesc.isSMS = isSub; } else { clickedImg = document.getElementById('imgEmail' + mailListID) clickedImg.src = "/Common/images/NotifyMe/NotifyMeEmail" + (isSub ? "Selected" : "") + ".png"; clickedImg.alt = (isSub ? ALT_SUBBED_EMAIL : ALT_ENABLED_EMAIL); clickedImg.title = clickedImg.alt; mailListDesc.isEmail = isSub; } if (isSub) showSubscriptionModal(false, isSMS); } else alert('The list could not be ' + (isSub ? 'subscribed to.' : 'unsubscribed from.')); if (mailListDesc) { if (isSMS) mailListDesc.workSMS = false; else mailListDesc.workEmail = false; } } function showSubscriptionModal(force, isSMS) { /// Shows modal after a user attempts to sign up for an SMS or email notification. /// The mailing list to modify subscription for. if (document.aspnetForm.SHOWHELP.value == 'true' || force) { // Alt Icon: /Common/Images/NotifyMeIconSmall.png var iconHTML = 'Notify Me'; var titleText = iconHTML + 'Attention'; var formName; var height; if (isSMS) { formName = "NotifyMeSMSSubHelp.htm"; height = "190px"; } else { formName = "NotifyMeSubHelp.aspx"; height = "215px"; } openGenericModalDialog(height, 'subHelp', titleText, '/common/modules/NotifyMe/' + formName); } } function subUnsub(mailListID, isSMS, isNotifyMeSignInRequired) { /// Invoked when user clicks a subscribe/unsubscribe image button. /// The mailing list to modify subscription for. /// Whether or not the subscription is email or SMS. var mailListDesc = subInfo[mailListID]; var emailAddress = document.aspnetForm.EMAIL.value; var phoneNumber = document.getElementById('phoneNumber').value; var pendingMsg = 'Your subscription is pending. Please wait...'; var loggedIn = (document.aspnetForm.EMAIL.value + '' != ''); var iconHTML = 'Notify Me'; var titleText = iconHTML + 'Attention'; if (loggedIn && (!isNotifyMeSignInRequired || isUserLoggedIn())) { if (isSMS) { if ((phoneNumber + '').trim() == '') { savedMailListID = mailListID; openGenericModalDialog("190px", 'subHelp', titleText, '/common/modules/NotifyMe/NotifyMeNumberSubHelp.htm'); } else if (mailListDesc.canSMS && mailListDesc.workSMS) alert(pendingMsg); else if (mailListDesc.canSMS) { mailListDesc.workSMS = true; if (mailListDesc.isSMS) NotifyMeAjax.RemoveSubscriptionSMS(emailAddress, mailListID, true, false, subUnsubSuccess, subUnsubFailure, '-s' + mailListID); else NotifyMeAjax.AddSubscriptionSMS(emailAddress, mailListID, subUnsubSuccess, subUnsubFailure, '+s' + mailListID); } else subUnsubFailure(); } else { if (mailListDesc.canEmail && mailListDesc.workEmail) alert(pendingMsg); else if (mailListDesc.canEmail) { mailListDesc.workEmail = true; if (mailListDesc.isEmail) NotifyMeAjax.RemoveSubscriptionEmail(emailAddress, mailListID, true,false, subUnsubSuccess, subUnsubFailure, '-m' + mailListID); else NotifyMeAjax.AddSubscriptionEmail(emailAddress, mailListID, subUnsubSuccess, subUnsubFailure, '+m' + mailListID); } else subUnsubFailure(); } } else { alert('You must sign in to subscribe to or unsubscribe from lists.'); if(!isNotifyMeSignInRequired) document.getElementById('emailAddressSignIn').focus(); } } function signIn() { /// Invoked to sign-in to Notify Me. this._signIn = signIn; signIn = function () { alert('Your sign-in process is pending. Please wait...') }; var emailAddressSignIn = document.getElementById('emailAddressSignIn'); var fnFail = function (message) { alert(message); signIn = this._signIn; emailAddressSignIn.focus(); }; if (!emailValidate(emailAddressSignIn.value)) fnFail('Email address does not appear to be valid. Please check what you have entered.'); else { var email = emailAddressSignIn.value; NotifyMeAjax.EnsureProfileExists(email, "", signInSuccess, signInFailure, emailAddressSignIn.value); NotifyMeAjax.CheckUserForSMSAlert(email, function (result) { $('a[id^="ahrefSMS"]').css('display', result ? 'block' : 'none'); }); } } function signOut() { /// Invoked to sign-out of Notify Me. var emailAddressSignIn = document.getElementById('emailAddressSignIn'); emailAddressSignIn.value = ''; document.aspnetForm.EMAIL.value = ''; document.aspnetForm.ACCTID.value = ''; document.aspnetForm.SMS.value = ''; document.getElementById('divSignIn').style.display = 'block'; document.getElementById('divManage').style.display = 'none'; spnBounce.innerHTML = ''; spnBounce.style.display = 'none'; refreshLists(); } function saveSMSSuccess(result, userContext) { /// Callback executed when request to update stored SMS number is successfully made. /// Result from call to server. /// An arbitrary string passed to the server request routine. var phoneField = document.getElementById('phoneNumber'); var BULLET_CHAR = '\u25CF'; if (result) { //Bring profile details back from server as we are saving both phone number and address details on click of 'Save' and 'Save Profile Information' if (profileEditor) NotifyMeAjax.GetMinProfileInfo(document.aspnetForm.EMAIL.value, getMinInfoSuccess, function () { }); var refreshListSection = (document.aspnetForm.SMS.value == '' || phoneField.value == ''); document.aspnetForm.SMS.value = phoneField.value; if ($(divSMSDetails).is(':hidden')) { if (phoneField.value != '') { phoneField.value = phoneObfuscate(phoneField.value, BULLET_CHAR); } else { ysnSMS.checked = false; } } phoneFieldDirty = false; alert('Your subscription details have been updated.'); if (phoneField.value === '') { ysnSMS.checked = false; ToggleSMSDetails(null, false, false); } else { toggleSaveMobileNumberButton(false); } if (refreshListSection) refreshLists(); } else { alert('The SMS number could not be updated.'); phoneField.focus(); } } function saveSMSFailure(error, userContext) { /// Callback executed when request to update stored SMS number fails. /// Error object from server. alert('An error occurred and the SMS number could not be updated!'); } function checkForBulletChar(addressField) { var bullchar = '\u25CF'; if (addressField.indexOf(bullchar) >= 0) return true; else return false; } function saveSMSProfile() { /// Invoked when user clicks Save SMS link after editing their SMS number. Updates number stored for account. if (profileEditor && document.getElementById('fstFullProfile').style.display != 'none') { var oldAddressDetailsNotEmpty = !((('' + profileAddressDetails.FirstName + profileAddressDetails.LastName + profileAddressDetails.AddressLine1 + profileAddressDetails.AddressLine2 + profileAddressDetails.City + profileAddressDetails.PostalCode + profileAddressDetails.How).trim() == '') && (profileAddressDetails.State == 'zz' || (profileAddressDetails.State + '') == '')); var problems = new Array(); profileAddressDetails.FirstName = document.getElementById('firstName').value; profileAddressDetails.LastName = document.getElementById('lastName').value; profileAddressDetails.How = document.getElementById('how').value; if (!checkForBulletChar(document.getElementById('addressLine1').value)) profileAddressDetails.AddressLine1 = document.getElementById('addressLine1').value; else { if (profileAddressDetails.AddressLine1.length != document.getElementById('addressLine1').value.length) { problems.push('Address Line 1: You must update the entire field.'); } } if (!checkForBulletChar(document.getElementById('addressLine2').value)) profileAddressDetails.AddressLine2 = document.getElementById('addressLine2').value; else { if (profileAddressDetails.AddressLine2.length != document.getElementById('addressLine2').value.length) { problems.push('Address Line 2: You must update the entire field.'); } } if (!checkForBulletChar(document.getElementById('city').value)) profileAddressDetails.City = document.getElementById('city').value; else { if (profileAddressDetails.City.length != document.getElementById('city').value.length) { problems.push('City: You must update the entire field.'); } } if (!checkForBulletChar(document.getElementById('txtState').value)) profileAddressDetails.State = document.getElementById('txtState').value; else { if (profileAddressDetails.State.length != document.getElementById('txtState').value.length) { problems.push('State: You must update the entire field.'); } } if (!checkForBulletChar(document.getElementById('postalCode').value)) profileAddressDetails.PostalCode = document.getElementById('postalCode').value; else { if (profileAddressDetails.PostalCode.length != document.getElementById('postalCode').value.length) { problems.push('Postal Code: You must update the entire field.'); } } var profileDirty = !((('' + profileAddressDetails.FirstName + profileAddressDetails.LastName + profileAddressDetails.AddressLine1 + profileAddressDetails.AddressLine2 + profileAddressDetails.City + profileAddressDetails.PostalCode + profileAddressDetails.How).trim() == '') && (profileAddressDetails.State == 'zz' || (profileAddressDetails.State + '') == '')); if (!nullWhitespaceOrEmpty(profileAddressDetails.PostalCode) && !isZipCode(profileAddressDetails.PostalCode, intCountryCode)) { var codeName = (intCountryCode == 840 ? "ZIP" : "postal"); problems.push('The ' + codeName + ' code you entered is not valid.'); document.getElementById('postalCode').focus(); } if (!nullWhitespaceOrEmpty(profileAddressDetails.City) && nullWhitespaceOrEmpty(profileAddressDetails.State)) { problems.push('A state must be entered if a city is specified.'); document.getElementById('txtState').focus(); } if (problems.length > 0) { alert('Please correct these profile issues:\r\n\r\n* ' + problems.join('\r\n* ')); return; } //If previous and new profile address details are empty, no need to update the profile. else if (profileDirty || oldAddressDetailsNotEmpty) { var emailAddress = document.aspnetForm.EMAIL.value; NotifyMeAjax.UpdateProfile(emailAddress, profileAddressDetails.FirstName, profileAddressDetails.LastName, profileAddressDetails.AddressLine1, profileAddressDetails.AddressLine2, profileAddressDetails.City, profileAddressDetails.State, profileAddressDetails.PostalCode, profileAddressDetails.How, profileSaveSuccess, profileSaveFailure); } } if (phoneFieldDirty && document.getElementById('phoneNumber') != null) { var onValidNumber = function (newPhoneNumber) { var emailAddress = document.aspnetForm.EMAIL.value; NotifyMeAjax.UpdateSMSNumber(emailAddress, newPhoneNumber, saveSMSSuccess, saveSMSFailure); phoneNumberPlainText = newPhoneNumber; } validatePhoneInput(onValidNumber); } } function validatePhoneInput(onSuccess) { /// Validates phone number entered in UI. Displays alerts to user if data is missing or invalid. /// Function to execute if phone number validates successful. var newPhoneNumberField = document.getElementById('phoneNumber'); var newPhoneNumber = (newPhoneNumberField.value + '').trim(); var newEmailAddress = (document.getElementById('emailAddressManage').value + '').trim(); // Check for duplicate number in database NotifyMeAjax.CheckSMSNumber(newEmailAddress, newPhoneNumber, function (flag) { if (!flag) { alert('The phone number you entered is already registered with another email address.'); newPhoneNumberField.focus(); } else { if (newPhoneNumber != '' && !phoneValidate(newPhoneNumber)) { alert('Please enter a valid U.S. or Canadian phone number in the format shown.'); newPhoneNumberField.focus(); } else if (phoneStripFormatting(newPhoneNumber) == '5555550123') { alert('The example number is fictional and cannot not be used.'); newPhoneNumberField.focus(); } else { newPhoneNumberField.value = newPhoneNumber; onSuccess(newPhoneNumber); } } }); } function profileSaveSuccess(result, userContext) { /// Callback executed when request profile update is successfully made. /// Result from call to server. /// An arbitrary string passed to the server request routine. if (result) { fullProfileFieldSet = document.getElementById('fstFullProfile'); fullProfileFieldSet.style.display = ''; //If we are updating only profile address details and not phone number, only then bring profile details back from server //Otherwise bring it back from saveSMSSuccess if (!phoneFieldDirty) { NotifyMeAjax.GetMinProfileInfo(document.aspnetForm.EMAIL.value, getMinInfoSuccess, function () { }); alert('Your subscription details have been updated.'); } } else alert('Your subscription details could not be updated.'); } function profileSaveFailure(error, userContext) { /// Callback executed when request to update profile fails. /// Error object from server. alert('Your subscription details could not be updated due to error.'); } function nullWhitespaceOrEmpty(value) { /// Returns true if value is null, whitespace, or empty. /// Value to check. return (('' + value).trim() == ''); } function toggleMessageSection(id) { /// Toggles visibility of sections on message view. /// Id of element to toggle message section for. var messageBody = document.getElementById(id); var messageArrow = document.getElementById(id + '_arrow'); if (messageBody.style.display == 'none') { messageBody.style.display = 'block'; messageArrow.innerHTML = '▼'; } else { messageBody.style.display = 'none'; messageArrow.innerHTML = '►'; } } function toggleSaveMobileNumberButton(enable) { var btnSaveProfileInfo = $('#btnSaveProfileInformation'); var BULLET_CHAR = '\u25CF'; var phoneField = document.getElementById('phoneNumber'); if (enable && !isObfuscatedMobileNumber(phoneField.value)) { btnSaveProfileInfo.unbind('click'); btnSaveProfileInfo.removeClass('inactive'); } else { btnSaveProfileInfo.click(function (e) { e.preventDefault(); }); //Obfuscate the number if (phoneField.value != '' && !isObfuscatedMobileNumber(phoneField.value)) { phoneField.value = phoneObfuscate(phoneField.value, BULLET_CHAR); } btnSaveProfileInfo.addClass('inactive'); } } //returns true if validated else false //expected value ●●●-●●●-4562 function isObfuscatedMobileNumber(mobilenumber) { var BULLET_CHAR = '\u25CF'; if (mobilenumber != '' && mobilenumber != undefined && mobilenumber.indexOf(BULLET_CHAR) !== -1) { return true; } return false; } function SmsCheckbox_CheckedSuccess(result, userContext) { var ACTUAL_SMS_NUMBER = 4; var OBFUSC_SMS_NUMBER = 0; if (document.getElementById('phoneNumber') != null) { document.getElementById('phoneNumber').value = result[OBFUSC_SMS_NUMBER]; phoneFieldDirty = false; } if (result[ACTUAL_SMS_NUMBER] != null && result[ACTUAL_SMS_NUMBER] != undefined && result[ACTUAL_SMS_NUMBER] != '') { phoneNumberPlainText = result[ACTUAL_SMS_NUMBER]; toggleSaveMobileNumberButton(false); } else { toggleSaveMobileNumberButton(true); } } function UnsubscribeAll() { var emailAddress = document.aspnetForm.EMAIL.value; var mailList = [-1]; if (typeof subInfo !== 'undefined') { for (var element in subInfo) { if (element.isEmail || element.isSMS) { mailList.add(element.mid); } } } var loggedIn = (document.aspnetForm.EMAIL.value + '' !== ''); if (loggedIn) { if (confirm("Are you sure you want to unsubscribe from all lists?")) { NotifyMeAjax.RemoveAllSubscriptions(emailAddress, mailList, removeAllSubscriptionsSuccess, removeAllSubscriptionsFail); } } } function removeAllSubscriptionsSuccess(result, userContext) { if (result) { invalidateNMLists(); refreshLists(); } } function removeAllSubscriptionsFail(error, userContext) { alert('Your subscription details could not be updated due to error.'); } function onAccordionClick(panelName) { if ($('.' + panelName).css('display') === "block") { $('p#SubscribeToolTip').remove(); $('.' + panelName).css('display', 'none'); $('.' + panelName).parent().find('span.notifyMeAccordionArrow').html("►"); } else { $('.' + panelName).css('display', 'block'); $('.' + panelName).parent().find('span.notifyMeAccordionArrow').html("▼"); $('p#SubscribeToolTip').remove(); } }; window.pageHandleResponsive = true; $.when(window.Pages.rwdReady).done(function () { var $mainContent = $('.newCP.moduleContentNew#notifyMeContent'); toggleClassMedia('maxWidth350px', '#notifyMeContent:media(this-max-width:350px)'); toggleClassMedia('maxWidth400px', '#notifyMeContent:media(this-max-width:400px)'); toggleClassMedia('maxWidth550px', '#notifyMeContent:media(this-max-width:550px)'); });