need the counter to calculate and remember the total number of clicks by all users together - Follow Up Deployment
Browse files120 unmodified lines121122123124124125126127128252 unmodified lines3813823833843853863873883893903913923933943953963973983994004014024034044054064074084094102 unmodified lines413414415391416417418419420421422423120 unmodified lines <button class="cartoon-button bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white font-bold py-3 px-6 rounded-full text-2xl mb-4"> Will you push the horses? </button> <div class="text-amber-700 font-bold text-lg">Pushed: <span id="click-counter">0</span> times</div> <div class="text-5xl text-amber-700 animate-bounce mt-2">↓</div> <div class="text-5xl text-amber-700 animate-bounce mt-6">↓</div> </div> <img id="horse-image" src="https://www.dropbox.com/scl/fi/h9m9f345o94e3g49ealh3/DPTHtoken-logo-happy.png?rlkey=mnzcyc08vcpi87sk90kvoops7&st=0byeouiy&dl=1" data-happy="https://www.dropbox.com/scl/fi/h9m9f345o94e3g49ealh3/DPTHtoken-logo-happy.png?rlkey=mnzcyc08vcpi87sk90kvoops7&st=0byeouiy&dl=1" 252 unmodified lines muteBtn.innerHTML = '<i class="fas fa-volume-mute text-2xl bg-gradient-to-r from-purple-500 to-pink-500 bg-clip-text text-transparent"></i>'; } }); // Global click counter with localStorage persistence async function updateCounter() { try { // Simulate fetching total count from backend const response = await fetch('https://api.countapi.xyz/hit/dpthtoken/global'); const data = await response.json(); document.getElementById('click-counter').textContent = data.value.toLocaleString(); // Store user's personal count in localStorage let userCount = localStorage.getItem('dpth_user_clicks') || 0; userCount++; localStorage.setItem('dpth_user_clicks', userCount); } catch (error) { // Fallback to localStorage if API fails let totalCount = localStorage.getItem('dpth_total_clicks') || 0; totalCount++; localStorage.setItem('dpth_total_clicks', totalCount); document.getElementById('click-counter').textContent = totalCount; } }
// Initialize counter on page load updateCounter();
// Toggle horse image on click and play sound document.getElementById('horse-image').addEventListener('click', function() { const currentSrc = this.src;2 unmodified lines this.src = currentSrc === happySrc ? seriousSrc : happySrc; const horseSound = document.getElementById('horse-sound'); horseSound.currentTime = 0; // Rewind to start if already playing horseSound.currentTime = 0; horseSound.play(); // Update global counter updateCounter(); });
// Instagram embed scriptindex.html+30-2