Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Initialize trend meters
+ const trendCards = document.querySelectorAll('.trend-card');
+ trendCards.forEach(card => {
+ const meter = card.querySelector('.trend-meter');
+ const percentage = card.querySelector('p').textContent.match(/\d+/)[0];
+ meter.style.setProperty('--fill-percentage', `${percentage}%`);
+ });
+
+ // Search functionality
+ const searchBtn = document.getElementById('searchBtn');
+ const genreInput = document.getElementById('genreInput');
+
+ searchBtn.addEventListener('click', () => {
+ const genre = genreInput.value.trim();
+ if (genre) {
+ // Simulate API call with loading state
+ searchBtn.disabled = true;
+ searchBtn.textContent = 'Searching...';
+
+ setTimeout(() => {
+ // Simulate response
+ const randomTrend = Math.floor(Math.random() * 100);
+ alert(`${genre} is currently trending at ${randomTrend}%`);
+
+ searchBtn.disabled = false;
+ searchBtn.textContent = 'Search';
+ genreInput.value = '';
+ }, 1500);
+ }
+ });
+
+ // Chart initialization
+ const ctx = document.getElementById('trendChart').getContext('2d');
+ const gradient = ctx.createLinearGradient(0, 0, 0, 400);
+ gradient.addColorStop(0, 'rgba(108, 99, 255, 0.5)');
+ gradient.addColorStop(1, 'rgba(108, 99, 255, 0)');
+
+ new Chart(ctx, {
+ type: 'line',
+ data: {
+ labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
+ datasets: [{
+ label: 'Genre Popularity',
+ data: [65, 59, 80, 81, 56, 55],
+ fill: true,
+ backgroundColor: gradient,
+ borderColor: '#6c63ff',
+ tension: 0.4
+ }]
+ },
+ options: {
+ responsive: true,
+ maintainAspectRatio: false,
+ plugins: {
+ legend: {
+ display: false
+ }
+ }
+ }
+ });
+ });