-
Notifications
You must be signed in to change notification settings - Fork 0
/
h.js
71 lines (63 loc) · 1.33 KB
/
h.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
64
65
66
67
68
69
70
71
(function(){
var is_paused = false;
var colors = [
"#656555",
"#2B2B2B",
"#383838",
"#3F3F3F",
"#494949",
"#4F4F4F",
"#5F5F5F",
"#6F6F6F",
"#DCA3A3",
"#CC9393",
"#BC8383",
"#AC7373",
"#9C6363",
"#8C5353",
"#DFAF8F",
"#F0DFAF",
"#E0CF9F",
"#D0BF8F",
"#5F7F5F",
"#7F9F7F",
"#8FB28F",
"#9FC59F",
"#AFD8AF",
"#BFEBBF",
"#93E0E3",
"#94BFF3",
"#8CD0D3",
"#7CB8BB",
"#6CA0A3",
"#5C888B",
"#4C7073",
"#366060",
"#DC8CC3"
];
function range(start, count) {
return Array.apply(0, Array(count))
.map(function (element, index) {
return index + start;
});
}
function random_element(array) {
return array[Math.floor(Math.random() * array.length)];
}
var intervals = range(3, 20).map(function(e) { return e * 33 });
var blinder = null;
function blind_user() {
if (!is_paused) { document.body.style.backgroundColor = random_element(colors); }
}
function set_random_interval(f, intervals) {
clearInterval(blinder);
blinder = setInterval(f, random_element(intervals));
}
document.body.onkeyup = function(e) {
if(e.keyCode == 32) { is_paused = !is_paused; }
}
setInterval(function me() {
set_random_interval(blind_user, intervals);
return me;
}(), 1000);
})();