1/**************************************************************************************** 2========================================================================================= 3 Location Type: Template 4 5 Location1 Name: IAC Base 6 Location1 URL: /862f0c98-6dec-6388-bcc1-ff0000f88fcc 7 8 Location2 Name: IAC Stand Alone 9 Location2 URL: /dcf70b98-6dec-6388-bcc1-ff0000f88fcc 10========================================================================================= 11****************************************************************************************/ 12/* 2022-04-25: Copy of /assets/scripts/b4.common.min.js */ 13 14/** 15 * Global Variables & Functions 16 */ 17var lang = getLanguage(), 18 french = isFrench(); 19 20if (!String.prototype.startsWith) { 21 String.prototype.startsWith = function(searchString, position) { 22 position = position || 0; 23 return this.indexOf(searchString, position) == position; 24 }; 25} 26 27/** 28 * 29 * @param {object} e HTML event that triggered the function (click) 30 * @param {boolean} excludeReferrer If true, does NOT append current URL as ?ReturnUrl 31 * @param {boolean} bypassLogin If true, goes directly to Okta login page. 32 * @param {boolean} logoutFirst If true, triggers logout before redirecting to login page. 33 * @param {string} returnUrl If provided, uses this url instead of the current href. 34 */ 35function DECLogin(e, excludeReferrer, bypassLogin, logoutFirst, returnUrl) { 36 if (excludeReferrer == null) excludeReferrer = false; 37 if (bypassLogin == null) bypassLogin = false; 38 if (logoutFirst == null) logoutFirst = false; 39 if (e && e.preventDefault) e.preventDefault(); 40 41 const explicitPathsForExcludingReferrer = [ 42 "/advisor-hub/user/register_advisor", "/fr/carrefour-des-conseilles/user/inscription", 43 "/error/403", "/error/404", "/error/500", "/fr/error/403", "/fr/error/404", "/fr/error/500", 44 "/auth/password-change", "/auth/email-changed", "/fr/auth/changement-de-mot-de-passe", "/fr/auth/email-modifie", 45 "/auth/no-access", "/auth/logged-out", 46 ]; 47 excludeReferrer = explicitPathsForExcludingReferrer.includes(window.location.pathname); 48 49 var params = {}; 50 if (returnUrl) params.ReturnUrl = returnUrl; 51 else if (!excludeReferrer) params.ReturnUrl = window.location.href; 52 if (bypassLogin) params.bp = 1; 53 var querystring = new URLSearchParams(params); 54 var loginUrl = iac.utility.loginUrl + (querystring.size > 0 ? "?" + querystring : ""); 55 56 if (logoutFirst && iac.user.Id !== EMPTYGUID) { 57 Cookies.set("postLogoutRedirectUrl", loginUrl); 58 window.location = iac.utility.logoutUrl; 59 } 60 else { 61 window.location = loginUrl; 62 } 63} 64 65/** 66 * This function redirects the user to the Advisor Registration page - but comes with extended functionality through additional parameters. 67 * @param {object} e HTML event that triggered the function (click) 68 * @param {string} returnUrl If provided, will save the url as a Cookie to be saved to the users profile after they complete Registration. 69 * When they complete their Okta MFA setup, they will be redirected appropriately 70 */ 71function DECRegister(e, returnUrl) { 72 Cookies.set("ReturnUrl", returnUrl); 73} 74 75function getUrlParameter(sParam) { 76 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 77 sURLVariables = sPageURL.split('&'), 78 sParameterName, 79 i; 80 81 for (i = 0; i < sURLVariables.length; i++) { 82 sParameterName = sURLVariables[i].split('='); 83 84 if (sParameterName[0] == sParam) { 85 return sParameterName[1] == undefined ? true : sParameterName[1]; 86 } 87 } 88} 89 90function detectLang() { 91 // ADDED 2022-05-12: route via iac.helpers.js 92 return getLanguage(); 93} 94 95(function () { 96 french = isFrench(); 97 98 /** 99 * MISC 100 * 1) LinkRewriter 101 * 2) Email lowercase and trim 102 */ 103 $(document).ready(function () { 104 // 2022-06-10 IAC: NEW LinkRewriter for new Global.asax.cs EnvironmentMappings 105 if (window.location.host !== "iaclarington.com") { 106 rewriteAllIACLinks(); 107 } 108 109 // Auto Lowercase Email / Username Inputs on Forms. 110 $('input#UserName').bind("change keyup input", function () { 111 $(this).val($(this).val().toLowerCase().trim()); 112 }); 113 114 $('input#Email').bind("change keyup input", function () { 115 $(this).val($(this).val().toLowerCase().trim()); 116 }); 117 });
118 119 /** 120 * Converts all PROD links to their equivalent DEV/UAT link. 121 */ 122 function rewriteAllIACLinks() { 123 linkRewriter('https://iaclarington.com', iac.sso.pub); 124 linkRewriter('https://saleshub.iaclarington.com', iac.sso.shub); 125 linkRewriter('https://fds2.iaclarington.com', iac.funds.fds); 126 linkRewriter('https://ccm.ifglobalproducts.com', iac.sso.ccm); 127 linkRewriter('https://iac.ifglobalproducts.com', iac.sso.iac); 128 linkRewriter('https://login.iaclarington.com', iac.sso.idp); 129 } 130 131 /** 132 * Converts all PROD links to their equivalent DEV/UAT link. 133 * @param {string} linkToChange Non-encoded link that needs replacement. 134 * @param {string} replacement Non-encoded link to change to. 135 */ 136 function linkRewriter(linkToChange, replacement) { 137 var baseLinks = $(`[href*='${linkToChange}']`); 138 baseLinks.each(function () { 139 $(this).attr('href', $(this).attr('href').replace(linkToChange, replacement)); 140 }); 141 var languageSelectorInput = $(`input[data-sf-role="en"][value*='${linkToChange}']`); 142 if (languageSelectorInput.length) languageSelectorInput.val(languageSelectorInput.val()?.replace(linkToChange, replacement)); 143 languageSelectorInput = $(`input[data-sf-role="fr"][value*='${linkToChange}']`); 144 if (languageSelectorInput.length) languageSelectorInput.val(languageSelectorInput.val()?.replace(linkToChange, replacement)); 145 }; 146 147 148 /** 149 * Custom iac:userready: (Fires after Document.Ready and after AdvisorHubMenu is rendered) 150 * 1) User Probation Logic 151 * 2) Show/Hide of Advisor content based on access level 152 */ 153 var loginPageUrl = french ? "/fr/carrefour-des-conseillers/ouverture-de-session" : "/advisor-hub/login"; 154 $(document).on("iac:userready", function () { 155 try { 156 if (iac.user.HasAdvisorAccess) { 157 showMessagingIfInvalidAdvisorCodes(); 158 if (document.readyState === "loading") { 159 $(document).ready(transformContentForAdvisorAudience); // DEVNOTE: There are scenarioes where userready is firing before document.ready (uncommon). 160 } 161 else { 162 transformContentForAdvisorAudience(); 163 } 164 } 165 else { 166 if (document.readyState === "loading") { 167 $(document).ready(transformContentForInvestorAudience); // DEVNOTE: There are scenarioes where userready is firing before document.ready (uncommon). 168 } 169 else { 170 transformContentForInvestorAudience(); 171 } 172 } 173 } 174 catch (ex) { 175 console.log(ex); 176 } 177 }); 178 179 function transformContentForAdvisorAudience() { 180 // UI Updates for Advisors 181 $('a').removeClass('lock-link lock-link-white'); 182 } 183 184 function transformContentForInvestorAudience() { 185 $(".lock-link, .lock-link-white").each(function () { 186 try { 187 var thisLink = $(this); 188 var linkHref = thisLink.attr('href'); 189 if (!linkHref) throw ".lock-link class is being used on an invalid HTML element. This class only functions on <a> elements."; 190 191 var isAbsoluteLink = linkHref.startsWith("http://") > 0 || linkHref.startsWith("https://") > 0, 192 isRelativeLink = linkHref.startsWith('/') > 0; 193 194 var loginPageHref = loginPageUrl + "?ReturnUrl="; 195 if (isAbsoluteLink) loginPageHref += encodeURIComponent(linkHref); 196 else if (isRelativeLink) loginPageHref += encodeURIComponent(iac.sso.pub + linkHref); 197 else loginPageHref += encodeURIComponent(window.location.href); 198 thisLink.attr("href", loginPageHref); 199 } 200 catch (ex) { 201 console.log(ex); 202 } 203 }); 204 } 205 206 function showMessagingIfInvalidAdvisorCodes() { 207 try { 208 var isUserOnProbation = Cookies.get('user_status') === "Probation", 209 hasUserAlreadySeenNotificationPage = Cookies.get('user_status_notified') === "Notified"; 210 211 if (isUserOnProbation) { 212 if (hasUserAlreadySeenNotificationPage) { 213 $('#inactive_dealer_rep_notification').show(); 214 } 215 else { 216 Cookies.set('user_status_notified', "Notified"); 217 var notificationUrlBase = french ? "/fr/carrefour-des-conseillers
217/user/notification-de-compte" : "/advisor-hub/user/account-notification"; 218 window.location = notificationUrlBase; 219 } 220 } 221 else if (hasUserAlreadySeenNotificationPage) { 222 Cookies.remove("user_status_notified"); 223 } 224 } 225 catch (ex) { 226 console.log(); 227 } 228 } 229})();
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.