-
Notifications
You must be signed in to change notification settings - Fork 5
/
milestone.js
64 lines (47 loc) · 1.57 KB
/
milestone.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
(function() {
var gradients = {
time: function( diff ) {
var weeks = 0,
days = 0,
hours = 0,
minutes = 0,
seconds = 0,
milliseconds = 0;
//return this.weeks( diff ) + ":" + this.days( diff ) + ":" + this.hours( diff ) + ":" + this.minutes( diff ) + ":" + this.seconds( diff ) + ":" + this.milliseconds( diff );
},
weeks: function( diff ) {
return Math.floor( diff / 604800000 );
},
days: function( diff ) {
return Math.floor( diff / 86400000 );
},
Days: function( diff ) {
return Math.floor( diff / 86400000 );
},
hours: function( diff ) {
return Math.floor( diff / 3600000 );
},
minutes: function( diff ) {
return Math.floor( diff / 60000 );
},
seconds: function( diff ) {
return Math.floor( diff / 1000 );
},
milliseconds: function( diff ) {
return Math.floor( diff );
},
};
dashBoard.widget( "milestone", function( id, options ){
var today = new Date(),
milestone = new Date( options.when );
options.gradient = options.gradient || "time";
if (!options.what)
options.what = "due";
setInterval( function() {
if(milestone.getTime() - new Date().getTime() > 0)
document.getElementById( id ).innerHTML = options.gradient + " until " + options.what + ": " + gradients[ options.gradient ]( milestone.getTime() - new Date().getTime() );
else
document.getElementById( id ).innerHTML = options.gradient + " until " + options.what + ": " + "Complete!";
}, 1);
});
})();