All pastes #988699 Raw Edit

Miscellany

public javascript v1 · immutable
#988699 ·published 2008-04-17 20:22 UTC
rendered paste body
// Javascript hell, I know it's a wrong way to do it!var timeOut = '';var timer = '';function createCookie(name,value,days) {	if (days) {		var date = new Date();		date.setTime(date.getTime()+(days*24*60*60*1000));		var expires = "; expires="+date.toGMTString();	}	else var expires = "";	document.cookie = name+"="+value+expires+"; path=/";}function readCookie(name) {	var nameEQ = name + "=";	var ca = document.cookie.split(';');	for(var i=0;i < ca.length;i++) {		var c = ca[i];		while (c.charAt(0)==' ') c = c.substring(1,c.length);		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);	}	return null;}function eraseCookie(name) {	createCookie(name,"",-1);}function slideshowInit(timer) {	createCookie('licGallery', timer, 0);	return slideshowCheck();}function slideshowCheck() {	// Called on element load	timeOut = readCookie('licGallery');	if ( timeOut ) {		return true;	} else {		return false;	}}function slideshowShow(div, link) {	$('#' + div).load(link + ' #'+div);}function slideshowStart(div, link, timer) {	if ( !timer ) {		if ( slideshowCheck() ) {			timer = timeOut;		} else {			timer = 0;		}	}	if ( timer != 0 ) {		if ( slideshowInit(timer) ) {			alert(timeOut);			//setTimeout("slideshowShow("+div+", "+link+")", timeOut);			setTimeout(function(){slideshowShow(div, link)}, timeOut);		}	}}function slideshowAjax(div, link) {	if ( slideshowCheck() != false ) {		setTimeout(function(){slideshowShow(div, link)}, timeOut);	}}function slideshowEnd() {	eraseCookie();}javascript on the page being AJAX'd:<script language="JavaScript">slideshowAjax('mydiv','page2.php');</script>