jeffchannell.com

JMan Using jQuery

Posted in JavaScript
2010-05-10 22:35:47 +0000 UTC

As part of my site relaunch, I needed to rewrite a couple of things using jQuery instead of Mootools. One of these things is the Man Page footer at the bottom of the site. Rewriting it using jQuery actually ended up being fairly easy.

I'm not planning on incorporating this into the codebase of JMan, but I figured I'd share it nonetheless. So, here's a simple rewrite of JMan using nothing but jQuery:

(function($){
	$(document).ready(function(){
		function ManHandler(){
			var pct = Math.round(($(window).height()+$(window).scrollTop())/$(document).height()*100);
			$('#mantext').text(100 > pct ? '--More--('+pct+'%)' : '(END)');
		}
		$('<span id="mantext"></span>').appendTo($(document.body)).css({
			'display':'block',
			'opacity': 0.8,
			'position':'fixed',
			'bottom':'0px',
			'left':'0px',
			'z-index':5,
			'font-size':'0.8em',
			'font-weight':'bold',
			'background-color':'#000000',
			'color':'#FFFFFF',
			'width':'120px',
			'text-align':'center',
			'cursor':'default'
		});
		ManHandler();
		setInterval(ManHandler, 200);
	});
})(jQuery);