(function () { 'use strict'; if (window.__DBC_SITE_V282__) return; window.__DBC_SITE_V282__ = true; const html = document.documentElement; const body = document.body; function markRelease() { const release = body.dataset.dbcRelease || html.dataset.dbcRelease || 'v3.0.0'; html.dataset.dbcRelease = release; body.dataset.dbcRelease = release; body.classList.add('v282-enhanced'); const footer = document.querySelector('footer.site-footer, footer.v260-footer'); if (footer) footer.dataset.dbcRelease = release; } function stabilizeMeasuredContent() { if (body.classList.contains('home-v282')) return; document.querySelectorAll('[data-v270-reveal], [data-v280-reveal]').forEach(function (element) { element.classList.add('is-v270-visible', 'is-v280-visible'); }); } function wrapTechnicalTables() { document.querySelectorAll('main table').forEach(function (table) { const parent = table.parentElement; if (!parent || parent.classList.contains('v282-table-wrap')) return; if (/(?:table-wrap|table-scroll|table-container|overflow)/i.test(parent.className || '')) return; const wrapper = document.createElement('div'); wrapper.className = 'v282-table-wrap'; wrapper.tabIndex = 0; wrapper.setAttribute('role', 'region'); const section = table.closest('section, article'); const heading = section && section.querySelector('h2, h3'); wrapper.setAttribute('aria-label', heading ? `${heading.textContent.trim()}表格` : '技术信息表格'); parent.insertBefore(wrapper, table); wrapper.appendChild(table); }); } function centerCurrentPath() { if (!window.matchMedia('(max-width: 760px)').matches) return; document.querySelectorAll('.v281-path ol').forEach(function (list) { const current = list.querySelector('[data-v281-current]'); if (!current) return; const target = current.offsetLeft - Math.max(0, (list.clientWidth - current.offsetWidth) / 2); list.scrollLeft = Math.max(0, target); }); } function markScrollableNavigation() { document.querySelectorAll('.v270-context__links, .about-anchor-nav, .formal-page-nav__inner, .v245-local-nav__inner, .bioten-product-nav, .knowledge-anchor-nav').forEach(function (nav) { if (nav.scrollWidth > nav.clientWidth + 2) nav.dataset.v282Scrollable = 'true'; else nav.removeAttribute('data-v282-scrollable'); }); } function markFilePreviewForms() { if (window.location.protocol !== 'file:') return; document.querySelectorAll('form[action*=".php"], form[action^="/api/"]').forEach(function (form, index) { if (form.querySelector('.v300-file-preview-note')) return; const note = document.createElement('p'); note.className = 'v300-file-preview-note'; note.id = 'v300-file-preview-note-' + (index + 1); note.textContent = '本地 HTML 预览模式:页面内容可以浏览,表单提交需在已配置 PHP 的网站环境中完成。'; form.appendChild(note); const submit = form.querySelector('button[type="submit"], input[type="submit"]'); if (submit) submit.setAttribute('aria-describedby', note.id); form.addEventListener('submit', function (event) { event.preventDefault(); note.dataset.active = 'true'; note.setAttribute('role', 'status'); }); }); } markRelease(); stabilizeMeasuredContent(); wrapTechnicalTables(); centerCurrentPath(); markScrollableNavigation(); markFilePreviewForms(); let resizeFrame = 0; window.addEventListener('resize', function () { window.cancelAnimationFrame(resizeFrame); resizeFrame = window.requestAnimationFrame(function () { centerCurrentPath(); markScrollableNavigation(); }); }, { passive: true }); })();