-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.js
97 lines (83 loc) · 2.45 KB
/
clock.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
//selectors
const secondHand = document.querySelector(".second");
const hourHand = document.querySelector(".hour");
const minHand = document.querySelector(".min");
const time = document.querySelector(".time");
const day = document.querySelector(".day");
const date = document.querySelector(".date");
//analog pointers func
const clock =()=> {
const now = new Date();
//second
const seconds = now.getSeconds();
const secondsDegrees = ((seconds / 60) * 360) + 90;
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
//min
const minutes = now.getMinutes();
const minutesDegrees = ((minutes / 60) * 360) + 90;
minHand.style.transform = `rotate(${minutesDegrees}deg)`;
//hrs
const hour = now.getHours();
const hourDegrees = ((hour / 12) * 360) + 90;
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
time.innerText = `${hour % 12} : ${minutes} : ${seconds}`;
console.log(`h-${hour} : m-${minutes} : s-${seconds}`)
const weekDay = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];
day.innerText = weekDay[now.getDay()];
const dates = now.getDate();
const monthName = [
"JAN",
"FEB",
"MAR",
"APR",
"MAY",
"JUNE",
"JULY",
"AUG",
"SEP",
"OCT",
"NOV",
"DEC",
];
const month = monthName[now.getMonth()];
const year = now.getFullYear();
date.innerText = `${dates} : ${month} : ${year}`;
}
//vibenote every 8s
const vibe = document.querySelector(".vibeNotes");
// const vibeSetter = [
// "An early-morning walk is a blessing for the whole day.",
// "Today’s goals: Coffee and kindness. Maybe two coffees, and then kindness.",
// "Write it on your heart that every day is the best day in the year.",
// "Every morning, I wake up saying, ‘I’m still alive, a miracle.’ And so I keep on pushing",
// "If you’re changing the world, you’re working on important things. You’re excited to get up in the morning",
// ];
// //arr++
// let i = 0;
// function arrPlus() {
// if (vibeSetter.length > i) {
// vibe.innerText = vibeSetter[i];
// i++;
// } else {
// i = 0;
// }
// }
//api for random quotes generation
const api=()=>{
const data = fetch("https://goquotes-api.herokuapp.com/api/v1/random?count=1")
data
.then(r=>r.json())
.then(q=>{
vibe.innerText = q.quotes[0].text
})
}
setInterval(clock, 1000);//clock seconds pointer delay
setInterval(api, 8000);//vibenotes changer