-
-
Save mcsheffrey/1735253 to your computer and use it in GitHub Desktop.
Replace all characters in text nodes that are not spaces and then "shake" the body
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(undefined) { | |
var | |
deviateMin = 1, | |
deviateMax = 10, | |
marginSeed = 20, | |
paddingSeed = 20, | |
madnessInterval = 20, | |
findRegex = new RegExp(/[^ ]/g), | |
replaceText = "CONNOR ", | |
random = function(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
}, | |
deviate = function(num, dmin, dmax) { | |
var d_min = dmin || deviateMin, | |
d_max = dmax || deviateMax; | |
return (((random(1, 2) === 1) ? 1 : -1) * random(d_min, d_max)) + num; | |
}, | |
madness = function() { | |
document.body.style.backgroundPosition = deviate(10, 1, 10) + "px " + deviate(10, 1, 10) + "px"; | |
document.body.style['-webkit-transform'] = "rotate("+deviate(1, 1, 3)+"deg)"; | |
document.body.style.margin = deviate(marginSeed) + 'px ' + deviate(marginSeed) + 'px ' + deviate(marginSeed) + 'px ' + deviate(marginSeed) + 'px'; | |
document.body.style.padding = deviate(paddingSeed) + 'px ' + deviate(paddingSeed) + 'px ' + deviate(paddingSeed) + 'px ' + deviate(paddingSeed) + 'px'; | |
}, | |
walk = function(node, callback) { | |
var skip, tmp, depth = 0; | |
do { | |
if ( !skip ) { | |
skip = callback.call(node, depth) === false; | |
} | |
if ( !skip && (tmp = node.firstChild) ) { | |
depth++; | |
} else if ( tmp = node.nextSibling ) { | |
skip = false; | |
} else { | |
tmp = node.parentNode; | |
depth--; | |
skip = true; | |
} | |
node = tmp; | |
} while ( depth > 0 ); | |
}, | |
walkCb = function() { | |
if (this.nodeType == 3) { | |
this.nodeValue = this.nodeValue.replace(findRegex, replaceText); | |
} | |
}; | |
walk(document.documentElement, walkCb); | |
setInterval(madness, madnessInterval); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment