Last active
June 19, 2025 20:35
-
-
Save nexusofdoom/ddfd2b270906b44d5ff8776bd6226e2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Ultimate Wheel – Winner Popup, Sound, & Full Settings</title> | |
| <!-- Styles omitted for brevity, keep your original <style> block here --> | |
| <style> | |
| /* ... (all your original CSS styles unchanged) ... */ | |
| /* (Just as in your Gist/Pastebin!) */ | |
| </style> | |
| </head> | |
| <body> | |
| <!-- All your original HTML structure remains unchanged --> | |
| <!-- ... (settings icon, wheel container, modals, forms, etc.) ... --> | |
| <!-- PATCH: Idle Spin Speed Slider added to the settings modal --> | |
| <!-- (You already have this in your form, keep as-is, just make sure it's in the right place) --> | |
| <script> | |
| // --- All your original JS code below, with idle spinning patch fully integrated --- | |
| // --- IndexedDB helpers, settings, and all variables --- | |
| // ... (all your original code, unchanged, up to the following variables) ... | |
| // --- PATCH: Idle spinning variables --- | |
| let idleAnimFrame = null; | |
| let isIdleSpinning = false; | |
| // --- PATCH: integrate isSpinning at the top (if not already) --- | |
| let isSpinning = false; | |
| // --- PATCH: Ensure angle variable is at top level (if not already) --- | |
| let angle = 0; | |
| // ... (rest of your original variables and setup) ... | |
| // --- PATCH: Add idleSpinSpeed to settings and load/save logic --- | |
| // When loading settings from localStorage, ensure: | |
| if (typeof settings.idleSpinSpeed !== 'number') settings.idleSpinSpeed = 0.01; | |
| // --- PATCH: Idle animation logic --- | |
| function startIdleSpin() { | |
| if (isSpinning || isIdleSpinning) return; | |
| isIdleSpinning = true; | |
| function idleLoop() { | |
| if (!isIdleSpinning) return; | |
| angle += settings.idleSpinSpeed; | |
| drawWheel(); | |
| idleAnimFrame = requestAnimationFrame(idleLoop); | |
| } | |
| idleLoop(); | |
| } | |
| function stopIdleSpin() { | |
| isIdleSpinning = false; | |
| if (idleAnimFrame) cancelAnimationFrame(idleAnimFrame); | |
| idleAnimFrame = null; | |
| } | |
| // --- PATCH: In all spin functions, stop idle spin before starting --- | |
| // Example for your main spin function: | |
| function spinWheel() { | |
| stopIdleSpin(); | |
| if (isSpinning) return; | |
| isSpinning = true; | |
| // ... rest of your spin code ... | |
| // At the end of spin animation/promise: | |
| isSpinning = false; | |
| startIdleSpin(); | |
| } | |
| // PATCH: If you have lastNameSpin() or customSpin(), also call stopIdleSpin() at start, and startIdleSpin() at end. | |
| // --- PATCH: Make wheel and button start the real spin --- | |
| document.getElementById('spin-btn').onclick = spinWheel; | |
| document.getElementById('wheel-canvas').onclick = spinWheel; | |
| // --- PATCH: In settings form, ensure idleSpinSpeed field is kept in sync --- | |
| function populateSettingsForm() { | |
| // ... (all your code) ... | |
| f.elements['idleSpinSpeed'].value = settings.idleSpinSpeed; | |
| document.getElementById('idleSpinSpeedValue').textContent = settings.idleSpinSpeed; | |
| f.elements['idleSpinSpeed'].oninput = function(e) { | |
| document.getElementById('idleSpinSpeedValue').textContent = e.target.value; | |
| }; | |
| // ... (rest unchanged) ... | |
| } | |
| document.getElementById('settings-form').onsubmit = function(e) { | |
| e.preventDefault(); | |
| const fd = new FormData(this); | |
| // ... (all your assignments) ... | |
| settings.idleSpinSpeed = +fd.get('idleSpinSpeed') || 0.01; | |
| localStorage.setItem(SETTINGS_KEY, JSON.stringify(settings)); | |
| // ... (rest of your code) ... | |
| startIdleSpin(); | |
| }; | |
| // --- PATCH: Start idle spinning on load --- | |
| window.onload = function() { | |
| populateSettingsForm(); | |
| drawWheel(); | |
| startIdleSpin(); | |
| }; | |
| // --- All your other code, logic, helpers, and comments remain unchanged! --- | |
| // (Confetti, winner logic, file/image/audio handling, etc.) | |
| // The only changes are the PATCH lines for idle spinning and the slider. | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment