An alternative way of making pages live

Without having to do too much work, this makes sure that everytime someone makes an update to your site, all browsers on all computers with the page up refreshes. This is not a good way to do it, but it does work pretty well.

Update Tracker

$file = "tracker3.html";  // This is the tracker for every time a move is saved.
$fileHandle = fopen($file, 'w+') or die("can't open file");
$data = date('m/d/Y h:i:s a', time());
fwrite($fileHandle, ' ' . $data);
fclose($fileHandle);
filename: Check Tracker and update

var checkURL = "tracker.html";  //Status Save tracker
var checkURL2 = "tracker2.html";  //Header Loaded tracker.
var checkURL3 = "tracker3.html"; //Messages Save tracker
var pageLoad = 1;
var messagesLoad = 0; //messages pageload
var chessLoad = 0;

function checkTracker() {

	$.ajax(checkURL2, {
		type: 'HEAD',
		success: function (response2, status2, xhr2) {

			pageLoad = new Date(xhr2.getResponseHeader('Last-Modified')).getTime();
		}
	});

	$.ajax(checkURL3, {
		type: 'HEAD',
		success: function (response3, status3, xhr3) {

			messagesLoad = new Date(xhr3.getResponseHeader('Last-Modified')).getTime();
		}
	});

	$.ajax(checkURL, {
		type : 'HEAD',
		success : function (response, status, xhr) {
			
		chessLoad = new Date(xhr.getResponseHeader('Last-Modified')).getTime();

            	}
        }); 

	if (chessLoad >= pageLoad || messagesLoad >= pageLoad) {
		    location.reload();
        }

}

window.setInterval("checkTracker()", 1000);  

Leave a Reply

Your email address will not be published.