-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
117 lines (85 loc) · 2.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
function daysInMonth (month, year) {
return new Date(year, month, 0).getDate();
}
function days_passed_in_year(dt) {
var current = new Date(dt.getTime());
var previous = new Date(dt.getFullYear(), 0, 1);
return Math.ceil((current - previous + 1) / 86400000);
}
function days_of_a_year(year)
{
return isLeapYear(year) ? 366 : 365;
}
function isLeapYear(year) {
return year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
}
function second_past_in_day() {
date = new Date();
hour = date.getHours();
minutes = date.getMinutes();
seconds = date.getSeconds();
return hour * 60 * 60 + minutes * 60 + seconds
}
function seconds_past_in_day_percent() {
seconds_past = second_past_in_day();
full_seconds = 24 * 3600;
percent = Math.round( seconds_past / full_seconds * 100 ) + "%";
return percent
}
var datenow = new Date();
var daysPast = datenow.getDate();
var days_past_percent_month = Math.round((daysPast / daysInMonth(datenow.getMonth(),datenow.getFullYear()) ) * 100,2) + "%";
var days_past_percent_year = Math.round( days_passed_in_year(datenow) / days_of_a_year(datenow.getFullYear()) * 100 ) + "%";
var second_past_percent_day = seconds_past_in_day_percent()
$( document ).ready(function() {
var myVar = setInterval(function() {
myTimer();
}, 1000);
function myTimer() {
var d = new Date();
document.getElementById("clock").innerHTML = d.toLocaleTimeString();
}
$('#month-percent').animate({
width:days_past_percent_month},{complete:function() {
//console.log('done');
//$("#month-percent").html(days_past_percent_month);
}}
);
$('#year-percent').animate({
width:days_past_percent_year},{complete:function() {
//$("#year-percent").html(days_past_percent_year);
}}
);
$('#day-percent').animate({
width:second_past_percent_day},{complete:function() {
//$("#day-percent").html(seconds_past_in_day_percent());
}
});
$("#month-percent").prop("Counter", 0).animate({
Counter: days_past_percent_month
}, {
duration: 1200,
easing: "swing",
step: function(now) {
$(this).html(Math.ceil(now) + "%")
}
})
$("#year-percent").prop("Counter", 0).animate({
Counter: days_past_percent_year
}, {
duration: 1200,
easing: "swing",
step: function(now) {
$(this).html(Math.ceil(now) + "%")
}
})
$("#day-percent").prop("Counter", 0).animate({
Counter: second_past_percent_day
}, {
duration: 1200,
easing: "swing",
step: function(now) {
$(this).html(Math.ceil(now) + "%")
}
})
});