| |
|
|
| document.addEventListener('DOMContentLoaded', function() { |
| |
| const newsletterForm = document.getElementById('newsletter-form'); |
| if (newsletterForm) { |
| newsletterForm.addEventListener('submit', function(e) { |
| e.preventDefault(); |
| const email = this.querySelector('input[type="email"]').value; |
| |
| |
| |
| alert(`Thank you for subscribing with ${email}! You'll receive MCP updates soon.`); |
| this.reset(); |
| }); |
| } |
|
|
| |
| const navLinks = document.querySelectorAll('nav a[href^="#"]'); |
| navLinks.forEach(link => { |
| link.addEventListener('click', function(e) { |
| e.preventDefault(); |
| |
| const targetId = this.getAttribute('href'); |
| const targetElement = document.querySelector(targetId); |
| |
| if (targetElement) { |
| window.scrollTo({ |
| top: targetElement.offsetTop - 80, |
| behavior: 'smooth' |
| }); |
| } |
| }); |
| }); |
|
|
| |
| const sections = document.querySelectorAll('section[id]'); |
| window.addEventListener('scroll', function() { |
| const scrollPosition = window.scrollY + 150; |
| |
| sections.forEach(section => { |
| const sectionTop = section.offsetTop; |
| const sectionHeight = section.offsetHeight; |
| const sectionId = section.getAttribute('id'); |
| |
| if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) { |
| document.querySelector(`nav a[href="#${sectionId}"]`).classList.add('active'); |
| } else { |
| document.querySelector(`nav a[href="#${sectionId}"]`).classList.remove('active'); |
| } |
| }); |
| }); |
|
|
| |
| const codeBlocks = document.querySelectorAll('pre code'); |
| codeBlocks.forEach(block => { |
| |
| const keywords = ['import', 'const', 'let', 'var', 'function', 'return', 'async', 'await', 'new', 'class']; |
| const punctuation = ['{', '}', '[', ']', '(', ')', ',', ';', '.', ':']; |
| const strings = ['"', "'", '`']; |
| |
| |
| let content = block.textContent; |
| |
| |
| |
| |
| |
| block.classList.add('syntax-highlighted'); |
| }); |
| }); |
|
|