/* BIOTEN Developer shared context and return paths, V7.16.0. */ (function () { 'use strict'; const isDeveloperDetail = () => { const body = document.body; return Boolean(body && body.matches('[data-v710-family="developer"]') && !body.matches('[data-v740-page="developer-home"]')); }; const currentFile = () => window.location.pathname.split('/').pop() || 'index.html'; const activeSection = file => { if (file === 'developer-challenges.html' || file === 'developer-open-innovation.html') return 'challenges'; if (file === 'developer-evidence.html') return 'evidence'; if (file === 'developer-tools.html') return 'tools'; return 'applications'; }; const linkMarkup = (href, key, zh, en, active) => { const current = key === active ? ' aria-current="page"' : ''; return `${zh}`; }; const buildContext = active => { const nav = document.createElement('nav'); nav.className = 'dev7160-context'; nav.dataset.dev7160Context = 'true'; nav.dataset.dev7160AriaZh = '博碳开发者上下文导航'; nav.dataset.dev7160AriaEn = 'BIOTEN Developer context navigation'; nav.setAttribute('aria-label', nav.dataset.dev7160AriaZh); nav.innerHTML = `
${linkMarkup('bioten-lab.html', 'overview', '开发者总览', 'Developer Overview', active)} ${linkMarkup('bioten-lab.html#workbenches', 'applications', '应用路径', 'Application Paths', active)} ${linkMarkup('developer-challenges.html', 'challenges', '开放问题', 'Open Challenges', active)} ${linkMarkup('developer-evidence.html', 'evidence', '方法与证据', 'Methods & Evidence', active)} ${linkMarkup('developer-tools.html', 'tools', '开发工具', 'Developer Tools', active)} ${linkMarkup('contact.html?intent=developer#contact-form', 'intake', '提出任务', 'Propose a Task', active)}
`; return nav; }; const buildReturn = () => { const section = document.createElement('section'); section.className = 'dev7160-return'; section.dataset.dev7160Return = 'true'; section.setAttribute('aria-labelledby', 'dev7160-return-title'); section.innerHTML = `
BIOTEN DEVELOPER

把当前对象带回开发主链。

继续定义变量、验证要求和资料权限,或提交一个可由人工预审承接的开发任务。

`; return section; }; const applyLanguage = language => { const english = language === 'en'; document.querySelectorAll('[data-dev7160-zh][data-dev7160-en]').forEach(element => { element.textContent = english ? element.dataset.dev7160En : element.dataset.dev7160Zh; }); document.querySelectorAll('[data-dev7160-aria-zh][data-dev7160-aria-en]').forEach(element => { element.setAttribute('aria-label', english ? element.dataset.dev7160AriaEn : element.dataset.dev7160AriaZh); }); }; const init = () => { if (!isDeveloperDetail()) return; document.body.dataset.v7160DeveloperContext = 'true'; document.querySelectorAll('.logo-image-biocycle').forEach(link => { link.setAttribute('href', 'bioten.html'); link.setAttribute('aria-label', '博碳包装主页'); }); const header = document.querySelector('.site-header'); if (header && !document.querySelector('[data-dev7160-context]')) { header.insertAdjacentElement('afterend', buildContext(activeSection(currentFile()))); } const footer = document.querySelector('footer'); if (footer && !document.querySelector('[data-dev7160-return]')) { footer.insertAdjacentElement('beforebegin', buildReturn()); } const language = document.documentElement.dataset.lang === 'en' ? 'en' : 'zh'; applyLanguage(language); document.addEventListener('dbc:languagechange', event => { applyLanguage(event.detail?.language === 'en' ? 'en' : 'zh'); }); }; document.addEventListener('DOMContentLoaded', init, { once: true }); })();