Tam Nguyen Photography

New York Beauty and Fashion Photographer

jQuery Code for April’s Fool

Posted on March 29, 2013 in Technology, Tips

jQuery Code for April’s Fool

April’s Fool is approaching us, so I thought this post would be appropriate. Below is a jQuery code snippet that you can paste into your website that’s loaded with jQuery to run on the first day of April, 2013. The prerequisite is that jQuery.noConflict() has been called, and you have FTP access to your website or WordPress blog. Here are the things this code will do:

– Check to see if today is April’s Fool. If yes, proceed.
– Shake the entire page (Harlem shake, anyone?)
– Do a barrel roll
– Tilt the page when done
– If the visitor presses any key, the entire page will become editable.

Just paste the entire snippet into your WordPress footer.php file anywhere before the </body> tag and you’re ready to go.

<script type="text/javascript">
	var today = new Date();
	var april_fool = new Date('2013-04-01');
	if (Math.floor((today - april_fool)/(1000*60*60*24)) == 0) {
		jQuery(function(){
			jQuery(document).ready(function(){
				var l = 40;
				for( var i = 0; i < 30; i++ ) {
					jQuery('body').animate( { 'margin-left': "+=" + ( l = -l ) + 'px' }, 10);
				}
				setTimeout(function(){
					jQuery('body').css({
						'-webkit-transition': '-webkit-transform 3.5s ease',
						'-moz-transition': '-moz-transform 3.5s ease',
						'-o-transition': '-o-transform 3.5s ease',
						'-ms-transition': '-ms-transform 3.5s ease',
						'transition': 'transform 3.5s ease',
						'-webkit-transform': 'rotate(-362deg)',
						'-moz-transform': 'rotate(-362deg)',
						'-o-transform': 'rotate(-362deg)',
						'-ms-transform': 'rotate(-362deg)',
						'transform': 'rotate(-362deg)'
					});
				},1000);
				jQuery(window).keydown(function(){
					jQuery('body').contentEditable = true;
					return document.designMode = "on";
				});
			});
		});
	}
</script>

Here’s the demo of the script, which I’ve modified to run on any day.

Leave a Reply

Your email address will not be published. Required fields are marked *