$(document).ready(function() {
$("#date").html("<p>" + moment().format("dddd") + "</p>");
var sessionLengthMins = 25;
var startTime;
var gong = new Audio("http://callahanweb.xyz/_sounds/chinese-gong-daniel_simon.mp3");
// Click button to start timer
$("#startTimer").click(function() {
// Save the time at start
startTime = moment();
gong.play();
// Display clock immediately
$("#clock").html("<h3>" + moment().format("h:mm:ss a") + "</h3>");
// Update clock every second
var ticker = setInterval(function() {
var timeNow = moment();
// check difference between time now and start time
var timeDiff = timeNow.diff(startTime, "minutes");
$("#clock").html("<h3>" + timeNow.format("h:mm:ss a") + "</h3>");
// alert(timeDiff);
if (timeDiff === sessionLengthMins) {
gong.play();
clearInterval(ticker);
alert("Time up!");
}
}, 1000);
// Replace start button with stop button
$("button#startTimer").replaceWith("<button id='stopTimer'>Stop Timer</button>");
$("#stopTimer").on("click", function() {
clearInterval(ticker);
alert("Timer stopped.");
});
});
// Initialize Calendar
$("#calendar").ionCalendar({
onClick: function(date) {
alert(date);
// TODO:
// Send an AJAX request to nodejs route
// nodejs queries the database
// show modal with information about that day
// create a new BS tab
var newTab = $("<li><a href='#'>" + date + "</a></li>");
$(".nav").append(newTab);
}
});
// Show calendar on click
$("#showCal").click(function() {
$("#calendar").show();
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.