var ipaa = window.ipaa || {}; ipaa.portal = ipaa.portal || {}; ((o) => { o.triggerLoading = () => { $('#loading').show(); } o.stopLoading = () => { $('#loading').hide(); } const selectRoute = (hash) => { if (!hash || hash === "#/") { hash = "/pages/events"; } const url = hash.substring(1, hash.length).toLowerCase(); if(o.ignoredUrls.some(x => url.startsWith(x))){ const currentUrl= new URL(window.location.href); currentUrl.pathname=url; currentUrl.hash=""; window.top.location.href=currentUrl.toString(); return; } const iframe = $('#content-frame'); $("#header a").removeClass("is-checked"); $("#header a").each((i, el) => { const headerLink = $(el); if (url.startsWith(headerLink.attr("href"))) { headerLink.addClass("is-checked"); } }); const iframeHref = iframe.get(0).contentWindow.location.href.toLowerCase(); if (!iframeHref.endsWith(url)) { o.triggerLoading(); iframe.attr("src", url); } } o.handleIFrameLoad = () => { const iframe = $('#content-frame'); iframe.on('load', function () { o.stopLoading(); const iframeLocation = iframe.get(0).contentWindow.location; const iframeRelativeSrc = iframeLocation.pathname + iframeLocation.search; const urls = [iframeRelativeSrc, iframeLocation.href]; const IframeSrc = iframe.attr("src"); if (!urls.includes(IframeSrc)) { if(iframeLocation.pathname && iframeLocation.pathname.toLowerCase()==="/signin"){ window.top.location.href = iframeLocation.href; }else{ const src = iframeLocation.origin === window.top.location.origin ? iframeRelativeSrc : iframeLocation.href; window.top.location.hash = src; } } }); } o.registerRouteHandler = () => { $(window).on('hashchange', () => { const hash = window.location.hash; selectRoute(hash); }); } o.loadInitialHash=()=>{ const hash = window.location.hash; selectRoute(hash); } })(ipaa.portal); $(() => { ipaa.portal.registerRouteHandler(); ipaa.portal.handleIFrameLoad(); ipaa.portal.loadInitialHash(); });