-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
36 lines (29 loc) · 824 Bytes
/
main.js
File metadata and controls
36 lines (29 loc) · 824 Bytes
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
//To display @ DOM
const hr = document.querySelector('.hour')
const min = document.querySelector('.min')
const sec = document.querySelector('.sec')
//Update every sec
setInterval(()=>{
let date = new Date();
let h = date.getHours();
let m = date.getMinutes();
let s = date.getSeconds();
let session = ' AM';
//12h format
if(h>12){
h=h-12;
session=" PM";
}
//to make h/m/s as 01,02 instead of 1,2
h < 10 ? h='0'+h : h
m < 10 ? m='0'+m : m
s < 10 ? s='0'+s : s
//display
hr.innerHTML=h;
min.innerHTML=m;
sec.innerHTML=s;
document.querySelector('.am-pm').innerHTML = session;
},1000)
document.body.addEventListener('mousemove',(e)=>{
document.body.style.backgroundColor = "rgba(" + e.offsetX + "," + e.offsetY + ",50,0.5)";
})