-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmonkeyshine.js
50 lines (44 loc) · 1.79 KB
/
monkeyshine.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
// Rotate page 180
['', '-ms-', '-webkit-', '-o-', '-moz-'].map(function(prefix){
document.body.style[prefix + 'transform'] = 'rotate(180deg)';
});
// Flip images 180
['', '-ms-', '-webkit-', '-o-', '-moz-'].map(function(prefix){
Array.prototype.slice.call(document.querySelectorAll('img')).map(function(el){
el.style[prefix + 'transform'] = 'rotate(180deg)';
});
});
// Random orientations
['', '-ms-', '-webkit-', '-o-', '-moz-'].map(function(prefix){
Array.prototype.slice.call(document.querySelectorAll('div,p,span,img,a,body')).map(function(el){
el.style[prefix + 'transform'] = 'rotate(' + (Math.floor(Math.random() * 3) - 1) + 'deg)';
});
});
// Rotate page on mouse/key movement
setTimeout(function(){
document.onmousemove = document.onkeypress = function(){
['', '-ms-', '-webkit-', '-o-', '-moz-'].map(function(prefix){
document.body.style[prefix + 'transition'] = prefix + 'transform 3s';
document.body.style[prefix + 'transform'] = 'rotate(180deg)';
});
}
}, 5000);
// Replace text entered by the user with the contents of the TEXT variable
(function(){
var TEXT = 'i like frogs ';
Array.prototype.slice.call(document.querySelectorAll('input[type=text],textarea')).map(function(el){
el.onkeypress=function(evt){
var charCode = typeof evt.which == "number" ? evt.which : evt.keyCode;
if (charCode && charCode > 31) {
var start = this.selectionStart, end = this.selectionEnd;
this.value = this.value.slice(0, start) + TEXT[start % TEXT.length] + this.value.slice(end);
this.selectionStart = this.selectionEnd = start + 1;
}
return false;
}
});
}());
// Replace all images on the page with a picture of Justin Bieber
Array.prototype.slice.call(document.querySelectorAll('img')).map(function(el){
el.src = '//codebox.net/assets/images/monkeyshine/bieber.jpg';
});