How to use siblings method in Cypress

Best JavaScript code snippet using cypress

registersq.js

Source:registersq.js Github

copy

Full Screen

...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 } ...

Full Screen

Full Screen

characterUtility.js

Source:characterUtility.js Github

copy

Full Screen

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};...

Full Screen

Full Screen

Ship.js

Source:Ship.js Github

copy

Full Screen

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 } ...

Full Screen

Full Screen

register.js

Source:register.js Github

copy

Full Screen

...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提交表单数据...

Full Screen

Full Screen

pseudos.js

Source:pseudos.js Github

copy

Full Screen

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...

Full Screen

Full Screen

imagefield_crop.js

Source:imagefield_crop.js Github

copy

Full Screen

...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};...

Full Screen

Full Screen

wdg_teams_classification_01.js

Source:wdg_teams_classification_01.js Github

copy

Full Screen

...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);...

Full Screen

Full Screen

general.js

Source:general.js Github

copy

Full Screen

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 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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('

Full Screen

Using AI Code Generation

copy

Full Screen

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('

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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})

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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')

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Cypress Tutorial

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.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

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.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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