const data = JSON.parse(document.getElementById('page-data').textContent); const basePath = data.site.base_path; const ui = data.ui; document.documentElement.lang = data.locale; const e = value => String(value ?? '').replace(/[&<>"']/g, char => ({ '&':'&', '<':'<', '>':'>', '"':'"', "'":''' }[char])); const boldText = value => e(value).replace(/\*\*([^*]+)\*\*/g, '$1'); const href = value => /^#[a-z][\w-]*$/i.test(value) ? value : '#'; const companyHref = value => /^https:\/\/bineogen\.com\/[a-z0-9/-]*$/i.test(value) ? value : '#'; const companyMenu = item => item.items ? `
` : `${e(item.label)}`; const asset = value => /^\/[a-z0-9/_-]+\.(png|jpg|jpeg|webp|gif)$/i.test(value) ? basePath + value : ''; const videoAsset = value => /^\/[a-z0-9/_-]+\.mp4$/i.test(value) ? basePath + value : ''; const head = (section, light = false) => `
${section.label ? `${e(section.label)}` : ''}

${e(section.title)}

${section.description ? `

${e(section.description)}

` : ''}
`; const scenarioParagraphs = item => String(item.description ?? '').split(/\n\s*\n/).filter(Boolean).map(paragraph => `

${e(paragraph.trim())}

`).join(''); const applicationParagraphs = value => String(value ?? '').split(document.documentElement.lang === 'en' ? /(?<=\.)\s+(?=[A-Z])/ : /(?<=。)\s+(?=\S)/).filter(Boolean).map(part => `

${e(part.trim())}

`).join(''); const videoPlayButton = label => ``; const bilibiliMedia = (bvid, label, cover) => /^BV[0-9A-Za-z]{10}$/.test(bvid) ? `` : ''; const productMedia = item => { if (item.platform === 'bilibili' && /^BV[0-9A-Za-z]{10}$/.test(item.bvid)) { return bilibiliMedia(item.bvid, item.label, item.cover_image); } return `${videoPlayButton(item.label)}`; }; const scenarioMedia = item => item.video_platform === 'bilibili' ? bilibiliMedia(item.video_bvid, item.title, item.cover_image) : item.video ? `${videoPlayButton(`${item.title} ${ui.video}`)}` : `${e(item.title)} ${e(ui.image)}`; for (const key of ['ink','navy','teal','mint','paper','accent']) document.documentElement.style.setProperty(`--${key}`, data.theme[key]); const setFontSize = (name, value) => { const size = Number(value); if (Number.isInteger(size) && size >= 6 && size <= 120) { document.documentElement.style.setProperty(`--font-${name}`, `${size}px`); } }; setFontSize('body', data.theme.body_font_size); for (const module of ['brand','hero','scenarios','product','advantages','applications','gallery','footer']) { for (const [key, value] of Object.entries(data[module].font_sizes || {})) { if (/^[a-z_]+$/.test(key)) setFontSize(`${module}-${key.replaceAll('_', '-')}`, value); } } for (const module of ['hero','scenarios','product','advantages','applications','gallery']) { for (const [key, value] of Object.entries(data[module].spacing || {})) { const space = Number(value); if (/^[a-z_]+$/.test(key) && Number.isInteger(space) && space >= 0 && space <= 1600) { document.documentElement.style.setProperty(`--${module}-space-${key.replaceAll('_', '-')}`, `${space}px`); } } } for (const module of ['product','advantages']) { const color = data[module].media_background; if (typeof color === 'string' && /^#[0-9a-f]{6}$/i.test(color)) { document.documentElement.style.setProperty(`--${module}-media-background`, color); } } document.documentElement.style.setProperty('--nav-height', `${Number(data.navigation.height) || 56}px`); document.documentElement.style.setProperty('--nav-font-size', `${Number(data.navigation.font_size) || 14}px`); for (const [name, value] of [['top', data.hero.background_overlay_top], ['bottom', data.hero.background_overlay_bottom]]) { const opacity = Number(value); if (Number.isFinite(opacity) && opacity >= 0 && opacity <= 1) { document.documentElement.style.setProperty(`--hero-overlay-${name}`, String(opacity)); } } document.documentElement.style.setProperty('--rail-right', `${Number(data.navigation.rail.right) || 28}px`); document.documentElement.style.setProperty('--rail-font-size', `${Number(data.navigation.rail.font_size) || 13}px`); document.documentElement.style.setProperty('--rail-width', `${Number(data.navigation.rail.width) || 168}px`); document.getElementById('app').innerHTML = `
${e(ui.brand_icon)}${e(data.brand.name)}${e(data.brand.eyebrow)}

${e(data.hero.title)}

${e(data.hero.description)}

${head(data.scenarios)}
${data.scenarios.items.map((item,i)=>``).join('')}
${head(data.product,true)}
${data.product.headline ? `

${e(data.product.headline)}

` : ''}

${boldText(data.product.body)}

${data.product.points.map(item=>`${item.number ? `${e(item.number)}` : ''}

${e(item.title)}

${e(item.description)}

`).join('')}
${data.product.videos.map((item,i)=>`
${productMedia(item)}
`).join('')}
${head(data.applications)}
${data.applications.items.map((item,i)=>`
${item.image ? `${e(item.title)}` : ``}

${e(item.title)}

${applicationParagraphs(item.description)}
`).join('')}
${head(data.advantages)}
${data.advantages.video_platform === 'bilibili' ? bilibiliMedia(data.advantages.video_bvid, ui.advantage_video, data.advantages.cover_image) : `${videoPlayButton(ui.advantage_video)}`}
${data.advantages.items.map(item=>`

${e(item.title)}

${e(item.description)}

↗
`).join('')}
`; const rail = document.querySelector('.section-rail'); const siteMenu = document.querySelector('.language-nav'); const companyMenuToggle = siteMenu.querySelector('.company-menu-toggle'); const closeCompanyMenu = () => { siteMenu.classList.remove('is-open'); companyMenuToggle.setAttribute('aria-expanded', 'false'); }; companyMenuToggle.addEventListener('click', () => { const open = !siteMenu.classList.contains('is-open'); siteMenu.classList.toggle('is-open', open); companyMenuToggle.setAttribute('aria-expanded', String(open)); }); siteMenu.querySelectorAll('.company-nav-link,.company-nav-dropdown a,.language-switch').forEach(link => { link.addEventListener('click', closeCompanyMenu); }); document.addEventListener('click', event => { if (!siteMenu.contains(event.target)) closeCompanyMenu(); }); document.addEventListener('keydown', event => { if (event.key === 'Escape') closeCompanyMenu(); }); window.matchMedia('(min-width: 922px)').addEventListener('change', event => { if (event.matches) closeCompanyMenu(); }); document.querySelectorAll('.company-nav-group').forEach(group => { const trigger = group.querySelector('.company-nav-trigger'); const dropdown = group.querySelector('.company-nav-dropdown'); const show = open => { dropdown.hidden = !open; trigger.setAttribute('aria-expanded', String(open)); }; group.addEventListener('mouseenter', () => show(true)); group.addEventListener('mouseleave', () => show(false)); trigger.addEventListener('click', () => show(dropdown.hidden)); group.addEventListener('focusout', event => { if (!group.contains(event.relatedTarget)) show(false); }); }); function updateRailScale() { if (data.navigation.rail.compensate_zoom !== true) return; const current = (window.devicePixelRatio || 1) * (window.visualViewport?.scale || 1); const compensation = (Number(data.navigation.rail.size_multiplier) || 1) / current; rail.style.setProperty('--rail-zoom-compensation', String(compensation)); } window.addEventListener('resize', updateRailScale); window.visualViewport?.addEventListener('resize', updateRailScale); updateRailScale(); const railLinks = [...rail.querySelectorAll('a')]; const railSections = railLinks.map(link => document.getElementById(link.dataset.railTarget)); function updateRail() { const marker = window.scrollY + window.innerHeight * 0.36; let active = 0; railSections.forEach((section, i) => { if (section && section.getBoundingClientRect().top + window.scrollY <= marker) active = i; }); railLinks.forEach((link, i) => { link.classList.toggle('is-active', i === active); if (i === active) link.setAttribute('aria-current', 'location'); else link.removeAttribute('aria-current'); }); } let railUpdatePending = false; window.addEventListener('scroll', () => { if (railUpdatePending) return; railUpdatePending = true; requestAnimationFrame(() => { railUpdatePending = false; updateRail(); }); }, {passive:true}); window.addEventListener('resize', updateRail); updateRail(); const hero = document.querySelector('.hero'); const heroBackground = hero.querySelector('.hero-background'); const heroRotation = Number(data.hero.background_rotation) || 0; heroBackground.style.transform = `translate(-50%, -50%) rotate(${heroRotation}deg)`; function sizeHeroBackground() { const quarterTurn = Math.abs(heroRotation % 180) === 90; heroBackground.style.width = `${quarterTurn ? hero.clientHeight : hero.clientWidth}px`; heroBackground.style.height = `${quarterTurn ? hero.clientWidth : hero.clientHeight}px`; } new ResizeObserver(sizeHeroBackground).observe(hero); sizeHeroBackground(); function setCoverFrame(video, configuredSecond) { const second = Number(configuredSecond); if (!video || !Number.isFinite(second) || second < 0) return; let coverTime = 0; let coverPending = false; const seekToCover = () => { coverTime = Math.min(second, Math.max(0, video.duration - 0.1)); if (coverTime > 0) { video.currentTime = coverTime; coverPending = true; } }; if (video.readyState >= 1) seekToCover(); else video.addEventListener('loadedmetadata', seekToCover, {once:true}); video.addEventListener('play', () => { if (coverPending && Math.abs(video.currentTime - coverTime) < 0.25) video.currentTime = 0; coverPending = false; }); } for (const video of document.querySelectorAll('.scenario-visual video, .product-video-slide video, .advantage-media video')) { const button = video.parentElement.querySelector('.video-center-play'); const updateButton = () => { button.hidden = !video.paused; }; button.addEventListener('click', () => video.play().catch(updateButton)); video.addEventListener('play', updateButton); video.addEventListener('pause', updateButton); video.addEventListener('ended', updateButton); updateButton(); } const productVideoSlides = [...document.querySelectorAll('.product-video-slide')]; productVideoSlides.forEach((slide, i) => setCoverFrame(slide.querySelector('video'), data.product.videos[i].cover_second)); for (const frame of document.querySelectorAll('.product-visual iframe, .advantage-media iframe, .scenario-visual iframe')) { const start = frame.parentElement.querySelector('.product-start-overlay'); start.addEventListener('click', () => { frame.src = `${frame.dataset.playerSrc}&muted=0`; frame.parentElement.querySelector('.bilibili-cover').hidden = true; start.hidden = true; }); } setCoverFrame(document.querySelector('.advantage-video'), data.advantages.cover_second); const scenarioTabs = [...document.querySelectorAll('.scenario-tab')]; const scenarioPanels = [...document.querySelectorAll('.scenario-feature')]; scenarioPanels.forEach((panel, i) => setCoverFrame(panel.querySelector('video'), data.scenarios.items[i].cover_second)); const scenarioTrack = document.querySelector('.scenario-track'); let scenarioIndex = 0; function showScenario(index, focusTab = false) { scenarioIndex = (index + scenarioTabs.length) % scenarioTabs.length; scenarioTrack.style.transform = `translateX(-${scenarioIndex * 100}%)`; scenarioTabs.forEach((tab, i) => { const active = i === scenarioIndex; tab.classList.toggle('is-active', active); tab.setAttribute('aria-selected', String(active)); tab.tabIndex = active ? 0 : -1; scenarioPanels[i].setAttribute('aria-hidden', String(!active)); scenarioPanels[i].inert = !active; if (!active) scenarioPanels[i].querySelector('video')?.pause(); const frame = scenarioPanels[i].querySelector('iframe'); if (frame && !active && frame.getAttribute('src')) { frame.removeAttribute('src'); frame.parentElement.querySelector('.bilibili-cover').hidden = false; frame.parentElement.querySelector('.product-start-overlay').hidden = false; } }); scenarioTabs[scenarioIndex].parentElement.scrollTo({ left: scenarioTabs[scenarioIndex].offsetLeft - scenarioTabs[0].offsetLeft, behavior: 'smooth' }); if (focusTab) scenarioTabs[scenarioIndex].focus(); } scenarioTabs.forEach((tab, i) => { tab.addEventListener('click', () => showScenario(i)); tab.addEventListener('keydown', event => { if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') { event.preventDefault(); showScenario(i + (event.key === 'ArrowRight' ? 1 : -1), true); } }); }); document.querySelector('.scenario-prev').addEventListener('click', () => showScenario(scenarioIndex - 1)); document.querySelector('.scenario-next').addEventListener('click', () => showScenario(scenarioIndex + 1)); showScenario(0); const gallerySlides = [...document.querySelectorAll('.gallery-slide')]; const galleryThumbs = [...document.querySelectorAll('.gallery-thumb')]; const galleryTrack = document.querySelector('.gallery-track'); const galleryViews = gallerySlides.map(slide => slide.querySelector('.gallery-main-image')); const galleryViewStates = galleryViews.map(() => ({scale:1, x:0, y:0, dragging:false})); const galleryMinScale = Math.max(1, Number(data.gallery.viewer.min_scale) || 1); const galleryMaxScale = Math.max(galleryMinScale, Number(data.gallery.viewer.max_scale) || 5); const galleryZoomSensitivity = Math.max(0.0001, Number(data.gallery.viewer.zoom_sensitivity) || 0.0015); const clamp = (value, min, max) => Math.min(max, Math.max(min, value)); const galleryRotation = index => Number(data.gallery.cases[index].rotation) || 0; function sizeGalleryThumbnail(index) { if (!galleryRotation(index)) return; const frame = galleryThumbs[index].querySelector('.gallery-thumb-image'); const img = frame.querySelector('img'); img.style.width = `${frame.clientHeight}px`; img.style.height = `${frame.clientWidth}px`; } function renderGalleryView(index) { const view = galleryViews[index]; const img = view.querySelector('img'); const state = galleryViewStates[index]; const rotated = Math.abs(galleryRotation(index) % 180) === 90; if (rotated) { img.style.width = `${view.clientHeight - 36}px`; img.style.height = `${view.clientWidth}px`; } if (img.naturalWidth && img.naturalHeight) { const fit = Math.min(img.offsetWidth / img.naturalWidth, img.offsetHeight / img.naturalHeight); const visibleWidth = (rotated ? img.naturalHeight : img.naturalWidth) * fit * state.scale; const visibleHeight = (rotated ? img.naturalWidth : img.naturalHeight) * fit * state.scale; const maxX = rotated ? Math.max(0, (visibleWidth - view.clientWidth) / 2) : Math.abs(visibleWidth - view.clientWidth) / 2; const maxY = rotated ? Math.max(0, (visibleHeight - view.clientHeight) / 2) : Math.abs(visibleHeight - img.offsetHeight) / 2; state.x = clamp(state.x, -maxX, maxX); state.y = clamp(state.y, -maxY, maxY); } img.style.transform = `translate(${state.x}px, ${state.y}px) rotate(${galleryRotation(index)}deg) scale(${state.scale})`; } function resetGalleryView(index) { Object.assign(galleryViewStates[index], {scale:galleryMinScale, x:0, y:0, dragging:false}); galleryViews[index].classList.remove('is-dragging'); renderGalleryView(index); } let galleryIndex = 0; function showGallery(index, focusThumb = false) { galleryIndex = (index + gallerySlides.length) % gallerySlides.length; galleryViews.forEach((_, i) => resetGalleryView(i)); galleryTrack.style.transform = `translateX(-${galleryIndex * 100}%)`; gallerySlides.forEach((slide, i) => { slide.setAttribute('aria-hidden', String(i !== galleryIndex)); slide.inert = i !== galleryIndex; }); galleryThumbs.forEach((thumb, i) => { const active = i === galleryIndex; thumb.classList.toggle('is-active', active); thumb.setAttribute('aria-current', String(active)); }); const item = data.gallery.cases[galleryIndex]; document.querySelector('.gallery-counter').textContent = `${String(galleryIndex + 1).padStart(2, '0')} / ${String(gallerySlides.length).padStart(2, '0')}`; document.querySelector('.gallery-category').textContent = item.category; document.querySelector('.gallery-title').textContent = item.title; document.querySelector('.gallery-description').textContent = item.caption; document.querySelector('.gallery-open').href = asset(item.image); galleryThumbs[galleryIndex].parentElement.scrollTo({ left: galleryThumbs[galleryIndex].offsetLeft - galleryThumbs[0].offsetLeft, behavior: 'smooth' }); if (focusThumb) galleryThumbs[galleryIndex].focus(); } galleryThumbs.forEach((thumb, i) => { thumb.addEventListener('click', () => showGallery(i)); thumb.addEventListener('keydown', event => { if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') { event.preventDefault(); showGallery(i + (event.key === 'ArrowRight' ? 1 : -1), true); } }); }); document.querySelector('.gallery-prev').addEventListener('click', () => showGallery(galleryIndex - 1)); document.querySelector('.gallery-next').addEventListener('click', () => showGallery(galleryIndex + 1)); galleryViews.forEach((view, i) => { const state = galleryViewStates[i]; if (galleryRotation(i)) { galleryThumbs[i].classList.add('is-rotated'); galleryThumbs[i].style.setProperty('--thumb-rotation', `${galleryRotation(i)}deg`); sizeGalleryThumbnail(i); } view.querySelector('img').addEventListener('load', () => renderGalleryView(i)); view.addEventListener('wheel', event => { event.preventDefault(); const nextScale = clamp(state.scale * Math.exp(-event.deltaY * galleryZoomSensitivity), galleryMinScale, galleryMaxScale); const rect = view.getBoundingClientRect(); const pointX = event.clientX - rect.left - rect.width / 2; const pointY = event.clientY - rect.top - rect.height / 2; state.x = pointX - (pointX - state.x) * nextScale / state.scale; state.y = pointY - (pointY - state.y) * nextScale / state.scale; state.scale = nextScale; renderGalleryView(i); }, {passive:false}); view.addEventListener('pointerdown', event => { if (event.button !== 0) return; event.preventDefault(); view.setPointerCapture(event.pointerId); state.dragging = true; state.startX = event.clientX; state.startY = event.clientY; state.originX = state.x; state.originY = state.y; view.classList.add('is-dragging'); }); view.addEventListener('pointermove', event => { if (!state.dragging) return; state.x = state.originX + event.clientX - state.startX; state.y = state.originY + event.clientY - state.startY; renderGalleryView(i); }); const endDrag = event => { if (!state.dragging) return; state.dragging = false; view.classList.remove('is-dragging'); if (view.hasPointerCapture(event.pointerId)) view.releasePointerCapture(event.pointerId); }; view.addEventListener('pointerup', endDrag); view.addEventListener('pointercancel', endDrag); view.addEventListener('dblclick', () => resetGalleryView(i)); view.addEventListener('keydown', event => { if (event.key === '+' || event.key === '=') state.scale = clamp(state.scale * 1.2, galleryMinScale, galleryMaxScale); else if (event.key === '-') state.scale = clamp(state.scale / 1.2, galleryMinScale, galleryMaxScale); else if (event.key === 'ArrowLeft') state.x -= 30; else if (event.key === 'ArrowRight') state.x += 30; else if (event.key === 'ArrowUp') state.y -= 30; else if (event.key === 'ArrowDown') state.y += 30; else if (event.key === 'Home') return resetGalleryView(i); else return; event.preventDefault(); renderGalleryView(i); }); }); window.addEventListener('resize', () => galleryViews.forEach((_, i) => { renderGalleryView(i); sizeGalleryThumbnail(i); })); showGallery(0);