### Get Page Tags Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Returns a predefined string of page tags, typically used for analytics or categorization. ```javascript sl.dataUtils.getPageTags = sl.dataUtils.getPageTags || function() { return "silicon-labs-tags=content-type:software-pages;"; }; ``` -------------------------------- ### JavaScript Utility Functions for Simplicity Studio Source: https://www.silabs.com/developer-tools/simplicity-studio This snippet includes various JavaScript utility functions for Simplicity Studio, such as reading cookies, getting content types, and retrieving profile information. It's used for site-wide functionalities and data retrieval. ```javascript var silabsProfileCookie; silabsprofileCookie = 'silabsprofile'; var sl = sl || {}; var digitalData = digitalData || {}; var pageTags = ""; var aemHierarchy = "content:siliconlabs:en:software-and-tools:simplicity-studio"; sl.currentRunMode = 'prod'; sl.ssoDomain = 'https://community.silabs.com'; sl.ssoEndpointUrl = 'https://community.silabs.com/idp/login?app=0sp16000000PBKn'; sl.registrationUrl = 'https://community.silabs.com/SL_CommunitiesSelfReg'; sl.ssoLogoutUrl = 'https://community.silabs.com/SL_Logout?LOF=https://www.silabs.com/system/sling/logout.html?resource=' + window.location.pathname; //sl.ssoLogoutUrl = sl.ssoLogoutUrl.replace("\u005Bthedomain\u005D",curDomain); //if (sl.currentRunMode == "prod") { // sl.ssoLogoutUrl = "https://siliconlabs.force.com/apex/SL_Logout?LOF=https://" + window.location.hostname + "/system/sling/logout.html?resource=" + window.location.pathname; //} //else { // sl.ssoLogoutUrl = "https://full-siliconlabs.cs67.force.com/apex/SL_Logout?LOF=https://" + window.location.hostname + "/system/sling/logout.html?resource=" + window.location.pathname; //} sl.utils = sl.utils || {}; sl.dataUtils = sl.dataUtils || {}; sl.contentTypeMappings = new Map(); sl.contentTypeMappings.set('/apps/siliconlabs/templates/casestudypage', 'Case Study'); sl.utils.readCookie = sl.utils.readCookie || function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; }; sl.dataUtils.getContentType = sl.dataUtils.getContentType || function() { // TODO: Should this use the content type tag? //return sl.contentTypeMappings.get("\/apps\/siliconlabs\/templates\/genericpage"); var currtags = "content\u002Dtype:software\u002Dpages,silicon\u002Dlabs\u002Dsoftware:development\u002Denvironments\/simplicity\u002Dstudio"; var fndCtype = currtags; if (currtags !== null && typeof currtags != 'undefined') { var tagArr = currtags.split(','); for (var i = 0, length = tagArr.length; i < length; i++) { var currTagVals = tagArr[i].split(':'); if (currTagVals[0] == 'content-type') { return currTagVals[1]; } } } return ""; }; sl.dataUtils.getExperienceLevel = sl.dataUtils.getExperienceLevel || function() { var experienceLevel = ""; return experienceLevel; } sl.dataUtils.getBreadcrumbText = sl.dataUtils.getBreadcrumbText || function() { if (document.getElementById('breadcrumbs') !== null && document.getElementById('breadcrumbs').getElementsByClassName('column')[0].children[0]) { return document.getElementById('breadcrumbs').getElementsByClassName('column')[0].children[0].innerHTML.replace(/<[^>]*>/g, "").trim().replace(/\n/g, '').replace(/\s\s+/g, ' '); } }; sl.dataUtils.getProfileID = sl.dataUtils.getProfileID || function(cookie) { function containsProfileID(str) { return str.indexOf('UserID') > -1; } if (cookie) { var profile = cookie.split('|').filter(containsProfileID); if (profile.length > 0) { return profile[0].split('=')[1]; } } return "unknown"; }; sl.dataUtils.getContactID = sl.dataUtils.getContactID || function(cookie) { function containsContactID(str) { return str.indexOf('ContactID') > -1; } if (cookie) { var contact = cookie.split('|').filter(containsContactID); if (contact.length > 0) { return contact[0].split('=')[1]; } } return "unknown"; }; sl.dataUtils.getIsEmployee = sl.dataUtils.getIsEmployee || function(cookie) { function containsIsEmployee(str) { return str.indexOf('IsEmployee') > -1; } if (cookie) { var contact = cookie.split('|').filter(containsIsEmployee); if (contact.length > 0) { return contact[0].split('=')[1]; } } return "unknown"; }; sl.dataUtils.getcTier = sl.dataUtils.getcTier || function(cookie) { function containscTier(str) { return str.indexOf('cTier') > -1; } if (cookie) { var contact = cookie.split('|').filter(containscTier); if (contact.length > 0) { return contact[0].split('=')[1]; } } return "none"; }; sl.dataUtils.getdisplyname = sl.dataUtils.getdisplyname || function(cookie) { function containsdisplayName(str) { return str.indexOf('communityUserName') > -1; } if (cookie) { var contact = cookie.split('|').filter(containsdisplayName); if (contact.length > 0) { return contact[0].split('=')[1]; } } return ""; }; sl.dataUtils.getPageLanguage = sl.dataUtils.getPageLanguage || function() { if (document.documentElement.lang !== null) { return document.documentElement.lang; } }; sl.dataUtils.getPageTitleText = sl.dataUtils.getPageTitleText || function() { if (document.getElementsByTagName('title')[0].innerHTML !== null) { return document.getElementsByTagName('title')[0].innerHTML; } }; ``` -------------------------------- ### Get Site Section Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Returns the site section identifier. Currently returns an empty string. ```javascript sl.dataUtils.getSiteSection = sl.dataUtils.getSiteSection || function() { var siteSection = ""; return siteSection; }; ``` -------------------------------- ### Get Page Title Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Retrieves the inner HTML content of the page's title tag. ```javascript sl.dataUtils.getPageTitleText = sl.dataUtils.getPageTitleText || function() { if (document.getElementsByTagName('title')[0].innerHTML !== null) { return document.getElementsByTagName('title')[0].innerHTML; } }; ``` -------------------------------- ### Get cTier Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Retrieves the customer tier (cTier) from a cookie string. Returns 'none' if not found. ```javascript sl.dataUtils.getcTier = sl.dataUtils.getcTier || function(cookie) { function containscTier(str) { return str.indexOf('cTier') > -1; } if (cookie) { var contact = cookie.split('|').filter(containscTier); if (contact.length > 0) { return contact[0].split('=')[1]; } } return "none"; }; ``` -------------------------------- ### Get AEM Hierarchy Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Returns a string representing the AEM (Adobe Experience Manager) content hierarchy for the page. ```javascript sl.dataUtils.getAemHierachy = sl.dataUtils.getAemHierachy || function() { return "content:siliconlabs:en:software-and-tools:simplicity-connect-mobile-app"; }; ``` -------------------------------- ### Get Page Language Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Retrieves the language attribute from the HTML document's root element. ```javascript sl.dataUtils.getPageLanguage = sl.dataUtils.getPageLanguage || function() { if (document.documentElement.lang !== null) { return document.documentElement.lang; } }; ``` -------------------------------- ### Get Display Name Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Extracts the community user's display name from a cookie string. Returns an empty string if not found. ```javascript sl.dataUtils.getdisplyname = sl.dataUtils.getdisplyname || function(cookie) { function containsdisplayName(str) { return str.indexOf('communityUserName') > -1; } if (cookie) { var contact = cookie.split('|').filter(containsdisplayName); if (contact.length > 0) { return contact[0].split('=')[1]; } } return ""; }; ``` -------------------------------- ### Get Contact ID Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Extracts the ContactID from a cookie string. Returns 'unknown' if not found. ```javascript sl.dataUtils.getContactID = sl.dataUtils.getContactID || function(cookie) { function containsContactID(str) { return str.indexOf('ContactID') > -1; } if (cookie) { var contact = cookie.split('|').filter(containsContactID); if (contact.length > 0) { return contact[0].split('=')[1]; } } return "unknown"; }; ``` -------------------------------- ### Coveo Search Initialization Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Sets up variables for edit/design modes and initializes the Coveo search library by appending necessary scripts. ```javascript var isEdit = false; var isDesign = false; var munchkinTags = "silicon-labs-tags=content-type:software-pages;"; (function() { // Triggers const INPUT_SELECTOR = '#globalsearchbox'; const ICON_SELECTOR = '.secondary-nav.menu-search.search-icon'; // the icon you mentioned // Coveo bundles (version aligned with your CSS) const COVEO_JS = 'https://static.cloud.coveo.com/searchui/v2.10112/js/CoveoJsSearch.Lazy.min.js'; const COVEO_CULTURE = 'https://static.cloud.coveo.com/searchui/v2.10112/js/cultures/en.js'; let coveoLoadingPromise = null; function appendScript(src) { return new Promise((resolve, reject) => { const existing = document.querySelector(`script[src="${src}"]`); if (existing) return resolve(existing); const s = document.createElement('script'); s.src = src; s.async = true; s.onload = () => resolve(s); s.onerror = () => ``` -------------------------------- ### Website Initialization and Configuration Source: https://www.silabs.com/development-tools/wireless/efr32xg22e-explorer-kit This JavaScript code initializes website-specific variables, configurations, and utility functions. It sets up domain information, SSO parameters, and content type mappings for the Silicon Labs website. ```javascript var silabsProfileCookie; silabsprofileCookie = 'silabsprofile'; var sl = sl || {}; var digitalData = digitalData || {}; var pageTags = ""; var aemHierarchy = "content:siliconlabs:en:development-tools:wireless:efr32xg22e-explorer-kit"; sl.currentRunMode = 'prod'; sl.ssoDomain = 'https://community.silabs.com'; sl.ssoEndpointUrl = 'https://community.silabs.com/idp/login?app=0sp16000000PBKn'; sl.registrationUrl = 'https://community.silabs.com/SL_Registration'; sl.ssoLogoutUrl = 'https://community.silabs.com/SL_Logout?LOF=https://www.silabs.com/system/sling/logout.html?resource=' + window.location.pathname; //sl.ssoLogoutUrl = sl.ssoLogoutUrl.replace("\u005Bthedomain\u005D",curDomain); //if (sl.currentRunMode == "prod") { // sl.ssoLogoutUrl = "https://siliconlabs.force.com/apex/SL_Logout?LOF=https://" + window.location.hostname + "/system/sling/logout.html?resource=" + window.location.pathname; //} //else { // sl.ssoLogoutUrl = "https://full-siliconlabs.cs67.force.com/apex/SL_Logout?LOF=https://" + window.location.hostname + "/system/sling/logout.html?resource=" + window.location.pathname; //} sl.utils = sl.utils || {}; sl.dataUtils = sl.dataUtils || {}; sl.contentTypeMappings = new Map(); sl.contentTypeMappings.set('/apps/siliconlabs/templates/casestudypage', 'Case Study'); sl.utils.readCookie = sl.utils.readCookie || function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; }; sl.dataUtils.getContentType = sl.dataUtils.getContentType || function() { // TODO: Should this use the content type tag? //return sl.contentTypeMappings.get("\/apps\/siliconlabs\/templates\/kitandboardpage"); var currtags = "silicon\u002Dlabs\u002Ddevice\u002Dtype:explorer\u002Dkits,silicon\u002Dlabs\u002Dkits:wireless\u002Dkits\/multiprotocol\u002Dkits\/xg22\u002Dek2710a,silicon\u002Dlabs\u002Dboards:wireless\u002Dboards\/multiprotocol\u002Dboards\/BRD2705A,silicon\u002Dlabs\u002Dproducts:wireless\/bluetooth\u002Dlow\u002Denergy\/efr32bg22\u002Dseries\u002D2\u002Dsocs,silicon\u002Dlabs\u002Dboards:wireless\u002Dboards\/multiprotocol\u002Dboards\/BRD4415A,silicon\u002Dlabs\u002Dproducts:wireless\/proprietary\/efr32fg22\u002Dseries\u002D2\u002Dsocs,silicon\u002Dlabs\u002Dproducts:wireless\/zigbee\u002Dand\u002Dthread\/efr32mg22\u002Dseries\u002D2\u002Dsocs,content\u002Dtype:product\u002Dpages\/device\u002Dpage,silicon\u002Dlabs\u002Dboards:wireless\u002Dboards\/multiprotocol\u002Dboards\/BRD2710A"; var fndCtype = currtags; if (currtags !== null && typeof currtags != 'undefined') { var tagArr = currtags.split(','); for (var i = 0, length = tagArr.length; i < length; i++) { var currTagVals = tagArr[i].split(':'); if (currTagVals[0] == 'content-type') { return currTagVals[1]; } } } return ""; }; sl.dataUtils.getExperienceLevel = sl.dataUtils.getExperienceLevel || function() { var experienceLevel = ""; return experienceLevel; } sl.dataUtils.getBreadcrumbText = sl.dataUtils.getBreadcrumbText || function() { if (document.getElementById('breadcrumbs') !== null && document.getElementById('breadcrumbs').getElementsByClassName('column')[0].children[0]) { return } }; ``` -------------------------------- ### Get Profile ID Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Extracts the UserID from a cookie string. Returns 'unknown' if not found. ```javascript sl.dataUtils.getProfileID = sl.dataUtils.getProfileID || function(cookie) { function containsProfileID(str) { return str.indexOf('UserID') > -1; } if (cookie) { var profile = cookie.split('|').filter(containsProfileID); if (profile.length > 0) { return profile[0].split('=')[1]; } } return "unknown"; }; ``` -------------------------------- ### Initialize Header Search and User Intent Source: https://www.silabs.com/development-tools/wireless/efr32xg22e-energy-harvesting-explorer-kit Initializes the header search component and sets up user intent tracking for Coveo search. This function should be called when the component is ready. ```javascript wsl.components.headerSearch.init(); } } function onUserIntent() { window.__coveoUserIntent = true; loadCoveoOnce().then(() => setTimeout(initHeaderSearchWhenReady, 0)); } ``` -------------------------------- ### Get Is Employee Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Determines if the user is an employee based on a cookie string. Returns 'unknown' if not found. ```javascript sl.dataUtils.getIsEmployee = sl.dataUtils.getIsEmployee || function(cookie) { function containsIsEmployee(str) { return str.indexOf('IsEmployee') > -1; } if (cookie) { var contact = cookie.split('|').filter(containsIsEmployee); if (contact.length > 0) { return contact[0].split('=')[1]; } } return "unknown"; }; ``` -------------------------------- ### Initialize Coveo Search and Header Source: https://www.silabs.com/developer-tools/simplicity-studio Loads Coveo JavaScript libraries and initializes the header search functionality. It includes logic to handle script loading, user intent detection, and ensures the search input is focused. ```javascript const INPUT_SELECTOR = '#globalsearchbox'; const ICON_SELECTOR = '.secondary-nav.menu-search.search-icon'; const COVEO_JS = 'https://static.cloud.coveo.com/searchui/v2.10112/js/CoveoJsSearch.Lazy.min.js'; const COVEO_CULTURE = 'https://static.cloud.coveo.com/searchui/v2.10112/js/cultures/en.js'; let coveoLoadingPromise = null; function appendScript(src) { return new Promise((resolve, reject) => { const existing = document.querySelector(`script[src="${src}"]`); if (existing) return resolve(existing); const s = document.createElement('script'); s.src = src; s.async = true; s.onload = () => resolve(s); s.onerror = () => reject(new Error('Failed to load ' + src)); document.body.appendChild(s); }); } function loadCoveoOnce() { if (!coveoLoadingPromise) { coveoLoadingPromise = appendScript(COVEO_JS) .then(() => appendScript(COVEO_CULTURE)) .catch(err => { console.error('[Coveo] script load failed:', err); coveoLoadingPromise = null; throw err; }); } return coveoLoadingPromise; } function initHeaderSearchWhenReady() { var wsl = window.sl; if (wsl && wsl.components && wsl.components.headerSearch && typeof wsl.components.headerSearch.checkForCoveObject === 'function') { wsl.components.headerSearch.checkForCoveObject(200, 30); // ~6 seconds max } else if (wsl && wsl.components && wsl.components.headerSearch && typeof wsl.components.headerSearch.init === 'function') { wsl.components.headerSearch.init(); } } function onUserIntent() { window.__coveoUserIntent = true; loadCoveoOnce().then(() => setTimeout(initHeaderSearchWhenReady, 0)); } function openAndFocusInput() { const input = document.querySelector(INPUT_SELECTOR); if (input) { try { input.focus(); } catch(e) {} } } document.addEventListener('click', (e) => { if (e.target.closest(ICON_SELECTOR)) { openAndFocusInput(); onUserIntent(); return; } if (e.target.closest(INPUT_SELECTOR)) { onUserIntent(); return; } }, { passive: true }); document.addEventListener('focusin', (e) => { if (e.target.closest(INPUT_SELECTOR)) onUserIntent(); }); document.addEventListener('keydown', (e) => { if (e.key && e.key.length === 1 && !coveoLoadingPromise) { const active = document.activeElement; if (active && active.matches && active.matches(INPUT_SELECTOR)) { onUserIntent(); } } }); window.addEventListener('sl-mobile-menu-opened', function() { if ``` -------------------------------- ### Initialize Usabilla Feedback Widget (Alternative) Source: https://docs.silabs.com/rail/2.16.5/rail-getting-started-overview This is an alternative JavaScript code snippet for initializing the Usabilla feedback widget. It may be used in different configurations or for A/B testing purposes. ```javascript window.usabilla||function(){var a=window,d=a.document,c={},f=d.createElement("div"),h=!1,a=a.usabilla=function(){(c.a=c.a||[]).push(arguments)};a._=c;c.ids={};f.style.display="none";(function(){if(!d.body)return setTimeout(arguments.callee,100);d.body.insertBefore(f,d.body.firstChild).id="usabilla";h=!0})();a.load=function(a,g,k){if(!c.ids[g]){var e=c.ids={};e.url="//"+a+"/"+g+".js?s1";e.config=k;setTimeout(function(){if(!h)return setTimeout(arguments.callee,100);var b=d.createElement("iframe"),a;b.id="usabilla-"+g;/MSIE[ ]+6/.test(navigator.userAgent)&&(b.src="javascript:false");f.appendChild(b);try{b.contentWindow.document.open()}catch(c){e.domain=d.domain,a="javascript:var d=document.open();d.domain='"+e.domain+"';",b.src=a+"void(0);"}try{var l=b.contentWindow.document;l.write([""].join(""));l.close()}catch(m){b.src=a+'d.write("'+loaderHtml().replace(/"/g,String.fromCharCode(92)+'"')+'");d.close();'}b.contentWindow.config=k;b.contentWindow.SCRIPT_ID=g},0)}}(); window.usabilla.load("w.usabilla.com", "f7a057456879"); ``` -------------------------------- ### Simplicity Studio Page Data Utilities Source: https://www.silabs.com/developer-tools/simplicity-studio Provides utility functions for retrieving page-specific data such as tags, AEM hierarchy, and site section. These functions are defined with fallbacks to ensure they exist. ```javascript sl.dataUtils.getPageTags = sl.dataUtils.getPageTags || function() { return "silicon-labs-tags=content-type:software-pages;silicon-labs-software:development-environments/simplicity-studio;"; }; sl.dataUtils.getAemHierachy = sl.dataUtils.getAemHierachy || function() { return "content:siliconlabs:en:software-and-tools:simplicity-studio"; }; sl.dataUtils.getSiteSection = sl.dataUtils.getSiteSection || function() { var siteSection = ""; return siteSection; }; ``` -------------------------------- ### Handle Mobile Menu Opening for Search Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Listens for a custom 'sl-mobile-menu-opened' event and triggers user intent if the window width is less than or equal to 1023px. ```javascript window.addEventListener('sl-mobile-menu-opened', function() { if (window.innerWidth <= 1023) onUserIntent(); }); ``` -------------------------------- ### Initialize Usabilla Feedback Widget Source: https://docs.silabs.com/rail/2.16.5/rail-getting-started-overview This JavaScript code initializes the Usabilla feedback widget. It should be included in your project to enable user feedback collection. ```javascript try { _satellite.pageBottom(); } catch(err) { console.log("Adobe DTM (Analytics) _satellite has not been loaded. Is there any chance you're using an AdBlocker?"); } ``` ```javascript window.usabilla||function(){var a=window,d=a.document,c={},f=d.createElement("div"),h=!1,a=a.usabilla=function(){(c.a=c.a||[]).push(arguments)};a._=c;c.ids={};f.style.display="none";(function(){if(!d.body)return setTimeout(arguments.callee,100);d.body.insertBefore(f,d.body.firstChild).id="usabilla";h=!0})();a.load=function(a,g,k){if(!c.ids[g]){var e=c.ids={};e.url="//"+a+"/"+g+".js?s1";e.config=k;setTimeout(function(){if(!h)return setTimeout(arguments.callee,100);var b=d.createElement("iframe"),a;b.id="usabilla-"+g;/MSIE[ ]+6/.test(navigator.userAgent)&&(b.src="javascript:false");f.appendChild(b);try{b.contentWindow.document.open()}catch(c){e.domain=d.domain,a="javascript:var d=document.open();d.domain='"+e.domain+"';",b.src=a+"void(0);"}try{var l=b.contentWindow.document;l.write([""].join(""));l.close()}catch(m){b.src=a+'d.write("'+loaderHtml().replace(/"/g,String.fromCharCode(92)+'"')+'");d.close();'}b.contentWindow.config=k;b.contentWindow.SCRIPT_ID=g},0)}}(); window.usabilla.load("w.usabilla.com", "effc008d13a5"); ``` -------------------------------- ### Get Breadcrumb Text Utility Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Retrieves the cleaned and trimmed breadcrumb text from the page. It removes HTML tags and extra whitespace. ```javascript sl.dataUtils.getBreadcrumbText || function() { if (document.getElementById('breadcrumbs') !== null && document.getElementById('breadcrumbs').getElementsByClassName('column')[0].children[0]) { return document.getElementById('breadcrumbs').getElementsByClassName('column')[0].children[0].innerHTML.replace(/<[^>]*>/g, "").trim().replace(/\n/g, '').replace(/\s\s+/g, ' '); } }; ``` -------------------------------- ### Responsive Ask AI Icon and Text Source: https://www.silabs.com/development-tools/wireless/efr32xg22e-energy-harvesting-explorer-kit This CSS code defines styles for displaying an 'Ask AI' icon and text responsively across different screen sizes. It ensures the element is visible on desktop and hidden on smaller devices, with specific adjustments for tablet widths. ```css @media (min-width: 1025px) { .menu-search.secondary-nav .icon-container .sparkle-icon, .menu-search.secondary-nav .ask-ai-wrapper .sparkle-icon, .menu-search.secondary-nav .kapa-ask-ai-widget.sparkle-icon { display: none; } } @media (max-width: 1024px) { .sparkle-icon { display: block; position: absolute; right: 20px; top: 25px; margin: 0px; padding: 0px; } .desktop-ai .sparkle-icon { display: none; } /* hide Ask AI text for tablet/mobile */ .desktop-ai .ask-ai { display: none; } } @media (max-width: 600px) { .sparkle-icon { display: block; position: absolute; right: 20px; top: 20px; margin: 0px; padding: 0px; } .desktop-ai .sparkle-icon { display: none; } /* hide Ask AI text for mobile */ .desktop-ai .ask-ai { display: none; } } /* show Ask AI text on desktop only */ @media (min-width: 1025px) { .desktop-ai .ask-ai { display: inline-block; } } /* Show Ask AI icon and text at exactly 1024px width (iPad Pro fix) */ @media (width: 1024px) { .desktop-ai .sparkle-icon { display: inline-block !important; position: static !important; margin: 0 3px 0 0; padding: 0; } .desktop-ai .ask-ai { display: inline-block !important; position: static !important; margin-left: 3px; padding: 0; transform: none !important; opacity: 1 !important; font-size: 14px; color: #777; white-space: nowrap; } .desktop-ai .ask-ai:hover { color: #d91e2a; } } ``` -------------------------------- ### JavaScript Utility Functions for EFR32XG22E Kit Source: https://www.silabs.com/development-tools/wireless/efr32xg22e-energy-harvesting-explorer-kit A collection of JavaScript utility functions used for interacting with website data and elements related to the EFR32XG22E Energy Harvesting Explorer Kit. These functions assist in data retrieval and content management. ```javascript window.location.pathname; //} else { // sl.ssoLogoutUrl = "https://full-siliconlabs.cs67.force.com/apex/SL_Logout?LOF=https://" + window.location.hostname + "/system/sling/logout.html?resource=" + window.location.pathname; //} sl.utils = sl.utils || {}; sl.dataUtils = sl.dataUtils || {}; sl.contentTypeMappings = new Map(); sl.contentTypeMappings.set('/apps/siliconlabs/templates/casestudypage', 'Case Study'); sl.utils.readCookie = sl.utils.readCookie || function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; }; sl.dataUtils.getContentType = sl.dataUtils.getContentType || function() { // TODO: Should this use the content type tag? //return sl.contentTypeMappings.get("\/apps\/siliconlabs\/templates\/kitandboardpage"); var currtags = "silicon\u002Dlabs\u002Ddevice\u002Dtype:explorer\u002Dkits,silicon\u002Dlabs\u002Dboards:wireless\u002Dboards\/multiprotocol\u002Dboards\/BRD2705A,silicon\u002Dlabs\u002Dproducts:wireless\/bluetooth\u002Dlow\u002Denergy\/efr32bg22\u002Dseries\u002D2\u002Dsocs,silicon\u002Dlabs\u002Dboards:wireless\u002Dboards\/multiprotocol\u002Dboards\/BRD4415A,silicon\u002Dlabs\u002Dproducts:wireless\/zigbee\u002Dand\u002Dthread\/efr32mg22\u002Dseries\u002D2\u002Dsocs,content\u002Dtype:product\u002Dpages\/device\u002Dpage,silicon\u002Dlabs\u002Dboards:wireless\u002Dboards\/multiprotocol\u002Dboards\/BRD2710A,silicon\u002Dlabs\u002Dkits:wireless\u002Dkits\/multiprotocol\u002Dkits\/xg22\u002Dek8200a"; var fndCtype = currtags; if (currtags !== null && typeof currtags != 'undefined') { var tagArr = currtags.split(','); for (var i = 0, length = tagArr.length; i < length; i++) { var currTagVals = tagArr[i].split(':'); if (currTagVals[0] == 'content-type') { return currTagVals[1]; } } } return ""; }; sl.dataUtils.getExperienceLevel = sl.dataUtils.getExperienceLevel || function() { var experienceLevel = ""; return experienceLevel; } sl.dataUtils.getBreadcrumbText = sl.dataUtils.getBreadcrumbText || function() { if (document.getElementById('breadcrumbs') !== null && document.getElementById('breadcrumbs').getElementsByClassName('column')[0].children[0]) { return document.getElementById('breadcrumbs').getElementsByClassName('column')[0].children[0].innerHTML.replace(/<[^>]*>/g, "").trim().replace(/\n/g, '').replace(/\s\s+/g, ' '); } }; sl.dataUtils.getProfileID = sl.dataUtils.getProfileID || function(cookie) { function containsProfileID(str) { return str.indexOf('UserID') > -1; } if (cookie) { var profile = cookie.split('|').filter(containsProfileID); if (profile.length > 0) { return profile[0].split('=')[1]; } } return "unknown"; }; sl.dataUtils.getContactID = sl.dataUtils.getContactID || function(cookie) { function containsContactID(str) { return str.indexOf('ContactID') > -1; } if (cookie) { var contact = cookie.split('|').filter(containsContactID); if (contact.length > 0) { return contact[0].split('=')[1]; } } return "unknown"; }; sl.dataUtils.getIsEmployee = sl.dataUtils.getIsEmployee || function(cookie) { function containsIsEmployee(str) { return str.indexOf('IsEmployee') > -1; } if (cookie) { var contact = cookie.split('|').filter(containsIsEmployee); if (contact.length > 0) { return contact[0].split('=')[1]; } } return "unknown"; }; sl.dataUtils.getcTier = sl.dataUtils.getcTier || function(cookie) { function containscTier(str) { return str.indexOf('cTier') > -1; } if (cookie) { var contact = cookie.split('|').filter(containscTier); if (contact.length > 0) { return contact[0].split('=')[1]; } } return "none"; }; sl.dataUtils.getdisplyname = sl.dataUtils.getdisplyname || function(cookie) { function containsdisplayName(str) { return str.indexOf('communityUserName') > -1; } if (cookie) { var contact = cookie.split('|').filter(containsdisplayName); if (contact.length > 0) { return contact[0].split('=')[1]; } } return ""; }; sl.dataUtils.getPageLanguage = sl.dataUtils.getPageLanguage || function() { if (document.documentElement.lang !== null) { return document.documentElement.lang; } }; sl.dataUtils.getPageTitleText = sl.dataUtils.getPageTitleText || function() { if (document.getElementsByTagName('title')[0].innerHTML !== null) { return document.getElementsByTagName('title')[0].innerHTML; } }; sl.dataUtils.getPageTags = sl.dataUtils.getPageTags || function() { return ``` -------------------------------- ### Initialize Event Listener for Site Parameter Source: https://docs.silabs.com/energy-harvesting/energy-harvesting-start This JavaScript code initializes an event listener that checks for a 'site' parameter in the URL. It sets a data-expression attribute on a tab element based on whether the 'site' parameter is present. This is typically used for controlling UI elements or search behavior based on the context. ```javascript document.addEventListener('DOMContentLoaded', function () { const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); let site = urlParams.get('site'); if (!site) { document.getElementById('silabs-docs-tab').setAttribute('data-expression', '@source==("Docs.Silabs - TopLevel", "DAM Feed") OR @uri=("silabs.com/whitepapers", "silabs.com/support")'); } else { document.getElementById('silabs-docs-tab').setAttribute('data-expression', '@source==("Docs.Silabs - TopLevel","DAM Feed")OR @uri=("silabs.com/whitepapers", "silabs.com/support")'); } getToken(); }); ``` -------------------------------- ### Open and Focus Search Input Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Selects the global search input element and attempts to focus it. This action is intended to trigger lazy loading listeners. ```javascript const INPUT_SELECTOR = '#globalsearchbox'; function openAndFocusInput() { const input = document.querySelector(INPUT_SELECTOR); if (input) { try { input.focus(); } catch(e) {} } } ``` -------------------------------- ### Delegate Keydown Listener for Search Input Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Attaches a delegated keydown listener to the document. If a single character key is pressed while the search input is active and Coveo scripts are not yet loading, it triggers user intent. ```javascript document.addEventListener('keydown', (e) => { if (e.key && e.key.length === 1 && !coveoLoadingPromise) { const active = document.activeElement; if (active && active.matches && active.matches(INPUT_SELECTOR)) { onUserIntent(); } } }); ``` -------------------------------- ### Trigger User Intent on Mobile Menu Events Source: https://www.silabs.com/development-tools/wireless/efr32xg22e-energy-harvesting-explorer-kit Listens for mobile menu events and window resize to trigger user intent for search on smaller screens. It also handles immediate triggering on hamburger menu interaction. ```javascript // If the input is injected later, observe and arm once it appears window.addEventListener('sl-mobile-menu-opened', function() { if (window.innerWidth <= 1023) onUserIntent(); }); // Trigger immediately on hamburger interaction to avoid class-observer lag/jitter document.addEventListener('click', function(e) { if (e.target.closest('.menu-button') && window.innerWidth <= 1023) onUserIntent(); }, { passive: true }); ``` -------------------------------- ### Page Load Animation Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Applies a simple opacity transition to the body for a fade-in effect on page load. ```css body { opacity:0; } body { opacity:1; } ``` -------------------------------- ### Initialize Header Search Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Initializes the header search component, checking for specific functions or directly calling the init method. This is part of the lazy loading strategy. ```javascript function initHeaderSearchWhenReady() { var wsl = window.sl; if (wsl && wsl.components && wsl.components.headerSearch && typeof wsl.components.headerSearch.checkForCoveObject === 'function') { wsl.components.headerSearch.checkForCoveObject(200, 30); // ~6 seconds max } else if (wsl && wsl.components && wsl.components.headerSearch && typeof wsl.components.headerSearch.init === 'function') { wsl.components.headerSearch.init(); } } ``` -------------------------------- ### Delegated Event Listeners for Search Interaction Source: https://www.silabs.com/development-tools/wireless/efr32xg22e-energy-harvesting-explorer-kit Sets up delegated event listeners for click, focusin, and keydown events to trigger user intent for the search functionality. It handles interactions with the search icon, input field, and active elements. ```javascript // Delegated listeners: document.addEventListener('click', (e) => { // 1) If the icon is clicked, open/focus input, then trigger lazy load if (e.target.closest(ICON_SELECTOR)) { openAndFocusInput(); onUserIntent(); return; } // 2) If the input itself is clicked if (e.target.closest(INPUT_SELECTOR)) { onUserIntent(); return; } }, { passive: true }); document.addEventListener('focusin', (e) => { if (e.target.closest(INPUT_SELECTOR)) onUserIntent(); }); document.addEventListener('keydown', (e) => { if (e.key && e.key.length === 1 && !coveoLoadingPromise) { const active = document.activeElement; if (active && active.matches && active.matches(INPUT_SELECTOR)) { onUserIntent(); } } }); ``` -------------------------------- ### Mobile Header Interaction Logic Source: https://www.silabs.com/developer-tools/simplicity-studio Handles user intent for mobile header interactions, including search and menu button clicks. Ensures functionality is triggered correctly on different screen sizes and DOM states. ```javascript window.innerWidth <= 1023) onUserIntent(); }); // Trigger immediately on hamburger interaction to avoid class-observer lag/jitter document.addEventListener('click', function(e) { if (e.target.closest('.menu-button') && window.innerWidth <= 1023) onUserIntent(); }, { passive: true }); function warmLoadHeaderSearchIfMobile() { if (window.innerWidth > 1023) return; onUserIntent(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', warmLoadHeaderSearchIfMobile); } else { warmLoadHeaderSearchIfMobile(); } document.addEventListener('pointerdown', function(e) { if (e.target.closest('.menu-button') && window.innerWidth <= 1023) onUserIntent(); }, { passive: true, capture: true }); const mo = new MutationObserver(() => { const input = document.querySelector(INPUT_SELECTOR); if (input) { console.log('[Coveo] detected #globalsearchbox added to DOM.'); mo.disconnect(); // (Listeners are delegated already; nothing else needed here) } }); mo.observe(document.documentElement, { childList: true, subtree: true }); console.log('[Coveo] lazy loader armed (icon + input).'); })(); ``` -------------------------------- ### Trigger User Intent on Pointer Down for Mobile Menu Source: https://www.silabs.com/development-tools/wireless/efr32xg22e-energy-harvesting-explorer-kit Handles user intent triggering on pointer down events for the mobile menu button, ensuring responsiveness on smaller screens. This uses capture phase for immediate execution. ```javascript document.addEventListener('pointerdown', function(e) { if (e.target.closest('.menu-button') && window.innerWidth <= 1023) onUserIntent(); }, { passive: true, capture: true }); ``` -------------------------------- ### Digital Data Structure for Simplicity Studio Page Source: https://www.silabs.com/developer-tools/simplicity-studio Defines the digitalData object, which holds comprehensive information about the current page, including page info, attributes, products, software, and community-related data. ```javascript digitalData = { "page": { "pageInfo": { "pageTitle": sl.dataUtils.getPageTitleText(), "contentType": sl.dataUtils.getContentType(), "breadcrumbText": sl.dataUtils.getBreadcrumbText(), "siteSpace": "www", "pageTags": sl.dataUtils.getPageTags(), "aemHierachy": sl.dataUtils.getAemHierachy(), "experienceLevel": sl.dataUtils.getExperienceLevel(), "siteSection": sl.dataUtils.getSiteSection() }, "attributes": { "language": sl.dataUtils.getPageLanguage() } }, "products": null, "kits": null, "referenceDesigns": null, "applications": null, "software": [ { "softwareInfo": { "softwareLevel-1": "Development Environments", "softwareLevel-2": "Simplicity Studio", "softwareLevel-3": null, "softwareLevel-4": null } } ], "technologies": null, "accessory": null, "user": { "profile": { "profileInfo": { "profileID": sl.dataUtils.getProfileID(sl.utils.readCookie(silabsProfileCookie)), "contactID": sl.dataUtils.getContactID(sl.utils.readCookie(silabsProfileCookie)), "isEmployee": sl.dataUtils.getIsEmployee(sl.utils.readCookie(silabsProfileCookie)), "cTier": sl.dataUtils.getcTier(sl.utils.readCookie(silabsProfileCookie)), "communityUserName": sl.dataUtils.getdisplyname(sl.utils.readCookie(silabsProfileCookie)) } } }, "community": { "attributes": { "subjectTags": "" }, "forumInfo": { "answerStatus": "", "numReplies": "", "topicauthorName": "", "topicauthorID": "", "answerauthorName": "", "answerauthorID": "", "escalationStatus": "" }, "kbInfo": { "KBauthor": "" } } }; //console.log(digitalData) body { opacity: 0; } body { opacity: 1; } _satellite.pageBottom(); ``` -------------------------------- ### Trigger User Intent for Search Source: https://www.silabs.com/developer-tools/simplicity-connect-mobile-app Sets a flag for Coveo user intent and triggers the loading of Coveo scripts, followed by search initialization. This is called on various user interactions. ```javascript function onUserIntent() { window.__coveoUserIntent = true; loadCoveoOnce().then(() => setTimeout(initHeaderSearchWhenReady, 0)); } ``` -------------------------------- ### Digital Data Structure for Page and Product Information Source: https://www.silabs.com/development-tools/wireless/efr32xg22e-explorer-kit This JavaScript object structures page and product information for digital data collection. It includes details like page title, content type, breadcrumbs, product line, category, family, and kit information. ```javascript digitalData = { "page": { "pageInfo": { "pageTitle": sl.dataUtils.getPageTitleText(), "contentType": sl.dataUtils.getContentType(), "breadcrumbText": sl.dataUtils.getBreadcrumbText(), "siteSpace": "www", "pageTags": sl.dataUtils.getPageTags(), "aemHierachy": sl.dataUtils.getAemHierachy(), "experienceLevel": sl.dataUtils.getExperienceLevel(), "siteSection": sl.dataUtils.getSiteSection() }, "attributes": { "language": sl.dataUtils.getPageLanguage() } }, "products": [ { "productInfo" : { "productLine" : "Wireless", "productCategory" : "Bluetooth Low Energy", "partNumber" : null, "productFamily" : "EFR32BG22 Series 2 SoCs" }, "attributes" : { "productType" : [ "Explorer Kits" ] } }, { "productInfo" : { "productLine" : "Wireless", "productCategory" : "Proprietary", "partNumber" : null, "productFamily" : "EFR32FG22 Series 2 SoCs" }, "attributes" : { "productType" : [ "Explorer Kits" ] } }, { "productInfo" : { "productLine" : "Wireless", "productCategory" : "ZigBee and Thread", "partNumber" : null, "productFamily" : "EFR32MG22 Series 2 SoCs" }, "attributes" : { "productType" : [ "Explorer Kits" ] } } ], "kits": [ { "productInfo" : { "kitLine" : "Wireless Kits", "kitCategory" : "Multiprotocol Kits", "partNumber" : null, "kitFamily" : "xG22-EK2710A" }, "attributes" : { "productType" : [ "Explorer Kits" ] } } ], "referenceDesigns": null, "applications": null, "software": null, "technologies": null, "accessory": null, "user": { "profile": { "profileInfo": { "profileID": sl.dataUtils.getProfileID(sl.utils.readCookie(silabsProfileCookie)), "contactID": sl.dataUtils.getContactID(sl.utils.readCookie(silabsProfileCookie)), "isEmployee": sl.dataUtils.getIsEmployee(sl.utils.readCookie(silabsProfileCookie)), "cTier": sl.dataUtils.getcTier(sl.utils.readCookie(silabsProfileCookie)), "communityUserName": sl.dataUtils.getdisplyname(sl.utils.readCookie(silabsProfileCookie)), ``` -------------------------------- ### Warm Load Header Search for Mobile Source: https://www.silabs.com/development-tools/wireless/efr32xg22e-energy-harvesting-explorer-kit Ensures the header search is pre-loaded for mobile viewports. It triggers the user intent function if the window width is below a certain threshold. ```javascript function warmLoadHeaderSearchIfMobile() { if (window.innerWidth > 1023) return; onUserIntent(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', warmLoadHeaderSearchIfMobile); } else { warmLoadHeaderSearchIfMobile(); } ```