Generate a website for creating a high intensity interval timer. The user should be…
- User
Generate a website for creating a high intensity interval timer. The user should be presented with a form to gather the following details
Timer Details Name: Number of Sets: High Intensity Intervals Name: Duration (in seconds) Color: Low Intensity Intervals Name: Duration (in seconds) Color: Warmup Interval Name: Duration (in seconds) Color: Cooldown Interval Name: Duration (in seconds) Color:then when they click create they should be directed to a fully functional timer based on their selections in the form. Assistant
Sure, here's a simple HTML and JavaScript implementation for a high-intensity interval timer website. This example includes a form to gather the timer details and a functional timer based on the user's selections.
HTML and JavaScript Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>High Intensity Interval Timer</title> <style> body { font-family: Arial, sans-serif; margin: 20px; } form { margin-bottom: 20px; } label { display: block; margin: 5px 0; } input, select { width: 100%; padding: 8px; margin: 5px 0 10px 0; display: inline-block; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } button { width: 100%; background-color: #4CAF50; color: white; padding: 14px 20px; margin: 8px 0; border: none; border-radius: 4px; cursor: pointer; } button:hover { background-color: #45a049; } #timer { font-size: 2em; margin-top: 20px; } </style> </head> <body> <h2>Create Your High Intensity Interval Timer</h2> <form id="timerForm"> <label for="timerName">Timer Details Name:</label> <input type="text" id="timerName" name="timerName" required> <label for="numberOfSets">Number of Sets:</label> <input type="number" id="numberOfSets" name="numberOfSets" min="1" required> <label for="highIntensityName">High Intensity Intervals Name:</label> <input type="text" id="highIntensityName" name="highIntensityName" required> <label for="highIntensityDuration">Duration (in seconds):</label> <input type="number" id="highIntensityDuration" name="highIntensityDuration" min="1" required> <label for="highIntensityColor">Color:</label> <input type="color" id="highIntensityColor" name="highIntensityColor" required> <label for="lowIntensityName">Low Intensity Intervals Name:</label> <input type="text" id="lowIntensityName" name="lowIntensityName" required> <label for="lowIntensityDuration">Duration (in seconds):</label> <input type="number" id="lowIntensityDuration" name="lowIntensityDuration" min="1" required> <label for="lowIntensityColor">Color:</label> <input type="color" id="lowIntensityColor" name="lowIntensityColor" required> <label for="warmupName">Warmup Interval Name:</label> <input type="text" id="warmupName" name="warmupName" required> <label for="warmupDuration">Duration (in seconds):</label> <input type="number" id="warmupDuration" name="warmupDuration" min="1" required> <label for="warmupColor">Color:</label> <input type="color" id="warmupColor" name="warmupColor" required> <label for="cooldownName">Cooldown Interval Name:</label> <input type="text" id="cooldownName" name="cooldownName" required> <label for="cooldownDuration">Duration (in seconds):</label> <input type="number" id="cooldownDuration" name="cooldownDuration" min="1" required> <label for="cooldownColor">Color:</label> <input type="color" id="cooldownColor" name="cooldownColor" required> <button type="button" onclick="createTimer()">Create Timer</button> </form> <div id="timer"></div> <script> let interval; let currentTime = 0; let currentSet = 0; let timerDetails = {}; function createTimer() { timerDetails = { name: document.getElementById('timerName').value, numberOfSets: parseInt(document.getElementById('numberOfSets').value), highIntensity: { name: document.getElementById('highIntensityName').value, duration: parseInt(document.getElementById('highIntensityDuration').value), color: document.getElementById('highIntensityColor').value }, lowIntensity: { name: document.getElementById('lowIntensityName').value, duration: parseInt(document.getElementById('lowIntensityDuration').value), color: document.getElementById('lowIntensityColor').value }, warmup: { name: document.getElementById('warmupName').value, duration: parseInt(document.getElementById('warmupDuration').value), color: document.getElementById('warmupColor').value }, cooldown: { name: document.getElementById('cooldownName').value, duration: parseInt(document.getElementById('cooldownDuration').value), color: document.getElementById('cooldownColor').value } }; startWarmup(); } function startWarmup() { updateTimer(timerDetails.warmup.name, timerDetails.warmup.duration, timerDetails.warmup.color); currentTime = timerDetails.warmup.duration; interval = setInterval(countdown, 1000); } function startTimer() { updateTimer(timerDetails.highIntensity.name, timerDetails.highIntensity.duration, timerDetails.highIntensity.color); currentTime = timerDetails.highIntensity.duration; interval = setInterval(countdown, 1000); } function startLowIntensity() { updateTimer(timerDetails.lowIntensity.name, timerDetails.lowIntensity.duration, timerDetails.lowIntensity.color); currentTime = timerDetails.lowIntensity.duration; interval = setInterval(countdown, 1000); } function startCooldown() { updateTimer(timerDetails.cooldown.name, timerDetails.cooldown.duration, timerDetails.cooldown.color); currentTime = timerDetails.cooldown.duration; interval = setInterval(countdown, 1000); } function countdown() { if (currentTime <= 0) { clearInterval(interval); currentSet++; if (currentSet < timerDetails.numberOfSets) { startLowIntensity(); } else { startCooldown(); } } else { currentTime--; document.getElementById('timer').textContent = `${currentTime} seconds`; } } function updateTimer(name, duration, color) { document.getElementById('timer').style.color = color; document.getElementById('timer').textContent = `${name}: ${duration} seconds`; } </script> </body> </html>Explanation
- Form: The form gathers all the necessary details for the timer, including names, durations, and colors for high-intensity, low-intensity, warmup, and cooldown intervals.
- JavaScript:
- The
createTimerfunction collects the form data and initializes the timer. - The
startWarmup,startTimer,startLowIntensity, andstartCooldownfunctions handle the different phases of the timer. - The
countdownfunction decreases the timer by one second every second and switches between intervals as needed. - The
updateTimerfunction updates the display with the current interval's name, duration, and color.
- The
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.