PageSourceSearch

https://www.commonwealthsportfoundation.com/resources/cgf/v1.54.1/widgets/cgf_onboarding.js

js commonwealthsportfoundation.com collected 2026-10-01 02:45:06 UTC 16,041 bytes, 1 lines download raw bytes

1"use strict";PULSE.app.templates["onboarding.modal"]=_.template('<section class="onboarding photo-modal js-onboarding-modal"> <div class="onboarding__container wrapper" data-modal-action="close"> <button data-modal-action="close" class="onboarding__close js-close" tabindex="0" aria-label="<%= PULSE.I18N.lookupKey( \'label.modalClose\', \'\' ) %>"> <%= render( { cssClass: \'onboarding__close-icon\', name: \'cross\' },\n            \'common.render-svg\' ) %> </button> <div class="onboarding__header"> <%= render( { cssClass: \'onboarding__celebration-mark\', name:\n            \'celebration-mark\' }, \'common.render-svg\' ) %> <h2 class="onboarding__title"> <%= PULSE.I18N.lookupKey( \'label.onboarding.title\', \'\' ) %> </h2> </div> <div class="onboarding__content js-onboarding-content"></div> <div class="onboarding__nav"> <p class="onboarding__preferences-info"> <%= PULSE.I18N.lookupKey( \'label.onboarding.preferencesInfo\', \'\'\n                ) %> </p> <div class="onboarding__button-container"> <button class="js-back button button--secondary"> <span class="js-title title"><%= PULSE.I18N.lookupKey( \'label.modalClose\', \'\' )\n                        %></span> </button> <button class="js-next button"> <% if( typeof singularScreen && singularScreen === true ) {\n                    %> <span class="u-hide-tablet"><%= PULSE.I18N.lookupKey( \'label.button.saveChanges\',\n                        \'\' ) %></span> <span class="u-show-tablet"><%= PULSE.I18N.lookupKey( \'label.button.save\', \'\' )\n                        %></span> <% } else { %> <span class="js-title title"><%= PULSE.I18N.lookupKey(\n                        \'label.button.next\', \'\' ) %></span> <% } %> </button> </div> <div class="onboarding__pagination u-hide"> <span class="onboarding__pagination-item js-onboarding-pagination is-active"></span> <span class="onboarding__pagination-item js-onboarding-pagination"></span> <span class="onboarding__pagination-item js-onboarding-pagination"></span> </div> </div> </div> </section> '),PULSE.app.templates["onboarding.profile"]=_.template('<div class="preferences__games js-onboarding-content-profile u-hide"> <h3 class="preferences__title preferences__title--profile"> <%= PULSE.I18N.lookupKey( \'label.preferences.profile.attendingGames\', \'\'\n        ) %> </h3> <ul class="preferences__games-list"> <% _.each( data, function( item ) { %> <li class="preferences__games-item <% if (item.isActive) { %>is-active<% } %>"> <button class="preferences__games-button js-preference-button" data-code="<%= item.id %>" data-description="<%= item.label %>" aria-label="<%= item.label %>" aria-pressed="<% if (item.isActive) { %>true<% } else { %>false<% } %>"> <% if (item.id === "cwg2027" || item.id === "cwg2030") { %> <div class="preferences__games-icon-cwg preferences__games-icon-cwg--<%= item.id %>"></div> <div class="preferences__games-label"> <%= PULSE.I18N.lookupKey(\n                        \'label.preferences.profile.attendingGames.\' + item.id, \'\' ) %> </div> <% } %> <% if (item.id === "none") { %> <%= render( { cssClass:\n                \'preferences__games-icon-none\', name: \'play-tv\' },\n                \'common.render-svg\' ) %> <div class="preferences__games-label"> <%= PULSE.I18N.lookupKey(\n                        \'label.preferences.profile.attendingGames.none\', \'\' ) %> </div> <% } %> </button> </li> <% } ); %> </ul> </div> '),PULSE.app.templates["onboarding.sports"]=_.template('<div class="preferences__sports js-onboarding-content-sports u-hide"> <h3 class="preferences__title"><%= PULSE.I18N.lookupKey( \'label.preferences.sports.title\', \'\' ) %></h3> <input type="text" class="js-sports-search preferences__search" placeholder="<%= PULSE.I18N.lookupKey( \'label.preferences.sports.search\', \'\' ) %>"> <% if (data.isGlasgow) { %> <div class="preferences__legend"> <%= render( { cssClass: \'preferences__icon-star preferences__icon-star--legend\', name: \'star\' },\n            \'common.render-svg\' ) %> <span class="preferences__legend-text"><%= PULSE.I18N.lookupKey( \'label.preferences.sports.inGames\', \'\' ) %></span> </div> <% } %> <ul class="preferences__list"> <% _.each( data, function( item ) { %> <li class="preferences__list-item <% if (item.isActive) { %>is-active<% } %>"> <button class="preferences__button js-preference-button" data-code="<%= item.id %>" data-description="<%= item.label %>" aria-label="<%= item.label %>" aria-pressed="<% if (item.isActive) { %>true<% } else { %>false<% } %>"> <div data-code="<%= item.id %>" class="preferences__icon"></div> <%= item.label %> <% if (item.isGames && data.isGlasgow) { %> <%= render( { cssClass: \'preferences__icon-star\', name: \'star\' },\n                        \'common.render-svg\' ) %> <% } %> </button> </li> <% } ); %> </ul> </div>'),PULSE.app.templates["onboarding.teams"]=_.template('<div class="preferences__teams js-onboarding-content-teams u-hide"> <h3 class="preferences__title"> <%= PULSE.I18N.lookupKey( \'label.preferences.teams.title\', \'\' ) %> </h3> <input type="text" class="js-teams-search preferences__search" placeholder="<%= PULSE.I18N.lookupKey( \'label.preferences.teams.search\', \'\' ) %>"> <ul class="preferences__list"> <% _.each( data, function( item ) { %> <li class="preferences__list-item <% if (item.isActive) { %>is-active<% } %>"> <button class="preferences__button js-preference-button" data-code="<%= item.id %>" data-description="<%= item.label %>" aria-label="<%= item.label %>" aria-pressed="<% if (item.isActive) { %>true<% } else { %>false<% } %>"> <img class="preferences__flag" src="https://static-files.birmingham2022.com/photos/flags/<%= item.id %>.png" loading="lazy"> <%= item.label %> </button> </li> <% } ); %> </ul> </div> '),function(e,t,s,n){const i={CONTENT:".js-onboarding-content",CONTENT_PROFILE:".js-onboarding-content-profile",CONTENT_TEAMS:".js-onboarding-content-teams",CONTENT_SPORTS:".js-onboarding-content-sports",NEXT:".js-next",CLOSE_SKIP:".js-close",SKIP:".js-skip",BACK:".js-back",TITLE:".js-title",MODAL_SELECTOR:".js-onboarding-modal",BUTTON:".js-preference-button",BUTTON_GAMES:".js-preference-games-button",PAGINATOR:".js-onboarding-pagination"},a={MODAL:"onboarding.modal",PROFILE:"onboarding.profile",TEAMS:"onboarding.teams",SPORTS:"onboarding.sports"},r=[{PROFILE:"attending-games"},{TEAMS:"favourite-country"},{SPORTS:"favourite-sport"}],o={KEY:"attending-games",LEGACY_ID:"cwg",IDS:["cwg2027","cwg2030"]};e.Onboarding=class{constructor(){this.container=document.querySelector(".js-onboarding"),this.preferencesSdk=this.createPreferencesSdk(),this.isGlasgow="site:Glasgow 2026"===t.getSiteTag(),this.preferencesSdk&&this.init()}createPreferencesSdk(){let t;return window.pulseliveID?.Preferences&&(t=new window.pulseliveID.Preferences("cwg",async function(){return await e.SSO.updateToken(),await e.SSO.token})),t}init(){this.screenIndex=this.getScreenIndexFromURL(),void 0===this.screenIndex?(this.screenIndex=0,this.singularScreen=!1):this.singularScreen=!0,this.renderModal(),this.fetchPreferences()}renderModal(){const n={singularScreen:this.singularScreen};this.container.innerHTML=e.templating.render(n,a.MODAL),t.bodyScroll.disable(),this.content=this.container.querySelector(i.CONTENT),this.close=this.container.querySelector(i.CLOSE_SKIP),this.skip=this.container.querySelector(i.SKIP),this.back=this.container.querySelector(i.BACK),this.back&&(this.backTitle=this.back.querySelector(i.TITLE)),this.next=this.container.querySelector(i.NEXT),this.next&&(this.nextTitle=this.next.querySelector(i.TITLE)),this.modal=this.container.querySelector(i.MODAL_SELECTOR),this.modal&&(0===this.screenIndex?s.style.addClass(this.modal,"onboarding--profile"):s.style.removeClass(this.modal,"onboarding--profile")),this.singularScreen||(this.paginatorItems=this.container.querySelectorAll(i.PAGINATOR),this.paginatorItems?.[0]?.parentElement&&s.style.removeClass(this.paginatorItems[0].parentElement,"u-hide")),this.container&&s.style.addClass(this.container,"onboarding-wrapper--open"),this.setListeners()}renderPaginatorItems(){this.paginatorItems&&this.paginatorItems.length&&this.paginatorItems.forEac
1h((e,t)=>{this.screenIndex===t?s.style.addClass(e,"is-active"):s.style.removeClass(e,"is-active")})}async renderModalContents(s){let o=this.getModelContentsKeys(),l=this.getModelContentsValues(),c={};if(Array.isArray(s)&&s.length){let e={"attending-games":{key:"attending-games",label:"Attending Games",values:[]},"favourite-country":{key:"favourite-country",label:"Favourite Country",values:[]},"favourite-sport":{key:"favourite-sport",label:"Favourite Sport",values:[]}};this.favourites=await this.getUserPreferences(o),o.forEach(t=>{this.favourites.find(e=>e.key===t)||this.favourites.push(e[t])}),o.forEach(e=>{c[e]=this.favourites.find(t=>t.key===e)})}if(this.favourites&&o.length===r.length&&l.length===r.length){this.buttons={},this.filterInput={};const r=Object.keys(n.PREFERENCES_SPORTS_GAMES);o.forEach((t,n)=>{let i;if(i=s.find(e=>e.key&&e.key===t),i&&i.values){let s={};s.data=i.values,s.data.forEach(e=>{delete e.isActive,c[t].values.forEach(t=>{t.id===e.id&&(e.isActive=!0)}),e.isGames=r.includes(e.id)}),s.data.isGlasgow=this.isGlasgow,this.content.innerHTML+=e.templating.render(s,a[l[n]])}}),l.forEach((e,s)=>{this.buttons[e]=this.content.querySelectorAll(`${i["CONTENT_"+e]} ${i.BUTTON}`),t.addMultiAriaClickListener(this.buttons[e],this.clickItem.bind(this,o[s],c[o[s]].values)),"PROFILE"!==e&&(this.filterInput[e]=this.content.querySelector(`.js-${e.toLowerCase()}-search`),this.filterInput[e]&&this.filterInput[e].addEventListener("keyup",this.searchList.bind(this,e)))})}}setListeners(){this.close&&t.addAriaClickListener(this.close,this.onClose.bind(this)),this.back&&t.addAriaClickListener(this.back,this.onBack.bind(this)),this.skip&&t.addAriaClickListener(this.skip,this.onSkip.bind(this)),this.next&&t.addAriaClickListener(this.next,this.onNext.bind(this))}clickItem(e,t,n){this.modalInitialValues||(this.modalInitialValues={},this.modalInitialValues[e]=JSON.parse(JSON.stringify(t))),n.preventDefault();const a=n.currentTarget,r=a.parentElement,l=a.getAttribute("data-code"),c=a.getAttribute("data-description"),d=t.findIndex(e=>e.id===l);if("none"===l)-1===d&&this.unselectAllExcept(t,r);else{const e=t.findIndex(e=>"none"===e.id);if(e>=0&&a?.parentElement?.parentElement){const s=a.parentElement.parentElement.querySelector(`${i.BUTTON}[data-code='none']`).parentElement;s&&this.unselect(e,t,s)}}d>-1?this.unselect(d,t,r):(e===o.KEY&&this.unselectAllExcept(t,r),t.push({id:l,label:c}),s.style.addClass(r,"is-active"))}unselect(e,t,n){t.splice(e,1),s.style.removeClass(n,"is-active")}unselectAllExcept(e,t){if(t?.parentElement)for(const e of t.parentElement.children)e!==t&&s.style.removeClass(e,"is-active");if(e?.length)for(;e?.length;)e.pop()}searchList(e,t){if(t?.target&&this.buttons?.[e]){const n=t.target.value.toUpperCase();for(let t=0;t<this.buttons[e].length;t++){const i=this.buttons[e][t].getAttribute("data-description"),a=this.buttons[e][t].parentElement;i.toUpperCase().indexOf(n)>-1?s.style.removeClass(a,"u-hide"):s.style.addClass(a,"u-hide")}}}async getUserPreferences(e){let t;if(t=[],this.preferencesSdk){const s=await this.preferencesSdk.get(),n=await this.migrateLegacyGamesPref(s);s&&(t=this.prepareUserPreferences(e,n))}return t}async migrateLegacyGamesPref(e){if(!Array.isArray(e)||!this.preferencesSdk)return e;const t=e.find(e=>e.slug===o.KEY);if(!t)return e;const s=this.parsePreferenceValue(t.value);if(!(Array.isArray(s)&&s.some(e=>"none"===e.id)))return e;const n=this.getGamesPrefValues([{id:"none"}]);return await this.preferencesSdk.update(t.id,JSON.stringify(n)),e.map(e=>e.slug===o.KEY?{...e,value:JSON.stringify(n)}:e)}prepareUserPreferences(e,t){let s;return s=[],Array.isArray(t)&&t.length&&e.forEach(e=>{let n;const i=t.find(t=>t.slug===e);i&&(n={},n.id=i.id,n.key=e,n.values=this.getPreparedPrefValues(e,i.value),Array.isArray(n.values)&&s.push(n))}),s}setUserPreferences(){if(this.preferencesSdk&&Array.isArray(this.favourites)){const e=this.favourites.map(e=>{const t=e.id;let s;return s=e.key===o.KEY?JSON.stringify(this.getGamesPrefValues(e.values)):JSON.stringify(e.values),t&&s?this.preferencesSdk.update(t,s).catch(e=>(console.warn("[PulseliveSSO] Preferences Error",e),null)):Promise.resolve(null)});Promise.all(e).then(()=>{t.event.fireEvent(t.CONSTANTS.EVENTS.PREFERENCES.FINISH,{},document)})}}parsePreferenceValue(e){if(!e)return null;try{return JSON.parse(e)}catch(e){return null}}getPreparedPrefValues(e,t){const s=this.parsePreferenceValue(t);return e===o.KEY?this.getPreparedGamesValues(s):Array.isArray(s)?s:[]}getPreparedGamesValues(e){return Array.isArray(e)?e.filter(e=>e?.id!==o.LEGACY_ID):e&&"object"==typeof e?o.IDS.filter(t=>e[t]).map(e=>({id:e,label:this.getAttendingGamesLabelById(e)})):[]}getGamesPrefValues(e){const t=Array.isArray(e)?e.map(e=>e.id):[],s=n.PREFERENCES.find(e=>e.key===o.KEY);return(s?.values||[]).filter(e=>t.includes(e.id))}getAttendingGamesLabelById(e){const t=n.PREFERENCES.find(e=>e.key===o.KEY),s=t?.values?.find(t=>
1t.id===e);return s?.label||e}onBack(){this.previousModal()}onSkip(){this.singularScreen?this.closeModal():(this.skipSelection(),this.skipModal())}onNext(){this.singularScreen||this.screenIndex===r.length-1?(this.closeModal(),this.setUserPreferences()):this.skipModal()}onClose(){this.closeModal(),this.setUserPreferences()}fetchPreferences(){const e=n.PREFERENCES;this.renderModalContents(e).then(()=>this.setupScreen()).catch(()=>{console.warn("[PulseliveSSO] Preferences Error")})}setupScreen(){if(s.style.removeClass(this.content,"is-loaded"),this.content?.children?.length>0){let e;for(let t=0;t<this.content.children.length;t++)e=this.content.children[t],e&&(this.screenIndex===t?s.style.removeClass(e,"u-hide"):s.style.addClass(e,"u-hide"))}this.singularScreen||this.renderPaginatorItems(),this.setupScreenButtons(),s.style.addClass(this.content,"is-loaded")}setupScreenButtons(){this.backTitle&&this.nextTitle&&(0===this.screenIndex?this.backTitle.textContent=PULSE.I18N.lookupKey("label.modalClose"):(this.backTitle.textContent=PULSE.I18N.lookupKey("label.button.back"),this.screenIndex===r.length-1?this.nextTitle.textContent=PULSE.I18N.lookupKey("label.button.finish"):this.nextTitle.textContent=PULSE.I18N.lookupKey("label.button.next")))}getModelContentsValues(){return r.map(e=>Object.keys(e)[0])}getModelContentsKeys(){return r.map(e=>Object.values(e)[0])}getScreenIndexFromURL(){let e;const t=new URLSearchParams(window.location.search).get("preferences");if(t){let s,n;r.forEach((i,a)=>{s=Object.keys(i),s&&s.length&&(n=s[0],n&&n===t.toUpperCase()&&(e=a))})}return e}closeModal(){this.modal.remove(),this.modal=null,this.container&&s.style.removeClass(this.container,"onboarding-wrapper--open"),t.bodyScroll.enable()}closeModalRedirect(){this.closeModal(),this.redirect()}previousModal(){this.screenIndex--,this.screenIndex<0?this.onClose():this.setupScreen()}skipModal(){this.screenIndex++,this.screenIndex>=r.length?this.closeModal():this.setupScreen()}skipSelection(){this.favourites&&this.modalInitialValues&&(Object.keys(this.modalInitialValues).forEach(e=>{let t=this.favourites.find(t=>t.key===e);t?.values&&(t.values=this.modalInitialValues[e])}),this.modalInitialValues=null)}redirect(){const e=this.getRedirectUrl();e&&(window.location.href=e)}getRedirectUrl(){let n;const i=new URL(document.location).searchParams.get("redirect_uri");if(i){const a=new URL(decodeURIComponent(i));if(a){let i;window.location.origin&&(i=window.location.origin,window.location.pathname&&(i+=window.location.pathname));let r=a.origin+a.pathname+"?onboarded="+t.CONSTANTS.USER_STATUS.ONBOARDED;i&&(r+=`&redirect_uri=${encodeURIComponent(i)}`),s.localStorage.getStorage("refreshToken",!0)&&e.environment.sso?.id&&(r+=`&client_id=${e.environment.sso.id}&refresh_token=`+s.localStorage.getStorage("refreshToken",!0)),r+="#preferences",n=r}}return n}},document.dispatchEvent(new Event(n.ONBOARDING.READY))}(PULSE.app,PULSE.app.common,PULSE.core,PULSE.app.common.CONSTANTS);

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.