/** * js-cookie v2.1.0 * https://github.com/js-cookie/js-cookie */ (function(factory){if(typeof define==='function'&&define.amd){define(factory)}else if(typeof exports==='object'){module.exports=factory()}else{var _OldCookies=window.Cookies;var api=window.Cookies=factory();api.noConflict=function(){window.Cookies=_OldCookies;return api}}}(function(){function extend(){var i=0;var result={};for(;i1){attributes=extend({path:'/'},api.defaults,attributes);if(typeof attributes.expires==='number'){var expires=new Date();expires.setMilliseconds(expires.getMilliseconds()+attributes.expires*864e+5);attributes.expires=expires}try{result=JSON.stringify(value);if(/^[\{\[]/.test(result)){value=result}}catch(e){}if(!converter.write){value=encodeURIComponent(String(value)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)}else{value=converter.write(value,key)}key=encodeURIComponent(String(key));key=key.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent);key=key.replace(/[\(\)]/g,escape);return(document.cookie=[key,'=',value,attributes.expires&&'; expires='+attributes.expires.toUTCString(),attributes.path&&'; path='+attributes.path,attributes.domain&&'; domain='+attributes.domain,attributes.secure?'; secure':''].join(''))}if(!key){result={}}var cookies=document.cookie?document.cookie.split('; '):[];var rdecode=/(%[0-9A-Z]{2})+/g;var i=0;for(;i'+ '易网验证码加载失败,请点击刷新按钮'+ '
'+ '
'+ '
'+ ''+ '
'+ '
'+ ''); $('body').append('
'); $('#clicaptcha-mask').click(function(){ $('#clicaptcha-box').hide(); $(this).hide(); }); $('#clicaptcha-box .clicaptcha-refresh-btn').click(function(){ $this.clicaptcha(opts); }); } $('#clicaptcha-box, #clicaptcha-mask').show(); $('#clicaptcha-box .clicaptcha-img').attr('src', opts.src + '?' + new Date().getTime()).load(function(){ var thisObj = $(this); var text = Cookies.get('clicaptcha_text').split(','); var title = '请依次点击'; var t = []; for(var i = 0; i < text.length; i++){ t.push('“'+text[i]+'”'); } title += t.join('、'); $('#clicaptcha-box .clicaptcha-title').html(title); var xyArr = []; thisObj.off('mousedown').on('mousedown', function(e){ e.preventDefault(); thisObj.off('mouseup').on('mouseup', function(e){ $('#clicaptcha-box .clicaptcha-title span:eq('+xyArr.length+')').addClass('clicaptcha-clicked'); xyArr.push(($(document).scrollLeft() + e.clientX - $(this).offset().left) + ',' + ($(document).scrollTop() + e.clientY - $(this).offset().top)); if(xyArr.length == text.length){ var captchainfo = [xyArr.join('-'), thisObj.width(), thisObj.height()].join(';'); $.ajax({ type: 'POST', url: opts.src, data: { do : 'check', info : captchainfo } }).done(function(cb){ if(cb == 1){ $this.val(captchainfo).data('ischeck', true); $('#clicaptcha-box .clicaptcha-title').html(opts.success_tip); setTimeout(function(){ $('#clicaptcha-box, #clicaptcha-mask').hide(); opts.callback(); }, 1500); }else{ $('#clicaptcha-box .clicaptcha-title').html(opts.error_tip); setTimeout(function(){ $this.clicaptcha(opts); }, 1500); } }); } }); }); }); return this; }, 'clicaptchaCheck': function(){ var ischeck = false; if(this.data('ischeck') == true){ ischeck = true; } return ischeck; }, 'clicaptchaReset': function(){ this.val('').removeData('ischeck'); return this; } }); //默认参数 var defaluts = { src: 'clicaptcha/clicaptcha.php', success_tip: '验证成功!', error_tip: '未点中正确区域,请重试!', callback: function(){} }; })(window.jQuery);