/**
* DBC / BIOTEN V4.3.0
* Semantic route and editorial interaction layer.
*/
(() => {
'use strict';
const init = () => {
document.documentElement.dataset.v430Ready = 'true';
initContactRouter();
initContactIntentState();
initArticleOrientation();
keepCurrentLocalNavigationVisible();
};
function initContactRouter() {
const hero = document.querySelector('body.contact-suite-page .contact-hero');
if (!hero || hero.querySelector('[data-v430-contact-routes]')) return;
const routes = document.createElement('aside');
routes.className = 'v430-contact-routes';
routes.dataset.v430ContactRoutes = '';
routes.setAttribute('aria-label', '合作入口');
routes.innerHTML = [
{
number: '01 · DBC',
title: '业务与联合开发',
copy: '集团合作、博碳生物应用方向及其他专业业务,从对象、阶段与预期结果开始。',
action: '进入合作表单 →',
href: '#contact-form'
},
{
number: '02 · PACKAGING',
title: '博碳包装项目',
copy: '食品、美妆、医药医疗与特种包装,先提交结构、内容物、工艺与目标市场。',
action: '开始项目预审 →',
href: 'sample.html'
},
{
number: '03 · EVIDENCE',
title: '资料与授权',
copy: '公开资料直接浏览;TDS、SDS、报告与受控文件按项目用途进入申请路径。',
action: '进入资料中心 →',
href: 'resources.html'
}
].map(route => `
${route.number}
${route.title}
${route.copy}
${route.action}
`).join('');
hero.append(routes);
}
function initContactIntentState() {
const form = document.querySelector('body.contact-suite-page form[data-bioten-request-form]');
if (!form) return;
const params = new URLSearchParams(window.location.search);
const intent = params.get('intent') || params.get('from');
if (!intent) return;
const intentLabels = {
'bioten-platform': '博碳生物材料平台 / 联合应用开发',
'bioten-agriculture': '博碳生物 · 农业科技',
'bioten-personal-care': '博碳生物 · 日化与个人护理',
'bioten-waterborne-coatings': '博碳生物 · 生物基水性涂层',
'bioten-health-research': '博碳生物 · 联合研究 / NDA 项目',
'bioten-packaging': '博碳包装',
'food-beverage': '食品与饮料包装',
'beauty-care': '美妆与个护包装',
'medical-outer': '医药与医疗包装',
'special-performance': '特种包装',
ecoten: '城市更新与建筑涂层',
dpu: 'DPU 运动地材',
casu: 'CASU 电池与先进材料',
antux: 'ANTUX 涂料与渠道合作',
'dbc-group': 'DBC 集团合作 / 联合研发'
};
const hiddenIntent = form.querySelector('[name="intent"]');
if (hiddenIntent) hiddenIntent.value = intent;
const preset = Array.from(form.querySelectorAll('option[data-intent-preset]')).find(option => {
return String(option.dataset.intentPreset || '').split(/\s+/).includes(intent);
});
if (preset) preset.selected = true;
const notice = document.createElement('p');
notice.className = 'v430-intent-notice';
notice.setAttribute('role', 'status');
notice.textContent = `已按来源预选:${intentLabels[intent] || '合作需求'}。您可在表单中继续调整。`;
form.insertAdjacentElement('beforebegin', notice);
}
function initArticleOrientation() {
const article = document.querySelector('body.news-article-page .news-original-article');
const content = article?.querySelector('.news-content-original');
const body = article?.querySelector('.news-body-original');
if (!article || !content || !body) return;
const headings = Array.from(content.querySelectorAll('h2, h3')).filter(heading => {
return !heading.closest('.news-continue') && heading.textContent.trim().length > 0;
});
if (headings.length >= 2) {
const toc = document.createElement('nav');
toc.className = 'v430-article-toc';
toc.setAttribute('aria-label', '文章目录');
toc.innerHTML = 'ARTICLE INDEX · 文章目录
';
const list = toc.querySelector('ol');
headings.forEach((heading, index) => {
if (!heading.id) heading.id = `article-section-${String(index + 1).padStart(2, '0')}`;
const item = document.createElement('li');
const link = document.createElement('a');
link.href = `#${heading.id}`;
link.textContent = heading.textContent.trim();
item.append(link);
list.append(item);
});
body.insertAdjacentElement('beforebegin', toc);
}
const progress = document.createElement('div');
progress.className = 'v430-reading-progress';
progress.setAttribute('aria-hidden', 'true');
progress.innerHTML = '';
document.body.prepend(progress);
let queued = false;
const updateProgress = () => {
const top = article.offsetTop;
const distance = Math.max(article.offsetHeight - window.innerHeight, 1);
const value = Math.min(1, Math.max(0, (window.scrollY - top) / distance));
progress.style.setProperty('--v430-reading-progress', `${(value * 100).toFixed(2)}%`);
queued = false;
};
const requestUpdate = () => {
if (queued) return;
queued = true;
window.requestAnimationFrame(updateProgress);
};
updateProgress();
window.addEventListener('scroll', requestUpdate, { passive: true });
window.addEventListener('resize', requestUpdate, { passive: true });
}
function keepCurrentLocalNavigationVisible() {
const currentLinks = document.querySelectorAll([
'.v270-context [aria-current="page"]',
'.dv21-domain-switch [aria-current="page"]',
'.resources-page-nav .is-active',
'.bioten-page-nav [aria-current="page"]'
].join(','));
currentLinks.forEach(link => {
if (typeof link.scrollIntoView !== 'function') return;
window.requestAnimationFrame(() => {
link.scrollIntoView({ block: 'nearest', inline: 'center' });
});
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init, { once: true });
} else {
init();
}
})();