Dr420000's picture
Создай сайт для на английском языкеW3 SaaS как интерактивную лабораторию по расшифровке Digital DNA бизнеса. Концепция: мы не предлагаем услуги, мы расшифровываем цифровой геном компании и синтезируем идеальные SaaS-решения.
71a659c verified
Raw History Blame Contribute Delete
6.51 kB
// DigitalDNA Lab - Main JavaScript
console.log('DigitalDNA Lab initialized');
// DOM Content Loaded
document.addEventListener('DOMContentLoaded', function() {
initializeDNAAnimation();
setupDragAndDrop();
setupInteractiveElements();
setupSequencingButton();
});
// Initialize DNA Animation
function initializeDNAAnimation() {
const dnaContainer = document.getElementById('dna-animation');
if (dnaContainer) {
// Vanta.js is initialized in the HTML
console.log('DNA animation initialized');
}
}
// Setup Drag and Drop for Genomic Constructor
function setupDragAndDrop() {
const geneItems = document.querySelectorAll('.gene-item');
const sequenceContainer = document.getElementById('dna-sequence-container');
const sequencePreview = document.getElementById('sequence-preview');
let currentSequence = [];
geneItems.forEach(item => {
item.addEventListener('dragstart', function(e) {
e.dataTransfer.setData('text/plain', item.querySelector('.text-acid-green').textContent);
item.classList.add('dragging');
});
item.addEventListener('dragend', function() {
item.classList.remove('dragging');
});
});
sequenceContainer.addEventListener('dragover', function(e) {
e.preventDefault();
sequenceContainer.classList.add('drag-over');
});
sequenceContainer.addEventListener('dragleave', function() {
sequenceContainer.classList.remove('drag-over');
});
sequenceContainer.addEventListener('drop', function(e) {
e.preventDefault();
sequenceContainer.classList.remove('drag-over');
const geneId = e.dataTransfer.getData('text/plain');
if (geneId && !currentSequence.includes(geneId)) {
currentSequence.push(geneId);
updateSequenceDisplay();
// Add visual feedback
const feedback = document.createElement('div');
feedback.className = 'p-2 mb-2 bg-green-100 text-green-800 rounded text-sm';
feedback.textContent = `Added ${geneId} to sequence`;
sequenceContainer.appendChild(feedback);
setTimeout(() => feedback.remove(), 2000);
}
});
function updateSequenceDisplay() {
sequencePreview.textContent = `Digital DNA Sequence: [${currentSequence.join(', ')}]`;
// Clear and rebuild sequence display
sequenceContainer.innerHTML = '';
currentSequence.forEach(gene => {
const geneElement = document.createElement('div');
geneElement.className = 'gene-item bg-white p-3 rounded-lg shadow-sm mb-2 border border-green-300';
geneElement.innerHTML = `<span class="text-acid-green font-mono">${gene}</span>`;
sequenceContainer.appendChild(geneElement);
});
if (currentSequence.length === 0) {
sequenceContainer.innerHTML = '<p class="text-gray-500 text-center">Drag and drop genes here to build your solution</p>';
}
}
// Allow removing genes by clicking
sequenceContainer.addEventListener('click', function(e) {
if (e.target.classList.contains('gene-item')) {
const geneText = e.target.querySelector('.font-mono').textContent;
const index = currentSequence.indexOf(geneText);
if (index > -1) {
currentSequence.splice(index, 1);
updateSequenceDisplay();
}
}
});
}
// Setup Interactive Elements
function setupInteractiveElements() {
// Sequencing button
const sequencingBtn = document.getElementById('start-sequencing');
if (sequencingBtn) {
sequencingBtn.addEventListener('click', function() {
this.innerHTML = 'Sequencing<span class="loading-dots"></span>';
this.disabled = true;
setTimeout(() => {
alert('Digital DNA sequencing complete! Your business genome has been analyzed.');
this.innerHTML = 'Launch Sequencing';
this.disabled = false;
}, 3000);
});
}
// Self-diagnosis scan
const scanBtn = document.querySelector('button:contains("Run Self-Diagnosis Scan")');
if (scanBtn) {
scanBtn.addEventListener('click', function() {
window.location.href = '/diagnosis.html';
});
}
// Hover effects for DNA elements
const dnaElements = document.querySelectorAll('[class*="dna"]');
dnaElements.forEach(el => {
el.addEventListener('mouseenter', function() {
this.style.transform = 'scale(1.05)';
});
el.addEventListener('mouseleave', function() {
this.style.transform = 'scale(1)';
});
});
}
// Setup Sequencing Button with Animation
function setupSequencingButton() {
const button = document.getElementById('start-sequencing');
if (button) {
button.addEventListener('mouseenter', function() {
this.style.boxShadow = '0 0 20px rgba(0, 255, 0, 0.5)';
});
button.addEventListener('mouseleave', function() {
this.style.boxShadow = '0 4px 14px rgba(0, 255, 0, 0.3)';
});
}
}
// Utility function for contains selector
function containsSelector(selector, text) {
const elements = document.querySelectorAll(selector);
return Array.from(elements).find(el => el.textContent.includes(text));
}
// Smooth scrolling for navigation
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Parallax effect for sections
window.addEventListener('scroll', function() {
const scrolled = window.pageYOffset;
const parallaxElements = document.querySelectorAll('.parallax');
parallaxElements.forEach(el => {
const speed = parseFloat(el.getAttribute('data-speed')) || 0.5;
el.style.transform = `translateY(${scrolled * speed}px)`;
});
});
// Initialize feather icons
feather.replace();
// Export functions for global access
window.DigitalDNA = {
initializeDNAAnimation,
setupDragAndDrop,
setupInteractiveElements
};