### Consent Flow Initialization (JavaScript) Source: https://blog.xojo.com/2022/07/21/tips-for-using-xojos-issue-tracking-system Initializes the consent flow for website tracking, checking for `HTGA4` configuration, applying automatic consent if applicable, or using stored consent from cookies. If no stored consent is found, it implies the cookie notice will handle the request. This script is crucial for managing user privacy preferences. ```javascript function initConsentFlow() { log("Starting consent flow"); // Check if HTGA4 config is available if (typeof window.HTGA4 === 'undefined') { log("HTGA4 config not available"); return; } // If user should get automatic consent (notice disabled or non-EU user with EU-only setting) if (window.HTGA4.should_auto_consent) { log("Auto consent granted → always track"); if (typeof window.htga4_update_consent === 'function') { window.htga4_update_consent('yes'); } return; } // Check if user has already given consent const storedConsent = getCookie(window.HTGA4.cookie_notice_cookie_key); if (storedConsent === 'yes' || storedConsent === 'no') { log("Using stored consent:", storedConsent); if (typeof window.htga4_update_consent === 'function') { window.htga4_update_consent(storedConsent); } } else { log("No stored consent found"); // Cookie notice will handle showing the consent request // PHP side determines if notice should be shown based on region/settings } } initConsentFlow(); ``` -------------------------------- ### CSS for Code Highlighting and Styling Source: https://blog.xojo.com/2022/07/21/tips-for-using-xojos-issue-tracking-system Provides CSS rules for styling code snippets, specifically for Xojo syntax highlighting and general web page elements. It defines colors for different code elements like comments, keywords, strings, and numbers, as well as basic body and heading styles. ```css /*# sourceURL=ct-apex-style-inline-css */ .hljs-ln td { border: none; } .hljs-comment { color:#7D1012 } .hljs-keyword { color: #0A5FFE; font-weight:normal } .hljs-literal { color: #0A5FFE; font-weight:normal } .hljs-meta { color: #0A5FFE; font-weight:normal } .hljs-data_type { color:#0A5FFE } .hljs-string { color:#9D33D5 } .hljs-integer { color:#28C732 } .hljs-double { color:#146319 } .hljs-rgb_component:nth-of-type(1) { color:#FB2025 } .hljs-rgb_component:nth-of-type(2) { color:#28C732 } .hljs-rgb_component:nth-of-type(3) { color:#0A5FFE } .hljs-rgb_component:nth-of-type(4) { color:#232323 } /* You can add your own CSS here. Click the help icon above to learn more. */ .comments-link { display: none; } .comments { display: none; } .logo { max-width: 60%; } body { color: #000000; font-family: 'Helvetica', sans-serif; } h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: 'Helvetica', sans-serif; } .widget-title { font-size: 100%; } input[type=search] { font-size: 100%; } p.tagline { font-size:120%; font-weight:60; } .hljs-ln-n { margin-right:10px; } ``` -------------------------------- ### WordPress Emoji Settings Initialization (JavaScript) Source: https://blog.xojo.com/2022/07/21/tips-for-using-xojos-issue-tracking-system This JavaScript code initializes WordPress emoji settings, likely for handling emoji rendering across different browsers and platforms. It parses emoji settings from a JSON object embedded in the HTML and sets up support tests for emoji rendering. It includes functions for testing emoji support using canvas rendering. ```javascript const a=JSON.parse(document.getElementById("wp-emoji-settings").textContent),o=(window._wpemojiSettings=a,"wpEmojiSettingsSupports"),s=["flag","emoji"];function i(e){try{var t={supportTests:e,timestamp:(new Date).valueOf()};sessionStorage.setItem(o,JSON.stringify(t))}catch(e){}}function c(e,t,n){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(t,0,0);t=new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data);e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(n,0,0);const a=new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data);return t.every((e,t)=>e===a[t])}function p(e,t){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(t,0,0);var n=e.getImageData(16,16,1,1);for(let e=0;e { const dropdown = document.getElementById( dropdownId ); function onSelectChange() { setTimeout( () => { if ( 'escape' === dropdown.dataset.lastkey ) { return; } if ( dropdown.value && parseInt( dropdown.value ) > 0 && dropdown instanceof HTMLSelectElement ) { dropdown.parentElement.submit(); } }, 250 ); } function onKeyUp( event ) { if ( 'Escape' === event.key ) { dropdown.dataset.lastkey = 'escape'; } else { delete dropdown.dataset.lastkey; } } function onClick() { delete dropdown.dataset.lastkey; } dropdown.addEventListener( 'keyup', onKeyUp ); dropdown.addEventListener( 'click', onClick ); dropdown.addEventListener( 'change', onSelectChange ); })( "cat" ); //# sourceURL=WP_Widget_Categories%3A%3Awidget /* ]]> */ ``` -------------------------------- ### Debug Logging Function (JavaScript) Source: https://blog.xojo.com/2022/07/21/tips-for-using-xojos-issue-tracking-system A simple JavaScript logging function `log` that outputs messages to the console only if a `DEBUG` variable is true. This is useful for conditional debugging during development. It accepts a variable number of arguments, similar to `console.log`. ```javascript const DEBUG = window.HTGA4 && window.HTGA4.debug; function log(...args) { if (DEBUG) console.log(...args); } ``` -------------------------------- ### Cookie Value Retrieval Function (JavaScript) Source: https://blog.xojo.com/2022/07/21/tips-for-using-xojos-issue-tracking-system A JavaScript helper function `getCookie` designed to retrieve the value of a specific cookie from the document's cookies. It parses the `document.cookie` string to find and return the value associated with the provided cookie name. Returns null if the cookie is not found. ```javascript function getCookie(name) { const value = `; ${document.cookie}`; const parts = value.split(`; ${name}=`); if (parts.length === 2) return parts.pop().split(';').shift(); return null; } ``` -------------------------------- ### Google Analytics Consent Update Function (JavaScript) Source: https://blog.xojo.com/2022/07/21/tips-for-using-xojos-issue-tracking-system This JavaScript function, `htga4_update_consent`, updates Google Analytics consent settings for ad storage, analytics storage, ad user data, and ad personalization. It takes a 'consent' parameter ('yes' or 'no') and dispatches a custom event upon granting consent. It's designed to be called within a web page's script. ```javascript window.htga4_update_consent = function(consent) { gtag('consent', 'update', { 'ad_storage': consent === 'yes' ? 'granted' : 'denied', 'analytics_storage': consent === 'yes' ? 'granted' : 'denied', 'ad_user_data': consent === 'yes' ? 'granted' : 'denied', 'ad_personalization': consent === 'yes' ? 'granted' : 'denied' }); // Dispatch custom event for consent changes if (consent === 'yes') { window.dispatchEvent(new CustomEvent('htga4_consent_granted')); } }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.