function addScript(src, callback) { if (!document.getElementById('iframe-resizer-script')) { var scriptElement = document.createElement('script'); scriptElement.setAttribute('id', 'iframe-resizer-script'); scriptElement.setAttribute('src', src); scriptElement.onload = callback; scriptElement.onerror = function () { console.error(`failed to load iframe resizer script`); }; document.getElementsByTagName('head')[0].appendChild(scriptElement); } else { setTimeout(callback, 750); } } function initializeScripts(id, url) { addScript(`${url}/iframeResizer.min.js`, function () { iFrameResize( { heightCalculationMethod: 'taggedElement', log: false, targetOrigin: '*' }, `#${id}` ); }); } // "initialize" was misspelled in previous iterations of the embed code // This can't be removed without breaking client implementations of the widget. function initalizeScripts(id, url) { return initializeScripts(id, url); } function generateWidget({ clientId, hasCareerList, hasEmployment, hasAllLocations, hasImages, hasJobOpenings, hasNationalData, hasOutlook, hasSkills, hasVisitButton, hasWages, id, isHourlyWage, isQa, labelSet, locationName, orderCareersBy, primaryColor, programs, title, version, visitButtonColor, headingText = '', stylesheetHref }) { const widgetIframe = document.createElement('iframe'); widgetIframe.setAttribute('title', title); widgetIframe.setAttribute('id', id); widgetIframe.setAttribute('data-cy', id); widgetIframe.setAttribute('style', 'border: 0; min-width: 100%; width: 1px'); widgetIframe.setAttribute( 'onload', `initializeScripts('${id}', 'https://widget.lightcastcc-qa.com')` ); widgetIframe.setAttribute( 'src', `https://widget.lightcastcc${ isQa ? '-qa' : '' }.com?hasCareerList=${hasCareerList}&hasEmployment=${hasEmployment}&hasAllLocations=${hasAllLocations}&hasImages=${hasImages}&hasJobOpenings=${hasJobOpenings}&hasNationalData=${hasNationalData}&hasOutlook=${hasOutlook}&hasSkills=${hasSkills}&hasVisitButton=${hasVisitButton}&hasWages=${hasWages}&isHourlyWage=${isHourlyWage}&labelSet=${labelSet}&clientId=${clientId}&locationName=${locationName}&orderCareersBy=${orderCareersBy}&primaryColor=${primaryColor}&programs=${programs}&visitButtonColor=${visitButtonColor}&headingText=${ headingText === 'false' || !headingText ? '' : headingText }${!!stylesheetHref ? `&stylesheetHref=${stylesheetHref}` : ''}${ !!version ? `&version=${version}` : '' }` ); const currentDiv = document.getElementById(`${id}-wrapper`); currentDiv.appendChild(widgetIframe); } function generateAlumniWidget({ currentSite, nation, primaryColor, accordionHeadingText, accordionType, carouselHeadingText, clientId, geographyLevel, hasAccordion, hasOverview, hasCarousel, hasSalaryRange, hasLowConfidenceMatches, isOnlyAfterGraduation, overviewHeadingText, selectedCampus, selectedDegreeLevel, selectedGeography, subsequentAttainmentLevel, programs, headingText, selectedCompanies, selectedOccupations, selectedSkills, overview, graduationTimeframe, id, title = 'alumni widget', isQa = 'false' }) { const widgetIframe = document.createElement('iframe'); widgetIframe.setAttribute('title', title); widgetIframe.setAttribute('id', id); widgetIframe.setAttribute('data-cy', id); widgetIframe.setAttribute('style', 'border: 0; min-width: 100%; width: 1px'); widgetIframe.setAttribute( 'onload', `initializeScripts('${id}', 'https://widget.lightcastcc-qa.com')` ); widgetIframe.setAttribute( 'src', `https://widget.lightcastcc${ isQa ? '-qa' : '' }.com/alumni?currentSite=${currentSite}&nation=${nation}&primaryColor=${primaryColor}&accordionHeadingText=${ !!accordionHeadingText ? accordionHeadingText : '' }&accordionType=${accordionType}&carouselHeadingText=${ !!carouselHeadingText ? carouselHeadingText : '' }&clientId=${clientId}&geographyLevel=${geographyLevel}&hasAccordion=${hasAccordion}&hasOverview=${hasOverview}&hasCarousel=${hasCarousel}&hasSalaryRange=${hasSalaryRange}&hasLowConfidenceMatches=${hasLowConfidenceMatches}&isOnlyAfterGraduation=${isOnlyAfterGraduation}&overviewHeadingText=${ !!overviewHeadingText ? overviewHeadingText : '' }&selectedCampus=${selectedCampus}&selectedDegreeLevel=${selectedDegreeLevel}&selectedGeography=${selectedGeography}&subsequentAttainmentLevel=${subsequentAttainmentLevel}&programs=${programs}&headingText=${ !!headingText ? headingText : '' }&selectedCompanies=${selectedCompanies}&selectedOccupations=${selectedOccupations}&selectedSkills=${selectedSkills}&overview=${overview}&graduationTimeframe=${graduationTimeframe}&id=${id}` ); const currentDiv = document.getElementById(`${id}-wrapper`); currentDiv.appendChild(widgetIframe); }