Commit 14e41e12 authored by Sanjit Singh Chouhan's avatar Sanjit Singh Chouhan

Timers

parent cfbdf5e7
var banner = document.createElement("div");
// Welcome Message
var message = document.createTextNode("Welcome to Summer of Data");
banner.appendChild(message);
/**
* Timers
* */
function timeDifferene(t1, t2) {
var distance = t2 - t1;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
return days ? (days + "d ") : hours ? hours + "h " : '' + minutes ? minutes + "m " : '' + seconds + "s ";
}
var time_completed = document.createElement('span');
banner.appendChild(time_completed);
time_completed.style.paddingLeft = '10px';
var startTime = new Date("May 27, 2018 09:00:00").getTime();
setInterval(function () {
while (time_completed.firstChild) {
time_completed.removeChild(time_completed.firstChild);
}
var time_completed_text = timeDifferene(startTime, new Date().getTime());
time_completed.appendChild(document.createTextNode('Completed: ' + time_completed_text));
}, 1000);
var time_remaining = document.createElement('span');
banner.appendChild(time_remaining);
time_remaining.style.paddingLeft = '10px';
var endTime = new Date("June 25, 2018 09:00:00").getTime();
setInterval(function () {
while (time_remaining.firstChild) {
time_remaining.removeChild(time_remaining.firstChild);
}
var time_remaining_text = timeDifferene(new Date().getTime(), endTime);
time_remaining.appendChild(document.createTextNode('Remaining: ' + time_remaining_text));
}, 1000);
/**
* Schedule Button
* */
var schedule_btn = document.createElement("button");
schedule_btn.id = 'schedule_btn';
schedule_btn.appendChild(document.createTextNode("View Today's Schedule"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment