/** * auth-shared.js — Shared utility for all auth pages * Provides: makePasswordToggle(), passwordStrengthMeter() */ function makePasswordToggle(btnId, inputId, iconId) { const btn = document.getElementById(btnId); const input = document.getElementById(inputId); const icon = document.getElementById(iconId); if (!btn || !input || !icon) return; btn.addEventListener('click', function () { const isHidden = input.type === 'password'; input.type = isHidden ? 'text' : 'password'; icon.innerHTML = isHidden ? '' + '' + '' : '' + ''; }); } function passwordStrengthMeter(inputId, barId, textId) { const input = document.getElementById(inputId); const bar = document.getElementById(barId); const text = document.getElementById(textId); if (!input || !bar || !text) return; input.addEventListener('input', function () { const v = this.value; let score = 0; if (v.length >= 8) score++; if (/[A-Z]/.test(v)) score++; if (/[a-z]/.test(v)) score++; if (/[0-9]/.test(v)) score++; if (/[^A-Za-z0-9]/.test(v)) score++; const classes = ['', 'weak', 'fair', 'good', 'good', 'strong']; const labels = ['', 'Weak', 'Fair', 'Good', 'Good', 'Strong']; const cls = classes[score] || ''; bar.className = 'pw-strength-fill ' + cls; text.className = 'pw-strength-text ' + cls; text.textContent = v.length ? labels[score] : ''; }); } // Check for cross-origin iframe context (Hugging Face Spaces) document.addEventListener('DOMContentLoaded', function() { let isFramed = false; try { isFramed = (window.self !== window.top); } catch (e) { isFramed = true; } if (isFramed) { const banner = document.createElement('div'); banner.style.cssText = ` position: fixed; top: 0; left: 0; right: 0; background: #ef4444; color: white; text-align: center; padding: 14px; font-weight: 600; font-size: 15px; z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.5); `; banner.innerHTML = `
Browsers block login cookies inside iframes. Open App in New Tab
`; document.body.prepend(banner); // Adjust layout to prevent overlap const authPage = document.querySelector('.auth-page'); if (authPage) authPage.style.marginTop = '60px'; const mainHeader = document.querySelector('header'); if (mainHeader) mainHeader.style.marginTop = '50px'; } });