document.addEventListener('DOMContentLoaded', (event) => { const forms = document.querySelectorAll('.question-form'); forms.forEach(form => { const inputs = form.querySelectorAll('input[type="radio"]'); inputs.forEach(input => { input.addEventListener('change', () => { // Reset the custom styling for all options inputs.forEach(inpt => { const labelSpan = inpt.nextElementSibling; labelSpan.style.backgroundColor = '#eee'; // Default background color labelSpan.style.color = '#333'; // Default text color }); // Apply custom styling to the selected option const selectedLabelSpan = input.nextElementSibling; selectedLabelSpan.style.backgroundColor = '#4CAF50'; // Selected background color selectedLabelSpan.style.color = 'white'; // Selected text color }); }); }); }); function showAnswer(element) { const form = element.closest('form'); form.querySelector('.answer-description').style.display = 'block'; form.querySelector('.result').style.display = 'none'; // Hide result if shown } function checkAnswer(element, correctAnswer) { const form = element.closest('form'); const resultElement = form.querySelector('.result'); var selectedAnswer = form.querySelector('input[name="answer"]:checked')?.value; // Reset the style for new selections resultElement.style.fontSize = '16px'; resultElement.style.fontWeight = 'bold'; resultElement.style.padding = '10px'; resultElement.style.borderRadius = '5px'; resultElement.style.marginTop = '10px'; resultElement.style.color = '#fff'; // Check if an answer has been selected if (selectedAnswer === undefined) { resultElement.textContent = 'Please select an option before submitting.' resultElement.style.backgroundColor = '#4d4dff'; } else if (selectedAnswer === correctAnswer) { resultElement.textContent = 'Correct!'; resultElement.style.backgroundColor = '#4CAF50'; // Green color } else { resultElement.textContent = 'Incorrect, please try again.'; resultElement.style.backgroundColor = '#f44336'; // Red color } resultElement.style.display = 'block'; form.querySelector('.answer-description').style.display = 'none'; // Hide answer description if shown }
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TTNP7H3K" height=0 width=0 style=display:none;visibility:hidden></iframe> Manage Preferences // Ensure dataLayer is initialized window.dataLayer = window.dataLayer || []; // Function to set a cookie with enhanced security function setCookie(name, value, days) { let expires = ""; if (days) { let date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=Strict"; } // Function to get a cookie function getCookie(name) { let nameEQ = name + "="; let ca = document.cookie.split(';'); for (let i = 0; i < ca.length; i++) { let 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; } // Function to pre-populate checkboxes based on cookie function populateCheckboxes(preferences) { document.getElementById('analytics-storage').checked = preferences.analytics_storage; document.getElementById('ad-storage').checked = preferences.ad_storage; document.getElementById('ad-user-data').checked = preferences.ad_user_data; document.getElementById('ad-personalization').checked = preferences.ad_personalization; } // Check if consent has already been given window.onload = function() { let consent = getCookie('user_consent'); if (consent) { let preferences = JSON.parse(consent); initializeConsent(preferences); populateCheckboxes(preferences); } else { document.getElementById('consent-popup').style.display = 'block'; } }; // Function to get current consent preferences from checkboxes function getConsentPreferences() { return { analytics_storage: document.getElementById('analytics-storage').checked, ad_storage: document.getElementById('ad-storage').checked, ad_user_data: document.getElementById('ad-user-data').checked, ad_personalization: document.getElementById('ad-personalization').checked }; } // Function to initialize Google Consent Mode function initializeConsent(preferences) { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'consent_update', 'ad_storage': preferences.ad_storage ? 'granted' : 'denied', 'ad_user_data': preferences.ad_user_data ? 'granted' : 'denied', 'ad_personalization': preferences.ad_personalization ? 'granted' : 'denied', 'analytics_storage': preferences.analytics_storage ? 'granted' : 'denied' }); } // Handle Save Preferences button document.getElementById('save-consent').addEventListener('click', function() { let preferences = getConsentPreferences(); setCookie('user_consent', JSON.stringify(preferences), 365); document.getElementById('consent-popup').style.display = 'none'; initializeConsent(preferences); }); // Handle Accept All button document.getElementById('accept-all').addEventListener('click', function() { let preferences = { analytics_storage: true, ad_storage: true, ad_user_data: true, ad_personalization: true }; setCookie('user_consent', JSON.stringify(preferences), 365); document.getElementById('consent-popup').style.display = 'none'; initializeConsent(preferences); }); // Handle Decline All button document.getElementById('decline-all').addEventListener('click', function() { let preferences = { analytics_storage: false, ad_storage: false, ad_user_data: false, ad_personalization: false }; setCookie('user_consent', JSON.stringify(preferences), 365); document.getElementById('consent-popup').style.display = 'none'; initializeConsent(preferences); }); // Handle Manage Preferences link document.getElementById('manage-preferences').addEventListener('click', function(e) { e.preventDefault(); document.getElementById('consent-popup').style.display = 'block'; }); var CrayonSyntaxSettings = {"version":"_2.7.2_beta","is_admin":"0","ajaxurl":"https:\/\/tecadmin.net\/wp-admin\/admin-ajax.php","prefix":"crayon-","setting":"crayon-setting","selected":"crayon-setting-selected","changed":"crayon-setting-changed","special":"crayon-setting-special","orig_value":"data-orig-value","debug":""}; var CrayonSyntaxStrings = {"copy":"Press %s to Copy, %s to Paste","minimize":"Click To Expand Code"}; var BunyadLazyConf = {"type":"normal"}; var Bunyad = {"ajaxurl":"https:\/\/tecadmin.net\/wp-admin\/admin-ajax.php"}; var consent_api = {"consent_type":"","waitfor_consent_hook":"","cookie_expiration":"30","cookie_prefix":"wp_consent"};