PHP Classes
elePHPant
Icontem

File: ajax/ui.js

Recommend this page to a friend!
  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: Version 3
Date: 9 days ago
Size: 1,462 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();
}

function selectChanged(select) {
    if ($(select).val() == 'gif') {
        $('#spnGif').show();
		$('#divURL').show();
		$('#divHTML').hide();
		$('#divConvert').hide();		
        $('#spnScreenshot').hide();
    }
    else {
		$('#divConvert select').change();
		$('#divConvert').show();
        $('#spnScreenshot').show();
        $('#spnGif').hide();
    }
}

function selectConvertChanged(select) {
    if ($(select).val() == 'url') {
		$('#divURL').show();
		$('#divHTML').hide();
    }
    else {
		$('#divHTML').show();
		$('#divURL').hide();
    }
}

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