const SITE_THEME_STORAGE_KEY = 'dbc-site-theme'; const SITE_LANGUAGE_STORAGE_KEY = 'dbc-site-language'; const LEGACY_REQUEST_STORAGE_KEY = 'biotenRequestFormLast'; const FORM_PRIVACY_NOTICE_VERSION = '2026-07-15'; const SITE_LANGUAGE_PACK_FILES = [ 'assets/js/site-en-core.js?v=20260717-v271', 'assets/js/site-en-v720-primary.js?v=20260721-v720' ]; applyBaseSiteTheme(); applySavedSiteLanguage(); document.addEventListener('DOMContentLoaded', () => { markUnifiedPage(); initSiteLanguageToggle(); syncBiotenHeroDarkMode(); const params = new URLSearchParams(window.location.search); const intent = params.get('intent') || params.get('from'); if (intent) { const field = document.querySelector('[name="intent"]'); if (field) field.value = intent; document.querySelectorAll('[data-intent-preset]').forEach(option => { const intents = String(option.dataset.intentPreset || '').split(/\s+/).filter(Boolean); if (option instanceof HTMLOptionElement && intents.includes(intent)) option.selected = true; }); } document.querySelectorAll('form[data-demo]').forEach(form => { form.addEventListener('submit', event => { event.preventDefault(); form.querySelector('[data-status]').textContent = document.documentElement.dataset.lang === 'en' ? 'Saved as a demo lead for future CRM / CMS integration.' : '已记录为演示线索,可在后续接入 CRM / CMS。'; }); }); const saveButton = document.querySelector('[data-save-page-pdf]'); if (saveButton) { saveButton.addEventListener('click', () => savePageAsPdf(saveButton)); } initHomeReveals(); initBiotenFloatingIcons(); initHomepageCardTilt(); initHomeNewsViewToggle(); initNewsCardImageLinks(); initBrandSphereControl(); initSectionNavState(); initBackToTop(); initNewsArticleEnhancements(); initBiotenRequestForm(); initSiteNavigation(); }); document.addEventListener('dbc:translations-loaded', () => { if (isEnglishReadyPage() && document.documentElement.dataset.lang === 'en') { translatePageLanguage('en'); scheduleSiteLanguageRefreshes(); } }); document.addEventListener('dbc:languagechange', (event) => { if (!isEnglishReadyPage()) return; const language = event.detail?.language === 'en' ? 'en' : 'zh'; translatePageLanguage(language); }); const SITE_LANGUAGE_DICTIONARY = Object.freeze({ "菜单": "Menu", "世界杯竞猜官网": "DBC", "世界杯竞猜官网首页": "DBC Home", "博碳循环": "BIOTEN", "博碳": "BIOTEN", "主导航": "Main navigation", "博碳生物": "BIOTEN", "博碳包装": "BIOTEN Packaging", "博碳开发者": "BIOTEN Developer", "博碳观察": "BIOTEN Observer", "新闻动态": "Newsroom", "资料中心": "Resource Center", "知识与标准": "Knowledge & Standards", "联系合作": "Contact", "网站地图": "Sitemap", "隐私与数据使用说明": "Privacy & Data Use Notice", "查看": "View", "查看详情": "View details", "了解更多": "Learn more", "联系咨询": "Contact us", "提交": "Submit", "重置": "Reset", "复制": "Copy", "下载": "Download", "回到顶部": "Back to top", "返回顶部": "Back to top", "中文": "中文", "英文": "English", "中": "中", "英": "EN" }); const SITE_LANGUAGE_ATTRIBUTE_NAMES = ['aria-label', 'title', 'alt', 'placeholder', 'content']; const SITE_LANGUAGE_SKIP_SELECTOR = 'script,style,noscript,template,svg,canvas,code,pre,[data-v720-language-managed],[data-site-language-link]'; const SITE_PRODUCT_NAME_REPLACEMENTS = [ ['01 / Bioten™ Plus(通用候选路线)', 'Bioten™ Plus'], ['02 / Bioten™ Pro(定制协同路线)', 'Bioten™ Pro'], ['03 / Bioten™ Ultra(专项验证路线)', 'Bioten™ Ultra'], ['Bioten™ Plus(通用候选路线)', 'Bioten™ Plus'], ['Bioten™ Pro(定制协同路线)', 'Bioten™ Pro'], ['Bioten™ Ultra(专项验证路线)', 'Bioten™ Ultra'], ['(通用候选路线)', ''], ['(定制协同路线)', ''], ['(专项验证路线)', ''], ['通用候选路线', 'Bioten™ Plus'], ['定制协同路线', 'Bioten™ Pro'], ['专项验证路线', 'Bioten™ Ultra'] ]; let siteLanguageMutationObserver = null; let siteLanguageMutationTimer = 0; let siteLanguagePacksRequested = false; let siteLanguageIsTranslating = false; function applyBaseSiteTheme() { document.documentElement.dataset.theme = 'light'; document.documentElement.style.colorScheme = 'light'; } function getStoredSiteLanguage() { const siteLanguage = document.documentElement.dataset.siteLanguage; if (siteLanguage === 'en' || siteLanguage === 'zh') return siteLanguage; if (!isEnglishReadyPage()) return 'zh'; try { return localStorage.getItem(SITE_LANGUAGE_STORAGE_KEY) === 'en' ? 'en' : 'zh'; } catch (error) { return 'zh'; } } function applySavedSiteLanguage(language = getStoredSiteLanguage()) { const siteLanguage = document.documentElement.dataset.siteLanguage; const lang = siteLanguage === 'en' || siteLanguage === 'zh' ? siteLanguage : (isEnglishReadyPage() && language === 'en' ? 'en' : 'zh'); document.documentElement.dataset.lang = lang; document.documentElement.lang = lang === 'en' ? 'en' : 'zh-CN'; } function isEnglishReadyPage() { const htmlFlag = document.documentElement.getAttribute('data-en-ready'); const bodyFlag = document.body ? document.body.getAttribute('data-en-ready') : null; return htmlFlag === '' || htmlFlag === 'true' || bodyFlag === '' || bodyFlag === 'true'; } function translateSiteText(value, language) { const text = String(value || ''); const trimmed = text.trim(); if (!trimmed) return text; if (language !== 'en') return text; const compact = normalizeWhitespaceForTranslation(trimmed); let translated; if (Object.prototype.hasOwnProperty.call(SITE_LANGUAGE_DICTIONARY, trimmed)) { translated = SITE_LANGUAGE_DICTIONARY[trimmed]; } else if (Object.prototype.hasOwnProperty.call(SITE_LANGUAGE_DICTIONARY, compact)) { translated = SITE_LANGUAGE_DICTIONARY[compact]; } else { translated = getLoadedSiteTranslation(trimmed); if (typeof translated !== 'string') translated = getLoadedSiteTranslation(compact); } const hasTranslation = typeof translated === 'string'; const normalized = normalizeProductNamesForEnglish(hasTranslation ? translated : trimmed); if (!hasTranslation && normalized === trimmed) return text; const leading = text.match(/^\s*/)?.[0] || ''; const trailing = text.match(/\s*$/)?.[0] || ''; return `${leading}${normalized}${trailing}`; } function normalizeWhitespaceForTranslation(value) { return String(value || '').replace(/\s+/g, ' ').trim(); } function getLoadedSiteTranslation(key) { const translations = window.DBC_EN_TRANSLATIONS; if (!translations || typeof translations !== 'object') return undefined; return Object.prototype.hasOwnProperty.call(translations, key) ? translations[key] : undefined; } function normalizeProductNamesForEnglish(value) { let normalized = String(value || ''); SITE_PRODUCT_NAME_REPLACEMENTS.forEach(([source, target]) => { normalized = normalized.split(source).join(target); }); return normalized .replace(/\b(Bioten™ (?:Plus|Pro|Ultra))(?=[A-Za-z0-9])/g, '$1 ') .replace(/\s{2,}/g, ' ') .trim(); } function translatePageLanguage(language = getStoredSiteLanguage()) { if (!isEnglishReadyPage()) language = 'zh'; applySavedSiteLanguage(language); if (language === 'en') loadSiteLanguagePacks(); siteLanguageIsTranslating = true; try { if (!document.documentElement.dataset.dbcOriginalTitle) { document.documentElement.dataset.dbcOriginalTitle = document.title; } const originalTitle = document.documentElement.dataset.dbcOriginalTitle; document.title = language === 'en' ? translateSiteText(originalTitle, language) : originalTitle; document.querySelectorAll('*').forEach(element => { if (element.matches(SITE_LANGUAGE_SKIP_SELECTOR)) return; SITE_LANGUAGE_ATTRIBUTE_NAMES.forEach(attribute => { if (!element.hasAttribute(attribute)) return; if (!element.dataset.dbcOriginalAttrs) element.dataset.dbcOriginalAttrs = '{}'; let originals = {}; try { originals = JSON.parse(element.dataset.dbcOriginalAttrs || '{}'); } catch (error) { originals = {}; } if (!Object.prototype.hasOwnProperty.call(originals, attribute)) { originals[attribute] = element.getAttribute(attribute); element.dataset.dbcOriginalAttrs = JSON.stringify(originals); } const original = originals[attribute]; element.setAttribute(attribute, language === 'en' ? translateSiteText(original, language) : original); }); }); const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, { acceptNode(node) { const parent = node.parentElement; if (!parent || parent.closest(SITE_LANGUAGE_SKIP_SELECTOR)) return NodeFilter.FILTER_REJECT; return node.nodeValue.trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; } }); const nodes = []; while (walker.nextNode()) nodes.push(walker.currentNode); nodes.forEach(node => { if (typeof node.__dbcOriginalText !== 'string') node.__dbcOriginalText = node.nodeValue; node.nodeValue = language === 'en' ? translateSiteText(node.__dbcOriginalText, language) : node.__dbcOriginalText; }); } finally { siteLanguageIsTranslating = false; } applyPrimaryLanguageOverrides(language); if (language === 'en') translateCurrentChineseFragments(); } function applyPrimaryLanguageOverrides(language) { const file = decodeURIComponent(window.location.pathname.split('/').pop() || 'index.html').toLowerCase(); if (file !== 'bioten-platform.html') return; const heading = document.querySelector('.btp580-hero h1'); if (!heading) return; heading.setAttribute('data-v720-language-managed', 'true'); const html = language === 'en' ? 'PHA waterborne emulsionsdesigned and verifiedfor industrial applications.' : '让 PHA 水性功能乳液,成为可设计、可验证的产业材料。'; if (heading.innerHTML !== html) heading.innerHTML = html; } function loadSiteLanguagePacks() { if (!isEnglishReadyPage()) return; if (siteLanguagePacksRequested) return; siteLanguagePacksRequested = true; SITE_LANGUAGE_PACK_FILES.forEach(src => { const script = document.createElement('script'); script.src = src; script.async = false; script.defer = true; script.dataset.dbcLanguagePack = 'true'; document.head.appendChild(script); }); } function scheduleSiteLanguageRefreshes() { if (!isEnglishReadyPage()) return; [250, 750, 1500, 3000, 5000].forEach(delay => { window.setTimeout(() => { if (document.documentElement.dataset.lang === 'en') translateCurrentChineseFragments(); }, delay); }); } function translateCurrentChineseFragments(root = document.body) { if (!root || document.documentElement.dataset.lang !== 'en') return; const hasChinese = /[\u4e00-\u9fff]/; const translateCurrentValue = value => { const text = String(value || ''); if (!hasChinese.test(text) || text.trim() === '中') return text; return translateSiteText(text, 'en'); }; document.querySelectorAll('*').forEach(element => { if (element.matches(SITE_LANGUAGE_SKIP_SELECTOR)) return; SITE_LANGUAGE_ATTRIBUTE_NAMES.forEach(attribute => { if (!element.hasAttribute(attribute)) return; const current = element.getAttribute(attribute); const translated = translateCurrentValue(current); if (translated !== current) { if (!element.dataset.dbcOriginalAttrs) element.dataset.dbcOriginalAttrs = '{}'; let originals = {}; try { originals = JSON.parse(element.dataset.dbcOriginalAttrs || '{}'); } catch (error) { originals = {}; } if (!Object.prototype.hasOwnProperty.call(originals, attribute)) { originals[attribute] = current; element.dataset.dbcOriginalAttrs = JSON.stringify(originals); } element.setAttribute(attribute, translated); } }); }); const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, { acceptNode(node) { const parent = node.parentElement; if (!parent || parent.closest(SITE_LANGUAGE_SKIP_SELECTOR)) return NodeFilter.FILTER_REJECT; return hasChinese.test(node.nodeValue || '') ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; } }); const nodes = []; while (walker.nextNode()) nodes.push(walker.currentNode); nodes.forEach(node => { if (node.nodeValue.trim() === '中') return; const translated = translateCurrentValue(node.nodeValue); if (translated !== node.nodeValue) { if (typeof node.__dbcOriginalText !== 'string') node.__dbcOriginalText = node.nodeValue; node.nodeValue = translated; } }); } function initSiteLanguageMutationObserver() { if (!isEnglishReadyPage() || siteLanguageMutationObserver || !document.body) return; siteLanguageMutationObserver = new MutationObserver(mutations => { if (siteLanguageIsTranslating) return; if (document.documentElement.dataset.lang !== 'en') return; if (!mutations.some(mutation => (mutation.addedNodes && mutation.addedNodes.length) || mutation.type === 'characterData')) return; mutations.forEach(mutation => { if (mutation.type === 'characterData' && mutation.target && mutation.target.nodeValue && /[\u4e00-\u9fff]/.test(mutation.target.nodeValue)) { mutation.target.__dbcOriginalText = mutation.target.nodeValue; } }); window.clearTimeout(siteLanguageMutationTimer); siteLanguageMutationTimer = window.setTimeout(() => { if (document.documentElement.dataset.lang !== 'en') return; translatePageLanguage('en'); }, 80); }); siteLanguageMutationObserver.observe(document.body, { childList: true, characterData: true, subtree: true }); } function injectLanguageToggleRuntimeStyles() { if (document.getElementById('dbc-language-toggle-runtime-style')) return; const style = document.createElement('style'); style.id = 'dbc-language-toggle-runtime-style'; style.textContent = ` html body[class][class][class][class][class][class] .site-header.site-header .language-toggle.language-toggle, html[data-lang="en"] body[class][class][class][class][class][class] .site-header.site-header .language-toggle.language-toggle{ width:72px!important; min-width:72px!important; max-width:72px!important; height:44px!important; min-height:44px!important; padding:6px!important; border:1px solid rgba(64,145,235,.28)!important; border-radius:999px!important; background:linear-gradient(180deg,rgba(255,255,255,.96),rgba(237,247,255,.9))!important; background-image:linear-gradient(180deg,rgba(255,255,255,.96),rgba(237,247,255,.9))!important; color:#1769c2!important; box-shadow:0 10px 24px rgba(48,126,214,.14),inset 0 1px 0 rgba(255,255,255,.95)!important; text-shadow:none!important; -webkit-backdrop-filter:blur(14px) saturate(150%)!important; backdrop-filter:blur(14px) saturate(150%)!important; } html body[class][class][class][class][class][class] .site-header.site-header .language-toggle.language-toggle:hover, html[data-lang="en"] body[class][class][class][class][class][class] .site-header.site-header .language-toggle.language-toggle:hover{ border-color:rgba(38,132,235,.46)!important; background:linear-gradient(180deg,#fff,rgba(225,242,255,.96))!important; background-image:linear-gradient(180deg,#fff,rgba(225,242,255,.96))!important; color:#0f67bd!important; box-shadow:0 12px 28px rgba(38,132,235,.18),inset 0 1px 0 rgba(255,255,255,1)!important; transform:translateY(-1px)!important; } html body[class] .site-header.site-header .language-toggle-track, html[data-lang="en"] body[class] .site-header.site-header .language-toggle-track{ width:64px!important; height:30px!important; border:1px solid rgba(64,145,235,.22)!important; border-radius:999px!important; background:linear-gradient(180deg,#f7fbff,#e9f5ff)!important; box-shadow:inset 0 1px 3px rgba(23,105,194,.12)!important; } html body[class] .site-header.site-header .language-toggle-option, html[data-lang="en"] body[class] .site-header.site-header .language-toggle-option{ color:#3f7fbd!important; font-size:11px!important; font-weight:780!important; letter-spacing:0!important; text-shadow:none!important; } html body[class] .site-header.site-header .language-toggle-thumb, html[data-lang="en"] body[class] .site-header.site-header .language-toggle-thumb{ left:3px!important; top:3px!important; width:28px!important; height:22px!important; border-radius:999px!important; background:linear-gradient(180deg,#4aa3ff,#1476d4)!important; box-shadow:0 5px 12px rgba(20,118,212,.32),inset 0 1px 0 rgba(255,255,255,.45)!important; } html body[class] .site-header.site-header .language-toggle[aria-pressed="false"] .language-toggle-option-zh, html body[class] .site-header.site-header .language-toggle[aria-pressed="true"] .language-toggle-option-en, html[data-lang="en"] body[class] .site-header.site-header .language-toggle[aria-pressed="false"] .language-toggle-option-zh, html[data-lang="en"] body[class] .site-header.site-header .language-toggle[aria-pressed="true"] .language-toggle-option-en{ color:#fff!important; } html body[class] .site-header.site-header .language-toggle[aria-pressed="true"] .language-toggle-thumb, html[data-lang="en"] body[class] .site-header.site-header .language-toggle[aria-pressed="true"] .language-toggle-thumb{ transform:translateX(30px)!important; background:linear-gradient(180deg,#78bdff,#2385e2)!important; } `; document.head.appendChild(style); } function initSiteLanguageToggle() { const headerInner = document.querySelector('.site-header .header-inner'); if (!headerInner) return; // The standalone sites navigate between directories instead of translating in place. if (headerInner.querySelector('[data-site-language-link]')) { applySavedSiteLanguage(); return; } headerInner.querySelectorAll('[data-theme-toggle],.theme-toggle').forEach(element => element.remove()); if (!isEnglishReadyPage()) { const unavailableButton = headerInner.querySelector('[data-language-toggle],.language-toggle'); if (unavailableButton && unavailableButton.hasAttribute('data-language-home-fallback')) { unavailableButton.disabled = false; unavailableButton.removeAttribute('data-language-unavailable'); unavailableButton.setAttribute('aria-label', 'Open the English homepage'); unavailableButton.setAttribute('title', '进入英文首页'); unavailableButton.setAttribute('aria-pressed', 'false'); applySavedSiteLanguage('zh'); return; } if (unavailableButton) { unavailableButton.disabled = true; unavailableButton.setAttribute('data-language-unavailable', ''); unavailableButton.setAttribute('aria-label', 'English content is being prepared'); unavailableButton.setAttribute('title', '英文内容正在准备中'); unavailableButton.setAttribute('aria-pressed', 'false'); } applySavedSiteLanguage('zh'); return; } injectLanguageToggleRuntimeStyles(); let button = headerInner.querySelector('[data-language-toggle]'); if (!button) { button = document.createElement('button'); headerInner.appendChild(button); } button.className = 'language-toggle'; button.type = 'button'; button.setAttribute('data-language-toggle', ''); if (!button.querySelector('.language-toggle-track')) { button.innerHTML = [ '' ].join(''); } const setButtonState = language => { const isEnglish = language === 'en'; button.setAttribute('aria-label', isEnglish ? 'Switch to Chinese' : 'Switch to English'); button.setAttribute('title', isEnglish ? 'Switch to Chinese' : 'Switch to English'); button.setAttribute('aria-pressed', String(isEnglish)); }; const setLanguage = language => { const nextLanguage = language === 'en' ? 'en' : 'zh'; if (nextLanguage === 'zh') { window.clearTimeout(siteLanguageMutationTimer); siteLanguageMutationTimer = 0; } try { localStorage.setItem(SITE_LANGUAGE_STORAGE_KEY, nextLanguage); } catch (error) { // Language still updates for the current page if storage is unavailable. } translatePageLanguage(nextLanguage); setButtonState(nextLanguage); document.dispatchEvent(new CustomEvent('dbc:languagechange', { detail: { language: nextLanguage } })); }; const initialLanguage = getStoredSiteLanguage(); translatePageLanguage(initialLanguage); initSiteLanguageMutationObserver(); setButtonState(initialLanguage); button.addEventListener('click', () => { const currentLanguage = document.documentElement.dataset.lang === 'en' ? 'en' : 'zh'; setLanguage(currentLanguage === 'en' ? 'zh' : 'en'); }); } function getStoredSiteTheme() { try { const theme = localStorage.getItem(SITE_THEME_STORAGE_KEY); return theme === 'dark' || theme === 'light' ? theme : ''; } catch (error) { return ''; } } function getPreferredSiteTheme() { return getStoredSiteTheme() || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); } function applySavedSiteTheme(theme = getPreferredSiteTheme()) { document.documentElement.dataset.theme = theme; document.documentElement.style.colorScheme = theme; } function injectDarkModeRuntimeStyles() { if (document.getElementById('dbc-dark-runtime-style')) return; const style = document.createElement('style'); style.id = 'dbc-dark-runtime-style'; style.textContent = ` html[data-theme="dark"] body{ background:#0d1110!important; color:#f5f8f6!important; } html[data-theme="dark"] body .site-header, html[data-theme="dark"] body header.site-header{ background:#0d1110!important; background-image:none!important; border-color:rgba(255,255,255,.14)!important; } html[data-theme="dark"] body .site-header :is(.header-inner,.brand-logos,.nav,.nav-item){ background:transparent!important; background-image:none!important; } html[data-theme="dark"] body .site-header :is(.nav-link,.nav a){ color:#d8e2de!important; -webkit-text-fill-color:#d8e2de!important; } html[data-theme="dark"] body .site-header :is(.nav-item.is-active>.nav-link,.nav-link[aria-current="page"],.nav-link:hover,.nav-link:focus){ color:#6ee8a2!important; -webkit-text-fill-color:#6ee8a2!important; } html[data-theme="dark"] body .site-header .nav-menu, html[data-theme="dark"] body .site-header .nav-menu::before, html[data-theme="dark"] body .site-header .nav-menu a, html[data-theme="dark"] body .site-header .nav-menu a strong, html[data-theme="dark"] body .site-header .nav-menu a span{ background:#111916!important; background-image:none!important; border-color:rgba(255,255,255,.14)!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } html[data-theme="dark"] body .theme-toggle{ background:rgba(18,24,22,.88)!important; border-color:rgba(255,255,255,.18)!important; color:#ecf4ef!important; -webkit-text-fill-color:#ecf4ef!important; } html[data-theme="dark"] body main, html[data-theme="dark"] body :is(.product-lines-main,.request-page,.lab-request-hero){ background:#0d1110!important; background-image:none!important; color:#f5f8f6!important; } html[data-theme="dark"] body main :is(section,article,aside,form,table,thead,tbody,tfoot,tr,th,td,dl,ul,ol,li,figure,blockquote,div[class],span:not(.theme-toggle-text):not(.theme-toggle-thumb):not(.theme-toggle-track):not(.company-proof-badge)){ background-color:#0d1110!important; background-image:none!important; border-color:rgba(255,255,255,.12)!important; box-shadow:none!important; } html[data-theme="dark"] body main :is(h1,h2,h3,h4,h5,h6,strong,b,dt,th,a){ color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; text-shadow:none!important; } html[data-theme="dark"] body main :is(p,li,dd,td,span,small,em,label,legend){ color:#c8d1cd!important; -webkit-text-fill-color:#c8d1cd!important; text-shadow:none!important; } html[data-theme="dark"] body main :is(.home-eyebrow,.hero-eyebrow,.eyebrow,.section-kicker,.tag,[class*="kicker"],[class*="label"]){ background:transparent!important; color:#6ee8a2!important; -webkit-text-fill-color:#6ee8a2!important; } html[data-theme="dark"] body main :is(button,.button,.home-link,.dbc-btn,input,select,textarea){ background:#111916!important; background-image:none!important; border-color:rgba(110,232,162,.32)!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } html[data-theme="dark"] body :is(footer,.site-footer,.footer), html[data-theme="dark"] body :is(footer,.site-footer,.footer) :is(.footer-inner,.footer-note,.footer-directory,.footer-column,.footer-column h3,.footer-column a,.footer-bottom,.footer-bottom strong,.footer-legal,.footer-legal span){ background:#0d1110!important; background-image:none!important; border-color:rgba(255,255,255,.12)!important; box-shadow:none!important; } html[data-theme="dark"] body :is(footer,.site-footer,.footer) :is(.footer-inner,.footer-note,.footer-bottom,.footer-legal,.footer-legal span){ color:#c8d1cd!important; -webkit-text-fill-color:#c8d1cd!important; } html[data-theme="dark"] body :is(footer,.site-footer,.footer) :is(.footer-column h3,.footer-bottom strong){ color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } html[data-theme="dark"] body :is(footer,.site-footer,.footer) .footer-column a{ color:#9ff1bd!important; -webkit-text-fill-color:#9ff1bd!important; } /* Final dark-mode overrides for page templates that lock white panels with high-specificity !important rules. */ html[data-theme="dark"][data-theme] body[class] main:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body.product-editorial-page.product-editorial-page.product-lines-detail-page.product-lines-detail-page main.product-lines-main.pro-product-main:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body.product-editorial-page.product-editorial-page.bioten-matrix-page.bioten-matrix-page main:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body.nav-editorial-page.nav-editorial-page.bioten-request-page.bioten-request-page main.request-page:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:#0d1110!important; background-color:#0d1110!important; background-image:none!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } html[data-theme="dark"][data-theme] body[class] main :is(section,article,aside,nav,form,fieldset,table,thead,tbody,tfoot,tr,th,td,dl,ul,ol,li,figure,figcaption,blockquote,details,summary,div[class]):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC):not(.theme-toggle):not(.theme-toggle-track):not(.theme-toggle-thumb){ background-color:#0d1110!important; background-image:none!important; border-color:rgba(255,255,255,.12)!important; box-shadow:none!important; } html[data-theme="dark"][data-theme] body[class] main span:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC):not(.theme-toggle-text):not(.theme-toggle-thumb):not(.theme-toggle-track):not(.company-proof-badge):not([class*="icon"]){ background-color:transparent!important; background-image:none!important; border-color:rgba(255,255,255,.12)!important; color:#c8d1cd!important; -webkit-text-fill-color:#c8d1cd!important; } html[data-theme="dark"][data-theme] body[class] main :is(h1,h2,h3,h4,h5,h6,strong,b,dt,th,a):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body[class] main :is(h1,h2,h3,h4,h5,h6,strong,b,dt,th,a) span:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; text-shadow:none!important; } html[data-theme="dark"][data-theme] body[class] main :is(p,li,dd,td,small,em,label,legend,summary,figcaption):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ color:#c8d1cd!important; -webkit-text-fill-color:#c8d1cd!important; text-shadow:none!important; } html[data-theme="dark"][data-theme] body.news-article-page.news-article-page.news-article-page.news-article-page main article.news-original-article > header.news-hero.news-original-hero:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body.news-article-page.news-article-page main :is(.news-hero,.news-original-hero):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:#0d1110!important; background-color:#0d1110!important; background-image:none!important; border-color:rgba(255,255,255,.12)!important; box-shadow:none!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } html[data-theme="dark"][data-theme] body.news-article-page.news-article-page main :is(.news-hero,.news-original-hero)::before, html[data-theme="dark"][data-theme] body.news-article-page.news-article-page main :is(.news-hero,.news-original-hero)::after, html[data-theme="dark"][data-theme] body.news-article-page.news-article-page main :is(.news-hero,.news-original-hero) :is(.news-hero-copy,.news-hero-heading)::before, html[data-theme="dark"][data-theme] body.news-article-page.news-article-page main :is(.news-hero,.news-original-hero) :is(.news-hero-copy,.news-hero-heading)::after{ background:none!important; background-image:none!important; border-color:rgba(255,255,255,.12)!important; box-shadow:none!important; } html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page .site-header.site-header:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body[class] .site-header.site-header:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:#0d1110!important; background-color:#0d1110!important; background-image:none!important; border-color:rgba(255,255,255,.14)!important; box-shadow:none!important; color:#d8e2de!important; -webkit-text-fill-color:#d8e2de!important; } html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page .site-header.site-header :is(.header-inner,.brand-logos,.nav,.nav-item):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body[class] .site-header.site-header :is(.header-inner,.brand-logos,.nav,.nav-item):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:transparent!important; background-color:transparent!important; background-image:none!important; color:#d8e2de!important; -webkit-text-fill-color:#d8e2de!important; } html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page .site-header.site-header :is(.nav-link.nav-link,#site-nav > .nav-link.nav-link,#site-nav > .nav-item.nav-item > .nav-link.nav-link):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body[class] .site-header.site-header :is(.nav-link.nav-link,#site-nav > .nav-link.nav-link,#site-nav > .nav-item.nav-item > .nav-link.nav-link):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:transparent!important; color:#d8e2de!important; -webkit-text-fill-color:#d8e2de!important; } html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page .site-header.site-header :is(.nav-item.nav-item:hover > .nav-link.nav-link,.nav-item.nav-item:focus-within > .nav-link.nav-link,.nav-item.nav-item.is-active > .nav-link.nav-link,.nav-link.nav-link:hover,.nav-link.nav-link[aria-current="page"]):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body[class] .site-header.site-header :is(.nav-item.nav-item:hover > .nav-link.nav-link,.nav-item.nav-item:focus-within > .nav-link.nav-link,.nav-item.nav-item.is-active > .nav-link.nav-link,.nav-link.nav-link:hover,.nav-link.nav-link[aria-current="page"]):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:rgba(54,199,121,.13)!important; color:#6ee8a2!important; -webkit-text-fill-color:#6ee8a2!important; } html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page .site-header.site-header .nav-menu.nav-menu, html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page .site-header.site-header .nav-menu.nav-menu a, html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page .site-header.site-header .nav-menu.nav-menu a strong, html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page .site-header.site-header .nav-menu.nav-menu a span{ background:#111916!important; background-color:#111916!important; background-image:none!important; border-color:rgba(255,255,255,.14)!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page main.bioten-lab-main :is(.lab-request-hero,.lab-request-hero *,details,summary,.card,.glass,.field,.summary-card,.callout,.hint,.ok,.warn,.err,.info):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background-color:#0d1110!important; background-image:none!important; border-color:rgba(255,255,255,.12)!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; box-shadow:none!important; } html[data-theme="dark"][data-theme] body[class] main :is(a,.button,.dbc-btn,[class*="btn"],[class*="link"]):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC):not(.logo):not(.logo-image):not(.nav-link){ background-color:#111916!important; background-image:none!important; border-color:rgba(110,232,162,.32)!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } html[data-theme="dark"][data-theme] body[class] main :is(a,.button,.dbc-btn,[class*="btn"],[class*="link"]):hover:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC):not(.logo):not(.logo-image):not(.nav-link), html[data-theme="dark"][data-theme] body[class] main :is(a,.button,.dbc-btn,[class*="btn"],[class*="link"]):focus:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC):not(.logo):not(.logo-image):not(.nav-link){ background-color:#16231d!important; color:#6ee8a2!important; -webkit-text-fill-color:#6ee8a2!important; } html[data-theme="dark"][data-theme] body.news-list-page.news-list-page main img.openai-news-image:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body.news-list-page.news-list-page main .openai-news-image:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:#111916!important; background-color:#111916!important; } html[data-theme="dark"][data-theme] body.nav-editorial-page.nav-editorial-page.bioten-request-page.bioten-request-page main.request-page :is(.request-options label,.request-options-grid label,.request-options-featured label,.agreement-check):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:#111916!important; background-color:#111916!important; background-image:none!important; border-color:rgba(110,232,162,.24)!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } html[data-theme="dark"][data-theme] body.nav-editorial-page.nav-editorial-page.bioten-request-page.bioten-request-page main.request-page :is(.request-options label,.request-options-grid label,.request-options-featured label,.agreement-check):has(input:checked):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:#16231d!important; background-color:#16231d!important; border-color:rgba(110,232,162,.46)!important; } html[data-theme="dark"][data-theme] body.compliance-map-page.compliance-map-page main .compliance-map-shell .dog-marker.dog-marker:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body.compliance-map-page.compliance-map-page main .compliance-map-shell .dog-marker.dog-marker :is(.dog,.market-flag):not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:transparent!important; background-color:transparent!important; background-image:none!important; border-color:transparent!important; box-shadow:none!important; } html[data-theme="dark"][data-theme] body.compliance-map-page.compliance-map-page main .compliance-map-shell .market-docs.market-docs i:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:rgba(17,25,22,.92)!important; background-color:rgba(17,25,22,.92)!important; background-image:none!important; border-color:rgba(110,232,162,.24)!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } html[data-theme="dark"][data-theme]:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC), html[data-theme="dark"][data-theme] body.bioten-lab-page.bioten-lab-page.nav-editorial-page.nav-editorial-page.site-unified-page.site-unified-page:not(#dbcDarkForceA):not(#dbcDarkForceB):not(#dbcDarkForceC){ background:#0d1110!important; background-color:#0d1110!important; background-image:none!important; color:#f5f8f6!important; -webkit-text-fill-color:#f5f8f6!important; } `; document.head.appendChild(style); } function setImportantStyle(element, property, value) { if (!element) return; element.style.setProperty(property, value, 'important'); } function clearInlineStyles(element, properties) { if (!element) return; properties.forEach(property => element.style.removeProperty(property)); if (!element.getAttribute('style')) element.removeAttribute('style'); } function syncBiotenHeroDarkMode() { const hero = document.getElementById('bioten-particle-hero'); if (!hero) return; const isDark = document.documentElement.dataset.theme === 'dark'; const transparentLayers = hero.querySelectorAll([ '.bioten-hero-floating-icons', '.bioten-hero-floating-icon', '.bioten-particle-hero__content', '.bioten-particle-hero__intro', '.bioten-particle-hero__actions' ].join(',')); const icons = hero.querySelectorAll('.bioten-hero-floating-icon'); const orbs = hero.querySelectorAll('.bioten-hero-floating-orb'); const actions = hero.querySelectorAll('.bioten-particle-hero__actions a'); const styledElements = [hero, ...transparentLayers, ...icons, ...orbs, ...actions]; const touchedProperties = [ 'background', 'background-color', 'background-image', 'border-color', 'box-shadow', 'color', '-webkit-text-fill-color', 'filter' ]; if (!isDark) { styledElements.forEach(element => clearInlineStyles(element, touchedProperties)); return; } setImportantStyle(hero, 'background', 'radial-gradient(circle at 50% 28%,rgba(221,186,87,.16),transparent 34%),linear-gradient(180deg,#0d1110 0%,#121916 72%,#0d1110 100%)'); setImportantStyle(hero, 'background-color', '#0d1110'); transparentLayers.forEach(layer => { setImportantStyle(layer, 'background', 'transparent'); setImportantStyle(layer, 'background-color', 'transparent'); setImportantStyle(layer, 'background-image', 'none'); }); icons.forEach(icon => { setImportantStyle(icon, 'filter', 'drop-shadow(0 18px 34px rgba(221,186,87,.16)) drop-shadow(0 12px 28px rgba(110,232,162,.1))'); }); orbs.forEach(orb => { setImportantStyle(orb, 'background', 'radial-gradient(circle at 50% 50%,rgba(255,255,255,.2) 0%,rgba(216,182,90,.14) 54%,rgba(255,255,255,0) 74%)'); setImportantStyle(orb, 'background-color', 'transparent'); setImportantStyle(orb, 'filter', 'blur(6px)'); }); actions.forEach((action, index) => { if (index === 0) { setImportantStyle(action, 'background', '#d8b65a'); setImportantStyle(action, 'background-color', '#d8b65a'); setImportantStyle(action, 'border-color', '#d8b65a'); setImportantStyle(action, 'color', '#0d1110'); setImportantStyle(action, '-webkit-text-fill-color', '#0d1110'); return; } setImportantStyle(action, 'background', 'rgba(17,25,22,.74)'); setImportantStyle(action, 'background-color', 'rgba(17,25,22,.74)'); setImportantStyle(action, 'border-color', 'rgba(221,186,87,.34)'); setImportantStyle(action, 'color', '#f5f8f6'); setImportantStyle(action, '-webkit-text-fill-color', '#f5f8f6'); }); } function initBrandSphereControl() { const sphere = document.querySelector('.rail-brand-mosaic'); if (!sphere) return; sphere.setAttribute('role', 'button'); sphere.setAttribute('tabindex', '0'); sphere.setAttribute('aria-label', '品牌矩阵旋转球,点击暂停,鼠标移开继续旋转'); sphere.setAttribute('aria-pressed', 'false'); const resume = () => { sphere.classList.remove('is-paused'); sphere.setAttribute('aria-pressed', 'false'); }; const pause = () => { sphere.classList.add('is-paused'); sphere.setAttribute('aria-pressed', 'true'); }; sphere.addEventListener('click', pause); sphere.addEventListener('mouseleave', resume); sphere.addEventListener('blur', resume); sphere.addEventListener('keydown', event => { if (event.key !== 'Enter' && event.key !== ' ') return; event.preventDefault(); if (sphere.classList.contains('is-paused')) { resume(); } else { pause(); } }); } function markUnifiedPage() { const pathname = window.location.pathname.toLowerCase(); const page = (pathname.split('/').pop() || 'index.html').toLowerCase(); const preservedPages = new Set([ 'index.html', 'bioten.html', 'solutions.html', 'bioten-packaging.html', 'solutions-food-packaging.html', 'solutions-industrial.html', 'contact-intent-paper-sample.html', 'bioten-products-plus.html', 'bioten-products-pro.html', 'bioten-products-ultra.html' ]); const isProductDetailRoute = /\/bioten\/products\/(plus|pro|ultra)\/?$/.test(pathname); if (!preservedPages.has(page) && !isProductDetailRoute) { document.body.classList.add('site-unified-page'); } } function savePageAsPdf(button) { const originalLabel = button.textContent; button.disabled = true; button.textContent = '打开中...'; document.body.classList.add('is-exporting'); requestAnimationFrame(() => { window.print(); setTimeout(() => { document.body.classList.remove('is-exporting'); button.disabled = false; button.textContent = originalLabel; }, 800); }); } function initHomeReveals() { const revealItems = document.querySelectorAll('.apple-home .home-band, .apple-home .home-product-focus, .apple-home .site-footer'); if (!revealItems.length) return; if (!('IntersectionObserver' in window)) { revealItems.forEach(item => item.classList.add('is-visible')); return; } const observer = new IntersectionObserver(entries => { entries.forEach(entry => { if (!entry.isIntersecting) return; entry.target.classList.add('is-visible'); observer.unobserve(entry.target); }); }, { threshold: 0.14, rootMargin: '0px 0px -8% 0px' }); revealItems.forEach(item => observer.observe(item)); } function initBiotenFloatingIcons() { const hero = document.getElementById('bioten-particle-hero'); if (!hero || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; const items = hero.querySelectorAll('.bioten-hero-floating-icon'); if (!items.length) return; hero.addEventListener('mousemove', event => { items.forEach((item, index) => { const rect = item.getBoundingClientRect(); const itemX = rect.left + rect.width / 2; const itemY = rect.top + rect.height / 2; const dx = itemX - event.clientX; const dy = itemY - event.clientY; const distance = Math.hypot(dx, dy) || 1; const influence = Math.max(0, 1 - distance / 360); const directionX = dx / distance; const directionY = dy / distance; const weight = 7 + index * 1.2; const lift = influence * (5 + index * 0.8); item.style.setProperty('--parallax-x', `${directionX * influence * weight}px`); item.style.setProperty('--parallax-y', `${directionY * influence * weight - lift}px`); }); }); hero.addEventListener('mouseleave', () => { items.forEach(item => { item.style.removeProperty('--parallax-x'); item.style.removeProperty('--parallax-y'); }); }); } function initHomeNewsViewToggle() { const roots = document.querySelectorAll('[data-news-view-root]'); if (!roots.length) return; if (document.body.classList.contains('news-list-page')) { const buttons = document.querySelectorAll('.news-business-panel [data-news-view]'); if (!buttons.length) return; const setSharedView = view => { roots.forEach(root => { root.dataset.view = view; }); buttons.forEach(button => { const isActive = button.dataset.newsView === view; button.classList.toggle('is-active', isActive); button.setAttribute('aria-pressed', String(isActive)); }); }; buttons.forEach(button => { button.addEventListener('click', () => setSharedView(button.dataset.newsView)); }); setSharedView('grid'); return; } roots.forEach(root => { const scope = root.closest('.company-news, .news-business-panel') || document; const buttons = scope.querySelectorAll('[data-news-view]'); if (!buttons.length) return; const setView = view => { root.dataset.view = view; buttons.forEach(button => { const isActive = button.dataset.newsView === view; button.classList.toggle('is-active', isActive); button.setAttribute('aria-pressed', String(isActive)); }); }; buttons.forEach(button => { button.addEventListener('click', () => setView(button.dataset.newsView)); }); setView('grid'); }); } function initNewsCardImageLinks() { const cards = document.querySelectorAll('.home-news-card, .news-event-card'); cards.forEach(card => { const image = card.querySelector('img.openai-news-image, .home-news-media img'); if (!image || image.closest('a')) return; const link = card.querySelector('.news-actions a[href], a[href^="news-"][href$=".html"]'); if (!link) return; const imageLink = document.createElement('a'); imageLink.className = 'news-image-link'; imageLink.href = link.getAttribute('href'); imageLink.setAttribute('aria-label', link.textContent.trim() || image.alt || '阅读新闻详情'); image.parentNode.insertBefore(imageLink, image); imageLink.appendChild(image); }); } function initHomepageCardTilt() { const cards = document.querySelectorAll('.dbc-home-page .brand-feature, .dbc-home-page .brand-mini, .dbc-home-page .product-line, .dbc-home-page .company-news-grid article, .dbc-home-page .barrier-grid div, .dbc-home-page .lab-grid-home div'); if (!cards.length || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; cards.forEach(card => { card.addEventListener('mousemove', event => { const rect = card.getBoundingClientRect(); const rx = ((event.clientX - rect.left) / rect.width) - 0.5; const ry = ((event.clientY - rect.top) / rect.height) - 0.5; card.style.setProperty('--tilt-x', `${ry * -3}deg`); card.style.setProperty('--tilt-y', `${rx * 3}deg`); card.style.transform = `translateY(-4px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y))`; }); card.addEventListener('mouseleave', () => { card.style.removeProperty('--tilt-x'); card.style.removeProperty('--tilt-y'); card.style.transform = ''; }); }); } function initSectionNavState() { const navs = document.querySelectorAll([ '.home-page-nav', '.bioten-page-nav', '.about-anchor-nav', '.knowledge-anchor-nav', '.resources-page-nav', '.packaging-anchor', '.bioten-product-nav', '.pl-anchor-nav', '.vp-anchor-nav', '.article-nav', '.solutions-anchor' ].join(', ')); if (!navs.length) return; navs.forEach(nav => { const links = Array.from(nav.querySelectorAll('a[href^="#"]')); const sectionPairs = []; links.forEach(link => { const target = document.querySelector(link.getAttribute('href')); if (target) sectionPairs.push({ target, link }); }); if (!sectionPairs.length) return; const setActiveLink = activeLink => { links.forEach(link => { const isActive = link === activeLink; link.classList.toggle('is-active', isActive); if (isActive) { link.setAttribute('aria-current', 'true'); } else { link.removeAttribute('aria-current'); } }); }; const updateActiveLink = () => { const marker = window.scrollY + window.innerHeight * 0.42; let activePair = sectionPairs[0]; sectionPairs.forEach(pair => { const top = pair.target.getBoundingClientRect().top + window.scrollY; if (top <= marker) activePair = pair; }); setActiveLink(activePair.link); }; let ticking = false; const queueUpdate = () => { if (ticking) return; ticking = true; window.requestAnimationFrame(() => { ticking = false; updateActiveLink(); }); }; window.addEventListener('scroll', queueUpdate, { passive: true }); window.addEventListener('resize', queueUpdate); updateActiveLink(); }); } function initBackToTop() { let button = document.querySelector('[data-back-to-top]'); if (!button) { button = document.createElement('button'); button.className = 'site-back-to-top'; button.type = 'button'; button.setAttribute('data-back-to-top', ''); button.setAttribute('aria-label', '回到顶部'); button.innerHTML = ''; document.body.appendChild(button); } const toggleButton = () => { button.classList.toggle('is-visible', window.scrollY > window.innerHeight * 0.6); }; button.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth' }); }); window.addEventListener('scroll', toggleButton, { passive: true }); window.addEventListener('resize', toggleButton); toggleButton(); } function initNewsArticleEnhancements() { if (!document.body.classList.contains('news-article-page')) return; const heading = document.querySelector('.news-article-heading'); const content = document.querySelector('.news-content-original, .news-content'); if (!heading || !content) return; const meta = heading.querySelector('p'); if (meta && !heading.querySelector('.news-article-actions')) { const actions = document.createElement('div'); actions.className = 'news-article-actions'; actions.setAttribute('aria-label', '文章操作'); actions.innerHTML = [ '', '下载', '' ].join(''); meta.insertAdjacentElement('afterend', actions); const articleFilename = decodeURIComponent(window.location.pathname.split('/').pop() || ''); const pdfLink = actions.querySelector('[data-news-pdf]'); pdfLink.href = `docs/assets/pdf/news/${articleFilename.replace(/\.html$/i, '.pdf')}`; actions.querySelector('[data-news-share]').addEventListener('click', async event => { const button = event.currentTarget; const title = document.title; const url = window.location.href; try { if (navigator.share) { await navigator.share({ title, url }); } else if (navigator.clipboard) { await navigator.clipboard.writeText(url); flashActionLabel(button, '已复制链接'); } } catch (error) { if (navigator.clipboard) { await navigator.clipboard.writeText(url); flashActionLabel(button, '已复制链接'); } } }); actions.querySelector('[data-news-like]').addEventListener('click', event => { const button = event.currentTarget; const key = `dbc-news-liked:${window.location.pathname}`; const liked = localStorage.getItem(key) === '1'; localStorage.setItem(key, liked ? '0' : '1'); button.classList.toggle('is-liked', !liked); button.setAttribute('aria-label', liked ? '点赞' : '已点赞'); button.setAttribute('title', liked ? '点赞' : '已点赞'); }); const likeButton = actions.querySelector('[data-news-like]'); if (localStorage.getItem(`dbc-news-liked:${window.location.pathname}`) === '1') { likeButton.classList.add('is-liked'); likeButton.setAttribute('aria-label', '已点赞'); likeButton.setAttribute('title', '已点赞'); } } const continueSection = content.querySelector('.news-continue'); if (continueSection && !content.querySelector('.news-continue-return')) { const returnWrap = document.createElement('div'); returnWrap.className = 'news-continue-return'; returnWrap.innerHTML = '返回企业动态'; continueSection.insertAdjacentElement('beforebegin', returnWrap); } } function flashActionLabel(button, label) { const originalLabel = button.getAttribute('aria-label'); const originalTitle = button.getAttribute('title'); button.setAttribute('aria-label', label); button.setAttribute('title', label); button.classList.add('is-feedback'); window.setTimeout(() => { button.setAttribute('aria-label', originalLabel || ''); button.setAttribute('title', originalTitle || ''); button.classList.remove('is-feedback'); }, 1400); } function escapeAttribute(value) { return escapeHtml(value).replace(/`/g, '`'); } function initBiotenRequestForm() { const form = document.querySelector('[data-bioten-request-form]'); if (!form) return; clearLegacyRequestStorage(); prepareRequestSecurityFields(form); const status = form.querySelector('[data-request-status]'); const result = document.querySelector('[data-request-result]'); const endpoint = getSameOriginRequestEndpoint(form); const recipient = (form.dataset.requestRecipient || 'Bioten™ 团队').trim(); const resetStatus = (form.dataset.resetStatus || '提交后,团队将根据申请信息安排对应负责人跟进。').trim(); const isEnglishSiteLanguage = () => document.documentElement.dataset.lang === 'en'; const submittedAtLabel = () => new Date().toLocaleString(isEnglishSiteLanguage() ? 'en-US' : 'zh-CN', { hour12: false }); form.addEventListener('submit', async event => { event.preventDefault(); if (!form.checkValidity()) { form.reportValidity(); return; } const formData = new FormData(form); const submittedAt = submittedAtLabel(); const payload = { submittedAt, fields: Object.fromEntries(formData.entries()) }; formData.forEach((value, key) => { const values = formData.getAll(key).map(item => String(item).trim()).filter(Boolean); if (values.length > 1) payload.fields[key] = values; else payload.fields[key] = String(value).trim(); }); // Historical ANTUX forms use `applicant`; keep the shared API contract // without removing the original business field. if (!String(payload.fields.contact || '').trim() && String(payload.fields.applicant || '').trim()) { payload.fields.contact = String(payload.fields.applicant).trim(); } if (result) { result.hidden = true; result.innerHTML = ''; } if (status) { status.textContent = isEnglishSiteLanguage() ? `Submitting the form to ${recipient}.` : `表单正在提交至${recipient}。`; } let serverMessage = ''; try { const response = await fetch(endpoint, { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify(payload) }); const data = await response.json().catch(() => ({})); if (!response.ok || data.ok === false) { serverMessage = typeof data.message === 'string' ? data.message.trim() : ''; throw new Error('request_failed'); } clearLegacyRequestStorage(); if (status) { status.textContent = isEnglishSiteLanguage() ? `Form submitted to ${recipient}. Submitted at: ${submittedAt}.` : `表单已提交至${recipient}。提交时间:${submittedAt}。`; } } catch (error) { if (status) { status.textContent = isEnglishSiteLanguage() ? 'The submission did not complete. Please retry later or use the published contact channel.' : (serverMessage || '提交暂未完成,请稍后重试或使用页面公布的联系方式。'); } } }); form.addEventListener('reset', () => { clearLegacyRequestStorage(); window.setTimeout(() => refreshRequestStartTime(form), 0); if (status) status.textContent = isEnglishSiteLanguage() ? `After submission, ${recipient} will arrange the appropriate follow-up.` : resetStatus; if (result) { result.hidden = true; result.innerHTML = ''; } }); } function clearLegacyRequestStorage() { try { localStorage.removeItem(LEGACY_REQUEST_STORAGE_KEY); } catch (error) { // The form remains usable when browser storage is unavailable. } } function prepareRequestSecurityFields(form) { let privacyVersion = form.querySelector('input[name="privacy_notice_version"]'); if (!privacyVersion) { privacyVersion = document.createElement('input'); privacyVersion.type = 'hidden'; privacyVersion.name = 'privacy_notice_version'; form.prepend(privacyVersion); } privacyVersion.value = FORM_PRIVACY_NOTICE_VERSION; let startedAt = form.querySelector('input[name="form_started_at"]'); if (!startedAt) { startedAt = document.createElement('input'); startedAt.type = 'hidden'; startedAt.name = 'form_started_at'; form.prepend(startedAt); } if (!form.querySelector('input[name="fax_number"]')) { const honeypot = document.createElement('div'); honeypot.hidden = true; honeypot.setAttribute('aria-hidden', 'true'); honeypot.setAttribute('data-form-honeypot', ''); const input = document.createElement('input'); input.type = 'text'; input.name = 'fax_number'; input.tabIndex = -1; input.autocomplete = 'off'; honeypot.appendChild(input); form.prepend(honeypot); } refreshRequestStartTime(form); } function refreshRequestStartTime(form) { const startedAt = form.querySelector('input[name="form_started_at"]'); if (startedAt) startedAt.value = String(Date.now()); } function getSameOriginRequestEndpoint(form) { const fallback = '/api/paper-sample.php'; try { const endpoint = new URL((form.dataset.requestEndpoint || fallback).trim(), window.location.href); if (endpoint.origin !== window.location.origin) return fallback; return `${endpoint.pathname}${endpoint.search}`; } catch (error) { return fallback; } } function escapeHtml(value) { return String(value) .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } function initSiteNavigation() { const header = document.querySelector('.site-header'); const nav = document.getElementById('site-nav'); const toggle = document.querySelector('.nav-toggle'); if (!header || !nav) return; setActiveNavigation(nav); if (toggle) { toggle.addEventListener('click', () => { const isOpen = header.classList.toggle('is-nav-open'); toggle.setAttribute('aria-expanded', String(isOpen)); }); } nav.querySelectorAll('.nav-item > .nav-link').forEach(link => { link.addEventListener('click', event => { if (!window.matchMedia('(max-width: 980px)').matches) return; const item = link.closest('.nav-item'); if (item && item.dataset.navSection === 'bioten') return; const menu = item && item.querySelector('.nav-menu'); if (!menu) return; event.preventDefault(); const willOpen = !item.classList.contains('is-open'); nav.querySelectorAll('.nav-item.is-open').forEach(openItem => { if (openItem !== item) openItem.classList.remove('is-open'); }); item.classList.toggle('is-open', willOpen); }); }); nav.addEventListener('click', event => { const link = event.target.closest('a[href]'); if (!link || link.classList.contains('nav-link')) return; header.classList.remove('is-nav-open'); if (toggle) toggle.setAttribute('aria-expanded', 'false'); nav.querySelectorAll('.nav-item.is-open').forEach(item => item.classList.remove('is-open')); }); document.addEventListener('click', event => { if (header.contains(event.target)) return; header.classList.remove('is-nav-open'); if (toggle) toggle.setAttribute('aria-expanded', 'false'); nav.querySelectorAll('.nav-item.is-open').forEach(item => item.classList.remove('is-open')); }); document.addEventListener('keydown', event => { if (event.key !== 'Escape') return; header.classList.remove('is-nav-open'); if (toggle) toggle.setAttribute('aria-expanded', 'false'); nav.querySelectorAll('.nav-item.is-open').forEach(item => item.classList.remove('is-open')); }); } function setActiveNavigation(nav) { const pathname = window.location.pathname.toLowerCase(); const fileName = (pathname.split('/').pop() || 'index.html').toLowerCase(); const routePath = pathname.replace(/\/index\.html$/, '/'); const sectionMap = [ ['solutions', ['solutions', 'packaging', 'paper-sample']], ['products', ['bioten-products', '/bioten/products/']], ['lab', ['bioten-lab', '/bioten/lab/']], ['resources', ['resources', 'portal-login']], ['knowledge', ['knowledge']], ['about', ['about', 'contact', 'news']], ['bioten', ['bioten']], ['home', ['index.html', '_index.html']] ]; const active = sectionMap.find(([, keys]) => keys.some(key => fileName.includes(key) || routePath.includes(key))) || ['home']; nav.querySelectorAll('[data-nav-section]').forEach(item => { if (item.dataset.navSection === active[0]) { item.classList.add('is-active'); const link = item.matches('a') ? item : item.querySelector('.nav-link'); if (link) link.setAttribute('aria-current', 'page'); } }); nav.querySelectorAll('.nav-menu a[href]').forEach(link => { const href = link.getAttribute('href').split('#')[0].split('?')[0].toLowerCase(); if (href === fileName) { link.setAttribute('aria-current', 'page'); } }); }