<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: white;
margin: 0;
}
.container {
text-align: center;
background-color: white;
}
#dare {
font-size: 72px;;
margin-bottom: 20px;
}
#timer {
font-size: 60px;
margin-top: 20px;
}
#startButton {
padding: 10px 20px;
font-size: 1em;
cursor: pointer;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container">
<h1>Productivity Dare</h1>
<p id="dare"></p>
<button id="startButton">Start Dare</button>
<div id="timer">01:00</div>
</div>
<script>
const dares = [
"Organize your workspace",
"Write down your top 3 tasks",
"Take a short walk",
"Drink a glass of water",
"Stretch for 1 minute"
];
const startButton = document.getElementById("startButton");
const dareElement = document.getElementById("dare");
const timerElement = document.getElementById("timer");
startButton.addEventListener("click", startDare);
function startDare() {
const dare = dares[Math.floor(Math.random() * dares.length)];
dareElement.innerText = dare;
let timer = 60; // 1 minute in seconds
const countdown = setInterval(() => {
const minutes = Math.floor(timer / 60);
const seconds = timer % 60;
timerElement.innerText = `${minutes < 10 ? '0' : ''}${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
if (timer === 0) {
clearInterval(countdown);
showCompletionDialog();
} else {
timer--;
}
}, 1000);
}
function showCompletionDialog() {
const userResponse = confirm("You completed the task?");
if (userResponse) {
alert("Great job! Try another dare.");
} else {
alert("No worries, you can try another dare.");
}
resetDare();
}
function resetDare() {
dareElement.innerText = "";
timerElement.innerText = "01:00";
}
</script>
</body>
</html>