1/** 2 * @file 3 * Course Finder Plus instantiation code 4 */ 5'use strict'; 6(function (settings) { 7 function initializeCourseFinderPlus() { 8 const cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)klg\.features\.CourseFinderPlusExperiment\s*\=\s*([^;]*).*$)|^.*$/, "$1"); 9 // Only load Course Finder Plus if the experiment cookie is set to 'true'. 10 if (cookieValue?.toLowerCase() !== 'true') { 11 return; 12 } 13 let queryString; 14 const container = document.querySelector('#course-finder-plus-container'); 15 16 // Get the content type from drupalSettings 17 const languageId = settings?.components?.course_finder_plus?.languageId || undefined; 18 const countryId = settings?.components?.course_finder_plus?.countryId || undefined; 19 const purposeId = settings?.components?.course_finder_plus?.purposeId || undefined; 20 21 const preselectedFilters = { 22 language: languageId || undefined, 23 purpose: purposeId === 'all' ? '' : (purposeId || undefined), 24 destination: countryId || undefined, 25 }; 26 27 const cfElement = elementLoader.load('klg-course-finder-plus', 28 { 29 preselectedFilters: preselectedFilters 30 }, 31 { 32 searchFiltersChanged: (searchParams) => { 33 queryString = Object.keys(searchParams.detail).map(function(key) { 34 return key + '=' + searchParams.detail[key]; 35 }).join('&'); 36 37 // Check if the URL is properly configured in drupalSettings 38 const resultsUrl = settings?.components?.course_finder_plus?.url || '/course-finder'; 39 window.location.href = resultsUrl + '?' + queryString; 40 } 41 } 42 ); 43 container.appendChild(cfElement); 44 } 45 window.addEventListener('load', () => initializeCourseFinderPlus()); 46})(drupalSettings);
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.