-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
63 lines (52 loc) · 1.98 KB
/
script.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
setInterval(function() {
var color = '#'+Math.floor(Math.random()*16777215).toString(16);
document.querySelector('body').style.backgroundColor = color;
document.querySelector('p').style.opacity = '1';
setTimeout(function() {
document.querySelector('p').style.opacity = '0';
}, 1000);
}, 2000);
document.addEventListener('mousemove', function(event) {
document.getElementById('image').style.left = event.clientX-69 + 'px';
document.getElementById('image').style.top = event.clientY-52 + 'px';
});
document.addEventListener('click', function(event) {
var image = document.createElement('img');
if (Math.random() < 0.1) {
var image = document.createElement('img');
image.src = 'pictures/img5.png';
image.style.width = '100%';
var audio = new Audio('audio/flex.mp3');
setTimeout(function(){
image.style.width = '130px';
image.style.height = '130px';
image.style.left = event.clientX-60 + 'px';
image.style.top = event.clientY-60 + 'px';
}, 2000);
} else {
image.src = 'pictures/img3.png';
var audio = new Audio('audio/ninja.mp3');
image.style.width = '130px';
image.style.height = '130px';
image.style.left = event.clientX-60 + 'px';
image.style.top = event.clientY-60 + 'px';
image.style.animation = Math.random() < 0.5 ? 'spin1 5s linear infinite' : 'spin2 5s linear infinite';
}
image.style.position = 'absolute';
document.body.append(image);
event.preventDefault();
audio.play();
});
document.addEventListener('contextmenu', function(event) {
var image = document.createElement('img');
image.src = 'pictures/img4.png';
image.style.left = event.clientX-64 + 'px';
image.style.top = event.clientY-60 + 'px';
image.style.position = 'absolute';
image.style.width = '130px';
image.style.height = '130px';
document.body.append(image);
event.preventDefault();
var audio = new Audio('audio/flex.mp3');
audio.play();
});