Login   Register  
PHP Classes
elePHPant
Icontem

File: ajax/ui.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of GrabzIt  >  GrabzIt PHP Library  >  ajax/ui.js  >  Download  
File: ajax/ui.js
Role: Auxiliary data
Content type: text/plain
Description: JavaScript that powers the demo.
Class: GrabzIt PHP Library
Take screenshots of Web pages using GrabzIt
Author: By
Last change: Stopped ajax calls being cached.
Date: 6 months ago
Size: 1,041 bytes
 

Contents

Class file image Download
var timeout = null;

function checkForResults() {
	//clear div
	$('#divResults').html('');
	//read result directory and display
	$.getJSON('ajax/results.php?r='+Math.floor((Math.random()*100000)+1), function(data) {
		$.each(data, function(key, val) {
                        if (val.indexOf(".pdf") !== -1)
                        {
			    $('#divResults').append('<a title="Click to open" target="_blank" href="'+val+'"><img class="result" src="css/pdf.png"></img></a>');
                        }
                        else
                        {
			    $('#divResults').append('<img title="Click to zoom in" class="result" onclick="zoom(\''+val+'\')" src="'+val+'"></img>');
                        }
		});
	});
	timeout = setTimeout("checkForResults()", 5000);
}

function zoom(url)
{
	clearTimeout(timeout);
	$('#divResults').html('<img class="zoomedResult" title="Click to zoom out" onclick="zoomout()" src="'+url+'">');
}

function zoomout()
{
	checkForResults();
}

$(document).ready(function() {
        checkForResults();
});