function Captcha(){var self=this; self._init(); }Captcha.prototype._init=function(){var self=this; self.idRecaptcha=null; self.jCaptcha='
'; self.uid=null; self.div=null; self.grecaptchaLoaded=false; self.waitForLoad=null; self.data=null; }; Captcha.prototype.render=function(data,div){var self=this; if(!div){div="captchaDiv"; }self.div=div; self.data=data; if(inet.countryCode==undefined){self.waitForLoad=true; return; }if(data.exceeds=="true"){if(inet.countryCode&&inet.countryCode.toUpperCase()!="CN"){if(self.grecaptchaLoaded){self.waitForLoad=false; var captchaDiv=document.getElementById(div); if(self.idRecaptcha!=null&&self.idRecaptcha!=undefined){grecaptcha.reset(self.idRecaptcha); }else{self.idRecaptcha=grecaptcha.render(captchaDiv,{sitekey:inet.siteKey}); $("#"+div).addClass("recoveryPassCaptcha validatorCaptcha inlineBlock"); }}else{self.waitForLoad=true; }}else{$("#"+div).html(self.jCaptcha); $("#jCaptchaImg").attr("src","data:image/png;base64,"+data.image); $("#jCaptchaInput").val(i18n.msg("enter.captcha")); $("#"+div).removeClass("hide"); self.uid=data.uid; $(document).off("click","#jCaptchaRefresh").on("click","#jCaptchaRefresh",function(event){self.reset(); }); $(document).off("focus","#jCaptchaInput").on("focus","#jCaptchaInput",function(event){self._changePlaceHolder(event,i18n.msg("enter.captcha")); }); $(document).off("blur","#jCaptchaInput").on("blur","#jCaptchaInput",function(event){self._changePlaceHolder(event,i18n.msg("enter.captcha")); }); }$("#"+div).removeClass("hide"); }else{self.hide(); }$("body").loader("hide"); inet._setFirstFieldFormFocus(); }; Captcha.prototype.reset=function(image){var self=this; if(inet.countryCode&&inet.countryCode.toUpperCase()!="CN"){grecaptcha.reset(self.idRecaptcha); }else{if(image){$("#jCaptchaImg").attr("src","data:image/png;base64,"+image); }else{var data={countryCode:inet.countryCode}; userServiceFacade.refreshCaptchaImg(data,self._onSuccessRefreshCaptchaImg,self._onErrorRefreshCaptchaImg,self); }}}; Captcha.prototype._onSuccessRefreshCaptchaImg=function(data){var self=this; $("#jCaptchaImg").attr("src","data:image/png;base64,"+data.image); self.uid=data.uid; }; Captcha.prototype._onErrorRefreshCaptchaImg=function(response,textStatus,errorThrown){messageHandler.handleErrors(response,"messageArea"); }; Captcha.prototype.val=function(){var self=this; var value={}; if(inet.countryCode&&inet.countryCode.toUpperCase()!="CN"){var captchaToken=$(".g-recaptcha-response").val(); if(captchaToken!=""){value={"g-recaptcha-response":captchaToken,countryCode:inet.countryCode}; }}else{var captchaText=$("#jCaptchaInput").val(); if(captchaText!=""&&captchaText!=i18n.msg("enter.captcha")){value={recaptcha_response_field:captchaText,uid:self.uid,countryCode:inet.countryCode}; }}return value; }; Captcha.prototype.isRequired=function(){var self=this; var required=false; if(self.div){required=!$("#"+self.div).hasClass("hide"); }return required; }; Captcha.prototype.addBorderValidation=function(){var self=this; if(inet.countryCode&&inet.countryCode.toUpperCase()!="CN"){$("#"+self.div).addClass("rojo"); }else{$("#jCaptchaInput").addClass("rojo"); }}; Captcha.prototype.removeBorderValidation=function(){var self=this; if(inet.countryCode&&inet.countryCode.toUpperCase()!="CN"){$("#"+self.div).removeClass("rojo"); }else{$("#jCaptchaInput").removeClass("rojo"); }}; Captcha.prototype.hide=function(){var self=this; $("#"+self.div).html(""); $("#"+self.div).addClass("hide"); if($(".gc-bubbleDefault").parent()){$(".gc-bubbleDefault").parent().remove(); $("ins").remove(); }self.captchaDiv=$("#"+self.div); if(self.captchaDiv){var parentCaptcha=$(self.captchaDiv).parent(); $(self.captchaDiv).remove(); parentCaptcha.append('
'); }self.div=null; self.idRecaptcha=null; }; Captcha.prototype._changePlaceHolder=function(event,placeHolder){var self=this; var target=$("#"+event.target.id); if(event.type=="focusin"){if(target.val()==placeHolder){target.val(""); }}else{if(event.type=="focusout"){if(target.val()==""){target.val(placeHolder); }}}}; Captcha.prototype.onLoadGRecaptcha=function(){var self=this; self.grecaptchaLoaded=true; if(self.waitForLoad){self.render(self.data,self.div); }}; Captcha.prototype.onLoadCaptcha=function(){var self=this; if(self.waitForLoad){self.render(self.data,self.div); }}; var captcha=new Captcha();