Best JavaScript code snippet using cypress
registersq.js
Source:registersq.js
...8 })9 //éªè¯è¡¨åã10 $('#verifyCode').focusin(function () {11 $('#verifyCode').addClass("textinput_hover");12 $(this).parent().siblings(".formerr").hide();13 $(this).parent().siblings(".formerr1").show();14 }).focusout(function () {15 $('#verifyCode').removeClass("textinput_hover");16 var thisval = $(this).val();17 if (!thisval) {18 $(this).parent().siblings(".formerr").hide();19 $(this).parent().siblings(".formerr4").show();20 }21 else {22 if (thisval.length != 4) {23 $(this).parent().siblings(".formerr").hide();24 $(this).parent().siblings(".formerr4").show();25 } else {26 $(this).parent().siblings(".formerr").hide();27 $(this).parent().siblings(".formerr3").show();28 }29 }30 });31 $('#username').focusin(function () {32 $('#username').addClass("textinput_hover");33 $(this).parent().siblings(".formerr").hide();34 $(this).parent().siblings(".formerr1").show();35 $(".recommendUser").hide();36 }).focusout(function () {37 $('#username').removeClass("textinput_hover");38 var username = $(this).val();39 if (!username) {40 $(this).parent().siblings(".formerr").hide();41 $(this).parent().siblings(".formerr4").show();42 }43 else {44 if (isChn(username)|| username == "" || username.length < 6 || username.length > 20) {45 $(this).parent().siblings(".formerr").hide();46 $(this).parent().siblings(".formerr2").show();47 } else {48 checkUserName();49 }50 }51 });52 $("#password").focusin(function () {53 $('#password').addClass("textinput_hover");54 $(this).parent().siblings(".formerr").hide();55 $(this).parent().siblings(".formerr1").show();56 }).focusout(function () {57 $('#password').removeClass("textinput_hover");58 var passvalue = $(this).val();59 if (!passvalue) {60 $(this).parent().siblings(".formerr").hide();61 $(this).parent().siblings(".formerr4").show();62 }63 else {64 if (/^\d+$/.test(passvalue) && passvalue.length < 9) {65 $(this).parent().siblings(".formerr").hide();66 $(this).parent().siblings(".formerr2").show();67 } else if (trimAll(passvalue).length < 6 || trimAll(passvalue).length > 20) {68 $(this).parent().siblings(".formerr").hide();69 $(this).parent().siblings(".formerr2").show();70 } else {71 $(this).parent().siblings(".formerr").hide();72 $(this).parent().siblings(".formerr3").show();73 $(this).parent().siblings(".formerr3").children(".ok").addClass("hasok");74 }75 }76 }).bind("keyup", function () {77 //å¤æå¯ç 强度78 var passvalue = $(this).val();79 if (passvalue.length > 5) {80 var passvalueChar = check(passvalue);81 if (passvalueChar == 1) {82 $(".pass_lv2").css({"width":"5px", "right":"37px"});8384 } else if (passvalueChar == 2) {85 $(".pass_lv2").css({"width":"10px", "right":"32px"})86 } else if (passvalueChar == 10) {87 $(".pass_lv2").css({"width":"15px", "right":"27px"})88 } else if (passvalueChar == 3) {89 $(".pass_lv2").css({"width":"20px", "right":"22px"})90 } else if (passvalueChar == 11) {91 $(".pass_lv2").css({"width":"25px", "right":"17px"})92 } else if (passvalueChar == 12) {93 $(".pass_lv2").css({"width":"30px", "right":"12px"})94 } else if (passvalueChar == 13) {95 $(".pass_lv2").css({"width":"35px", "right":"7px"})96 }97 ;9899 }100101 });102 $("#passwordaffirm").focusin(function () {103 $('#passwordaffirm').addClass("textinput_hover");104 $(this).parent().siblings(".formerr").hide();105 $(this).parent().siblings(".formerr1").show();106 }).focusout(function () {107 $('#passwordaffirm').removeClass("textinput_hover");108 var passvalue = $("#password").val();109 var haspassword = $(".ok").eq(1).hasClass("hasok");110 if (!$(this).val()) {111 $(this).parent().siblings(".formerr").hide();112 $(this).parent().siblings(".formerr4").show();113 }114 else {115 if ($(this).val() != passvalue || passvalue == "") {116 $(this).parent().siblings(".formerr").hide();117 $(this).parent().siblings(".formerr2").show();118 } else {119 $(this).parent().siblings(".formerr").hide();120 $(this).parent().siblings(".formerr3").show();121 }122 }123 });124 $(".zc_submit").click(register);125 $("#agreeRegister").click(function () {126 var chec = $("#agreeRegister").attr("checked");127 if (chec != "checked") {128 alert('请åæ第ä¸å¤§éç¨æ·æ³¨ååè®®ï¼');129 }130 });131 $("input").bind("keydown", function (e) {132 var key = e.which;133 if (key == 13) {134 e.preventDefault();135 register();136 }137 });138});139140function register() {141 var chec = $("#agreeRegister").attr("checked");142 if (chec != "checked") {143 alert('请åæ第ä¸å¤§éç¨æ·æ³¨ååè®®ï¼');144 return;145 }146 var uname = $.trim($("#username").val());147 var psw = trimAll($.trim($("#password").val()));148 var pswc = $.trim($("#passwordaffirm").val());149 var verifyCode = $.trim($("#verifyCode").val());150151 $('#username').removeClass("textinput_hover");152 $('#password').removeClass("textinput_hover");153 $('#passwordaffirm').removeClass("textinput_hover");154 $('#verifyCode').removeClass("textinput_hover");155156 if (!psw) {157 $('#password').focus();158 $('#password').parent().siblings(".formerr").hide();159 $('#password').parent().siblings(".formerr4").show();160 }161 else {162 if (/^\d+$/.test(psw) && psw.length < 9) {163 $('#password').focus();164 $('#password').parent().siblings(".formerr").hide();165 $('#password').parent().siblings(".formerr2").show();166 } else if (psw.length < 6 || psw.length > 20) {167 $('#password').focus();168 $('#password').parent().siblings(".formerr").hide();169 $('#password').parent().siblings(".formerr2").show();170 } else {171 if (!pswc) {172 $('#passwordaffirm').focus();173 $('#passwordaffirm').parent().siblings(".formerr").hide();174 $('#passwordaffirm').parent().siblings(".formerr4").show();175 }176 else {177 if (pswc != psw || psw == "") {178 $('#passwordaffirm').focus();179 $('#passwordaffirm').parent().siblings(".formerr").hide();180 $('#passwordaffirm').parent().siblings(".formerr2").show();181 } else {182 var shijian = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;183 if (!verifyCode) {184 $('#verifyCode').focus();185 $('#verifyCode').parent().siblings(".formerr").hide();186 $('#verifyCode').parent().siblings(".formerr4").show();187 }188 else {189 if (verifyCode.length != 4) {190 $('#verifyCode').focus();191 $('#verifyCode').parent().siblings(".formerr").hide();192 $('#verifyCode').parent().siblings(".formerr4").show();193 } else {194 $.ajax({195 url:'/register',196 type:'post',197 datatype:'json',198 data:{type:'register', user:uname, psw:psw, verifyCode:$("#verifyCode").val(),199 timeStr:$("#expireTimeR").val(),"fromUrl":$("#fromUrl").val()},200 success:function (data) {201 var code = data.code;202 var msg = data.msg;203 if (code == 199) {204 $('#username').focus();205 $('#username').parent().siblings(".formerr").hide();206 $('#username').parent().siblings(".formerr4").empty().207 addClass("warning").append("<span class='error'></span>" + msg).show();208 refleshVerifyCodeReg();209 }210 if (code == 201) {211 $('#password').focus();212 $('#password').parent().siblings(".formerr").hide();213 $('#password').parent().siblings(".formerr4").empty().214 addClass("warning").append("<span class='error'></span>" + msg).show();215 refleshVerifyCodeReg();216 }217 if (code == 202) {218 $('#verifyCode').focus();219 $('#verifyCode').parent().siblings(".formerr").hide();220 $('#verifyCode').parent().siblings(".formerr4").empty().221 addClass("warning").append("<span class='error'></span>" + msg).show();222 refleshVerifyCodeReg();223 }224 if (code == 200) {225 window.location.href = "/accountcenter.html";226 }227 if (code == 204) {228 alert(msg);229 window.location.href = '/register.html';230 }231 if (code == 400) {232 window.location.href = data.object;233 }234 },235 error:function () {236 window.location.href = '/register.html';237 }238 });239 }240 }241 }242 }243 }244 }245246247}248249function checkUserName()250{251 var uname = $.trim($("#username").val());252 $.ajax({253 url:'/checkUserName',254 type:'post',255 datatype:'json',256 data:{type:'register', userName:uname},257 success:function (data) {258 var code = data.code;259 var msg = data.msg;260 if (code == 199) {261 if(msg=="å·²ç»åå¨çç¨æ·å!")262 {263 $("#listUserName").empty();264 $.each(data.object,function(index,value){ $("#listUserName").append("<p><input type='radio' name='recommendname' /><label>"+value+"</label></p>")});265 $(".recommendUser").show();266 }267 else268 {269 $('#username').focus();270 $('#username').parent().siblings(".formerr").hide();271 $('#username').parent().siblings(".formerr4").empty().272 addClass("warning").append("<span class='error'></span>" + msg).show();273 refleshVerifyCodeReg();274 }275 } else276 {277 $('#username').parent().siblings(".formerr").hide();278 $('#username').parent().siblings(".formerr3").show();279 $('#password').focus();280 }281 },282 error:function () {283 window.location.href = '/register.html';284 }285 });286}287288//å»æç©ºæ ¼289function trimAll(str) {290 return str.replace(/(^\s*)|(\s*)|(\s*$)/g, "");291}292;293// å·æ°éªè¯ç 294function refleshVerifyCodeReg() {295 var timeStr = (new Date().getTime());296 $("#log_verifyCodeImgReg").attr("src", '/verifyCode?time=' + timeStr);297 $("#expireTimeR").val(timeStr);298}299300//é²æ²è¿·æ³¨åjs301$("#registerFcm").bind("click", function () {302 var chec = $("#agreeRegister").attr("checked");303 if (chec != "checked") {304 alert('请åæ第ä¸å¤§éç¨æ·æ³¨ååè®®ï¼');305 }306 else {307 var _name = $.trim($("#uName").val());308 var _psw = $.trim($("#uPsw").val());309 var _pswC = $.trim($("#uPswConfirm").val());310 var _email = $.trim($("#uEmail").val());311 var _rName = $.trim($("#rName").val());312 var _icn = $.trim($("#uIcn").val());313 var _code = $.trim($("#code").val());314 var _timeStr = $.trim($("#timeStr").val());315 if (!_name) {316 $("#uName").parent().siblings(".formerr").hide();317 $("#uName").parent().siblings(".formerr4").show();318 }319 else {320 var usern = /^[a-zA-Z0-9_]{1,}$/;321 if (isChn(_name) || !_name.match(usern) || _name == "" || _name.length < 6 || _name.length > 20) {322 $("#uName").parent().siblings(".formerr").hide();323 $("#uName").parent().siblings(".formerr2").show();324 } else {325 if (!_psw) {326 $("#uPsw").parent().siblings(".formerr").hide();327 $("#uPsw").parent().siblings(".formerr4").show();328 }329 else {330 if (/^\d+$/.test(_psw) && _psw.length < 9) {331 $("#uPsw").parent().siblings(".formerr").hide();332 $("#uPsw").parent().siblings(".formerr2").show();333 } else if (trimAll(_psw).length < 6 || trimAll(_psw).length > 20) {334 $("#uPsw").parent().siblings(".formerr").hide();335 $("#uPsw").parent().siblings(".formerr2").show();336 } else if (trimAll(_psw).length !=$("#uPsw").val().length) {337 $('#uPsw').focus();338 $('#uPsw').parent().siblings(".formerr").hide();339 $('#uPsw').parent().siblings(".formerr4").empty().340 addClass("warning").append("<span class='error'></span>å¯ç ä¸è½å«æç©ºæ ¼!").show();341 }342343 else {344 if (!_pswC) {345 $("#uPswConfirm").parent().siblings(".formerr").hide();346 $("#uPswConfirm").parent().siblings(".formerr4").show();347 }348 else {349 if (_psw != _pswC || _pswC == "") {350 $("#uPswConfirm").parent().siblings(".formerr").hide();351 $("#uPswConfirm").parent().siblings(".formerr2").show();352 } else {353 if (!_email) {354 $("#uEmail").parent().siblings(".formerr").hide();355 $("#uEmail").parent().siblings(".formerr4").show();356 }357 else {358 if (!isEmail(_email) || _email == "" || _email.length < 6 || _email.length > 50) {359 $("#uEmail").parent().siblings(".formerr").hide();360 $("#uEmail").parent().siblings(".formerr2").show();361 } else {362 if (!_code) {363 $("#code").parent().siblings(".formerr").hide();364 $("#code").parent().siblings(".formerr4").show();365 }366 else {367 if ($.trim(_code).length != 4) {368 $("#code").parent().siblings(".formerr").hide();369 $("#code").parent().siblings(".formerr2").show();370 } else {371 if (!_rName) {372 $("#rName").parent().siblings(".formerr").hide();373 $("#rName").parent().siblings(".formerr4").show();374 }375 else {376 if (!isChn(_rName) || _rName == "" || _rName.length < 2 || _rName.length > 8) {377 $("#rName").parent().siblings(".formerr").hide();378 $("#rName").parent().siblings(".formerr2").show();379 } else {380 if (!_icn) {381 $("#uIcn").parent().siblings(".formerr").hide();382 $("#uIcn").parent().siblings(".formerr4").show();383 }384 else {385 if (validateIdCard(_icn) > 0 || _icn == "" || _icn.length < 6 || _icn.length > 18) {386 $("#uIcn").parent().siblings(".formerr").hide();387 $("#uIcn").parent().siblings(".formerr2").show();388 } else {389 $.ajax({390 url:'/register2',391 type:'post',392 data:{"uName":_name, "uPsw":_psw, "uPswConfirm":_pswC, "uEmail":_email, "rName":_rName, "uIcn":_icn, "code":_code, "timeStr":_timeStr},393 dataType:'json',394 success:function (data) {395 var code = data.code;396 var msg = data.msg;397 if (code != 200) {398 refleshVerifyCodeRegfcm();399 if (code == 201) {400 $('#uName').parent().siblings(".formerr").hide();401 $('#uName').parent().siblings(".formerr4").empty().402 addClass("warning").append("<span class='error'></span>" + msg).show();403 }404 if (code == 202) {405 $('#uPsw').parent().siblings(".formerr").hide();406 $('#uPsw').parent().siblings(".formerr4").empty().407 addClass("warning").append("<span class='error'></span>" + msg).show();408 }409 if (code == 203) {410 $('#uPswConfirm').parent().siblings(".formerr").hide();411 $('#uPswConfirm').parent().siblings(".formerr4").empty().412 addClass("warning").append("<span class='error'></span>" + msg).show();413 }414 if (code == 204) {415 $('#uEmail').parent().siblings(".formerr").hide();416 $('#uEmail').parent().siblings(".formerr4").empty().417 addClass("warning").append("<span class='error'></span>" + msg).show();418 }419 if (code == 205) {420 $('#code').parent().siblings(".formerr").hide();421 $('#code').parent().siblings(".formerr4").empty().422 addClass("warning").append("<span class='error'></span>" + msg).show();423 }424 if (code == 206) {425 $('#rName').parent().siblings(".formerr").hide();426 $('#rName').parent().siblings(".formerr4").empty().427 addClass("warning").append("<span class='error'></span>" + msg).show();428 }429 if (code == 207) {430 $('#uIcn').parent().siblings(".formerr").hide();431 $('#uIcn').parent().siblings(".formerr4").empty().432 addClass("warning").append("<span class='error'></span>" + msg).show();433 }434 }435 else {436 window.location.href = "/accountcenter.html";437 }438 },439 error:function () {440 alert('è¿æ¥æå¡å¨é误!');441 }442 });443 }444 }445 }
...
characterUtility.js
Source:characterUtility.js
1const finalObj = {2 'a': { siblings: ['a', 'Ä', 'â'], tones: ['a', 'á', 'à ', 'ã', 'ả', 'ạ'] },3 'á': { siblings: ['á', 'ắ', 'ấ'], tones: ['a', 'á', 'à ', 'ã', 'ả', 'ạ'] },4 'à ': { siblings: ['à ', 'ằ', 'ầ'], tones: ['a', 'á', 'à ', 'ã', 'ả', 'ạ'] },5 'ã': { siblings: ['ã', 'ẵ', 'ẫ'], tones: ['a', 'á', 'à ', 'ã', 'ả', 'ạ'] },6 'ả': { siblings: ['ả', 'ẳ', 'ẩ'], tones: ['a', 'á', 'à ', 'ã', 'ả', 'ạ'] },7 'ạ': { siblings: ['ạ', 'ặ', 'áº'], tones: ['a', 'á', 'à ', 'ã', 'ả', 'ạ'] },8 'Ä': { siblings: ['a', 'Ä', 'â'], tones: ['Ä', 'ắ', 'ằ', 'ẵ', 'ẳ', 'ặ'] },9 'ắ': { siblings: ['á', 'ắ', 'ấ'], tones: ['Ä', 'ắ', 'ằ', 'ẵ', 'ẳ', 'ặ'] },10 'ằ': { siblings: ['à ', 'ằ', 'ầ'], tones: ['Ä', 'ắ', 'ằ', 'ẵ', 'ẳ', 'ặ'] },11 'ẵ': { siblings: ['ã', 'ẵ', 'ẫ'], tones: ['Ä', 'ắ', 'ằ', 'ẵ', 'ẳ', 'ặ'] },12 'ẳ': { siblings: ['ả', 'ẳ', 'ẩ'], tones: ['Ä', 'ắ', 'ằ', 'ẵ', 'ẳ', 'ặ'] },13 'ặ': { siblings: ['ạ', 'ặ', 'áº'], tones: ['Ä', 'ắ', 'ằ', 'ẵ', 'ẳ', 'ặ'] },14 'â': { siblings: ['a', 'Ä', 'â'], tones: ['â', 'ấ', 'ầ', 'ẫ', 'ẩ', 'áº'] },15 'ấ': { siblings: ['á', 'ắ', 'ấ'], tones: ['â', 'ấ', 'ầ', 'ẫ', 'ẩ', 'áº'] },16 'ầ': { siblings: ['à ', 'ằ', 'ầ'], tones: ['â', 'ấ', 'ầ', 'ẫ', 'ẩ', 'áº'] },17 'ẫ': { siblings: ['ã', 'ẵ', 'ẫ'], tones: ['â', 'ấ', 'ầ', 'ẫ', 'ẩ', 'áº'] },18 'ẩ': { siblings: ['ả', 'ẳ', 'ẩ'], tones: ['â', 'ấ', 'ầ', 'ẫ', 'ẩ', 'áº'] },19 'áº': { siblings: ['ạ', 'ặ', 'áº'], tones: ['â', 'ấ', 'ầ', 'ẫ', 'ẩ', 'áº'] },20 'e': { siblings: ['e', 'ê'], tones: ['e', 'é', 'è', 'ẽ', 'ẻ', 'ẹ'] },21 'é': { siblings: ['é', 'ế'], tones: ['e', 'é', 'è', 'ẽ', 'ẻ', 'ẹ'] },22 'è': { siblings: ['è', 'á»'], tones: ['e', 'é', 'è', 'ẽ', 'ẻ', 'ẹ'] },23 'ẽ': { siblings: ['ẽ', 'á»
'], tones: ['e', 'é', 'è', 'ẽ', 'ẻ', 'ẹ'] },24 'ẻ': { siblings: ['ẻ', 'á»'], tones: ['e', 'é', 'è', 'ẽ', 'ẻ', 'ẹ'] },25 'ẹ': { siblings: ['ẹ', 'á»'], tones: ['e', 'é', 'è', 'ẽ', 'ẻ', 'ẹ'] },26 'ê': { siblings: ['e', 'ê'], tones: ['ê', 'ế', 'á»', 'á»
', 'á»', 'á»'] },27 'ế': { siblings: ['é', 'ế'], tones: ['ê', 'ế', 'á»', 'á»
', 'á»', 'á»'] },28 'á»': { siblings: ['è', 'á»'], tones: ['ê', 'ế', 'á»', 'á»
', 'á»', 'á»'] },29 'á»
': { siblings: ['ẽ', 'á»
'], tones: ['ê', 'ế', 'á»', 'á»
', 'á»', 'á»'] },30 'á»': { siblings: ['ẻ', 'á»'], tones: ['ê', 'ế', 'á»', 'á»
', 'á»', 'á»'] },31 'á»': { siblings: ['ẹ', 'á»'], tones: ['ê', 'ế', 'á»', 'á»
', 'á»', 'á»'] },32 'i': { siblings: [], tones: ['i', 'Ã', 'ì', 'Ä©', 'á»', 'á»'] },33 'Ã': { siblings: [], tones: ['i', 'Ã', 'ì', 'Ä©', 'á»', 'á»'] },34 'ì': { siblings: [], tones: ['i', 'Ã', 'ì', 'Ä©', 'á»', 'á»'] },35 'Ä©': { siblings: [], tones: ['i', 'Ã', 'ì', 'Ä©', 'á»', 'á»'] },36 'á»': { siblings: [], tones: ['i', 'Ã', 'ì', 'Ä©', 'á»', 'á»'] },37 'á»': { siblings: [], tones: ['i', 'Ã', 'ì', 'Ä©', 'á»', 'á»'] },38 'o': { siblings: ['o', 'ô', 'Æ¡'], tones: ['o', 'ó', 'ò', 'õ', 'á»', 'á»'] },39 'ó': { siblings: ['ó', 'á»', 'á»'], tones: ['o', 'ó', 'ò', 'õ', 'á»', 'á»'] },40 'ò': { siblings: ['ò', 'á»', 'á»'], tones: ['o', 'ó', 'ò', 'õ', 'á»', 'á»'] },41 'õ': { siblings: ['õ', 'á»', 'ỡ'], tones: ['o', 'ó', 'ò', 'õ', 'á»', 'á»'] },42 'á»': { siblings: ['á»', 'á»', 'á»'], tones: ['o', 'ó', 'ò', 'õ', 'á»', 'á»'] },43 'á»': { siblings: ['á»', 'á»', 'ợ'], tones: ['o', 'ó', 'ò', 'õ', 'á»', 'á»'] },44 'ô': { siblings: ['o', 'ô', 'Æ¡'], tones: ['ô', 'á»', 'á»', 'á»', 'á»', 'á»'] },45 'á»': { siblings: ['ó', 'á»', 'á»'], tones: ['ô', 'á»', 'á»', 'á»', 'á»', 'á»'] },46 'á»': { siblings: ['ò', 'á»', 'á»'], tones: ['ô', 'á»', 'á»', 'á»', 'á»', 'á»'] },47 'á»': { siblings: ['õ', 'á»', 'ỡ'], tones: ['ô', 'á»', 'á»', 'á»', 'á»', 'á»'] },48 'á»': { siblings: ['á»', 'á»', 'á»'], tones: ['ô', 'á»', 'á»', 'á»', 'á»', 'á»'] },49 'á»': { siblings: ['á»', 'á»', 'ợ'], tones: ['ô', 'á»', 'á»', 'á»', 'á»', 'á»'] },50 'Æ¡': { siblings: ['o', 'ô', 'Æ¡'], tones: ['Æ¡', 'á»', 'á»', 'ỡ', 'á»', 'ợ'] },51 'á»': { siblings: ['ó', 'á»', 'á»'], tones: ['Æ¡', 'á»', 'á»', 'ỡ', 'á»', 'ợ'] },52 'á»': { siblings: ['ò', 'á»', 'á»'], tones: ['Æ¡', 'á»', 'á»', 'ỡ', 'á»', 'ợ'] },53 'ỡ': { siblings: ['õ', 'á»', 'ỡ'], tones: ['Æ¡', 'á»', 'á»', 'ỡ', 'á»', 'ợ'] },54 'á»': { siblings: ['á»', 'á»', 'á»'], tones: ['Æ¡', 'á»', 'á»', 'ỡ', 'á»', 'ợ'] },55 'ợ': { siblings: ['á»', 'á»', 'ợ'], tones: ['Æ¡', 'á»', 'á»', 'ỡ', 'á»', 'ợ'] },56 'u': { siblings: ['u', 'Æ°'], tones: ['u', 'ú', 'ù', 'Å©', 'ủ', 'ụ'] },57 'ú': { siblings: ['ú', 'ứ'], tones: ['u', 'ú', 'ù', 'Å©', 'ủ', 'ụ'] },58 'ù': { siblings: ['ù', 'ừ'], tones: ['u', 'ú', 'ù', 'Å©', 'ủ', 'ụ'] },59 'Å©': { siblings: ['Å©', 'ữ'], tones: ['u', 'ú', 'ù', 'Å©', 'ủ', 'ụ'] },60 'ủ': { siblings: ['ủ', 'á»'], tones: ['u', 'ú', 'ù', 'Å©', 'ủ', 'ụ'] },61 'ụ': { siblings: ['ụ', 'á»±'], tones: ['u', 'ú', 'ù', 'Å©', 'ủ', 'ụ'] },62 'Æ°': { siblings: ['u', 'Æ°'], tones: ['Æ°', 'ứ', 'ừ', 'ữ', 'á»', 'á»±'] },63 'ứ': { siblings: ['ú', 'ứ'], tones: ['Æ°', 'ứ', 'ừ', 'ữ', 'á»', 'á»±'] },64 'ừ': { siblings: ['ù', 'ừ'], tones: ['Æ°', 'ứ', 'ừ', 'ữ', 'á»', 'á»±'] },65 'ữ': { siblings: ['Å©', 'ữ'], tones: ['Æ°', 'ứ', 'ừ', 'ữ', 'á»', 'á»±'] },66 'á»': { siblings: ['ủ', 'á»'], tones: ['Æ°', 'ứ', 'ừ', 'ữ', 'á»', 'á»±'] },67 'á»±': { siblings: ['ụ', 'á»±'], tones: ['Æ°', 'ứ', 'ừ', 'ữ', 'á»', 'á»±'] },68 'y': { siblings: [], tones: ['y', 'ý', 'ỳ', 'ỹ', 'á»·', 'ỵ'] },69 'ý': { siblings: [], tones: ['y', 'ý', 'ỳ', 'ỹ', 'á»·', 'ỵ'] },70 'ỳ': { siblings: [], tones: ['y', 'ý', 'ỳ', 'ỹ', 'á»·', 'ỵ'] },71 'ỹ': { siblings: [], tones: ['y', 'ý', 'ỳ', 'ỹ', 'á»·', 'ỵ'] },72 'á»·': { siblings: [], tones: ['y', 'ý', 'ỳ', 'ỹ', 'á»·', 'ỵ'] },73 'ỵ': { siblings: [], tones: ['y', 'ý', 'ỳ', 'ỹ', 'á»·', 'ỵ'] },74 'A': { siblings: ['A', 'Ä', 'Ã'], tones: ['A', 'Ã', 'Ã', 'Ã', 'Ả', 'Ạ'] },75 'Ã': { siblings: ['Ã', 'Ắ', 'Ấ'], tones: ['A', 'Ã', 'Ã', 'Ã', 'Ả', 'Ạ'] },76 'Ã': { siblings: ['Ã', 'Ằ', 'Ầ'], tones: ['A', 'Ã', 'Ã', 'Ã', 'Ả', 'Ạ'] },77 'Ã': { siblings: ['Ã', 'Ẵ', 'Ẫ'], tones: ['A', 'Ã', 'Ã', 'Ã', 'Ả', 'Ạ'] },78 'Ả': { siblings: ['Ả', 'Ẳ', 'Ẩ'], tones: ['A', 'Ã', 'Ã', 'Ã', 'Ả', 'Ạ'] },79 'Ạ': { siblings: ['Ạ', 'Ặ', 'Ậ'], tones: ['A', 'Ã', 'Ã', 'Ã', 'Ả', 'Ạ'] },80 'Ä': { siblings: ['A', 'Ä', 'Ã'], tones: ['Ä', 'Ắ', 'Ằ', 'Ẵ', 'Ẳ', 'Ặ'] },81 'Ắ': { siblings: ['Ã', 'Ắ', 'Ấ'], tones: ['Ä', 'Ắ', 'Ằ', 'Ẵ', 'Ẳ', 'Ặ'] },82 'Ằ': { siblings: ['Ã', 'Ằ', 'Ầ'], tones: ['Ä', 'Ắ', 'Ằ', 'Ẵ', 'Ẳ', 'Ặ'] },83 'Ẵ': { siblings: ['Ã', 'Ẵ', 'Ẫ'], tones: ['Ä', 'Ắ', 'Ằ', 'Ẵ', 'Ẳ', 'Ặ'] },84 'Ẳ': { siblings: ['Ả', 'Ẳ', 'Ẩ'], tones: ['Ä', 'Ắ', 'Ằ', 'Ẵ', 'Ẳ', 'Ặ'] },85 'Ặ': { siblings: ['Ạ', 'Ặ', 'Ậ'], tones: ['Ä', 'Ắ', 'Ằ', 'Ẵ', 'Ẳ', 'Ặ'] },86 'Ã': { siblings: ['A', 'Ä', 'Ã'], tones: ['Ã', 'Ấ', 'Ầ', 'Ẫ', 'Ẩ', 'Ậ'] },87 'Ấ': { siblings: ['Ã', 'Ắ', 'Ấ'], tones: ['Ã', 'Ấ', 'Ầ', 'Ẫ', 'Ẩ', 'Ậ'] },88 'Ầ': { siblings: ['Ã', 'Ằ', 'Ầ'], tones: ['Ã', 'Ấ', 'Ầ', 'Ẫ', 'Ẩ', 'Ậ'] },89 'Ẫ': { siblings: ['Ã', 'Ẵ', 'Ẫ'], tones: ['Ã', 'Ấ', 'Ầ', 'Ẫ', 'Ẩ', 'Ậ'] },90 'Ẩ': { siblings: ['Ả', 'Ẳ', 'Ẩ'], tones: ['Ã', 'Ấ', 'Ầ', 'Ẫ', 'Ẩ', 'Ậ'] },91 'Ậ': { siblings: ['Ạ', 'Ặ', 'Ậ'], tones: ['Ã', 'Ấ', 'Ầ', 'Ẫ', 'Ẩ', 'Ậ'] },92 'E': { siblings: ['E', 'Ã'], tones: ['E', 'Ã', 'Ã', 'Ẽ', 'Ẻ', 'Ẹ'] },93 'Ã': { siblings: ['Ã', 'Ế'], tones: ['E', 'Ã', 'Ã', 'Ẽ', 'Ẻ', 'Ẹ'] },94 'Ã': { siblings: ['Ã', 'á»'], tones: ['E', 'Ã', 'Ã', 'Ẽ', 'Ẻ', 'Ẹ'] },95 'Ẽ': { siblings: ['Ẽ', 'á»'], tones: ['E', 'Ã', 'Ã', 'Ẽ', 'Ẻ', 'Ẹ'] },96 'Ẻ': { siblings: ['Ẻ', 'á»'], tones: ['E', 'Ã', 'Ã', 'Ẽ', 'Ẻ', 'Ẹ'] },97 'Ẹ': { siblings: ['Ẹ', 'á»'], tones: ['E', 'Ã', 'Ã', 'Ẽ', 'Ẻ', 'Ẹ'] },98 'Ã': { siblings: ['E', 'Ã'], tones: ['Ã', 'Ế', 'á»', 'á»', 'á»', 'á»'] },99 'Ế': { siblings: ['Ã', 'Ế'], tones: ['Ã', 'Ế', 'á»', 'á»', 'á»', 'á»'] },100 'á»': { siblings: ['Ã', 'á»'], tones: ['Ã', 'Ế', 'á»', 'á»', 'á»', 'á»'] },101 'á»': { siblings: ['Ẽ', 'á»'], tones: ['Ã', 'Ế', 'á»', 'á»', 'á»', 'á»'] },102 'á»': { siblings: ['Ẻ', 'á»'], tones: ['Ã', 'Ế', 'á»', 'á»', 'á»', 'á»'] },103 'á»': { siblings: ['Ẹ', 'á»'], tones: ['Ã', 'Ế', 'á»', 'á»', 'á»', 'á»'] },104 'I': { siblings: [], tones: ['I', 'Ã', 'Ã', 'Ĩ', 'á»', 'á»'] },105 'Ã': { siblings: [], tones: ['I', 'Ã', 'Ã', 'Ĩ', 'á»', 'á»'] },106 'Ã': { siblings: [], tones: ['I', 'Ã', 'Ã', 'Ĩ', 'á»', 'á»'] },107 'Ĩ': { siblings: [], tones: ['I', 'Ã', 'Ã', 'Ĩ', 'á»', 'á»'] },108 'á»': { siblings: [], tones: ['I', 'Ã', 'Ã', 'Ĩ', 'á»', 'á»'] },109 'á»': { siblings: [], tones: ['I', 'Ã', 'Ã', 'Ĩ', 'á»', 'á»'] },110 'O': { siblings: ['O', 'Ã', 'Æ '], tones: ['O', 'Ã', 'Ã', 'Ã', 'á»', 'á»'] },111 'Ã': { siblings: ['Ã', 'á»', 'á»'], tones: ['O', 'Ã', 'Ã', 'Ã', 'á»', 'á»'] },112 'Ã': { siblings: ['Ã', 'á»', 'á»'], tones: ['O', 'Ã', 'Ã', 'Ã', 'á»', 'á»'] },113 'Ã': { siblings: ['Ã', 'á»', 'á» '], tones: ['O', 'Ã', 'Ã', 'Ã', 'á»', 'á»'] },114 'á»': { siblings: ['á»', 'á»', 'á»'], tones: ['O', 'Ã', 'Ã', 'Ã', 'á»', 'á»'] },115 'á»': { siblings: ['á»', 'á»', 'Ợ'], tones: ['O', 'Ã', 'Ã', 'Ã', 'á»', 'á»'] },116 'Ã': { siblings: ['O', 'Ã', 'Æ '], tones: ['Ã', 'á»', 'á»', 'á»', 'á»', 'á»'] },117 'á»': { siblings: ['Ã', 'á»', 'á»'], tones: ['Ã', 'á»', 'á»', 'á»', 'á»', 'á»'] },118 'á»': { siblings: ['Ã', 'á»', 'á»'], tones: ['Ã', 'á»', 'á»', 'á»', 'á»', 'á»'] },119 'á»': { siblings: ['Ã', 'á»', 'á» '], tones: ['Ã', 'á»', 'á»', 'á»', 'á»', 'á»'] },120 'á»': { siblings: ['á»', 'á»', 'á»'], tones: ['Ã', 'á»', 'á»', 'á»', 'á»', 'á»'] },121 'á»': { siblings: ['á»', 'á»', 'Ợ'], tones: ['Ã', 'á»', 'á»', 'á»', 'á»', 'á»'] },122 'Æ ': { siblings: ['O', 'Ã', 'Æ '], tones: ['Æ ', 'á»', 'á»', 'á» ', 'á»', 'Ợ'] },123 'á»': { siblings: ['Ã', 'á»', 'á»'], tones: ['Æ ', 'á»', 'á»', 'á» ', 'á»', 'Ợ'] },124 'á»': { siblings: ['Ã', 'á»', 'á»'], tones: ['Æ ', 'á»', 'á»', 'á» ', 'á»', 'Ợ'] },125 'á» ': { siblings: ['Ã', 'á»', 'á» '], tones: ['Æ ', 'á»', 'á»', 'á» ', 'á»', 'Ợ'] },126 'á»': { siblings: ['á»', 'á»', 'á»'], tones: ['Æ ', 'á»', 'á»', 'á» ', 'á»', 'Ợ'] },127 'Ợ': { siblings: ['á»', 'á»', 'Ợ'], tones: ['Æ ', 'á»', 'á»', 'á» ', 'á»', 'Ợ'] },128 'U': { siblings: ['U', 'Ư'], tones: ['U', 'Ã', 'Ã', 'Ũ', 'Ủ', 'Ụ'] },129 'Ã': { siblings: ['Ã', 'Ứ'], tones: ['U', 'Ã', 'Ã', 'Ũ', 'Ủ', 'Ụ'] },130 'Ã': { siblings: ['Ã', 'Ừ'], tones: ['U', 'Ã', 'Ã', 'Ũ', 'Ủ', 'Ụ'] },131 'Ũ': { siblings: ['Ũ', 'á»®'], tones: ['U', 'Ã', 'Ã', 'Ũ', 'Ủ', 'Ụ'] },132 'Ủ': { siblings: ['Ủ', 'Ử'], tones: ['U', 'Ã', 'Ã', 'Ũ', 'Ủ', 'Ụ'] },133 'Ụ': { siblings: ['Ụ', 'á»°'], tones: ['U', 'Ã', 'Ã', 'Ũ', 'Ủ', 'Ụ'] },134 'Ư': { siblings: ['U', 'Ư'], tones: ['Ư', 'Ứ', 'Ừ', 'á»®', 'Ử', 'á»°'] },135 'Ứ': { siblings: ['Ã', 'Ứ'], tones: ['Ư', 'Ứ', 'Ừ', 'á»®', 'Ử', 'á»°'] },136 'Ừ': { siblings: ['Ã', 'Ừ'], tones: ['Ư', 'Ứ', 'Ừ', 'á»®', 'Ử', 'á»°'] },137 'á»®': { siblings: ['Ũ', 'á»®'], tones: ['Ư', 'Ứ', 'Ừ', 'á»®', 'Ử', 'á»°'] },138 'Ử': { siblings: ['Ủ', 'Ử'], tones: ['Ư', 'Ứ', 'Ừ', 'á»®', 'Ử', 'á»°'] },139 'á»°': { siblings: ['Ụ', 'á»°'], tones: ['Ư', 'Ứ', 'Ừ', 'á»®', 'Ử', 'á»°'] },140 'Y': { siblings: [], tones: ['Y', 'Ã', 'Ỳ', 'Ỹ', 'Ỷ', 'á»´'] },141 'Ã': { siblings: [], tones: ['Y', 'Ã', 'Ỳ', 'Ỹ', 'Ỷ', 'á»´'] },142 'Ỳ': { siblings: [], tones: ['Y', 'Ã', 'Ỳ', 'Ỹ', 'Ỷ', 'á»´'] },143 'Ỹ': { siblings: [], tones: ['Y', 'Ã', 'Ỳ', 'Ỹ', 'Ỷ', 'á»´'] },144 'Ỷ': { siblings: [], tones: ['Y', 'Ã', 'Ỳ', 'Ỹ', 'Ỷ', 'á»´'] },145 'á»´': { siblings: [], tones: ['Y', 'Ã', 'Ỳ', 'Ỹ', 'Ỷ', 'á»´'] },146 'd': { siblings: ['d', 'Ä'], tones: [] },147 'Ä': { siblings: ['d', 'Ä'], tones: [] },148 'D': { siblings: ['D', 'Ä'], tones: [] },149 'Ä': { siblings: ['D', 'Ä'], tones: [] }150};...
Ship.js
Source:Ship.js
1class Ship {2 constructor() {3 this.x = null;4 this.y = null;5 this.possibleCells = [];6 this.currentCEllsShip = [];7 this.currentSiblingsForNextStep = [];8 this.currentSiblingsShip = [];9 this.allShipsPlayer = [];10 this.killedShips = [];11 this.killedShipsPlayers = [];12 this.i = 0;13 this.j = 0;14 this.lengthShip = 4;15 this.amount = 1;16 }1718 init(setting, board, boardPlayer, game) {19 this.setting = setting;20 this.board = board;21 this.boardPlayer = boardPlayer;22 this.game = game;23 }2425 getAllPossibleCells() {26 this.possibleCells = [];27 for (let y = 1; y <= this.setting.rowsCount; y++) {28 for (let x = 1; x <= this.setting.colsCount; x++) {29 let arr = {30 x: x,31 y: y32 };33 this.possibleCells.push(arr);34 }35 }36 }37 // ÑаÑÑÑавлÑÑ ÐºÐ°Ñабли. Length - наÑаÑÐ¸Ð²Ð°ÐµÑ Ð¿Ð°Ð»ÑбÑ. Цикл Ñ J - колиÑеÑÑво каждÑÑ
каÑаблей38 arrangeShips(event) {39 while (this.lengthShip > 0 && this.amount < 5) {40 for (this.j; this.j < this.amount; this.j++) {41 for (this.i; this.i < this.lengthShip; this.i++) {42 if (event) {43 this.getPlayerArrange(event);44 return;45 }46 if (this.i == 0) {47 this.currentCEllsShip = [];48 this.currentSiblingsForNextStep = [];49 this.currentSiblingsShip = [];50 // иÑÑ Ð¿ÐµÑвÑÑ ÑÑейкÑ51 this.getFirstCell(this.lengthShip);52 } else {53 this.getNextCells(this.lengthShip);54 }55 }56 this.i = 0;57 this.deleteCellsFromArr(this.currentSiblingsShip, this.possibleCells);58 this.deleteCellsFromArr(this.currentCEllsShip, this.possibleCells);59 this.currentCEllsShip = [];60 this.currentSiblingsShip = [];61 }62 this.j = 0;63 this.amount++;64 this.lengthShip--;65 }66 this.lengthShip = 4;67 this.amount = 1;68 }69 getPlayerArrange(event) {70 let cellsForNextStep = this.getSiblingsCoordsForNextStep(this.x, this.y);71 let coords = this.getCoordsPlayerSell(event);72 if (!(this.i == 0)) {73 if (!this.isArrayHaveElem(cellsForNextStep, coords)) {74 this.game.message.innerText =75 "ÐалÑÐ±Ñ ÐºÐ¾ÑÐ°Ð±Ð»Ñ Ð´Ð¾Ð»Ð¶Ð½Ñ Ð½Ð°Ñ
одиÑÑÑ ÑÑдом";76 return;77 }78 }79 this.x = coords.x;80 this.y = coords.y;81 let currentCell = {82 x: this.x,83 y: this.y84 };8586 let currentSiblings = this.getSiblingsCoords(this.x, this.y);87 if (this.isSiblingsNotEmpty(currentSiblings)) {88 this.game.message.innerText = "ÐоÑабли не могÑÑ ÑÑоÑÑÑ ÑÑдом";89 return;90 }91 this.renderPlayerCell(event);92 this.allShipsPlayer.push(currentCell);93 this.i++;94 if (this.i == this.lengthShip) {95 this.j++;96 this.i = 0;97 if(this.j==4) this.game.messageStatus.innerText = "ÐÐ°Ñ Ñ
од";98 }99 return;100 }101 getCoordsPlayerSell(event) {102 let coords = {103 x: event.target.offsetLeft / Math.floor(event.target.offsetParent.offsetWidth / this.setting.colsCount) + 1,104 y: event.target.offsetTop / Math.floor(event.target.offsetParent.offsetHeight / this.setting.rowsCount) + 1105 }106 return coords;107 }108 renderPlayerCell(event) {109 let cell = event.target;110 cell.style.background = "green";111 cell.setAttribute("deck-player", `${this.lengthShip}`);112 cell.dataset.number = `${this.j}`;113 cell.innerText = `${this.lengthShip}`;114 }115 getFirstCell() {116 // полÑÑÐ°Ñ ÑандомнÑй ÑлеменÑ117118 let randomCell = this.getRandomCoords(this.possibleCells);119 let cellShip = this.board.getCellElem(randomCell.x, randomCell.y);120 cellShip.setAttribute("deck", `${this.lengthShip}`);121 cellShip.dataset.number = `${this.j}`;122 this.getAllSiblings(randomCell.x, randomCell.y,this.board);123124 //добавлÑÑ Ð³Ð¾ÑовÑÑ ÑÑÐµÐ¹ÐºÑ Ð² маÑÑив Ñ
ÑанÑÑий вÑе ÑÑейки ÑекÑÑего коÑаблÑ125 this.currentCEllsShip.push(randomCell);126 if (this.lengthShip > 1) {127 //Ñ ÑекÑÑей ÑÑейки Ð´ÐµÐ»Ð°Ñ Ð²ÑбоÑÐºÑ ÐºÐ¾Ð¾ÑÐ´Ð¸Ð½Ð°Ñ Ð´Ð»Ñ Ð¿Ð¾ÑледÑÑиÑ
ваÑианÑов Ñ
ода128 this.getSiblingsForNextStep(randomCell.x, randomCell.y,this.board);129 }130 }131 getRandomCoords(array) {132 return array[Math.floor(Math.random() * array.length)];133 }134 getNextCells() { 135 let nextCellCoords=this.getRandomCoords(this.currentSiblingsForNextStep);136 let nextCellShip = this.board.getCellElem(nextCellCoords.x, nextCellCoords.y);137 nextCellShip.setAttribute("deck", `${this.lengthShip}`);138 nextCellShip.dataset.number = `${this.j}`139 this.currentCEllsShip.push(nextCellCoords); 140 this.deleteCellFromArray(nextCellCoords,this.currentSiblingsForNextStep);141142 this.x = nextCellCoords.x;143 this.y = nextCellCoords.y;144145 let currentCoord = {146 x: this.x,147 y: this.y148 };149 this.deleteCellFromArray(currentCoord, this.currentSiblingsShip);150 this.getAllSiblings(this.x, this.y,this.board);151 this.getSiblingsForNextStep(this.x, this.y,this.board);152 }153154 getSiblingsForNextStep(x, y,field) {155 let siblingsCoordsForNextStep = this.getSiblingsCoordsForNextStep(x, y);156 for (let elem of siblingsCoordsForNextStep) {157 if (this.possibleCells.find(element => element.x == elem.x && element.y == elem.y)) {158 let siblingsForNextStep = field.getCellElem(elem.x, elem.y);159 if (this.currentSiblingsForNextStep.find(element => element.x == elem.x && element.y == elem.y))160 continue;161 if (siblingsForNextStep != null && siblingsForNextStep.getAttribute("deck") == null) {162 this.currentSiblingsForNextStep.push(elem);163 }164 }165 }166 }167168 getSiblingsCoordsForNextStep(x, y) {169 let siblings = [{170 x: x,171 y: y - 1172 },173 {174 x: x - 1,175 y: y176 },177 {178 x: x + 1,179 y: y180 },181 {182 x: x,183 y: y + 1184 }185 ];186 return siblings;187 } 188189 getAllSiblings(x, y,field) {190 let siblingsCoords = this.getSiblingsCoords(x, y);191 for (let elem of siblingsCoords) {192 let siblings = field.getCellElem(elem.x, elem.y);193 if (this.isArrayHaveElem(this.currentSiblingsShip, elem)) continue;194 if (siblings != null && siblings.getAttribute("deck") == null) {195 this.currentSiblingsShip.push(elem);196 }197 }198 }199200 getSiblingsCoords(x, y) {201 let siblingsCoords = [{202 x: x - 1,203 y: y - 1204 },205 {206 x: x,207 y: y - 1208 },209 {210 x: x + 1,211 y: y - 1212 },213 {214 x: x - 1,215 y: y216 },217 {218 x: x + 1,219 y: y220 },221 {222 x: x,223 y: y + 1224 },225 {226 x: x - 1,227 y: y + 1228 },229 {230 x: x + 1,231 y: y + 1232 }233 ];234 return siblingsCoords;235 }236237 isArrayHaveElem(array, elem) {238 let alreadyHave = array.find(element => element.x == elem.x && element.y == elem.y);239 return alreadyHave;240 }241 242 isSiblingsNotEmpty(currentSiblings) {243 for (let current of currentSiblings) {244 let siblings = this.boardPlayer.getCellElem(current.x, current.y);245 if (siblings == null) continue;246 if (siblings.getAttribute("deck-player") == `${this.lengthShip}` && siblings.getAttribute("data-number") == `${this.j}`) continue;247 if (siblings.hasAttribute("deck-player")) return true;248 }249 }250 deleteCellFromArray(cell, array) {251 let index = array.findIndex(252 item => item.x === cell.x && item.y === cell.y253 );254 if(index!=-1){255 array.splice(index, 1);256 } 257 }258 deleteCellsFromArr(arr, array) {259 for (let current of arr) {260 let alreadyHave = array.find(261 element => element.x == current.x && element.y == current.y262 );263 if (alreadyHave) {264 array.splice(array.indexOf(alreadyHave), 1);265 }266 }267 }
...
register.js
Source:register.js
...68 regStatus.phone = true;69 //å¤æææºå·æ¯å¦æ£ç¡®70 if( !regPhone.test(phone) ){71 $(this).css('border-color','#ff6f4a');72 $(this).siblings('.con-title').show();73 $(this).siblings('.con-ok').hide();74 regStatus.phone = false;75 return;76 }77 var _this = this;78 //å¤æææºå·æ¯å¦å·²è¢«æ³¨å79 $.ajax({80 url: 'http://10.9.151.199/PC-Project-Admin/checkAccount.php',81 data: {82 account: phone83 },84 dataType: 'jsonp',85 success: function(result){86 if(result.status){87 $(_this).siblings('.con-title').hide();88 $(_this).siblings('.con-ok').show();89 }else{90 $(_this).siblings('.con-title').show();91 $(_this).siblings('.con-ok').hide();92 regStatus.phone = false;93 }94 }95 });96 });97 contentphone.click(function(){98 $(this).siblings('.con-title').hide();99 });100 /*éªè¯ç éªè¯ (失ç¦éªè¯ éªè¯ç æ¯å¦åæ³ ä¸åæ³æ示è¾å
¥éªè¯ç )*/101 var regverify = /^[a-z1-9]{4}$/;102 contentverify.blur(function(){103 $(this).css('border-color','#ff6f4a');104 var verify = contentverify.val();105 var verify1 = bgColor.html();106 //å¤æéªè¯ç æ¯å¦æ£ç¡®107 if( regverify.test(verify) && verify == verify1){108 $(this).siblings('.con-title').hide();109 $(this).siblings('.con-ok').show();110 $(this).css('border-color','#ddd');111 regStatus.verify = true;112 return;113 }else{114 $(this).siblings('.con-title').show();115 $(this).siblings('.con-ok').hide();116 }117 });118 contentverify.click(function(){119 $(this).siblings('.con-title').hide();120 });121 /*çä¿¡éªè¯ç éªè¯ (失ç¦éªè¯ éªè¯ç æ¯å¦åæ³ ä¸åæ³æ示è¾å
¥éªè¯ç )*/122 var regText = /^\d{6}$/;123 contextclick.blur(function(){124 $(this).siblings('.con-title').show();125 //è·åçä¿¡éªè¯ç å
容126 var textval = contextclick.val();127 //å¤ææ¯å¦æ£ç¡®128 if( regText.test(textval) ){129 $(this).siblings('.con-title').hide();130 $(this).siblings('.con-ok').show();131 regStatus.text = true;132 return;133 }134 });135 contextclick.click(function(){136 $(this).siblings('.con-title').hide();137 });138 /*ç¨æ·åéªè¯ (失ç¦éªè¯ ç¨æ·åæ¯å¦åæ³ å¹¶ä¸è¦è·æ°æ®åºéçæ¯è¾)*/139 var regUser = /^\w{4,20}$/;140 contentuser.blur(function(){141 $(this).css('border-color','#ff6f4a');142 var user = contentuser.val();143 //å设ç¨æ·åæ£ç¡®144 regStatus.uname = true;145 //å¤æç¨æ·åæ¯å¦æ£ç¡®146 if( !regUser.test(user) ){147 $(this).siblings('.con-title').show();148 $(this).siblings('.con-ok').hide();149 regStatus.uname = false;150 return;151 }else{152 $(this).siblings('.con-title').hide();153 $(this).siblings('.con-ok').show();154 $(this).css('border-color','#ddd');155 }156 var _this = this;157 //å¤æç¨æ·åæ¯å¦å·²è¢«æ³¨å158 $.ajax({159 url: 'http://10.9.151.199/PC-Project-Admin/checkAccount.php',160 data: {161 account: user162 },163 dataType: 'jsonp',164 success: function(result){165 if(result.status){166 //ç¨æ·åå¯ç¨167 $(_this).siblings('.con-title').hide();168 $(_this).siblings('.con-ok').hide();169 $(_this).siblings('..con-exist').show();170 $(_this).css('border-color','#ff6f4a');171 }else{172 //ç¨æ·åå·²åå¨173 $(_this).siblings('.con-title').show();174 $(_this).siblings('.con-ok').hide();175 regStatus.uname = false;176 }177 }178 });179 });180 contentuser.click(function(){181 $(this).siblings('.con-title').hide();182 });183 /*å¯ç éªè¯ (å¯ç ç¹å»åå¤±ç¦ )*/184 var regPwd = /^[\w!@#$%^&*+]{8,20}$/;185 var regRuo = /^\d{1,5}|[a-z]{1,5}$/;186 var regQiang = /^[!@#$%^&*+]{8,}$/187 //失ç¦å¤æ188 contentpwd.blur(function(){189 var pwd = contentpwd.val();190 $(this).parents('.content1').find('.con-passwordstr').hide();191 $(this).siblings('.con-title').show();192 //å¦æå¯ç 满足æ¡ä»¶å°±æ¾ç¤º193 if( regPwd.test(pwd) ){194 $(this).siblings('.con-ok').show();195 $(this).siblings('.con-title').hide();196 regStatus.pwd = true;197 }else{198 $(this).siblings('.con-ok').hide();199 $(this).siblings('.con-title').show();200 }201 });202 //ç¹å»æ¶åç¶æ203 contentpwd.click(function(){204 $(this).parents('.content1').find('.con-passwordstr').show();205 $(this).siblings('.con-title').hide();206 });207 //è¾å
¥çæ¶åå¤æå¯ç 强度208 contentpwd.on('input',function(){209 var pwd = contentpwd.val();210 if( regQiang.test(pwd) ){211 $(this).parents('.content1')212 .find('.contentpwdruo').css('background-color','#fc9720')213 .siblings('.contentpwdzhong').css('background-color','#fc9720')214 .siblings('.contentpwdqiang').css('background-color','#fc9720');215 }else if( regRuo.test(pwd) ){216 $(this).parents('.content1')217 .find('.contentpwdruo').css('background-color','#fc9720');218 }else if( !pwd){219 $(this).parents('.content1')220 .find('.contentpwdruo').css('background-color','#eee')221 .siblings('.contentpwdzhong').css('background-color','#eee')222 .siblings('.contentpwdqiang').css('background-color','#eee');223 }else{224 $(this).parents('.content1')225 .find('.contentpwdruo').css('background-color','#fc9720')226 .siblings('.contentpwdzhong').css('background-color','#fc9720');227 };228 });229 /*确认å¯ç (å¤æä¿©å¯ç ä¸æ ·ä¹)*/230 contentconfirm.blur(function(){231 var pwd = contentpwd.val();232 var cfpwd = contentconfirm.val();233 $(this).siblings('.con-title').show();234 //å¦æ确认å¯ç 满足æ¡ä»¶å°±æ¾ç¤º235 if( pwd == cfpwd ){236 $(this).siblings('.con-ok').show();237 $(this).siblings('.con-title').hide();238 regStatus.confirm = true;239 }else{240 $(this).siblings('.con-ok').hide();241 $(this).siblings('.con-title').show();242 regStatus.confirm = false;243 }244 });245 //ç¹å»æ¶åç¶æ246 contentconfirm.click(function(){247 $(this).siblings('.con-title').hide();248 });249 /**/250 //ç¹å»ç»å½251 registnow.on('mouseenter',function(){252 //å¤æææçä¿¡æ¯ç¶æï¼å¦ææä¸åæ³çï¼ä¸è½æ³¨å253 if(regStatus.confirm && regStatus.pwd && regStatus.uname && regStatus.text && regStatus.verify && regStatus.phone){254 $(this).css({"background-color":"#33cb98 ","color":"#fff"});255 }else{256 alert('é¨åæ°æ®ä¸åæ³');257 };258 })259 registnow.click(function(){260 261 //éè¿ajaxæ交表åæ°æ®...
pseudos.js
Source:pseudos.js
1/* */ 2var DomUtils = require('domutils'),3 isTag = DomUtils.isTag,4 getText = DomUtils.getText,5 getParent = DomUtils.getParent,6 getChildren = DomUtils.getChildren,7 getSiblings = DomUtils.getSiblings,8 hasAttrib = DomUtils.hasAttrib,9 getName = DomUtils.getName,10 getAttribute = DomUtils.getAttributeValue,11 getNCheck = require('nth-check'),12 checkAttrib = require('./attributes').rules.equals,13 BaseFuncs = require('boolbase'),14 trueFunc = BaseFuncs.trueFunc,15 falseFunc = BaseFuncs.falseFunc;16function getFirstElement(elems) {17 for (var i = 0; elems && i < elems.length; i++) {18 if (isTag(elems[i]))19 return elems[i];20 }21}22function getAttribFunc(name, value) {23 var data = {24 name: name,25 value: value26 };27 return function attribFunc(next) {28 return checkAttrib(next, data);29 };30}31function getChildFunc(next) {32 return function(elem) {33 return !!getParent(elem) && next(elem);34 };35}36var filters = {37 contains: function(next, text) {38 return function contains(elem) {39 return next(elem) && getText(elem).indexOf(text) >= 0;40 };41 },42 icontains: function(next, text) {43 var itext = text.toLowerCase();44 return function icontains(elem) {45 return next(elem) && getText(elem).toLowerCase().indexOf(itext) >= 0;46 };47 },48 "nth-child": function(next, rule) {49 var func = getNCheck(rule);50 if (func === falseFunc)51 return func;52 if (func === trueFunc)53 return getChildFunc(next);54 return function nthChild(elem) {55 var siblings = getSiblings(elem);56 for (var i = 0,57 pos = 0; i < siblings.length; i++) {58 if (isTag(siblings[i])) {59 if (siblings[i] === elem)60 break;61 else62 pos++;63 }64 }65 return func(pos) && next(elem);66 };67 },68 "nth-last-child": function(next, rule) {69 var func = getNCheck(rule);70 if (func === falseFunc)71 return func;72 if (func === trueFunc)73 return getChildFunc(next);74 return function nthLastChild(elem) {75 var siblings = getSiblings(elem);76 for (var pos = 0,77 i = siblings.length - 1; i >= 0; i--) {78 if (isTag(siblings[i])) {79 if (siblings[i] === elem)80 break;81 else82 pos++;83 }84 }85 return func(pos) && next(elem);86 };87 },88 "nth-of-type": function(next, rule) {89 var func = getNCheck(rule);90 if (func === falseFunc)91 return func;92 if (func === trueFunc)93 return getChildFunc(next);94 return function nthOfType(elem) {95 var siblings = getSiblings(elem);96 for (var pos = 0,97 i = 0; i < siblings.length; i++) {98 if (isTag(siblings[i])) {99 if (siblings[i] === elem)100 break;101 if (getName(siblings[i]) === getName(elem))102 pos++;103 }104 }105 return func(pos) && next(elem);106 };107 },108 "nth-last-of-type": function(next, rule) {109 var func = getNCheck(rule);110 if (func === falseFunc)111 return func;112 if (func === trueFunc)113 return getChildFunc(next);114 return function nthLastOfType(elem) {115 var siblings = getSiblings(elem);116 for (var pos = 0,117 i = siblings.length - 1; i >= 0; i--) {118 if (isTag(siblings[i])) {119 if (siblings[i] === elem)120 break;121 if (getName(siblings[i]) === getName(elem))122 pos++;123 }124 }125 return func(pos) && next(elem);126 };127 },128 root: function(next) {129 return function(elem) {130 return !getParent(elem) && next(elem);131 };132 },133 scope: function(next, rule, options, context) {134 if (!context || context.length === 0) {135 return filters.root(next);136 }137 if (context.length === 1) {138 return function(elem) {139 return context[0] === elem && next(elem);140 };141 }142 return function(elem) {143 return context.indexOf(elem) >= 0 && next(elem);144 };145 },146 checkbox: getAttribFunc("type", "checkbox"),147 file: getAttribFunc("type", "file"),148 password: getAttribFunc("type", "password"),149 radio: getAttribFunc("type", "radio"),150 reset: getAttribFunc("type", "reset"),151 image: getAttribFunc("type", "image"),152 submit: getAttribFunc("type", "submit")153};154var pseudos = {155 empty: function(elem) {156 return !getChildren(elem).some(function(elem) {157 return isTag(elem) || elem.type === "text";158 });159 },160 "first-child": function(elem) {161 return getFirstElement(getSiblings(elem)) === elem;162 },163 "last-child": function(elem) {164 var siblings = getSiblings(elem);165 for (var i = siblings.length - 1; i >= 0; i--) {166 if (siblings[i] === elem)167 return true;168 if (isTag(siblings[i]))169 break;170 }171 return false;172 },173 "first-of-type": function(elem) {174 var siblings = getSiblings(elem);175 for (var i = 0; i < siblings.length; i++) {176 if (isTag(siblings[i])) {177 if (siblings[i] === elem)178 return true;179 if (getName(siblings[i]) === getName(elem))180 break;181 }182 }183 return false;184 },185 "last-of-type": function(elem) {186 var siblings = getSiblings(elem);187 for (var i = siblings.length - 1; i >= 0; i--) {188 if (isTag(siblings[i])) {189 if (siblings[i] === elem)190 return true;191 if (getName(siblings[i]) === getName(elem))192 break;193 }194 }195 return false;196 },197 "only-of-type": function(elem) {198 var siblings = getSiblings(elem);199 for (var i = 0,200 j = siblings.length; i < j; i++) {201 if (isTag(siblings[i])) {202 if (siblings[i] === elem)203 continue;204 if (getName(siblings[i]) === getName(elem))205 return false;206 }207 }208 return true;209 },210 "only-child": function(elem) {211 var siblings = getSiblings(elem);212 for (var i = 0; i < siblings.length; i++) {213 if (isTag(siblings[i]) && siblings[i] !== elem)214 return false;215 }216 return true;217 },218 link: function(elem) {219 return hasAttrib(elem, "href");220 },221 visited: falseFunc,222 selected: function(elem) {223 if (hasAttrib(elem, "selected"))224 return true;225 else if (getName(elem) !== "option")226 return false;227 var parent = getParent(elem);228 if (!parent || getName(parent) !== "select" || hasAttrib(parent, "multiple"))229 return false;230 var siblings = getChildren(parent),231 sawElem = false;232 for (var i = 0; i < siblings.length; i++) {233 if (isTag(siblings[i])) {234 if (siblings[i] === elem) {235 sawElem = true;236 } else if (!sawElem) {237 return false;238 } else if (hasAttrib(siblings[i], "selected")) {239 return false;240 }241 }242 }243 return sawElem;244 },245 disabled: function(elem) {246 return hasAttrib(elem, "disabled");247 },248 enabled: function(elem) {249 return !hasAttrib(elem, "disabled");250 },251 checked: function(elem) {252 return hasAttrib(elem, "checked") || pseudos.selected(elem);253 },254 required: function(elem) {255 return hasAttrib(elem, "required");256 },257 optional: function(elem) {258 return !hasAttrib(elem, "required");259 },260 parent: function(elem) {261 return !pseudos.empty(elem);262 },263 header: function(elem) {264 var name = getName(elem);265 return name === "h1" || name === "h2" || name === "h3" || name === "h4" || name === "h5" || name === "h6";266 },267 button: function(elem) {268 var name = getName(elem);269 return name === "button" || name === "input" && getAttribute(elem, "type") === "button";270 },271 input: function(elem) {272 var name = getName(elem);273 return name === "input" || name === "textarea" || name === "select" || name === "button";274 },275 text: function(elem) {276 var attr;277 return getName(elem) === "input" && (!(attr = getAttribute(elem, "type")) || attr.toLowerCase() === "text");278 }279};280function verifyArgs(func, name, subselect) {281 if (subselect === null) {282 if (func.length > 1 && name !== "scope") {283 throw new SyntaxError("pseudo-selector :" + name + " requires an argument");284 }285 } else {286 if (func.length === 1) {287 throw new SyntaxError("pseudo-selector :" + name + " doesn't have any arguments");288 }289 }290}291var re_CSS3 = /^(?:(?:nth|last|first|only)-(?:child|of-type)|root|empty|(?:en|dis)abled|checked|not)$/;292module.exports = {293 compile: function(next, data, options, context) {294 var name = data.name,295 subselect = data.data;296 if (options && options.strict && !re_CSS3.test(name)) {297 throw SyntaxError(":" + name + " isn't part of CSS3");298 }299 if (typeof filters[name] === "function") {300 verifyArgs(filters[name], name, subselect);301 return filters[name](next, subselect, options, context);302 } else if (typeof pseudos[name] === "function") {303 var func = pseudos[name];304 verifyArgs(func, name, subselect);305 if (next === trueFunc)306 return func;307 return function pseudoArgs(elem) {308 return func(elem, subselect) && next(elem);309 };310 } else {311 throw new SyntaxError("unmatched pseudo-class :" + name);312 }313 },314 filters: filters,315 pseudos: pseudos...
imagefield_crop.js
Source:imagefield_crop.js
...45 marginTop: '-' + Math.round(ry * c.y) + 'px',46 display: 'block'47 });48 // Crop image even if user has left image untouched.49 $(widget).siblings('.preview-existing').css({display: 'none'});50 $(widget).siblings(".edit-image-crop-x").val(c.x);51 $(widget).siblings(".edit-image-crop-y").val(c.y);52 if (c.w) $(widget).siblings(".edit-image-crop-width").val(c.w);53 if (c.h) $(widget).siblings(".edit-image-crop-height").val(c.h);54 $(widget).siblings(".edit-image-crop-changed").val(1);55 },56 onSelect: function(c) {57 $(widget).siblings('.preview-existing').css({display: 'none'});58 $(widget).siblings(".edit-image-crop-x").val(c.x);59 $(widget).siblings(".edit-image-crop-y").val(c.y);60 if (c.w) $(widget).siblings(".edit-image-crop-width").val(c.w);61 if (c.h) $(widget).siblings(".edit-image-crop-height").val(c.h);62 $(widget).siblings(".edit-image-crop-changed").val(1);63 },64 aspectRatio: settings.imagefield_crop[id].box.ratio,65 boxWidth: settings.imagefield_crop[id].box.box_width,66 boxHeight: settings.imagefield_crop[id].box.box_height,67 minSize: [Drupal.settings.imagefield_crop[id].minimum.width, Drupal.settings.imagefield_crop[id].minimum.height], 68 /*69 * Setting the select here calls onChange event, and we lose the original image visibility70 */71 setSelect: [72 parseInt($(widget).siblings(".edit-image-crop-x").val()),73 parseInt($(widget).siblings(".edit-image-crop-y").val()),74 parseInt($(widget).siblings(".edit-image-crop-width").val()) + parseInt($(widget).siblings(".edit-image-crop-x").val()),75 parseInt($(widget).siblings(".edit-image-crop-height").val()) + parseInt($(widget).siblings(".edit-image-crop-y").val())76 ]77 });78 });79 };80 }81};...
wdg_teams_classification_01.js
Source:wdg_teams_classification_01.js
...12 event.preventDefault();13 });14 15 $this.find('a.prev').bind(Pointer.DOWN,function(){16 $(this).parent().parent().siblings('.scroll').animate({17 'scrollTop': $theUl.scrollTop() - $theUl.height() - 218 }, 500);19 });20 21 $this.find('a.next').bind(Pointer.DOWN,function(){22 $(this).parent().parent().siblings('.scroll').animate({23 'scrollTop': $theUl.scrollTop() + $theUl.height() + 224 }, 500);25 });26 });27 28 /*Swipe*/29 $(document).ready(function(){30 $wtc = 164;31 $('.wdg_teams_classification_01 .scroll').bind('swipeup',function(){32 $(this).animate({33 'scrollTop': $(this).scrollTop() + $wtc34 }, 500);35 });36 $('.wdg_teams_classification_01 .scroll').bind('swipedown',function(){37 $(this).animate({38 'scrollTop': $(this).scrollTop() - $wtc39 }, 500);40 }); 41 });42 43 44 /*Monitoreo scroll*/45 var $wtc_altura = $('.wdg_teams_classification_01 .datos').height();46 $('.wdg_teams_classification_01 .scroll').scroll(function() {47 48 49 50 if($(this).scrollTop() + $(this).height() == $wtc_altura) {51 $(this).siblings('.degraded').css("visibility","hidden");52 //$(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings().children('.tvsa-caret-down').css('color','#000');53 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.next').addClass('bginactive');54 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.next').removeClass('bgactive');55 }56 else if ($.browser.msie && parseInt($.browser.version, 10) <= 8 && $(this).scrollTop() >= 475){57 58 $(this).siblings('.degraded').css("visibility","hidden");59 60 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.next').addClass('bginactive');61 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.next').removeClass('bgactive');62 }63 else{64 $(this).siblings('.degraded').css("visibility","visible");65 //$(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings().children('.tvsa-caret-down').css('color','#FFF');66 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.next').addClass('bgactive');67 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.next').removeClass('bginactive');68 }69 70 if($(this).scrollTop() == 0){71 //$(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings().children('.tvsa-caret-up').css('color','#000');72 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.prev').addClass('bginactive');73 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.prev').removeClass('bgactive');74 }75 else76 {77 //$(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings().children('.tvsa-caret-up').css('color','#FFF'); 78 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.prev').addClass('bgactive');79 $(this).siblings('.wdg_teams_classification_01_cnt').children().children().siblings('.prev').removeClass('bginactive');80 }81 }); 82 })($,Televisa);...
general.js
Source:general.js
1/* */ 2var DomUtils = require('domutils'),3 isTag = DomUtils.isTag,4 getParent = DomUtils.getParent,5 getChildren = DomUtils.getChildren,6 getSiblings = DomUtils.getSiblings,7 getName = DomUtils.getName;8module.exports = {9 __proto__: null,10 attribute: require('./attributes').compile,11 pseudo: require('./pseudos').compile,12 tag: function(next, data) {13 var name = data.name;14 return function tag(elem) {15 return getName(elem) === name && next(elem);16 };17 },18 descendant: function(next, rule, options, context, acceptSelf) {19 return function descendant(elem) {20 if (acceptSelf && next(elem))21 return true;22 var found = false;23 while (!found && (elem = getParent(elem))) {24 found = next(elem);25 }26 return found;27 };28 },29 parent: function(next, data, options) {30 if (options && options.strict)31 throw SyntaxError("Parent selector isn't part of CSS3");32 return function parent(elem) {33 return getChildren(elem).some(test);34 };35 function test(elem) {36 return isTag(elem) && next(elem);37 }38 },39 child: function(next) {40 return function child(elem) {41 var parent = getParent(elem);42 return !!parent && next(parent);43 };44 },45 sibling: function(next) {46 return function sibling(elem) {47 var siblings = getSiblings(elem);48 for (var i = 0; i < siblings.length; i++) {49 if (isTag(siblings[i])) {50 if (siblings[i] === elem)51 break;52 if (next(siblings[i]))53 return true;54 }55 }56 return false;57 };58 },59 adjacent: function(next) {60 return function adjacent(elem) {61 var siblings = getSiblings(elem),62 lastElement;63 for (var i = 0; i < siblings.length; i++) {64 if (isTag(siblings[i])) {65 if (siblings[i] === elem)66 break;67 lastElement = siblings[i];68 }69 }70 return !!lastElement && next(lastElement);71 };72 },73 universal: function(next) {74 return next;75 }...
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.pause()4 cy.contains('type').click()5 cy.url().should('include', '/commands/actions')6 cy.get('.action-email')7 .type('
Using AI Code Generation
1describe("My first test suite", function () {2 it("My first test case", function () {3 cy.get("#opentab").invoke("removeAttr", "target").click();4 cy.url().should("include", "rahulshettyacademy");5 cy.go("back");6 cy.get("#name").type("Hello");7 cy.get("#alertbtn").click();8 cy.get("[value='Confirm']").click();9 cy.on("window:alert", (str) => {10 expect(str).to.equal("Hello , share this practice page and share your knowledge");11 });12 cy.on("window:confirm", (str) => {13 expect(str).to.equal("Hello , Are you sure you want to confirm?");14 });15 cy.get("#opentab").then(function (el) {16 const url = el.prop("href");17 cy.log(url);18 cy.visit(url);19 });20 cy.get("#displayed-text").should("be.visible");21 cy.get("#hide-textbox").click();22 cy.get("#displayed-text").should("not.be.visible");23 cy.get("#show-textbox").click();24 cy.get("#displayed-text").should("be.visible");25 cy.get("#radio-btn-example").find("input[value='radio2']").check();26 cy.get("#radio-btn-example").find("input[value='radio2']").should("be.checked");27 cy.get("select").select("option2").should("have.value", "option2");28 cy.get("#autocomplete").type("ind");29 cy.get(".ui-menu-item div").each(($el, index, $list) => {30 if ($el.text() === "India") {31 $el.click();32 }33 });34 cy.get("#autocomplete").should("have.value", "India");35 cy.get("#checkbox-example").find("input[value='option2']").check();36 cy.get("#checkbox-example").find("input[value='option2']").should("be.checked");37 cy.get("#checkbox-example").find("input[value='option1']").uncheck();38 cy.get("#checkbox
Using AI Code Generation
1describe('Test sibling method of cypress', () => {2 it('Test sibling method', () => {3 cy.get('.ico-login').siblings().contains('Register').click()4 cy.get('.ico-login').siblings('.ico-register').click()5 })6})
Using AI Code Generation
1it.only('should navigate to the next page', () => {2 cy.contains('Online Banking').click()3 cy.contains('Feedback').click()4 cy.get('#feedback-title').type('test title')5 cy.get('#feedback-content').type('test content')6 cy.get('.btn-signin').click()7 cy.get('#feedback-title').should('be.empty')8 cy.get('#feedback-content').should('be.empty')9 cy.get('.offset3 > .span8').should('be.visible')10})11it.only('should navigate to the next page', () => {12 cy.contains('Online Banking').click()13 cy.contains('Feedback').click()14 cy.get('#feedback-title').type('test title')15 cy.get('#feedback-content').type('test content')16 cy.get('.btn-signin').click()17 cy.get('#feedback-title').should('be.empty')18 cy.get('#feedback-content').should('be.empty')19 cy.get('.offset3 > .span8').should('be.visible')20})21it.only('should navigate to the next page', () => {22 cy.contains('Online Banking').click()23 cy.contains('Feedback').click()24 cy.get('#feedback-title').type('test title')25 cy.get('#feedback-content').type('test content')26 cy.get('.btn-signin').click()27 cy.get('#feedback-title').should('be.empty')28 cy.get('#feedback-content').should('be.empty')29 cy.get('.offset3 > .span8').should('be.visible')30})31it.only('should navigate to the next page', () => {32 cy.contains('Online Banking').click()33 cy.contains('Feedback').click()34 cy.get('#feedback-title').type('test title')35 cy.get('#feedback
Using AI Code Generation
1describe('test', () => {2 it('test', () => {3 cy.get('h2')4 .next()5 .should('have.class', 'lead')6 cy.get('h2')7 .prev()8 .should('have.class', 'alert')9 cy.get('h2')10 .next()11 .next()12 .should('have.class', 'alert')13 cy.get('h2')14 .prev()15 .prev()16 .should('have.class', 'alert')17 cy.get('h2')18 .next()19 .next()20 .next()21 .should('have.class', 'alert')22 cy.get('h2')23 .prev()24 .prev()25 .prev()26 .should('have.class', 'alert')27 cy.get('h2')28 .next()29 .next()30 .next()31 .next()32 .should('have.class', 'alert')
Using AI Code Generation
1describe('Test using siblings method', function(){2 it('Open Posse website', function(){3 cy.get('.search-box-wrapper .search-box').type('London')4 cy.wait(2000)5 cy.get('.pac-container .pac-item').first().then(function(firstElement){6 const firstItem=firstElement.text()7 cy.wrap(firstElement).click()8 cy.get('.search-box-wrapper .search-box').should('have.value',firstItem)9 cy.get('.select2-chosen').click()10 cy.get('.select2-results li').contains('Rating').click()11 cy.get('.js-go').click()12 cy.get('.list-title').each(($el, index, $list) => {13 const text=$el.text()14 cy.log(text)15 if(text.includes('London')){16 cy.wrap($el).siblings('.listing-attributes').children('.listing-attributes__value--best').should('have.length',1)17 }18 })19 })20 })21})22describe('Test using parents method', function(){23 it('Open Posse website', function(){24 cy.get('.search-box-wrapper .search-box').type('London')25 cy.wait(2000)26 cy.get('.pac-container .pac-item').first().then(function(firstElement){27 const firstItem=firstElement.text()28 cy.wrap(firstElement).click()29 cy.get('.search-box-wrapper .search-box').should('have.value',firstItem)30 cy.get('.select2-chosen').click()31 cy.get('.select2-results li').contains('Rating').click()32 cy.get('.js-go').click()33 cy.get('.list-title').each(($el, index, $list) => {34 const text=$el.text()35 cy.log(text)36 if(text.includes('London')){37 cy.wrap($el).parents('.list-view-item').find('.listing-attributes__value--best').should('have.length',1)38 }39 })40 })41 })42})43describe('Test using children method', function(){44 it('Open Posse website', function(){45 cy.get('.search-box-wrapper .search-box').type
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!