-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpartymode.js
More file actions
38 lines (34 loc) · 1.13 KB
/
Copy pathpartymode.js
File metadata and controls
38 lines (34 loc) · 1.13 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
var partyModeBodyColor = undefined;
var partyModeInterval = undefined;
function partyModeRandomColor () {
return 'rgb(' +
(Math.floor(Math.random() * 256)) + ',' +
(Math.floor(Math.random() * 256)) + ',' +
(Math.floor(Math.random() * 256)) + ')';
}
function togglePartyMode () {
if (partyModeInterval) {
clearInterval(partyModeInterval);
partyModeInterval = undefined;
$("body").animate({backgroundColor: partyModeBodyColor}, 750);
$("img#partyModeDiscoBall").remove();
} else {
partyModeInterval = setInterval ( function () {
$("body").animate({backgroundColor: partyModeRandomColor()}, 400);
}, 500);
$("body").append(
$("<img></img>").attr("id","partyModeDiscoBall").attr("src","discoball.gif").css("position","absolute")
.css("left",$("body").width()/2-150)
);
}
}
$(document).ready( function () {
if ($("body").css("background-color") == "transparent") {
$("body").css("background-color","white");
}
partyModeBodyColor = $("body").css("background-color");
$("a.partyModeToggle").click ( function (ev) {
ev.preventDefault();
togglePartyMode();
});
});