Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Particle animation
+ const particleAnimation = document.querySelector('.particle-animation');
+ for (let i = 0; i < 50; i++) {
+ const particle = document.createElement('div');
+ particle.className = 'particle';
+ particle.style.cssText = `
+ position: absolute;
+ background: rgba(255, 255, 255, 0.1);
+ width: ${Math.random() * 10 + 5}px;
+ height: ${Math.random() * 10 + 5}px;
+ border-radius: 50%;
+ left: ${Math.random() * 100}%;
+ top: ${Math.random() * 100}%;
+ animation: float ${Math.random() * 10 + 5}s linear infinite;
+ `;
+ particleAnimation.appendChild(particle);
+ }
+
+ // Interactive editor
+ const editor = document.getElementById('particlesEditor');
+ const preview = document.getElementById('preview');
+
+ editor.addEventListener('input', () => {
+ try {
+ const particles = parseParticles(editor.value);
+ preview.innerHTML = `
${JSON.stringify(particles, null, 2)}
`;
+ } catch (e) {
+ preview.innerHTML = `
${e.message}
`;
+ }
+ });
+
+ // Smooth scroll for navigation
+ document.querySelectorAll('nav a').forEach(anchor => {
+ anchor.addEventListener('click', (e) => {
+ e.preventDefault();
+ const target = document.querySelector(anchor.getAttribute('href'));
+ target.scrollIntoView({ behavior: 'smooth' });
+ });
+ });
+ });
+
+ function parseParticles(input) {
+ if (!input.trim()) return {};
+
+ const lines = input.split('\n');
+ const result = {};
+ let currentContext = [result];
+ let currentIndent = 0;
+
+ lines.forEach(line => {
+ if (line.trim() === '') return;
+
+ const indent = line.search(/\S/);
+ const parts = line.trim().split(/\s+/);
+ const key = parts[0];
+ const value = parts.slice(1).join(' ');
+
+ if (indent > currentIndent) {
+ currentIndent = indent;
+ } else if (indent < currentIndent) {
+ const levels = (currentIndent - indent) / 2;
+ for (let i = 0; i < levels; i++) {
+ currentContext.pop();
+ }
+ currentIndent = indent;
+ }
+
+ if (value) {
+ currentContext[currentContext.length - 1][key] = isNaN(value) ? value : Number(value);
+ } else {
+ const newObject = {};
+ currentContext[currentContext.length - 1][key] = newObject;
+ currentContext.push(newObject);
+ }
+ });
+
+ return result;
+ }