forked from bertrandom/hodor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhodor.js
47 lines (32 loc) · 869 Bytes
/
hodor.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
var lastIndex = 0;
function hodor() {
var index,
hodorSound;
do {
index = Math.floor(Math.random() * (11)) + 1;
} while (index === lastIndex);
lastIndex = index;
hodorSound = soundManager.getSoundById('hodor' + index);
if (!hodorSound) {
hodorSound = soundManager.createSound({
id: 'hodor' + index,
url: './audio/hodor' + index + '.mp3'
});
}
hodorSound.play();
}
function changeColor() {
document.getElementById('hodor').style['background-color'] = randomColor({luminosity: 'dark'});
}
changeColor();
soundManager.setup({
url: './swf/',
onready: function() {
document.getElementById('hodor').onclick = function() {
hodor();
changeColor();
return false;
}
hodor();
}
});