1/************************************************************************ 2************************************************************************* 3@Name : QapTcha - jQuery Plugin 4@Revison : 4.2 5@Date : 06/09/2012 - dd/mm/YYYY 6@Author: ALPIXEL Agency - (www.myjqueryplugins.com - www.alpixel.fr) 7@License : Open Source - MIT License : http://www.opensource.org/licenses/mit-license.php 8 9************************************************************************** 10*************************************************************************/ 11jQuery.QapTcha = { 12 build : function(options) 13 { 14 var defaults = { 15 txtLock : 'Locked : form can\'t be submited', 16 txtUnlock : 'Unlocked : form can be submited', 17 disabledSubmit : true, 18 autoRevert : true, 19 PHPfile : 'php/Qaptcha.jquery.php', 20 autoSubmit : false, 21 valueIdOrClass :'' 22 }; 23 24 if(this.length>0) 25 return jQuery(this).each(function(i) { 26 /** Vars **/ 27 var 28 opts = $.extend(defaults, options), 29 $this = $(this), 30 form = $('form').has($this), 31 Clr = jQuery('<div>',{'class':'clr'}), 32 bgSlider = jQuery('<div>',{'class':'bgSlider'}), 33 Slider = jQuery('<div>',{'class':'Slider'}), 34 Iconscap = jQuery('<div>',{'class':'Iconscap_on'}), 35 TxtStatus = jQuery('<div>',{'class':' TxtStatus dropError',text:opts.txtLock}), 36 br = jQuery('<br>'), 37 inputQapTcha = jQuery('<input>',{name:generatePass(32),value:generatePass(7),type:'hidden'}); 38 39 /** Disabled submit button **/ 40 var submit = document.getElementById(opts.valueIdOrClass); 41 //if(opts.disabledSubmit) submit.disabled = true; 42 if(opts.disabledSubmit) form.find('[type=\'submit\']').attr('disabled','disabled'); 43 /** Construct DOM **/ 44 bgSlider.appendTo($this); 45 Iconscap.insertAfter(bgSlider); 46 Clr.insertAfter(Iconscap); 47 TxtStatus.insertAfter(Clr); 48 br.insertAfter(TxtStatus); 49 inputQapTcha.appendTo($this); 50 Slider.appendTo(bgSlider); 51 $this.show(); 52 53 Slider.draggable({ 54 revert: function(){ 55 if(opts.autoRevert) 56 { 57 if(parseInt(Slider.css("left")) > (bgSlider.width()-Slider.width()-10)) return false; 58 else return true; 59 } 60 }, 61 containment: bgSlider, 62 axis:'x', 63 stop: function(event,ui){ 64 if(ui.position.left > (bgSlider.width()-Slider.width()-10)) 65 { 66 // set the SESSION iQaptcha in PHP file 67 $.post(opts.PHPfile,{ 68 action : 'qaptcha', 69 qaptcha_key : inputQapTcha.attr('name') 70 }, 71 function(data) { 72 if(!data.error) 73 { 74 Slider.draggable('disable').css('cursor','default'); 75 inputQapTcha.val(''); 76 TxtStatus.text(opts.txtUnlock).addClass('dropSuccess').removeClass('dropError'); 77 Iconscap.toggleClass('Iconscap_off'); 78 $('input[type="submit"]').removeAttr('disabled'); 79 $(":submit").removeAttr("disabled"); 80 if(opts.autoSubmit) form.find('[type=\'submit\']').click(); 81 } 82 },'json'); 83 } 84 } 85 }); 86 87 function generatePass(nb) { 88 var chars = 'azertyupqsdfghjkmwxcvbn23456789AZERTYUPQSDFGHJKMWXCVBN_-#@'; 89 var pass = ''; 90 for(i=0;i<nb;i++){ 91 var wpos = Math.round(Math.random()*chars.length); 92 pass += chars.substring(wpos,wpos+1); 93 } 94 return pass; 95 } 96 97 }); 98 } 99}; jQuery.fn.QapTcha = jQuery.QapTcha.build;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.