blob: 1b4f0b7aedce8a05b9fa902e6b9644933518a02e (
plain)
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
|
'use strict';
function randomInteger(min, max) {
/* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random */
return Math.floor(Math.random() * (max - min)) + min;
}
function setColor(color) {
document.body.style.backgroundColor = color;
}
var hexCharacters = '0123456789abcdef'.split('');
function randomColor() {
var color = '#';
for (var i = 0; i < 6; i++) {
color += hexCharacters[randomInteger(0, hexCharacters.length)];
}
return color;
}
function randomlySetColor() {
setColor(randomColor());
}
function move(id, left, top) {
var element = document.getElementById(id);
element.style.left = left + "px";
element.style.top = top + "px";
}
function randomValidPosition(id) {
var width = window.innerWidth;
var height = window.innerHeight;
var element = document.getElementById(id);
return {
left: randomInteger(0, width - element.width),
top: randomInteger(0, height - element.height)
};
}
function randomlyMoveElement(id) {
var position = randomValidPosition(id);
move(id, position.left, position.top);
}
function rotate(text) {
// Adapted from Robert Quitt
return text.substring(1) + text[0];
}
var titleText = document.title + ' ' // buffer
setInterval(function() {
randomlySetColor();
randomlyMoveElement('aseem');
// document.title strips out spaces, so helper variable
titleText = rotate(titleText)
document.title = titleText
}, 220);
|