Metabolic Syndrome Risk Calculator
Assess your risk · Identify key markers · Take control of your health
Your Metabolic Risk Assessment
0
out of 5 criteria met
Low Risk
0 criteria met
5 criteria total
`;
}function openEmbedModal() {
const modal = document.getElementById('embedModal');
modal.classList.add('open');
document.body.style.overflow = 'hidden';// Generate embed code
const fullHTML = getEmbedHTML();
const escaped = fullHTML.replace(/`/g, '\\`').replace(/\${/g, '\\${');
const iframeCode =
`
`;document.getElementById('embedCodeDisplay').textContent = iframeCode;// Preview
const previewFrame = document.getElementById('embedPreviewFrame');
try {
previewFrame.srcdoc = fullHTML;
} catch (e) {
previewFrame.src = 'data:text/html;charset=utf-8,' + encodeURIComponent(fullHTML);
}
}function closeEmbedModal() {
document.getElementById('embedModal').classList.remove('open');
document.body.style.overflow = '';
}function copyEmbedCode() {
const code = document.getElementById('embedCodeDisplay').textContent;
navigator.clipboard?.writeText(code).then(() => {
const btn = document.getElementById('copyEmbedBtn');
btn.innerHTML = '
Copy';
btn.classList.remove('copied');
}, 2500);
}).catch(() => {
// Fallback
const textarea = document.createElement('textarea');
textarea.value = code;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
textarea.remove();
const btn = document.getElementById('copyEmbedBtn');
btn.innerHTML = '
Copy';
btn.classList.remove('copied');
}, 2500);
});
}// Close modal on overlay click
document.getElementById('embedModal').addEventListener('click', function(e) {
if (e.target === this) closeEmbedModal();
});// Close on Escape
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') closeEmbedModal();
});// ----- EXPOSE globals -----
window.calculateRisk = calculateRisk;
window.resetAll = resetAll;
window.shareResults = shareResults;
window.openEmbedModal = openEmbedModal;
window.closeEmbedModal = closeEmbedModal;
window.copyEmbedCode = copyEmbedCode;// ----- INIT -----
updateGenderDisplay();
calculateRisk();// Also recalc on gender toggle via event listeners already set upconsole.log('Metabolic Syndrome Risk Calculator loaded.');
console.log('💡 Embed feature available via the "Embed" button.');
})();