-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
65 lines (53 loc) · 1.45 KB
/
main.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 clock() {
var i = 0;
var current = new Date();
var clockSelector = $('.clock');
return {
hours: function(){
//set live hours
var hour = current.getHours();
if (hour > 12) { return hour = hour - 12 } else return hour;
},
minutes: function(){
//set live minutes
var minute = current.getMinutes()
if (minute < 10) {return minute = "0" + minute} return minute
},
seconds: function(){
//set live seconds
var second = current.getSeconds()
if (second < 10) {return second = "0" + second} return second
},
meridian : function (){
var meridian = "AM";
var hour = current.getHours()
if (hour >= 12){
return meridian = "PM"
} return meridian
},
display: function(){
//display the time
//console.log(current.getHours())
return clockSelector.text(this.hours() + ":" + this.minutes() + ":" + this.seconds() + " " + this.meridian())
},
increment: function(){
setInterval(function (){return clock().display()} , 1000)}
//increments seconds, minutes and hours
// i++
// if (second === 59){
// minute ++
// second = 0
// }
// if (minute === 59){
// hour ++
// minute = 0
// }
//var that = this;
// morningAlarm: function(){
// //will ask you if you slept well and change background image (maybe have a link to news and weather today)
// }
};
}
var timer = clock()
timer.increment()
//setInterval(function(){ return clock().display()},1000)