(() => { 'use strict'; const body = document.body; const root = document.documentElement; if (!body || root.dataset.v710Runtime === 'ready') return; root.dataset.v710Runtime = 'ready'; // V7.0.16 is the approved homepage interaction baseline. if (body.dataset.v710Family === 'home') return; const reduceMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches; if (reduceMotion) body.classList.add('v710-reduce-motion'); // Preserve a clear language boundary: pages without an approved English body // continue to the English homepage instead of presenting partial translation. const fallbackLanguage = document.querySelector('[data-language-home-fallback]'); if (fallbackLanguage) { fallbackLanguage.setAttribute('aria-label', 'Open the English homepage'); fallbackLanguage.setAttribute('title', '进入英文首页(当前页面正文为中文)'); } // Mark the current local route consistently in contextual and footer navigation. const current = decodeURIComponent(location.pathname.split('/').pop() || 'index.html'); document.querySelectorAll('main nav a[href], footer a[href]').forEach((link) => { const raw = link.getAttribute('href') || ''; if (!raw || /^(?:https?:|mailto:|tel:|#)/i.test(raw)) return; const file = decodeURIComponent(raw.split('#')[0].split('?')[0].replace(/^\.\//, '')) || current; if (file === current && !link.closest('[data-v710-ignore-current]')) { link.dataset.v710CurrentRoute = 'true'; } }); // Ensure external links opened in a new tab retain the expected security relation. document.querySelectorAll('a[target="_blank"]').forEach((link) => { const rel = new Set((link.getAttribute('rel') || '').split(/\s+/).filter(Boolean)); rel.add('noopener'); link.setAttribute('rel', [...rel].join(' ')); }); // Lazy images below the first content screen should not compete with the hero. document.querySelectorAll('main img').forEach((image, index) => { if (index > 1 && !image.hasAttribute('loading')) image.loading = 'lazy'; if (!image.hasAttribute('decoding')) image.decoding = 'async'; }); })();