(() => { 'use strict'; const root = document.documentElement; const body = document.body; if (!body || root.dataset.v7111Runtime === 'ready') return; root.dataset.v7111Runtime = 'ready'; const mainTitle = document.querySelector('main h1'); if (mainTitle) { const titleLength = Array.from((mainTitle.textContent || '').trim().replace(/\s+/g, '')).length; if (titleLength >= 42) mainTitle.dataset.v7111Title = 'xlong'; else if (titleLength >= 28) mainTitle.dataset.v7111Title = 'long'; else mainTitle.dataset.v7111Title = 'standard'; } if (body.dataset.v710Family === 'home') return; const footer = document.querySelector('footer.formal-site-footer'); const columns = footer ? [...footer.querySelectorAll('.footer-directory > .footer-column')] : []; if (!columns.length) return; const mobile = window.matchMedia('(max-width: 700px)'); columns.forEach((column, index) => { column.dataset.v7111FooterColumn = 'true'; column.dataset.v7111Open = 'false'; const heading = column.querySelector(':scope > h3'); if (!heading) return; let button = heading.querySelector(':scope > button'); if (!button) { button = document.createElement('button'); button.type = 'button'; button.textContent = heading.textContent.trim(); for (const attribute of ['data-nav-cn', 'data-nav-en']) { if (!heading.hasAttribute(attribute)) continue; button.setAttribute(attribute, heading.getAttribute(attribute)); heading.removeAttribute(attribute); } heading.textContent = ''; heading.append(button); } button.classList.add('v7111-footer-toggle'); button.dataset.v7111FooterToggle = 'true'; let links = column.querySelector(':scope > .v7111-footer-links'); if (!links) { links = document.createElement('div'); links.className = 'v7111-footer-links'; links.id = `v7111-footer-links-${index + 1}`; [...column.children].filter((child) => child.matches('a')).forEach((link) => links.append(link)); column.append(links); } button.setAttribute('aria-controls', links.id); button.setAttribute('aria-expanded', String(!mobile.matches)); const label = (button.textContent || '').trim(); button.setAttribute('aria-label', `${label}页脚目录`); button.addEventListener('click', () => { if (!mobile.matches) return; const willOpen = column.dataset.v7111Open !== 'true'; columns.forEach((item) => { item.dataset.v7111Open = 'false'; }); if (willOpen) column.dataset.v7111Open = 'true'; syncFooter(); }); }); function syncFooter() { columns.forEach((column) => { const button = column.querySelector('[data-v7111-footer-toggle]'); if (!button) return; const expanded = !mobile.matches || column.dataset.v7111Open === 'true'; button.setAttribute('aria-expanded', String(expanded)); }); } if (typeof mobile.addEventListener === 'function') mobile.addEventListener('change', syncFooter); else if (typeof mobile.addListener === 'function') mobile.addListener(syncFooter); syncFooter(); })();