How to use cpy method in storybook-root

Best JavaScript code snippet using storybook-root

reg.js

Source:reg.js Github

copy

Full Screen

1/*Author: zhaoyinfan Date:2014-05-05 version 2.0*/2var upcode =function(id,ls){3 if(document.getElementById(id)){4 document.getElementById(id).src += "?new=" + Math.random();5 $("#"+id).prev().attr("class","");6 $("#"+id).prev().prev().val('');7 }8}9var comMsg=function(msg){10 return GetLen(msg)>=38? "<font class='f_1'>"+msg+"</font>":"<font class='f_0'>"+msg+"</font>";11}12var email2val =function(id,obj){13 document.getElementById(id).value=obj.innerHTML;14 $("#person_mail").hide();15 $("#person_mail").html('');16 ckmem();17}18//show error massage19var showError =function(inputid,errid,msg){20 $("#"+inputid).parent().attr("class","").addClass("regM errorBorder");21 $("#"+inputid).next().attr("class","");22 $("#"+errid).attr("class","reg_error").html(comMsg(msg));23}24//show success massage25var showSuccess = function(inputid,errid,msg){26 $("#"+inputid).parent().attr("class","").addClass("regM defaultBorder");27 $("#"+inputid).next().attr("class","regOk");28 $("#"+errid).attr("class","").html("");29}30var showRestore =function(inputid,errid){31 $("#"+inputid).parent().attr("class","").addClass("regM defaultBorder");32 $("#"+inputid).next().attr("class","");33 $("#"+errid).attr("class","").html('');34}35/*----------------------个人注册JS------------------------------*/36var showcodeDiv =function(num){37 var code_1 = '<label><font>*</font> 短信验证码:</label>'+38 '<input type="text" style="width:143px" class="regCodeInput defaultBorder" id="sms_code" name="sms_code" onfocus="showCodetip(\'sms_code\',\'sms_codeErr\',4);" onkeyup="ckmcode(0,1);" onblur="ckmcode(0,0);"/>'+39 '<em></em><input name="gvCode" id="send" class="gvCode regMl6" type="button" onclick="getmcode();" value="获取短信验证码">'+40 '<span id="sms_codeErr" ></span>';41 var code_2 ='<label><font>*</font> 验证码:</label>'+42 '<input type="text" class="regCodeInput defaultBorder" id="auth_code" name="auth_code" onfocus="showCodetip(\'auth_code\',\'auth_codeErr\',5);" onkeyup="ckcode(0,1);" onblur="ckcode(0,0);"/>'+43 '<em></em><img id="code_img1" src="/validate/" onclick="this.src+=\'?new=\' + Math.random()" alt="看不清?点一下!" title="看不清?点一下!" width="106" height="36" border="0" class="floatleft regMl6">'+44 '<span class="codeTitle floatleft regMl6">看不清?<a href="javascript:void(0);" onclick="upcode(\'code_img1\');">换一换</a></span>'+45 '<span id="auth_codeErr" ></span>';46 //if(num==1&& !$.trim( $("#yzcode_1").html() )){47 if(num==1){48 //$("#yzcode_2").html(code_1).show();49 }50 if(num==2 ){51 $("#yzcode_2").html('').hide();52 $("#yzcode_3").show();53 }54 if(num==3 && !$.trim( $("#yzcode_2").html() )){55 $("#yzcode_2").html(code_1).show()56 $("#yzcode_3").show();57 }58}59var showtip =function(inputid,spanid,key){60 var ms = defaultArr[key];61 $("#"+inputid).parent().attr("class","").addClass("regM okBorder");62 $("#"+inputid).next().attr("class","");63 $("#"+spanid).attr("class","reg_error1").html(comMsg(ms));64 return ;65}66var showPwdtip =function(inputid,spanid,key){67 var ms = defaultArr[key];68 $("#"+inputid).parent().attr("class","").addClass("regM okBorder");69 $("#"+inputid).next().attr("class","");70 $("#"+spanid).attr("class","reg_error2").html(comMsg(ms));71 return ;72}73var showCodetip =function(inputid,spanid,key){74 var ms = defaultArr[key];75 $("#"+inputid).attr("class","").addClass("regCodeInput okBorder");76 $("#"+spanid).attr("class","reg_error1").html(comMsg(ms));77 return ;78}79var showCodeError =function(inputid,errid,msg){80 $("#"+inputid).attr("class","").addClass("regCodeInput errorBorder");81 $("#"+errid).attr("class","reg_error").html(comMsg(msg));82}83var tsmail_Arr =Array();84tsmail_Arr[0] = "qq.com";85tsmail_Arr[1] = "163.com";86tsmail_Arr[2] = "126.com";87tsmail_Arr[3] = "189.cn";88tsmail_Arr[4] = "sina.com";89tsmail_Arr[5] = "hotmail.com";90tsmail_Arr[6] = "gmail.com";91var mail_div =function(e){92 var event = e ? e : window.event;93 var keyCode = event.keyCode;94 var vschool = $(".accountSearch");95 if (keyCode == 40 || keyCode == 38 || keyCode == 13) {96 var tipindex = $("#hnseli").val() == "" ? -1 : $("#hnseli").val();97 var fobj;98 if (keyCode == 40) {99 tipindex++;100 if (tipindex == vschool.find("span").length) {101 tipindex = 0;102 vschool.find("span").eq(vschool.find("span").length - 1).css("background-color", "");103 }104 fobj = vschool.find("span").eq(tipindex);105 vschool.find("span").eq(tipindex - 1).css("background-color", "");106 fobj.css("background-color", "#E6E6E6");107 $("#userMam").val(fobj.html().replace(/<(\S*?)[^>]*>|<.*? \/>/g, ""));108 $("#schoolid").val(fobj.attr("value"));109 $("#hnseli").val(tipindex);110 return;111 } else if (keyCode == 38) {112 tipindex--;113 if (tipindex <= -1) {114 tipindex = vschool.find("span").length - 1;115 vschool.find("span").eq(0).css("background-color", "");116 }117 vschool.find("span").eq(tipindex + 1).css("background-color", "");118 fobj = vschool.find("span").eq(tipindex);119 fobj.css("background-color", "#E6E6E6");120 if (fobj.html() != null) {121 $("#userMam").val(fobj.html().replace(/<(\S*?)[^>]*>|<.*? \/>/g, ""));122 $("#schoolid").val(fobj.attr("value"));123 }124 $("#hnseli").val(tipindex);125 return;126 } else if (keyCode == 13) {127 if ($("#userMam").val().length >= 1) {128 var combinedValue = vschool.find("span").eq(tipindex).html();129 if (combinedValue != null) {130 $("#userMam").val(combinedValue.replace(/<(\S*?)[^>]*>|<.*? \/>/g, ""));131 }132 vschool.hide();133 if ($("#schoolid").val() != "") {134 $("#hnschool").val("1");135 $("#hnschool").attr("sta", 2);136 $("#userMam").blur();137 } else {138 $("#hnschool").val("-1");139 $("#hnschool").attr("sta", 0);140 }141 $("#hnseli").val(tipindex);142 return;143 }144 }145 }146 $("#person_mail").hide();147 var val = $.trim( $("#"+MailMId).val() );148 if(val==''){ return false; }149 showcodeDiv(2);150 var mLoArr = val.split('@');151 var mlogoNum = mLoArr.length-1;152 var mailist='';153 if(mlogoNum==1){154 //请输入您的常用邮箱155 showtip('userMam','userMamErr',1);156 var rightMstr = mLoArr[1];157 var leftMstr = mLoArr[0];158 for(var i=0;i<tsmail_Arr.length;i++){159 if( tsmail_Arr[i].indexOf(rightMstr)==0 && rightMstr ){160 var mail = leftMstr+"@"+ tsmail_Arr[i];161 mailist +='<span onmousedown="email2val(\'userMam\',this);">'+mail+'</span>';162 }163 if(rightMstr==''){164 var mail = val + tsmail_Arr[i];165 mailist +='<span onmousedown="email2val(\'userMam\',this);">'+mail+'</span>';166 }167 }168 if(mailist){169 var html =mailist;170 $("#person_mail").html(html).show();171 }172 }173}174//check mobile email175var mb; mb=0;176var ckmem =function(isCk){177 var val = $.trim( $("#"+MailMId).val() );178 $("#nameRegOk").val("");179 if(!isCk && !val){180 showRestore(MailMId,MailMErrId);181 return false;182 }/*183 if(val==''){184 showError(MailMId,MailMErrId,memArr[0]);185 $("#person_mail").hide().html('');186 return false;187 }*/188 if( !mobile_preg(val) ){189 showError(MailMId,MailMErrId,memArr[1]);190 $("#person_mail").hide().html('');191 return false;192 }193 var num_preg = /^[0-9]{1,}$/;194 if( num_preg.test(val) ){195 showcodeDiv(1);196 mb=1;197 if( !mobile_preg(val) ){198 showError(MailMId,MailMErrId,memArr[1]);199 $("#person_mail").hide().html('');200 return false;201 }202 $("#person_mail").hide().html('');203 //校验中204 $.ajaxSetup({async:false });205 var bol=false;206 $("#"+MailMErrId).attr("class","").addClass("reg_error1").html(comMsg("检测中...."));207 $.post("/ajax/verifmobile/",{"name":"userMobile","param":val},function(data){208 if(data!="y"){209 if(data.indexOf("请直接登录")>=0){210 var newData = comMsg(data).replace("请直接登录","<a href='/' style='color:#669900'>请直接登录</a>");211 if(data.indexOf("宜立方速运")>-1){212 newData = "该手机在宜立方速运已注册,请<a href='/' style='color:#669900'>直接登录></a>或<a href='/reg/findpass/?returnUrl=http://www.e3mall.cn/' target='_blank' style='color:#669900'>找回密码></a>";213 }214 $("#"+MailMId).parent().attr("class","").addClass("regM errorBorder").next().attr("class","");215 $("#"+MailMErrId).attr("class","reg_error").html(newData);216 }else{217 showError(MailMId,MailMErrId,data);218 }219 return false;220 }221 $("#nameRegOk").val(1);222 showSuccess(MailMId,MailMErrId,OkArr[0]);223 bol=true;224 });225 return bol;226 }227 /*else {228 mb=0;229 showcodeDiv(2);230 if( !mail_preg(val) ){231 showError(MailMId,MailMErrId,memArr[2]);232 $("#person_mail").hide().html('');233 return false;234 }235 $("#person_mail").hide().html('');236 $.ajaxSetup({async:false });237 $("#"+MailMErrId).attr("class","").addClass("reg_error1").html(comMsg("检测中...."));238 var bol=false;239 $.post("/ajax/verifemails/",{"name":"outemail","param":val},function(data){240 if(data!="y"){241 if(data.indexOf("请直接登录")>=0){242 var newData = comMsg(data).replace("请直接登录","<a href='/' style='color:#669900'>请直接登录</a>");243 if(data.indexOf("宜立方速运")>-1){244 newData = "该邮箱在宜立方速运已注册,请<a href='/' style='color:#669900'>直接登录></a>或<a href='/reg/findpass/?returnUrl=http://www.e3mall.cn/' target='_blank' style='color:#669900'>找回密码></a>";245 }246 $("#"+MailMId).parent().attr("class","").addClass("regM errorBorder").next().attr("class","");247 $("#"+MailMErrId).attr("class","reg_error").html(newData);248 }else{249 showError(MailMId,MailMErrId,data);250 }251 return false;252 }253 $("#nameRegOk").val(1);254 showSuccess(MailMId,MailMErrId,OkArr[0]);255 bol=true;256 });257 return bol;258 }*/259}260//密码强度显示261var showStrong=function(errid,rankid,rank){262 var def ="<font style='font-size:12px;'>安全程度:</font>";263 var midstr='<em class="default">弱</em><em class="default">中</em><em class="default">强</em>';264 if(parseInt(rank)==1){265 midstr ='<em class="ok">弱</em><em class="default">中</em><em class="default">强</em>';266 $("#"+rankid).html(def+midstr);267 $("#"+errid).attr("class","reg_error2").html(pwdArr[2]);268 return;269 }270 if(parseInt(rank)==2){271 midstr ='<em class="ok">弱</em><em class="ok">中</em><em class="default">强</em>';272 }273 if(parseInt(rank)==3){274 midstr ='<em class="ok">弱</em><em class="ok">中</em><em class="ok">强</em>';275 }276 $("#"+rankid).html(def+midstr);277}278//check password279var ckpwd=function(isCk,keyup){280 var val =$.trim( $("#"+PwdId).val() );281 if(val.length<6&&keyup==1){282 showStrong(PwdErrId,pwdStrong,0);283 showRestore(PwdId,PwdErrId);284 return false;285 }286 if(!isCk && !val){287 showRestore(PwdId,PwdErrId);288 return false;289 }290 if(val == ""){291 showError(PwdId,PwdErrId,pwdArr[0]);292 return false;293 }else if( pwdTotal(val) ==0){294 showError(PwdId,PwdErrId,pwdArr[3]);295 return false;296 }else if( pwdTotal(val) ==-1){297 showError(PwdId,PwdErrId,pwdArr[3]);298 return false;299 }else if( pwdTotal(val) <=50){300 $("#"+PwdId).parent().attr("class","").addClass("regM defaultBorder");301 $("#"+PwdId).next().attr("class","regOk");302 showStrong(PwdErrId,pwdStrong,1);303 return 1;304 }else if( pwdTotal(val)>51&&pwdTotal(val) <=60){305 showStrong(PwdErrId,pwdStrong,2);306 showSuccess(PwdId,PwdErrId,OkArr[0]);307 return 1;308 }else if( pwdTotal(val)>60){309 showStrong(PwdErrId,pwdStrong,3);310 showSuccess(PwdId,PwdErrId,OkArr[0]);311 return 1;312 }313 return false;314}315// check password 2316var ckpwd2=function(isCk){317 var val =$.trim( $("#"+PwdId).val() );318 var val2 =$.trim( $("#"+PwdId2).val() );319 if(!isCk && !val2){320 showRestore(PwdId2,PwdErrId2);321 return false;322 }323 if(val2 == ''){324 showError(PwdId2,PwdErrId2,pwd2Arr[0]);325 return false;326 }else if(val2!= val){327 showError(PwdId2,PwdErrId2,pwd2Arr[1]);328 return false;329 }330 showSuccess(PwdId2,PwdErrId2,OkArr[0]);331 return 1;332}333var ckmcode=function(isCk,keyup){334 var mcode =clsTrim($.trim( $("#"+MobileCodeId).val() ));335 if(mcode.length<6&&keyup==1){336 $("#"+MobileCodeId).next().attr("class","");337 return false;338 }339 if(!isCk && !mcode){340 $("#"+MobileCodeId).attr("class","").addClass("regCodeInput defaultBorder");341 $("#"+MobileCodeId).next().attr("class","");342 $("#"+MobileCodeErrId).attr("class","").html("");343 return false;344 }345 if(mcode==''){346 showCodeError(MobileCodeId,MobileCodeErrId,mcodeArr[0]);347 return false;348 }349 var mobileNum = $.trim( $("#"+MailMId).val() );350 $.ajaxSetup({async:false });351 $("#"+MobileCodeErrId).attr("class","").addClass("reg_error1").html(comMsg("检测中...."));352 var bol=false;353 $.post("/ajax/VerifSmscode/",{"mobile":mobileNum,"param":mcode},function(data){354 if(data!='y'){355 $("#"+MobileCodeId).next().attr("class","");356 showCodeError(MobileCodeId,MobileCodeErrId,data);357 return false;358 }359 $("#"+MobileCodeId).attr("class","regCodeInput defaultBorder").next().attr("class","regOk1").css("left","246px");360 $("#"+MobileCodeErrId).html("").attr("class","");361 bol=true;362 });363 return bol;364}365var ckcode =function(isCk,keyup){366 var Authcode =clsTrim($.trim( $("#"+pageCodeId).val() ));367 if(Authcode.length<4&&keyup==1){368 $("#"+pageCodeId).attr("class","").addClass("regCodeInput defaultBorder").next().attr("class","");369 $("#"+pageCodeErrId).attr("class","").html("");370 return false;371 }372 if(!isCk && !Authcode ){373 $("#"+pageCodeId).attr("class","").addClass("regCodeInput defaultBorder");374 $("#"+pageCodeErrId).attr("class","").html("");375 return false;376 }377 if(Authcode==''){378 showCodeError(pageCodeId,pageCodeErrId,codeArr[0]);379 return false;380 }else if(Authcode.length!=4){381 upcode(codeimgid);382 showCodeError(pageCodeId,pageCodeErrId,codeArr[1]);383 return false;384 }385 $.ajaxSetup({async:false });386 $("#"+pageCodeErrId).attr("class","").addClass("reg_error1").html(comMsg("检测中...."));387 var bol=false;388 $.post("/reg/codes/",{"name":"auth_code","param":Authcode},function(data){389 if(data!='y'){390 showCodeError(pageCodeId,pageCodeErrId,data);391 upcode(codeimgid);392 return false;393 }else{394 if( mb==1 && $("#yzcode_2").css("display")=='none'){395 showcodeDiv(3);396 $("#auth_code").val(Authcode);397 }398 $("#"+pageCodeId).attr("class","").addClass("regCodeInput defaultBorder").next().attr("class","regOk1");399 $("#"+pageCodeErrId).html("").attr("class","");400 bol=true;401 }402 });403 return bol;404}405var getmcode =function(){406 var mobileNum = $.trim( $("#"+MailMId).val() );407 var myzm=$("#auth_code").val(); //图片验证码408 var a1= $("#"+MailMErrId).html();409 if( !a1 ){410 $.post("/other/getsms/",{"mobile":mobileNum,'auth_code':myzm},function(data){411 if(data!='y'){412 upcode(codeimgid);413 showCodeError(MobileCodeId,MobileCodeErrId,data);414 return false;415 }416 if(data=='验证码不正确'){417 showCodeError(pageCodeId,pageCodeErrId,data);418 upcode(codeimgid);419 return false;420 }421 if(data=='y'){422 ctDown('send');423 $("#"+MobileCodeErrId).attr("class","reg_error1").html(comMsg("短信验证码已发送,请查收。"));return ;424 }425 });426 }else{427 showCodeError(MobileCodeId,MobileCodeErrId,comMsg(a1));428 }429}430var showDmtip=function(){431 $("#"+sfCodeId).attr("class","regInvitationInput okBorder floatleft");432 $("#"+sfCodeErrId).attr("class","reg_error1").html(comMsg("请输入优选单邀请码"));433}434var ckdmcode =function(isCk,keyup){435 var dmNum=clsTrim($.trim( $("#"+sfCodeId).val() ));436 if(dmNum.length<6&&keyup==1){437 $("#"+sfCodeId).attr("class","regInvitationInput defaultBorder floatleft").next().attr("class","");438 $("#"+sfCodeErrId).attr("class","").html("");439 return false;440 }441 if(!isCk && !dmNum){442 $("#"+sfCodeId).attr("class","regInvitationInput defaultBorder floatleft");443 $("#"+sfCodeErrId).attr("class","").html("");444 }445 if(dmNum){446 if( dmNum.length!=6 && dmNum.length!=12 && dmNum.length!=14 ){447 $("#"+sfCodeId).attr("class","regInvitationInput errorBorder floatleft");448 $("#"+sfCodeErrId).attr("class","reg_error").html(comMsg("邀请码错误"));449 return false;450 }451 $.ajaxSetup({async:false });452 $("#"+sfCodeErrId).attr("class","").addClass("reg_error1").html(comMsg("检测中...."));453 var bol=false;454 $.post("/ajax/validatedm/",{"name":sfCodeId,"param":dmNum},function(data){455 if(data!="y"){456 $("#"+sfCodeId).attr("class","regInvitationInput errorBorder floatleft");457 $("#"+sfCodeErrId).attr("class","reg_error").html(comMsg(data));458 return false;459 }else{460 $("#"+sfCodeId).next().attr("class","regOk1").css("left","243px");461 $("#"+sfCodeId).attr("class","regInvitationInput defaultBorder floatleft");462 $("#"+sfCodeErrId).html("").attr("class","");463 bol=true;464 }465 });466 return bol;467 }468}469var ckAgree =function(){470 var Agreestat = document.getElementById(AgreementId).checked;471 if(Agreestat==false){472 $("#"+AgreementErrId).attr("class","").addClass("reg_error").html( comMsg(agreeArr[0]) );473 return false;474 }475 $("#"+AgreementErrId).attr("class","").html('');476 return 1;477}478$("#"+pageCodeId).live("keyup",function(event){479 if (event.keyCode == 13) {480 sub_data();481 }482});483$("#"+MobileCodeId).live("keyup",function(event){484 if (event.keyCode == 13) {485 sub_data();486 }487});488var sub_data =function(){489 var mem = $.trim( $("#"+MailMId).val() );490 var cknameval = $.trim( $("#nameRegOk").val() );491 var a1= cknameval==1?true:false;492 var a2 = ckpwd(1);493 var a3 = ckpwd2(1);494 var a4 = false;495 var tjuid=$("#tjuid").val();496 var a5 = ckAgree(1);497 if(mobile_preg(mem)){498 var a41= ckmcode(1);499 var a42=ckcode(1);500 if(a41==true&&a42==true){501 var a4 = true;502 }else{503 var a4 = false;504 }505 }else{506 var a4 =ckcode(1);507 }508 var a6 = true;509 if($("#"+sfCodeId).val()){510 ckdmcode(1);511 var a6 = !$("#"+sfCodeErrId).html()?true:false;512 }513 if(!a1|| a2==false ||a3==false||a4==false||a5==false||a6==false){514 return false;515 }516 $("#sub_per").html('<a class="unit_login_in" href="javascript:void(0);">注册中...</a>');517 $.post("/register/Regperson/",$('#regForm_mod').serialize().replace(/\+/g,"")+"&tjuid="+tjuid,function(data){518 if(data=="y"){519 //跳转到注册成功页面520 $("#"+pageCodeId).attr("disabled", true);521 $("#"+MobileCodeId).attr("disabled", true);522 location.href="/reg/success/";523 return false;524 }525 if(data=="yy"){// 推荐526 $("#"+pageCodeId).attr("disabled", true);527 $("#"+MobileCodeId).attr("disabled", true);528 location.href="/recommend/?uid="+tjuid;529 return false;530 }531 $("#sub_per").html('<a href="javascript:void(0);" class="registerNow" id="reg_per_data">立即注册</a>');532 $("#"+pageCodeId).attr("disabled", false);533 $("#"+MobileCodeId).attr("disabled", false);534 upcode(codeimgid);535 jAlert('注册失败:' + data);536 });537}538//$("#reg_per_data").live("click",function(){sub_data();});539/*----------------------企业注册JS------------------------------*/540var showcpyError =function(inputid,errid,msg){541 $("#"+inputid).parent().attr("class","regM errorBorder");542 $("#"+inputid).next().attr("class","");543 var msg_new =comMsg(msg);544 $("#"+errid).attr("class","reg_error3 f-color").html(msg_new);545}546var showCodecpyError =function(inputid,errid,msg){547 $("#"+inputid).attr("class","regCodeInput errorBorder");548 $("#"+inputid).next().attr("class","");549 var msg_new = comMsg(msg);550 $("#"+errid).attr("class","reg_error3 f-color").html(msg_new);551}552var showcpytip =function(inputid,spanid,key){553 var msg = cpyDefaultArr[key];554 $("#"+inputid).parent().attr("class","").addClass("regM okBorder");555 $("#"+inputid).next().attr("class","");556 var msg_new = comMsg(msg);557 $("#"+spanid).attr("class","reg_error3").html(msg_new);558 return ;559}560var showCodecpytip =function(inputid,spanid,key){561 var msg = cpyDefaultArr[key];562 $("#"+inputid).attr("class","").addClass("regCodeInput okBorder");563 var msg_new =comMsg(msg);564 $("#"+spanid).attr("class","reg_error3").html(msg_new);565 return ;566}567var ckcpyname =function(isCk){568 var val = $.trim( $("#"+cpyUserNameId).val() );569 if(!isCk&&!val){570 showRestore(cpyUserNameId,cpyUserNameErrId);571 return false;572 }573 if(val==''){574 showcpyError(cpyUserNameId,cpyUserNameErrId,cpyUserNameArr[0]);575 return false;576 }else if( val.match(/^(sf)/i) ){577 showcpyError(cpyUserNameId,cpyUserNameErrId,cpyUserNameArr[1]);578 return false;579 }else if( val.match(/^(tmall)/i) ){580 showcpyError(cpyUserNameId,cpyUserNameErrId,cpyUserNameArr[4]);581 return false;582 }else if( val.match(/^(jd)/i) ){583 showcpyError(cpyUserNameId,cpyUserNameErrId,cpyUserNameArr[5]);584 return false;585 }else if( val.match(/^[0-9]{1,}$/) ){586 showcpyError(cpyUserNameId,cpyUserNameErrId,cpyUserNameArr[2]);587 return false;588 }else if(GetLen(val)<4 || GetLen(val)>20){589 showcpyError(cpyUserNameId,cpyUserNameErrId,cpyUserNameArr[3]);590 return false;591 }592 $.ajaxSetup({async:false });593 var bol=false;594 $.post("/ajax/verifUsername/",{"name":"userName","param":val},function(data){595 if(data!="y"){596 if(data.indexOf("请直接登录")>=0){597 $("#"+cpyUserNameId).parent().attr("class","regM errorBorder").next().attr("class","");598 var msg_new =comMsg(data).replace("请直接登录","<a href='/' style='color:#669900'>请直接登录</a>");599 $("#"+cpyUserNameErrId).attr("class","reg_error3 f-color").html(msg_new);600 }else{601 showcpyError(cpyUserNameId,cpyUserNameErrId,data);602 }603 return false;604 }605 showSuccess(cpyUserNameId,cpyUserNameErrId);606 bol=true;607 });608 return bol;609}610var ckcpypwd =function(isCk){611 var val =$.trim( $("#"+cpyPwdId).val() );612 var pwd_p1 = /\s/;613 var pwd_p2 = /^(.)\1+$/;614 var pwd_p3 = /^[a-zA-Z]+$/;615 var pwd_p4 = /^[0-9]+$/;616 var pwd_p5 = /^[a-zA-Z0-9_]{6,20}$/;617 if(!isCk&&!val){618 showRestore(cpyPwdId,cpyPwdIdErrId);619 return false;620 }621 if(val == ""){622 showcpyError(cpyPwdId,cpyPwdIdErrId,cpyPwdArr[0]);623 return false;624 }else if(val.length<6 || val.length>20){625 showcpyError(cpyPwdId,cpyPwdIdErrId,cpyPwdArr[1]);626 return false;627 }else if( pwdTotal(val) ==0){628 showcpyError(cpyPwdId,cpyPwdIdErrId,cpyPwdArr[2]);629 return false;630 }else if( pwdTotal(val) ==-1){631 showcpyError(cpyPwdId,cpyPwdIdErrId,cpyPwdArr[2]);632 return false;633 }634 showSuccess(cpyPwdId,cpyPwdIdErrId);635 return 1;636}637var ckcpypwd2 =function(isCk){638 var val =$.trim( $("#"+cpyPwdId).val() );639 var val2 =$.trim( $("#"+cpyPwd2Id).val() );640 if(!isCk&&!val2){641 showRestore(cpyPwd2Id,cpyPwd2ErrId);642 return false;643 }644 if(val2 == ''){645 showcpyError(cpyPwd2Id,cpyPwd2ErrId,cpyPwd2Arr[0]);646 return false;647 }else if(val2!= val){648 showcpyError(cpyPwd2Id,cpyPwd2ErrId,cpyPwd2Arr[1]);649 return false;650 }651 showSuccess(cpyPwd2Id,cpyPwd2ErrId);652 return 1;653}654var ckcpyrealName =function(isCk){655 var realName = $.trim( $("#"+cpyRealNameId).val() );656 if(!isCk&&!realName){657 showRestore(cpyRealNameId,cpyRealNameErrId);658 return false;659 }660 if(realName==''){661 showcpyError(cpyRealNameId,cpyRealNameErrId,cpyRealNameArr[0]);662 return false;663 }664 if ( GetLen(realName)<4 ||GetLen(realName)>20 ){665 showcpyError(cpyRealNameId,cpyRealNameErrId,cpyRealNameArr[1]);666 return false;667 }668 showSuccess(cpyRealNameId,cpyRealNameErrId);669 return 1;670}671var ckcpytel =function(isCk){672 var telNum = $.trim( $("#"+cpyTelphoneId).val() );673 if(!isCk&&!telNum){674 showRestore(cpyTelphoneId,cpyTelphoneErrId);675 return false;676 }677 if(telNum==''){678 showcpyError(cpyTelphoneId,cpyTelphoneErrId,cpyTelArr[0]);679 return false;680 }681 if ( tel_preg(telNum)==false){682 showcpyError(cpyTelphoneId,cpyTelphoneErrId,cpyTelArr[1]);683 return false;684 }685 showSuccess(cpyTelphoneId,cpyTelphoneErrId);686 return 1;687}688var ckcpymobile =function(){689 var cpymobile = $.trim( $("#"+cpyMobileId).val() );690 if(cpymobile==''){691 showRestore(cpyMobileId,cpyMobileErrId);692 return false;693 }694 if ( cpymobile && mobile_preg(cpymobile)==false){695 showcpyError(cpyMobileId,cpyMobileErrId,cpyMobArr[0]);696 return false;697 }698 $.ajaxSetup({async:false });699 var bol=false;700 $.post("/ajax/verifmobile/",{"name":"userMobile","param":cpymobile},function(data){701 if(data!="y"){702 if(data.indexOf("请直接登录")>=0){703 $("#"+cpyMobileId).parent().attr("class","regM errorBorder").next().attr("class","");704 var msg_new =comMsg(data).replace("请直接登录","<a href='/' style='color:#669900'>请直接登录</a>");705 if(data.indexOf("宜立方速运")>-1){706 msg_new = comMsg("该手机在宜立方速运已注册,请<a href='/' style='color:#669900'>直接登录></a>或<a href='/reg/findpass/?returnUrl=http://www.e3mall.cn/' target='_blank' style='color:#669900'>找回密码></a>");707 }708 $("#"+cpyMobileErrId).attr("class","reg_error3 f-color").html(msg_new);709 }else{710 showcpyError(cpyMobileId,cpyMobileErrId,data);711 }712 return false;713 }714 showSuccess(cpyMobileId,cpyMobileErrId);715 bol=true;716 });717 return bol;718}719var ckcpymail =function(){720 var cpymail = $.trim( $("#"+cpyEmailId).val() );721 if(cpymail==''){722 showRestore(cpyEmailId,cpyEmailErrId);723 return false;724 }725 if ( cpymail && mail_preg(cpymail)==false){726 showcpyError(cpyEmailId,cpyEmailErrId,cpyMaArr[0]);727 return false;728 }729 $.ajaxSetup({async:false });730 var bol=false;731 $.post("/ajax/verifemails/",{"name":"outemail","param":cpymail},function(data){732 if(data!="y"){733 if(data.indexOf("请直接登录")>=0){734 $("#"+cpyEmailId).parent().attr("class","regM errorBorder").next().attr("class","");735 var msg_new =comMsg(data).replace("请直接登录","<a href='/' style='color:#669900'>请直接登录</a>");736 if(data.indexOf("宜立方速运")>-1){737 msg_new = comMsg("该邮箱在宜立方速运已注册,请<a href='/' style='color:#669900'>直接登录></a>或<a href='/reg/findpass/?returnUrl=http://www.e3mall.cn/' target='_blank' style='color:#669900'>找回密码></a>");738 }739 $("#"+cpyEmailErrId).attr("class","reg_error3 f-color").html(msg_new);740 }else{741 showcpyError(cpyEmailId,cpyEmailErrId,data);742 }743 return false;744 }745 showSuccess(cpyEmailId,cpyEmailErrId);746 bol=true;747 });748 return bol;749}750//公司名751var ckcpy_name =function(isCk){752 var val = $.trim( $("#"+cpyNameId).val() );753 if(!isCk&&!val){754 showRestore(cpyNameId,cpyNameErrId);755 return false;756 }757 if(val==''){758 showcpyError(cpyNameId,cpyNameErrId,cpyNameArr[0]);759 return false;760 }761 if(GetLen(val)<4||GetLen(val)>40){762 showcpyError(cpyNameId,cpyNameErrId,cpyNameArr[1]);763 return false;764 }765 showSuccess(cpyNameId,cpyNameErrId);766 return 1;767}768//公司省获取市769var ckcpy_province =function(isCk){770 var proId = $.trim( $("#"+cpyProvinceId).val() );771 if(!isCk&&!proId){772 showRestore(cpyAddressId,cpyAddressErrId);773 return false;774 }775 if(proId==0){776 showcpyError(cpyAddressId,cpyAddressErrId,cpyAddressArr[0]);777 return false;778 }779 var bol=false;780 $.post("/reg/getcity/",{"cid":proId},function(data){781 if(data=='-1'){782 showcpyError(cpyAddressId,cpyAddressErrId,comArr[0]);783 return false;784 }785 $("#"+cpyCitiesId).html('<option value="0">请选择所在市</option>'+data);786 showRestore(cpyAddressId,cpyAddressErrId);787 bol=true;788 });789 return bol;790}791var ckcpy_cities =function(isCk){792 var proId = $.trim( $("#"+cpyCitiesId).val() );793 if(!isCk&&!proId){794 showRestore(cpyAddressId,cpyAddressErrId);795 return false;796 }797 if(proId==0){798 showcpyError(cpyAddressId,cpyAddressErrId,cpyAddressArr[1]);799 return false;800 }801 showRestore(cpyAddressId,cpyAddressErrId);802 return false;803}804//详细地址805var ckcpy_address =function(isCk){806 var proId = $.trim( $("#"+cpyProvinceId).val() );807 var cityId = $.trim( $("#"+cpyCitiesId).val() );808 var val = $.trim( $("#"+cpyAddressId).val() );809 if(!isCk&&!val){810 showRestore(cpyAddressId,cpyAddressErrId);811 return false;812 }813 if(proId==0){814 showcpyError(cpyAddressId,cpyAddressErrId,cpyAddressArr[0]);815 return false;816 }817 if(cityId==0){818 showcpyError(cpyAddressId,cpyAddressErrId,cpyAddressArr[1]);819 return false;820 }821 if(val==''){822 showcpyError(cpyAddressId,cpyAddressErrId,cpyAddressArr[2]);823 return false;824 }825 if(GetLen(val)<4||GetLen(val)>50){826 showcpyError(cpyAddressId,cpyAddressErrId,cpyAddressArr[3]);827 return false;828 }829 showSuccess(cpyAddressId,cpyAddressErrId);830 return 1;831}832//购买用途833var ckcpy_buyuse =function(isCk){834 var str=document.getElementsByName("cpybuyuse[]");835 var objarray=str.length;836 var chestr="";837 for (i=0;i<objarray;i++){838 if(str[i].checked == true) {839 chestr+=str[i].value+",";840 }841 }842 if(!isCk&&!chestr){843 showRestore(cpyBuyuseId,cpyBuyuseErrId);844 return false;845 }846 if(chestr == ""){847 showcpyError(cpyBuyuseId,cpyBuyuseErrId,cpyBuyuseArr[0]);848 return false;849 }850 showSuccess(cpyBuyuseId,cpyBuyuseErrId);851 return 1;852}853//网址854var ckcpy_website=function(){855 var val = $.trim( $("#"+cpyWebsiteId).val() );856 if(val==''){857 showRestore(cpyWebsiteId,cpyWebsiteErrId);858 return false;859 }860 if(val && url_preg(val)==false){861 showcpyError(cpyWebsiteId,cpyWebsiteErrId,cpyWebsiteArr[0]);862 return false;863 }864 showSuccess(cpyWebsiteId,cpyWebsiteErrId);865 return 1;866}867var ckcpycode =function(isCk,keyup){868 var Authcode =clsTrim($.trim( $("#"+cpyCodeId).val() ));869 if(Authcode.length<4&&keyup==1){870 $("#"+cpyCodeId).attr("class","regCodeInput defaultBorder").next().attr("class","");871 $("#"+cpyCodeErrId).html("").attr("class","");872 return false;873 }874 if(!isCk&&!Authcode){875 $("#"+cpyCodeId).attr("class","regCodeInput defaultBorder").next().attr("class","");876 $("#"+cpyCodeErrId).html("").attr("class","");877 return false;878 }879 if(Authcode==''){880 showCodecpyError(cpyCodeId,cpyCodeErrId,cpyCodeArr[0]);881 return false;882 }else if(Authcode.length!=4){883 upcode(cpyCodeImgId);884 showCodecpyError(cpyCodeId,cpyCodeErrId,cpyCodeArr[1]);885 return false;886 }887 $.ajaxSetup({async:false });888 var bol=false;889 $.post("/reg/codes/",{"name":"auth_code","param":Authcode},function(data){890 if(data!='y'){891 upcode(cpyCodeImgId);892 showCodecpyError(cpyCodeId,cpyCodeErrId,data);893 return false;894 }895 $("#"+cpyCodeId).attr("class","regCodeInput defaultBorder");896 $("#"+cpyCodeId).next().attr("class","regOk1").css("left","145px");897 $("#"+cpyCodeErrId).attr("class","").html("");898 bol=true;899 });900 return bol;901}902//协议勾选903var ckcpy_xy =function(){904 var val = document.getElementById(cpyAgreeId).checked;905 if(val==false){906 $("#"+cpyAgreeErrId).attr("class","reg_error3 f-color").html(comMsg(cpyAgreeArr[0]) );907 return false;908 }909 $("#"+cpyAgreeErrId).attr("class","").html('');910 return 1;911}912var cpy_subdata =function(){913 ckcpyname(1);914 var cm1 = $("#"+cpyUserNameErrId).html();915 ckcpypwd(1);916 var cm2 = $("#"+cpyPwdIdErrId).html();917 ckcpypwd2(1);918 var cm3 = $("#"+cpyPwd2ErrId).html();919 ckcpyrealName(1);920 var cm4 = $("#"+cpyRealNameErrId).html();921 ckcpytel(1);922 var cm5 = $("#"+cpyTelphoneErrId).html();923 ckcpymobile();924 var cm6 = $("#"+cpyMobileErrId).html();925 ckcpymail();926 var cm7 = $("#"+cpyEmailErrId).html();927 ckcpy_name(1);928 var cm8 = $("#"+cpyNameErrId).html();929 var cm9 = $("#"+cpyProvinceId).val();930 var cm10 = $("#"+cpyCitiesId).val();931 ckcpy_address(1);932 var cm11 = $("#"+cpyAddressErrId).html();933 ckcpy_buyuse(1);934 var cm12 = $("#"+cpyBuyuseErrId).html();935 ckcpy_website();936 var cm13 = $("#"+cpyWebsiteErrId).html();937 ckcpycode(1,0);938 var cm14 = $("#"+cpyCodeErrId).html();939 ckcpy_xy(1);940 var cm15 = $("#"+cpyAgreeErrId).html();941 if(cm1||cm2||cm3||cm4||cm5||cm6||cm7||cm8||cm9==0||cm10==0||cm11||cm12||cm13||cm14||cm15){942 return false;943 }944 $.post("/reg/Regcompany/",$('#regForm_cpy').serialize().replace(/\+/g,""),function(data){945 if(data=="y"){946 //跳转到注册成功页面947 $("#"+cpyCodeId).attr("disabled", true);948 location.href="/reg/success/";949 } else {950 upcode(cpyCodeImgId);951 $("#"+cpyCodeId).attr("disabled", false);952 jAlert('注册失败:' + data);953 }954 });955}956$("#"+cpyCodeId).live("keyup",function(event){957 if (event.keyCode == 13) {958 cpy_subdata();959 }...

Full Screen

Full Screen

path.js

Source:path.js Github

copy

Full Screen

1define(function (require) {2 var Path = require('../graphic/Path');3 var PathProxy = require('../core/PathProxy');4 var transformPath = require('./transformPath');5 var matrix = require('../core/matrix');6 // command chars7 var cc = [8 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z',9 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A'10 ];11 var mathSqrt = Math.sqrt;12 var mathSin = Math.sin;13 var mathCos = Math.cos;14 var PI = Math.PI;15 var vMag = function(v) {16 return Math.sqrt(v[0] * v[0] + v[1] * v[1]);17 };18 var vRatio = function(u, v) {19 return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));20 };21 var vAngle = function(u, v) {22 return (u[0] * v[1] < u[1] * v[0] ? -1 : 1)23 * Math.acos(vRatio(u, v));24 };25 function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {26 var psi = psiDeg * (PI / 180.0);27 var xp = mathCos(psi) * (x1 - x2) / 2.028 + mathSin(psi) * (y1 - y2) / 2.0;29 var yp = -1 * mathSin(psi) * (x1 - x2) / 2.030 + mathCos(psi) * (y1 - y2) / 2.0;31 var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);32 if (lambda > 1) {33 rx *= mathSqrt(lambda);34 ry *= mathSqrt(lambda);35 }36 var f = (fa === fs ? -1 : 1)37 * mathSqrt((((rx * rx) * (ry * ry))38 - ((rx * rx) * (yp * yp))39 - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp)40 + (ry * ry) * (xp * xp))41 ) || 0;42 var cxp = f * rx * yp / ry;43 var cyp = f * -ry * xp / rx;44 var cx = (x1 + x2) / 2.045 + mathCos(psi) * cxp46 - mathSin(psi) * cyp;47 var cy = (y1 + y2) / 2.048 + mathSin(psi) * cxp49 + mathCos(psi) * cyp;50 var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]);51 var u = [ (xp - cxp) / rx, (yp - cyp) / ry ];52 var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ];53 var dTheta = vAngle(u, v);54 if (vRatio(u, v) <= -1) {55 dTheta = PI;56 }57 if (vRatio(u, v) >= 1) {58 dTheta = 0;59 }60 if (fs === 0 && dTheta > 0) {61 dTheta = dTheta - 2 * PI;62 }63 if (fs === 1 && dTheta < 0) {64 dTheta = dTheta + 2 * PI;65 }66 path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);67 }68 function createPathProxyFromString(data) {69 if (!data) {70 return [];71 }72 // command string73 var cs = data.replace(/-/g, ' -')74 .replace(/ /g, ' ')75 .replace(/ /g, ',')76 .replace(/,,/g, ',');77 var n;78 // create pipes so that we can split the data79 for (n = 0; n < cc.length; n++) {80 cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);81 }82 // create array83 var arr = cs.split('|');84 // init context point85 var cpx = 0;86 var cpy = 0;87 var path = new PathProxy();88 var CMD = PathProxy.CMD;89 var prevCmd;90 for (n = 1; n < arr.length; n++) {91 var str = arr[n];92 var c = str.charAt(0);93 var off = 0;94 var p = str.slice(1).replace(/e,-/g, 'e-').split(',');95 var cmd;96 if (p.length > 0 && p[0] === '') {97 p.shift();98 }99 for (var i = 0; i < p.length; i++) {100 p[i] = parseFloat(p[i]);101 }102 while (off < p.length && !isNaN(p[off])) {103 if (isNaN(p[0])) {104 break;105 }106 var ctlPtx;107 var ctlPty;108 var rx;109 var ry;110 var psi;111 var fa;112 var fs;113 var x1 = cpx;114 var y1 = cpy;115 // convert l, H, h, V, and v to L116 switch (c) {117 case 'l':118 cpx += p[off++];119 cpy += p[off++];120 cmd = CMD.L;121 path.addData(cmd, cpx, cpy);122 break;123 case 'L':124 cpx = p[off++];125 cpy = p[off++];126 cmd = CMD.L;127 path.addData(cmd, cpx, cpy);128 break;129 case 'm':130 cpx += p[off++];131 cpy += p[off++];132 cmd = CMD.M;133 path.addData(cmd, cpx, cpy);134 c = 'l';135 break;136 case 'M':137 cpx = p[off++];138 cpy = p[off++];139 cmd = CMD.M;140 path.addData(cmd, cpx, cpy);141 c = 'L';142 break;143 case 'h':144 cpx += p[off++];145 cmd = CMD.L;146 path.addData(cmd, cpx, cpy);147 break;148 case 'H':149 cpx = p[off++];150 cmd = CMD.L;151 path.addData(cmd, cpx, cpy);152 break;153 case 'v':154 cpy += p[off++];155 cmd = CMD.L;156 path.addData(cmd, cpx, cpy);157 break;158 case 'V':159 cpy = p[off++];160 cmd = CMD.L;161 path.addData(cmd, cpx, cpy);162 break;163 case 'C':164 cmd = CMD.C;165 path.addData(166 cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]167 );168 cpx = p[off - 2];169 cpy = p[off - 1];170 break;171 case 'c':172 cmd = CMD.C;173 path.addData(174 cmd,175 p[off++] + cpx, p[off++] + cpy,176 p[off++] + cpx, p[off++] + cpy,177 p[off++] + cpx, p[off++] + cpy178 );179 cpx += p[off - 2];180 cpy += p[off - 1];181 break;182 case 'S':183 ctlPtx = cpx;184 ctlPty = cpy;185 var len = path.len();186 var pathData = path.data;187 if (prevCmd === CMD.C) {188 ctlPtx += cpx - pathData[len - 4];189 ctlPty += cpy - pathData[len - 3];190 }191 cmd = CMD.C;192 x1 = p[off++];193 y1 = p[off++];194 cpx = p[off++];195 cpy = p[off++];196 path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);197 break;198 case 's':199 ctlPtx = cpx;200 ctlPty = cpy;201 var len = path.len();202 var pathData = path.data;203 if (prevCmd === CMD.C) {204 ctlPtx += cpx - pathData[len - 4];205 ctlPty += cpy - pathData[len - 3];206 }207 cmd = CMD.C;208 x1 = cpx + p[off++];209 y1 = cpy + p[off++];210 cpx += p[off++];211 cpy += p[off++];212 path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);213 break;214 case 'Q':215 x1 = p[off++];216 y1 = p[off++];217 cpx = p[off++];218 cpy = p[off++];219 cmd = CMD.Q;220 path.addData(cmd, x1, y1, cpx, cpy);221 break;222 case 'q':223 x1 = p[off++] + cpx;224 y1 = p[off++] + cpy;225 cpx += p[off++];226 cpy += p[off++];227 cmd = CMD.Q;228 path.addData(cmd, x1, y1, cpx, cpy);229 break;230 case 'T':231 ctlPtx = cpx;232 ctlPty = cpy;233 var len = path.len();234 var pathData = path.data;235 if (prevCmd === CMD.Q) {236 ctlPtx += cpx - pathData[len - 4];237 ctlPty += cpy - pathData[len - 3];238 }239 cpx = p[off++];240 cpy = p[off++];241 cmd = CMD.Q;242 path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);243 break;244 case 't':245 ctlPtx = cpx;246 ctlPty = cpy;247 var len = path.len();248 var pathData = path.data;249 if (prevCmd === CMD.Q) {250 ctlPtx += cpx - pathData[len - 4];251 ctlPty += cpy - pathData[len - 3];252 }253 cpx += p[off++];254 cpy += p[off++];255 cmd = CMD.Q;256 path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);257 break;258 case 'A':259 rx = p[off++];260 ry = p[off++];261 psi = p[off++];262 fa = p[off++];263 fs = p[off++];264 x1 = cpx, y1 = cpy;265 cpx = p[off++];266 cpy = p[off++];267 cmd = CMD.A;268 processArc(269 x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path270 );271 break;272 case 'a':273 rx = p[off++];274 ry = p[off++];275 psi = p[off++];276 fa = p[off++];277 fs = p[off++];278 x1 = cpx, y1 = cpy;279 cpx += p[off++];280 cpy += p[off++];281 cmd = CMD.A;282 processArc(283 x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path284 );285 break;286 }287 }288 if (c === 'z' || c === 'Z') {289 cmd = CMD.Z;290 path.addData(cmd);291 }292 prevCmd = cmd;293 }294 path.toStatic();295 return path;296 }297 // TODO Optimize double memory cost problem298 function createPathOptions(str, opts) {299 var pathProxy = createPathProxyFromString(str);300 var transform;301 opts = opts || {};302 opts.buildPath = function (path) {303 path.setData(pathProxy.data);304 transform && transformPath(path, transform);305 // Svg and vml renderer don't have context306 var ctx = path.getContext();307 if (ctx) {308 path.rebuildPath(ctx);309 }310 };311 opts.applyTransform = function (m) {312 if (!transform) {313 transform = matrix.create();314 }315 matrix.mul(transform, m, transform);316 };317 return opts;318 }319 return {320 /**321 * Create a Path object from path string data322 * http://www.w3.org/TR/SVG/paths.html#PathData323 * @param {Object} opts Other options324 */325 createFromString: function (str, opts) {326 return new Path(createPathOptions(str, opts));327 },328 /**329 * Create a Path class from path string data330 * @param {string} str331 * @param {Object} opts Other options332 */333 extendFromString: function (str, opts) {334 return Path.extend(createPathOptions(str, opts));335 },336 /**337 * Merge multiple paths338 */339 // TODO Apply transform340 // TODO stroke dash341 // TODO Optimize double memory cost problem342 mergePath: function (pathEls, opts) {343 var pathList = [];344 var len = pathEls.length;345 var pathEl;346 var i;347 for (i = 0; i < len; i++) {348 pathEl = pathEls[i];349 if (pathEl.__dirty) {350 pathEl.buildPath(pathEl.path, pathEl.shape);351 }352 pathList.push(pathEl.path);353 }354 var pathBundle = new Path(opts);355 pathBundle.buildPath = function (path) {356 path.appendPath(pathList);357 // Svg and vml renderer don't have context358 var ctx = path.getContext();359 if (ctx) {360 path.rebuildPath(ctx);361 }362 };363 return pathBundle;364 }365 };...

Full Screen

Full Screen

allMail.js

Source:allMail.js Github

copy

Full Screen

1/*2 Author zhaoyinfan3 2013-08-094 注册公用js库5*/6var timeout = 120;7var ctDown = function (id) {8 --timeout;9 if(timeout > 0) {10 $("#"+id).attr("value",timeout+"秒后重新获取").removeClass("gvCode").addClass("gvCodeNo").attr("disabled", true);11 setTimeout("ctDown('"+id+"');", 1000);12 } else{13 $("#"+id).attr("value","点击获取验证码").attr("disabled", false).removeClass("gvCodeNo").addClass("gvCode").next().html('');14 timeout = 120;15 }16}17var timeoutajax = 120;18var ctAjaxDown = function (id) {19 --timeoutajax;20 if(timeoutajax > 0) {21 $("#"+id).attr("value",timeoutajax+"秒后重新获取").removeClass("reg_gvCode").addClass("reg_gvCodeNo").attr("disabled", true);22 setTimeout("ctAjaxDown('"+id+"');", 1000);23 } else{24 $("#"+id).attr("value","点击获取验证码").attr("disabled", false).removeClass("reg_gvCodeNo").addClass("reg_gvCode").next().html('');25 timeoutajax = 120;26 }27}28//check telphone29var tel_preg =function(tel){30 var preg=/^0[1-9][0-9]{1,2}-[0-9]{7,8}$/ ;31 var string = $.trim(tel);32 if(preg.test(string)){33 return 1;34 }35 return false;36}37//check mobile38var mobile_preg = function(mobile){39 var mob_preg = /^1[3|4|5|7|8][0-9]{9}$/;40 var string = $.trim(mobile);41 if(mob_preg.test(string)){42 return 1;43 }44 return false;45}46//check mail47var mail_preg = function(mail){48 if(mail.length>80){49 return false;50 }51 52 var ma_preg = /^\w+([-+.\']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;53 var string = $.trim(mail);54 if(ma_preg.test(string)){55 return 1;56 }57 return false;58}59//去掉中间的空格60function clsTrim(str){61 return str.replace(/\s/g,"");62}63var url_preg =function(url){64 if( url.length>70){65 return false;66 }67 var u_preg = /^[a-zA-z]+:\/\/[^\s]*$/;68 var string =$.trim(url); 69 if(u_preg.test(string)){70 return 1;71 }72 return false;73}74var GetLen = function(str) {75 var realLength = 0, len = str.length, charCode = -1;76 for (var i = 0; i < len; i++) {77 charCode = str.charCodeAt(i);78 if (charCode >= 0 && charCode <= 128) realLength += 1;79 else realLength += 2;80 }81 return realLength;82};83var lenpoints = function(pwd) {84 if (pwd.length <6||pwd.length >20) {85 return 0;86 };87 if (pwd.length >= 6 && pwd.length <= 7) {88 return 10;89 };90 if (pwd.length >= 8) {91 return 25;92 };93 return 0;94};95var pwdTotal = function(pwd) {96 if (!pwd || pwd == 'undefined') {97 return - 1;98 };99 if(lenpoints(pwd)==0){100 return 0;101 }102 var digit01 = /^[0-9]+$/;103 var digit10 = /[0-9]+/;104 var digit02 = /^[a-z]+$/;105 var digit20 = /[a-z]+/;106 var digit03 = /^[A-Z]+$/;107 var digit30 = /[A-Z]+/;108 var digitStr = /[a-zA-Z]/;109 var digitOther = /[_]+/;110 var safeStr =/^[0-9a-zA-z_]+$/;111 var totalPoints =0;112 if(!safeStr.test(pwd)){113 return -1;114 }115 if (digit20.test(pwd) && digit30.test(pwd)) {116 totalPoints += 20;117 };118 var pwd_num = 0;119 var t_num = 0;120 var pwd_mi=0;121 var pwd_max=0;122 for (var i = 0; i <= pwd.length; i++) {123 if (digit01.test(pwd.substr(i, 1))) {124 pwd_num++;125 }126 if (digitOther.test(pwd.substr(i, 1))) {127 t_num++;128 }129 if (digit02.test(pwd.substr(i, 1))) {130 pwd_mi ++;131 }132 if (digit03.test(pwd.substr(i, 1))) {133 pwd_max ++;134 }135 };136 if(pwd_mi&&!pwd_max){137 totalPoints += 10;138 }139 if(!pwd_mi&&pwd_max){140 totalPoints += 10;141 }142 if (pwd_num >= 1 && pwd_num < 3) {143 totalPoints += 10;144 };145 if (pwd_num >= 3) {146 totalPoints += 20;147 };148 if (t_num == 1) {149 totalPoints += 10;150 };151 if (t_num > 1) {152 totalPoints += 25;153 };154 if (digit20.test(pwd) && digit30.test(pwd) && digit10.test(pwd) && digitOther.test(pwd)) {155 totalPoints+=lenpoints(pwd);156 return totalPoints += 20;157 }158 if (digitStr.test(pwd) && digit10.test(pwd) && digitOther.test(pwd)) {159 totalPoints+=lenpoints(pwd);160 return totalPoints += 3;161 };162 if (digitStr.test(pwd) && digit10.test(pwd)) {163 totalPoints+=lenpoints(pwd);164 return totalPoints += 2;165 };166 if(totalPoints==0){167 return -1;168 }169 totalPoints+=lenpoints(pwd);170 return totalPoints;171}172/*-----------------个人注册数据------------------*/173var MailMId = "userMam";174var MailMErrId= "userMamErr";175var PwdId = "password";176var PwdErrId = "passwordErr";177var pwdStrong = "pwdStrong";178var PwdId2 = "password2";179var PwdErrId2 = "password2Err";180var pageCodeId ="auth_code";181var pageCodeErrId ="auth_codeErr";182var codeimgid = "code_img1";183var MobileCodeId ="sms_code";184var MobileCodeErrId="sms_codeErr";185var sfCodeId ="dm_number";186var sfCodeErrId ="dm_numberErr";187var AgreementId ="AgreeId";188var AgreementErrId="AgreeIdErr";189var defaultArr =[],OkArr=[],memArr =[],pwdArr=[],pwd2Arr=[],mcodeArr = [],codeArr=[],dmArr=[],agreeArr=[];190OkArr[0]= '通过信息验证!';191memArr[0] = '请输入您的手机号码';192memArr[1] = '请输入正确的手机号码';193memArr[2] = '请输入正确的邮箱地址';194pwdArr[0] = '请输入登录密码';195pwdArr[1] ='密码只能为6-20位字母数字下划线组合';196pwdArr[2] ='密码太简单,建议使用数字、字母、下划线组合';197pwdArr[3] ='密码只能为6-20位字母数字下划线组合';198pwd2Arr[0] = '请再次输入密码';199pwd2Arr[1] ='两次输入不一致,请重新输入';200mcodeArr[0]='请输入短信验证码';201mcodeArr[1]='短信验证码不正确';202codeArr[0] = '请输入验证码';203codeArr[1] ='网站验证码不正确';204dmArr[0] ='邀请码错误';205agreeArr[0] ='请阅读并同意注册协议';206defaultArr[1] ='请输入您的手机号码';207defaultArr[2] ='6-20位字符,可使用字母、数字、下划线。不建议使用纯数字或字母组合。';208defaultArr[3] ='请再次输入密码';209defaultArr[4] ='请输入短信验证码';210defaultArr[5] ='请输入验证码';211defaultArr[6] ='请输入您的优选单邀请码';212defaultArr[7] ='';213defaultArr[8] ='请输入您的用户名。可使用字母、数字、下划线。';214defaultArr[9] ='此手机号已经被注册!';215defaultArr[10] ='此用户名已经被注册!请重新输入。';216/*--------------------------------------------------企业注册数据---------------------------------------------------------*/217var cpyUserNameId = "cpyusername";218var cpyUserNameErrId= "cpyusernameErr";219var cpyPwdId = "cpypwd";220var cpyPwdIdErrId = "cpypwdErr";221var cpyPwd2Id = "cpypwd2";222var cpyPwd2ErrId = "cpypwd2Err";223var cpyCodeId = "cpyauth_code";224var cpyCodeErrId = "cpyauth_codeErr";225var cpyCodeImgId = "cpycode_img";226var cpyRealNameId = "cpyrealname";227var cpyRealNameErrId= "cpyrealnameErr";228var cpyTelphoneId = "cpytelphone";229var cpyTelphoneErrId = "cpytelphoneErr";230var cpyMobileId = "cpymobile";231var cpyMobileErrId = "cpymobileErr";232var cpyEmailId = "cpyemail";233var cpyEmailErrId = "cpyemailErr";234var cpySectionId = "cpysection";235var cpySectionErrId = "cpysectionErr"; 236var cpyNameId = "cpyname";237var cpyNameErrId = "cpynameErr";238var cpyProvinceId = "cpyprovince";239var cpyCitiesId = "cpycities";240var cpyAddressId = "cpyaddress";241var cpyAddressErrId = "cpyaddressErr";242var cpyBuyuseId = "cpybuyuse";243var cpyBuyuseErrId = "cpybuyuseErr";244var cpyWebsiteId = "cpywebsite";245var cpyWebsiteErrId = "cpywebsiteErr";246var cpyScaleId = "cpyscale";247var cpyScaleErrId = "cpyscaleErr";248var cpyTradeId = "cpytrade";249var cpyTradeErrId = "cpytradeErr";250var cpyNatureId = "cpynature";251var cpyNatureErrId = "cpynatureErr";252var cpyAgreeId = "cpyagree";253var cpyAgreeErrId = "cpyagreeErr"; 254var comArr=[],cpyDefaultArr=[], cpyUserNameArr =[],cpyPwdArr=[],cpyPwd2Arr=[],cpyCodeArr= [],cpyRealNameArr=[],cpyTelArr=[],cpyMobArr=[],cpyMaArr=[],cpyNameArr=[],cpyAddressArr=[],cpyBuyuseArr=[],cpyWebsiteArr=[],cpyAgreeArr=[];255cpyUserNameArr[0] ='请输入用户名';256cpyUserNameArr[1] ='用户名不能以SF开头';257cpyUserNameArr[2] ='用户名不能全部为数字';258cpyUserNameArr[3] ='用户名长度不得小于4大于20个字符';259cpyUserNameArr[4] ='用户名不能以tmall开头';260cpyUserNameArr[5] ='用户名不能以jd开头';261cpyPwdArr[0] ='请输入登录密码';262cpyPwdArr[1] ='密码长度需在6-20位之间';263cpyPwdArr[2] ='密码只能为6-20位字母数字下划线组合';264cpyPwd2Arr[0] ='请再次输入密码';265cpyPwd2Arr[1] ='两次输入密码不一致';266cpyCodeArr[0] ='请输入验证码';267cpyCodeArr[1] ='验证码不正确';268cpyRealNameArr[0] ='请输入联系人姓名';269cpyRealNameArr[1] ='联系人姓名长度应在4-20位之间';270cpyRealNameArr[2] ='联系人姓名只能由英文和中文组成';271cpyTelArr[0] ='公司电话不能为空';272cpyTelArr[1] ='公司电话错误';273cpyMobArr[0] ='公司手机号码错误';274cpyMaArr[0] ='公司邮箱地址错误';275cpyNameArr[0] ='请输入公司名称';276cpyNameArr[1] ='公司名称长度应在4-40位之间';277cpyAddressArr[0] ='请选择公司所在地';278cpyAddressArr[1] ='请选择公司所在地';279cpyAddressArr[2] ='请输入公司地址';280cpyAddressArr[3] ='公司地址长度应在4-50位之间';281cpyBuyuseArr[0] ='请选择购买用途';282cpyWebsiteArr[0] ='公司网址格式不正确,应如: http://www.e3mall.cn/';283cpyAgreeArr[0] ='请勾选注册协议';284cpyDefaultArr[0] ='请输入4-20位中、英文、数字、中划线和下划线';285cpyDefaultArr[1] ='6-20位字符,可使用字母、数字、下划线。不建议使用纯数字或字母组合。';286cpyDefaultArr[2] ='请再次输入密码';287cpyDefaultArr[3] ='请输入网站验证码';288cpyDefaultArr[4] ='4-20位字符,可由中文和英文组成';289cpyDefaultArr[5] ='请填写联系人常用固话,如010-87654312';290cpyDefaultArr[6] ='请输入联系人手机号码';291cpyDefaultArr[7] ='请输入联系人常用邮箱';292cpyDefaultArr[8] ='请填写工商局注册全称,4-40位字符';293cpyDefaultArr[9] ='请详细填写公司经营地址';294cpyDefaultArr[10] ='如http://www.e3mall.cn/';...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const cpy = require('storybook-root/cpy');2const path = require('path');3const source = path.join(__dirname, 'src');4const dest = path.join(__dirname, 'dist');5cpy(source, dest, {parents: true});6module.exports = {7 webpackFinal: async config => {8 return config;9 },10};11const path = require('path');12const root = require('storybook-root');13module.exports = {14 webpackFinal: async config => {15 return config;16 },17 presets: [path.resolve(root(), 'node_modules/@storybook/preset-create-react-app')],18};19const path = require('path');20const root = require('storybook-root');21module.exports = async ({config}) => {22 return config;23};

Full Screen

Using AI Code Generation

copy

Full Screen

1import { cpy } from 'storybook-root';2import { cpy } from 'storybook-root/other';3import { cpy } from 'storybook-root';4import { cpy } from 'storybook-root/other';5import { cpy } from 'storybook-root';6import { cpy } from 'storybook-root/other';7import { cpy } from 'storybook-root';8import { cpy } from 'storybook-root/other';9import { cpy } from 'storybook-root';10import { cpy } from 'storybook-root/other';11import { cpy } from 'storybook-root';12import { cpy } from 'storybook-root/other';13import { cpy } from 'storybook-root';14import { cpy } from 'storybook-root/other';15import { cpy } from 'storybook-root';16import { cpy } from 'storybook-root/other';17import { cpy } from 'storybook-root';18import { cpy } from 'storybook-root/other';19import { cpy } from 'storybook-root';20import { cpy } from 'storybook-root/other';21import { cpy } from 'storybook-root';22import { cpy } from 'storybook-root/other';23import { cpy } from 'storybook-root';24import { cpy } from 'storybook-root/other';25import { cpy } from '

Full Screen

Using AI Code Generation

copy

Full Screen

1const cpy = require('cpy');2cpy(['./node_modules/storybook-root/dist/**/*'], './dist');3{4 "scripts": {5 },6 "dependencies": {7 }8}

Full Screen

Using AI Code Generation

copy

Full Screen

1var storybook = require('./storybook-root');2storybook.cpy('story.txt', 'copy.txt', function(err){3 if(err){4 console.log(err);5 }6});7var storybook = require('./storybook-root');8storybook.read('story.txt', function(err, data){9 if(err){10 console.log(err);11 }12 console.log(data);13});14var storybook = require('./storybook-root');15storybook.read('story.txt', function(err, data){16 if(err){17 console.log(err);18 }19 console.log(data);20});21var storybook = require('./storybook-root');22storybook.read('story.txt', function(err, data){23 if(err){24 console.log(err);25 }26 console.log(data);27});28var storybook = require('./storybook-root');29storybook.read('story.txt', function(err, data){30 if(err){31 console.log(err);32 }33 console.log(data);34});35var storybook = require('./storybook-root');36storybook.read('story.txt', function(err, data){37 if(err){38 console.log(err);39 }40 console.log(data);41});42var storybook = require('./storybook-root');43storybook.read('story.txt', function(err, data){44 if(err){45 console.log(err);46 }47 console.log(data);48});49var storybook = require('./storybook-root');50storybook.read('story.txt', function(err, data){

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful