-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasteregg.js
More file actions
54 lines (41 loc) · 1.27 KB
/
easteregg.js
File metadata and controls
54 lines (41 loc) · 1.27 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
;(function(){
"use strict";
var interval, img, audio;
var easteregg = function() {
if (window.addEventListener) {
var keys = [],
konami = "38,38,40,40,37,39,37,39,66,65,13".split(',');
window.addEventListener("keydown", function(e){
keys.push(e.keyCode);
var position = keys.length -1;
if (konami[position] == keys[position])
{
if(konami.length === keys.length){
generate();
}
}
else if(e.keyCode == 15)
{
keys = [];
}
else{
keys = [];
}
}, true);
}
}
img = document.getElementById('madruga');
var generate = function() {
audio = document.createElement('audio');
audio.src = '/assets/images/toasty.ogg';
audio.play();
img.style.display = 'block';
document.body.appendChild(audio);
setTimeout(function(){ destroy() },3000);
};
var destroy = function() {
img.style.display = 'none';
document.body.removeChild(audio);
}
easteregg();
})();