-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
55 lines (46 loc) · 1.48 KB
/
script.js
File metadata and controls
55 lines (46 loc) · 1.48 KB
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
/* CLOCK */
function updateClock() {
const now = new Date();
let h = now.getHours();
let m = now.getMinutes();
let s = now.getSeconds();
let ampm = h >= 12 ? "PM" : "AM";
h = h % 12 || 12;
document.getElementById("time").innerText =
`${String(h).padStart(2,"0")}:${String(m).padStart(2,"0")}:${String(s).padStart(2,"0")}`;
document.getElementById("ampm").innerText = ampm;
document.getElementById("date").innerText =
now.toLocaleDateString("en-IN",{weekday:"long",day:"numeric",month:"long",year:"numeric"});
tick();
}
setInterval(updateClock,1000);
updateClock();
/* TICK SOUND */
const ctx = new (window.AudioContext||window.webkitAudioContext)();
function tick(){
const o = ctx.createOscillator();
const g = ctx.createGain();
o.frequency.value = 900;
g.gain.value = 0.015;
o.connect(g); g.connect(ctx.destination);
o.start(); o.stop(ctx.currentTime+0.05);
}
/* iOS DEPTH PARALLAX */
const card = document.querySelector(".depth");
document.addEventListener("mousemove", e=>{
const x = (window.innerWidth/2 - e.clientX)/25;
const y = (window.innerHeight/2 - e.clientY)/25;
card.style.transform = `rotateY(${x}deg) rotateX(${y}deg)`;
});
/* PARTICLES */
const p = document.querySelector(".particles");
for(let i=0;i<30;i++){
const s=document.createElement("span");
s.style.left=Math.random()*100+"vw";
s.style.animationDuration=5+Math.random()*6+"s";
p.appendChild(s);
}
/* DARK MODE */
function toggleMode(){
document.body.classList.toggle("light");
}