Login   Register  
PHP Classes
elePHPant
Icontem

File: js/dsscript.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Zehair  >  Captcha to download  >  js/dsscript.js  >  Download  
File: js/dsscript.js
Role: Auxiliary data
Content type: text/plain
Description: Jquery script
Class: Captcha to download
Show and check CAPTCHA images to protect downloads
Author: By
Last change:
Date: 2012-10-07 02:24
Size: 1,657 bytes
 

Contents

Class file image Download
/**
* 			CAPTCHA JS AJAX
*
* @author      Zehair ALAOUI SOSSE <deepscripts@gmail.com>
* @website     http://blog.deepscripts.com/
* @license     GPL v3
 */


$(document).ready(function()
{		
   /*
    * Check The Captcha
	*/
	$('#dscheckcapcha').live('click',function(event)
	{	
        event.preventDefault();
	    $('#dscaptchaerror').hide().html('');		
			
	    overlay(1);	
	    $.dsPOST('check',$('#dscaptchaverify').serialize(), 'json', function(data)
		{ 
            if(data.status==0)
			{  		        
			    $('#dscaptchaerror').fadeIn().html(data.erreur);
				$('#dscaptchaverify').stop(true,true).fadeTo(200,1);
				$('#dsrebuildcaptcha').click();
			}
			else
			{
			   	$('#dscaptchaverify').fadeOut(700, function()
				{
					$('#dslinkdownload').fadeIn(700).html(data.msg);
				});	   
			}
			
		}); 
		
	});
	
   /*
    * Reload Captcha
	*/
	$('#dsrebuildcaptcha').live('click',function(e)
	{	
        overlay(1);	
		$("#dsimageverify").attr("src", "php/ajax.php?action=captcha");		
	    overlay(0);
	});
	
	/*
    * Open the download in a new onglet
	*/
	$('.dscheckcapcha').live('click',function(e)
	{   
		var target = $(this).attr('href');
		window.open(target);
	});
	
   /*
    * AJAX function
	*/
	$.dsPOST = function(action,data,typedata,callback)
	{
	  $.post('php/ajax.php?action='+action,data,callback,typedata);
	}
	
   /*
    * Function to simulate loading...
	*/
	function overlay(type)
	{		
		var formTF = $('#dscaptchaverify');
		if(formTF.css('opacity') && formTF.css('opacity')!=1)
		{
			return false;
		}
		if(type==1)
			formTF.stop(true,true).fadeTo(200,0.5);	
		else
			formTF.stop(true,true).fadeTo(200,1);
	}	
});