-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
31 lines (28 loc) · 861 Bytes
/
Copy pathcontent.js
File metadata and controls
31 lines (28 loc) · 861 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
const clickHandler = (event) => {
const x = event.clientX / window.innerWidth
const y = event.clientY / window.innerHeight
confetti({
particleCount: 100,
spread: 70,
origin: { x: x, y: y },
zIndex: 99999
})
playSound()
}
const buttons = document.querySelectorAll('button,input[type="submit"],a')
buttons.forEach(button => {
button.addEventListener('click', clickHandler)
})
// alternative approach if NodeList.prototype.forEach() is not supported
// for (i = 0; i < buttons.length; i++) {
// buttons[i].addEventListener('click', clickHandler)
// }
const audioUrl = 'https://raw.githubusercontent.com/dpiTech/formfun/main/party-horn.wav'
const audio = new Audio(audioUrl)
const playSound = () => {
if (!audio.paused) {
audio.pause()
audio.currentTime = 0
}
audio.play()
}