A web page screensaver, able to transparently overlay any page if a user leaves their computer idle for too long. Makes for a great easter-egg on an otherwise boring site.
j=document;e=Math;k=j.body;k.innerHTML="<p>Don't idle...or else!</p>"+k.innerHTML;o=0;w=e.random;l=j.getElementById("c");z=l.style;A=l.getContext("2d");B=[];m=[0,0];g=0;function h(C,G){return(w()*(G-C)+C)<<0}function D(){with(A){clearRect(0,0,u,v);for(t=2;t;){r=0xffffff&m[--t]<<4|h(4,14);for(i=5;i;){with((f=B[t])[--i]){s=h(4,8);x=e.min(U,e.max(0,x+a*b));y=e.min(V,e.max(0,y+c*d));if(x<=0||x>=U){a*=-1;b=s;m[t]=r}if(y<=0||y>=V){c*=-1;d=s;m[t]=r}}}beginPath();lineWidth=8;strokeStyle="#"+m[t].toString(16);moveTo((n=f[0]).x,n.y);for(i=5;i;){lineTo((n=f[--i]).x,n.y)}stroke();closePath()}}g||(g=setInterval(D,20))}function E(){clearTimeout(o);if(g){clearInterval(g);A.clearRect(g=0,0,u,v)}o=setTimeout(D,3E3)}function F(){U=(u=l.width=innerWidth)-1;V=(v=l.height=innerHeight)-1}with(k.style){margin="0";background="#000";color="#fff"}F();z.position="absolute";z.top="0";for(t=2;t;){f=B[--t]=[];for(i=5;i;){p=(1&((w()*9)<<0))?1:-1;q=h(4,8);f[--i]={x:h(1,U),y:h(1,V),a:p,c:p,b:q,d:q}}}E();j.onmousemove=j.onkeydown=E;onresize=F
aj1kb2N1bWVudDtlPU1hdGg7az1qLmJvZHk7ay5pbm5lckhUTUw9IjxwPkRvbid0IGlkbGUuLi5vciBlbHNlITwvcD4iK2suaW5uZXJIVE1MO289MDt3PWUucmFuZG9tO2w9ai5nZXRFbGVtZW50QnlJZCgiYyIpO3o9bC5zdHlsZTtBPWwuZ2V0Q29udGV4dCgiMmQiKTtCPVtdO209WzAsMF07Zz0wO2Z1bmN0aW9uIGgoQyxHKXtyZXR1cm4odygpKihHLUMpK0MpPDwwfWZ1bmN0aW9uIEQoKXt3aXRoKEEpe2NsZWF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D.body;
B.innerHTML = "<p>Don't idle...or else!</p>" + B.innerHTML;
var wait=0,
Mra = M.random,
C = D.getElementById("c"),
Cs = C.style,
G = C.getContext("2d"),
points = [],
lc = [0,0],
move_it
;
function rand_range(imin,imax) {
return (Mra()*(imax-imin) + imin) << 0;
}
function doit() {
with(G){
clearRect(0,0,u,v);
for (t=2; t;) {
r = 0xffffff & lc[--t] << 4 | rand_range(4,14);
for (i=5; i;) { with ((f=points[t])[--i]) {
s = rand_range(4,8);
x = M.min(U,M.max(0,x + a*b));
y = M.min(V,M.max(0,y + c*d));
if (x <= 0 || x >= U) {
a *= -1;
b = s;
lc[t] = r;
}
if (y <= 0 || y >= V) {
c *= -1;
d = s;
lc[t] = r;
}
}}
beginPath();
lineWidth = 8;
strokeStyle = "#"+lc[t].toString(16);
moveTo((n=f[0]).x,n.y);
for (i=5; i;) {
lineTo((n=f[--i]).x,n.y);
}
stroke();
closePath();
}
}
move_it || (move_it = setInterval(doit,20));
}
function clear() {
clearTimeout(wait);
if (move_it) {
clearInterval(move_it);
G.clearRect(move_it = 0,0,u,v);
}
wait = setTimeout(doit,3E3);
}
function screen_size() {
U = (u = C.width = innerWidth) - 1;
V = (v = C.height = innerHeight) - 1;
}
with(B.style){
margin = "0";
background = "#000";
color = "#fff";
}
screen_size();
Cs.position = "absolute";
Cs.top = "0";
for (t=2; t;) {
f = points[--t] = [];
for (i=5; i;) {
p = (1 & ((Mra()*9)<<0)) ? 1 : -1;
q = rand_range(4,8);
f[--i] = {
x:rand_range(1,U),
y:rand_range(1,V),
a:p,
c:p,
b:q,
d:q
};
}
}
clear();
D.onmousemove=D.onkeydown=clear;
onresize=screen_size;
}(document,Math)