A Pen by Zoran Stanic on CodePen.
Created
November 10, 2016 23:23
-
-
Save pilgrim011/3207d2639c08c4c19782f66a13896882 to your computer and use it in GitHub Desktop.
Pomodoro Timer
This file contains 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
<body> | |
<div class = "container text-center"> | |
<div> | |
<h1>Pomodoro Clock</h1> | |
</div> | |
<div class="container text-center" id = "length"> | |
<h5>BREAK LENGTH</h5> | |
<h5>SESSION LENGTH</h5> | |
</div> | |
<div class="btn-group text-center"> | |
<button type="button" class="btn btn-primary"id = "breakplus">+</button> | |
<p id = "breakvalue"></p> | |
<button type="button" class="btn btn-primary"id = "breakminus">-</button> | |
</div> | |
<div class="btn-group text-center"> | |
<button type="button" class="btn btn-primary" id = "sessionplus">+</button> | |
<p id = "sessionvalue"></p> | |
<button type="button" class="btn btn-primary"id = "sessionminus">-</button> | |
</div> | |
<div class="center-block"><button type="button" class=" circle btn btn-primary" id = "crcl"></button></div> | |
</div> | |
<div> | |
<div class="text-center center-block"><button type="button" class="btn btn-primary" id = "reset">RESET</button></div> | |
</div> | |
</body> |
This file contains 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
$( document ).ready(function(){ | |
var toggle = true; | |
var a = document.getElementById("breakvalue"); | |
a.innerHTML = 7; | |
var b = document.getElementById("sessionvalue"); | |
b.innerHTML = 25; | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + b.innerHTML + "</h1>"); | |
$("#breakplus").on("click", function(){ | |
$("#breakvalue").html(eval(a.innerHTML)+1); | |
}); | |
$("#breakminus").on("click", function(){ | |
if (a.innerHTML>=2){ | |
$("#breakvalue").html(eval(a.innerHTML)-1); | |
} | |
}); | |
$("#sessionplus").on("click", function(){ | |
$("#sessionvalue").html(eval(b.innerHTML)+1); | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + b.innerHTML + "</h1>"); | |
clearInterval(inter); | |
}); | |
$("#sessionminus").on("click", function(){ | |
if(b.innerHTML>=2){ | |
$("#sessionvalue").html(eval(b.innerHTML)-1); | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + b.innerHTML + "</h1>"); | |
clearInterval(inter); | |
} | |
}); | |
var clck = $("#crcl").on("click", function (){ | |
var getId = document.getElementById("len"); | |
var idValue = getId.innerHTML; | |
console.log(idValue); | |
var capture = document.getElementById("crcl"); | |
var inner = capture.innerHTML; | |
var head = document.getElementById("numb"); | |
var inn = head.innerHTML; | |
var minutes = parseInt(inn); | |
var afterMins = inn.substr(inn.indexOf(":") + 1); | |
var seconds = Number(afterMins); | |
if(toggle&&isNaN(inn)&&idValue==="Session"){ | |
inter = setInterval(function(){ | |
if(seconds>=0){ | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + minutes + ":" + seconds-- + "</h1>");} | |
if (seconds<0){ | |
seconds=59; | |
minutes = minutes-1; | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + minutes + ":" + seconds-- + "</h1>");} | |
if(minutes<0){ | |
clearInterval(inter); | |
$("#crcl").html("<h3 id = len>Break!</h3>" + "</break>" + "<h1 id = numb>" + a.innerHTML + "</h1>"); | |
clockBreak(); | |
} | |
toggle=false; | |
}, 1000); | |
} | |
if(toggle&&!isNaN(inn)&&idValue==="Session"){ | |
minutes = eval(b.innerHTML-1); | |
seconds=59; | |
inter = setInterval(function(){ | |
if(seconds>=0){ | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + minutes + ":" + seconds-- + "</h1>"); | |
} | |
if (seconds<0){ | |
seconds=59; | |
minutes = eval(minutes-1); | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + minutes + ":" + seconds-- + "</h1>");} | |
if(eval(minutes)<0){ | |
clearInterval(inter); | |
$("#crcl").html("<h3 id = len>Break!</h3>" + "</break>" + "<h1 id = numb>" + a.innerHTML + "</h1>"); | |
clockBreak(); | |
} | |
toggle=false; | |
}, 1000); | |
} | |
if (!toggle&&idValue==="Session") { | |
toggle=true; | |
clearInterval(inter); | |
} | |
if(toggle&&isNaN(inn)&&idValue==="Break!"){ | |
inter = setInterval(function(){ | |
if(seconds>=0){ | |
$("#crcl").html("<h3 id = len>Break!</h3>" + "</break>" + "<h1 id = numb>" + minutes + ":" + seconds-- + "</h1>");} | |
if (seconds<0){ | |
seconds=59; | |
minutes = minutes-1; | |
$("#crcl").html("<h3 id = len>Break!</h3>" + "</break>" + "<h1 id = numb>" + minutes + ":" + seconds-- + "</h1>"); | |
} | |
if(minutes<0){ | |
clearInterval(inter); | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + 25 + "</h1>"); | |
$("#sessionvalue").html(25); | |
$("#breakvalue").html(7); | |
} | |
toggle=false; | |
}, 1000); | |
} | |
if (!toggle&&idValue==="Break!") { | |
toggle = true; | |
clearInterval(inter); | |
} | |
}); | |
var clockBreak = function (){ | |
var capture = document.getElementById("crcl"); | |
var inner = capture.innerHTML; | |
var head = document.getElementById("numb"); | |
var inn = head.innerHTML; | |
minutes = eval(a.innerHTML-1); | |
seconds=59; | |
inter = setInterval(function(){ | |
if(seconds>=0){ | |
$("#crcl").html("<h3 id = len>Break!</h3>" + "</break>" + "<h1 id = numb>" + minutes + ":" + seconds-- + "</h1>"); | |
} | |
if (seconds<0){ | |
seconds=59; | |
minutes = minutes-1; | |
$("#crcl").html("<h3 id = len>Break!</h3>" + "</break>" + "<h1 id = numb>" + minutes + ":" + seconds-- + "</h1>");} | |
if(eval(minutes)<0){ | |
clearInterval(inter); | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + 25 + "</h1>"); | |
$("#sessionvalue").html(25); | |
$("#breakvalue").html(7); | |
} | |
toggle=false; | |
}, 1000); | |
} | |
$("#reset").on("click", function(){ | |
$("#sessionvalue").html(25); | |
$("#breakvalue").html(7); | |
$("#crcl").html("<h3 id = len>Session</h3>" + "</break>" + "<h1 id = numb>" + 25 + "</h1>"); | |
toggle = true; | |
clearInterval(inter); | |
}); | |
}); |
This file contains 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
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> |
This file contains 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
h5{ | |
display:inline-block; | |
} | |
p{ | |
font-size:30px; | |
} | |
.circle | |
{ | |
width:500px; | |
height:500px; | |
border-radius:50%; | |
font-size:20px; | |
color:#fff; | |
line-height:500px; | |
text-align:center; | |
background:#000; | |
} |
This file contains 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
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment