// Main JavaScript for NotteClone Pro // Theme Toggle functionality class ThemeManager { constructor() { this.theme = localStorage.getItem('theme') || 'dark'; this.init(); } init() { // Set initial theme this.setTheme(this.theme); // Listen for system theme changes if (window.matchMedia) { window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => { if (!localStorage.getItem('theme')) { this.setTheme(e.matches ? 'dark' : 'light'); } }); } } setTheme(theme) { this.theme = theme; document.documentElement.className = theme; localStorage.setItem('theme', theme); } toggleTheme() { this.setTheme(this.theme === 'dark' ? 'light' : 'dark'); } } // Initialize theme manager const themeManager = new ThemeManager(); // API Integration for testimonials (using a placeholder API) async function fetchTestimonials() { try { // Using JSONPlaceholder for demo data const response = await fetch('https://jsonplaceholder.typicode.com/comments?_limit=3'); const comments = await response.json(); // Transform API data to testimonial format const testimonials = comments.map(comment => ({ name: comment.name.split(' ')[0] + ' ' + comment.name.split(' ')[1], role: 'NotteClone User', content: comment.body.length > 120 ? comment.body.substring(0, 120) + '...' : comment.body, rating: Math.floor(Math.random() * 3) + 3 // 3-5 stars })); return testimonials; } catch (error) { console.error('Error fetching testimonials:', error); return getFallbackTestimonials(); } } function getFallbackTestimonials() { return [ { name: "Alex Johnson", role: "Product Designer", content: "NotteClone Pro has completely transformed how I organize my design notes. The dark mode is perfect for late-night brainstorming sessions.", rating: 5 }, { name: "Sam Rivera", role: "Software Engineer", content: "As a developer who spends hours in dark-themed IDEs, having a note-taking app that matches my workflow is a game-changer.", rating: 5 }, { name: "Taylor Morgan", role: "Content Creator", content: "The organization features are incredible. I can finally keep all my ideas sorted without switching between multiple apps.", rating: 4 } ]; } // Initialize testimonials when DOM is loaded document.addEventListener('DOMContentLoaded', async function() { // Load testimonials if section exists const testimonialsSection = document.getElementById('testimonials'); if (testimonialsSection) { const testimonials = await fetchTestimonials(); renderTestimonials(testimonials); } // Add scroll animations setupScrollAnimations(); // Initialize tooltips if needed initTooltips(); }); function renderTestimonials(testimonials) { const container = document.querySelector('#testimonials .testimonials-container'); if (!container) return; container.innerHTML = testimonials.map((testimonial, index) => `
"${testimonial.content}"
${testimonial.role}