Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
674 changes: 674 additions & 0 deletions study-timer/LICENSE

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions study-timer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# study-timer
36 changes: 36 additions & 0 deletions study-timer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Study Timer</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="timer-style.css">
</head>
<body>
<div class="container">
<h1>Study Timer</h1>
<div class="clock-container">
<svg class="clock" viewBox="0 0 100 100">
<circle class="clock-face" cx="50" cy="50" r="45" />
<text id="timer" x="50" y="50" text-anchor="middle" dy="7">25:00</text>
</svg>
</div>
<div class="button-container">
<button class="start" onclick="startTimer()">Start Timer</button>

<button class="pause" onclick="pauseResumeTimer()">Pause Timer</button>
<button class="reset" onclick="resetTimer()">Reset Timer</button>

<br>
<button class="break" onclick="startBreak()">Start Break</button>
</div>
</div>
<audio id="audio" src="https://www.soundjay.com/misc/sounds/bell-ringing-05.mp3"></audio>

</div>

<script src="script.js"></script>
</body>
</html>
95 changes: 95 additions & 0 deletions study-timer/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
var timer;
var isPaused = false;
var isReset = false;

function startTimer() {
var presentTime = document.getElementById("timer").innerHTML;
var timeArray = presentTime.split(":");
var minutes = timeArray[0];
var seconds = timeArray[1];

if (isReset) {
startStudy();
isReset = false;
return;
}

if (seconds == 0) {
if (minutes == 0) {
document.getElementById("audio").play();
return;
} else {
minutes--;
seconds = 59;
}
} else {
seconds--;
}

document.getElementById("timer").innerHTML = minutes + ":" + (seconds < 10 ? "0" : "") + seconds;

if (!isPaused) {
timer = setTimeout(startTimer, 1000);
}
}

function startBreak() {
var presentTime = document.getElementById("timer").innerHTML;
var timeArray = presentTime.split(":");
var minutes = timeArray[0];
var seconds = timeArray[1];

if (isReset) {
startBreakTimer();
isReset = false;
return;
}

if (seconds == 0) {
if (minutes == 0) {
document.getElementById("audio").play();
return;
} else {
minutes--;
seconds = 59;
}
} else {
seconds--;
}

document.getElementById("timer").innerHTML = minutes + ":" + (seconds < 10 ? "0" : "") + seconds;

if (!isPaused) {
timer = setTimeout(startBreak, 1000);
}
}

function startStudy() {
clearTimeout(timer);
document.getElementById("timer").innerHTML = "25:00";
isPaused = false;
isReset = true;
}

function startBreakTimer() {
clearTimeout(timer);
document.getElementById("timer").innerHTML = "5:00";
isPaused = false;
isReset = true;
}

function pauseResumeTimer() {
isPaused = !isPaused;
if (!isPaused) {
startTimer();
}
}

function pauseTimer() {
isPaused = true;
}

function resetTimer() {
isReset = true;
startStudy();
}
141 changes: 141 additions & 0 deletions study-timer/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/* Import Google font - Poppins */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #618bff;
}
.container {
position: relative;
max-width: 350px;
width: 100%;
background: #fff;
border-radius: 12px;
padding: 20px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}
header {
font-size: 18px;
color: #333;
font-weight: 500;
text-align: center;
}
textarea {
width: 100%;
height: 180px;
border-radius: 8px;
margin: 20px 0;
padding: 10px 15px;
resize: none;
outline: none;
border: 1px solid #aaa;
}
button {
width: 100%;
padding: 14px 0;
border: none;
border-radius: 8px;
color: #fff;
background: #6e93f7;
cursor: pointer;
transition: all 0.3s ease;
}
button:hover {
background: #4070f4;
}

.start {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
color: #fff;
background: #6ef77c;
cursor: pointer;
transition: all 0.3s ease;
}

.pause {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
color: #fff;
background: #f7ce6e;
cursor: pointer;
transition: all 0.3s ease;
}

.reset {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
color: #fff;
background: #f7796e;
cursor: pointer;
transition: all 0.3s ease;
}

.break {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
color: #fff;
background: #f7876e;
cursor: pointer;
transition: all 0.3s ease;
}

.start:hover {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
color: #fff;
background: #47ff5a;
cursor: pointer;
transition: all 0.3s ease;
}

.pause:hover {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
color: #fff;
background: #f7c248;
cursor: pointer;
transition: all 0.3s ease;
}

.reset:hover {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
color: #fff;
background: #ff6355;
cursor: pointer;
transition: all 0.3s ease;
}

.break:hover {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
color: #fff;
background: #f66a4a;
cursor: pointer;
transition: all 0.3s ease;
}
36 changes: 36 additions & 0 deletions study-timer/timer-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
h1 {
text-align: center;
color: rgb(29, 29, 29);
}

.clock-container {
display: flex;
justify-content: center;
margin: 50px 0;
}

.clock {
width: 200px;
height: 200px;
}

.clock-face {
fill: #fff;
stroke: #f74949;
stroke-width: 2px;
}

#timer {
font-size: auto;
fill: #f74949;
}

.button-container {
display: flex;
justify-content: center;
}

button {
margin: 10px;
}