Best JavaScript code snippet using wpt
formule.js
Source:formule.js
1function verif_formule(form) {2 var msg1 = $(form).find('div#msg1').empty();3 var msg2 = $(form).find('div#msg2').empty();4 var msg3 = $(form).find('div#msg3').empty();5 $('#number').hide();6 $('#opearande').hide();7 $('#kpi').hide();8 var z=document.getElementById('toto').value.trim();9 taille=z.length;10 11 /*fonction qui retourne un tableau le 3 premier caractere avant un crochet ouvrant*/12 function avant_crochet()13 {14 // var tab3= new Array();15 //var k=0;16 var res1=1;17 var chaine="";18 for (var i = 0; i < taille; i++)19 {20 if((z.charAt(i)=="[")&& i>0)21 {22 23 chaine+=z.charAt(i-3);24 chaine+=z.charAt(i-2);25 chaine+=z.charAt(i-1);26 //tab3[k]=chaine27 28 29 if((chaine.indexOf("+")==-1)&&(chaine.indexOf("*")==-1)&&(chaine.indexOf("/")==-1)&&(chaine.indexOf("-")==-1)) 30 {31 res1=-1;32 //msg2.html('<p class="error2">"[" must be preceded by [ or + or - or * or / !!</p>');33 //document.getElementById('toto').focus();34 }35 //k++;36 chaine="";37 }38 39 }40 41 return res1;42 //tab3;43 44 45 }46 var val1=avant_crochet();47 /*fonction qui retourne un tableau le 3 premier caractere apres un crochet fermant*/48 function apres_crochet()49 {50 // var tab1= new Array();51 //var k=0;52 var res2=1;53 54 var chaine="";55 for (var i = 0; i < taille; i++)56 {57 if((z.charAt(i)=="]") && (i<taille-1))58 {59 60 chaine+=z.charAt(i+1);61 chaine+=z.charAt(i+2);62 // tab1[k]=chaine;63 if((chaine.indexOf("+")==-1)&&(chaine.indexOf("*")==-1)&&(chaine.indexOf("/")==-1)&&(chaine.indexOf("-")==-1)) 64 {65 res2=-1;66 //msg2.html('<p class="error2">"]" must be succesed by ] or + or - or * or / !!</p>');67 //document.getElementById('toto').focus();68 }69 //k++;70 71 chaine="";72 }73 74 75 76 }77 return res2;78// tab1;79 80 81 82 83 84 85 }86 var val2=apres_crochet();87 function apres_parenthese()88 {89 //var tab3= new Array();90 //var k=0;91 var res3=1;92 var chaine="";93 for (var i = 0; i < taille; i++)94 {95 if((z.charAt(i)==")")&& (i<taille-1))96 {97 98 chaine+=z.charAt(i+1);99 chaine+=z.charAt(i+2);100 101 //tab3[k]=chaine;102 if((chaine.indexOf("+")==-1)&&(chaine.indexOf("*")==-1)&&(chaine.indexOf("/")==-1)&&(chaine.indexOf("-")==-1)&&(chaine.indexOf("]")==-1))103 {104 res3=-1;105 //msg2.html('<p class="error2">")" must be succesed by ] or + or - or * or / !!</p>');106 //document.getElementById('toto').focus();107 108 }109 110 111 112 113 //k++;114 chaine="";115 }116 117 118 119 }120 121 122 return res3; 123 //tab3;124 125 126 127 }128 var val3=apres_parenthese();129 130 131 /*fonction qui retourne le nbre de '+' dans la formule*/132 function plus() 133 {134 var z=document.getElementById('toto').value.trim();135 var taille=z.length;136 var plus = 0;137 for (var i = 0; i < taille; i++)138 {139 if(z.charAt(i)=="+")140 {141 plus +=1;142 }143 144 }145 return plus;146 147 }148 /*fonction qui retourne le nbre de '-' dans la formule*/149 function moins() 150 {151 var z=document.getElementById('toto').value.trim();152 var taille=z.length;153 var moins = 0;154 for (var i = 0; i < taille; i++)155 {156 if(z.charAt(i)=="-")157 {158 moins +=1;159 }160 161 }162 return moins;163 164 }165 166 167 /*fonction qui retourne le nbre de '*' dans la formule*/168 function fois() 169 {170 var z=document.getElementById('toto').value.trim();171 var taille=z.length;172 var fois = 0;173 for (var i = 0; i < taille; i++)174 {175 if(z.charAt(i)=="*")176 {177 fois +=1;178 }179 180 }181 return fois;182 183 }184 185 /*fonction qui retourne le nbre de '/' dans la formule*/186 function sur() 187 {188 var z=document.getElementById('toto').value.trim();189 var taille=z.length;190 var sur = 0;191 for (var i = 0; i < taille; i++)192 {193 if(z.charAt(i)=="/")194 {195 sur +=1;196 }197 198 }199 return sur;200 201 }202 203 204 function parenthese_ouvrant1() 205 {206 var z=document.getElementById('toto').value.trim();207 var taille=z.length;208 var ouvrant = 0;209 for (var i = 0; i < taille; i++)210 {211 if(z.charAt(i)=="(")212 {213 ouvrant +=1;214 }215 216 }217 return ouvrant;218 219 }220 221 222 function parenthese_fermant1() 223 {224 var z=document.getElementById('toto').value.trim();225 var taille=z.length;226 var fermant = 0;227 for (var i = 0; i < taille; i++)228 {229 if(z.charAt(i)==")")230 {231 fermant +=1;232 }233 }234 return fermant;235 }236 237 238 var f1=plus();239 var f2=moins();240 var f3=fois();241 var f4=sur();242 243 244 245 246 function parenthese_ouvrant() 247 {248 var z=document.getElementById('toto').value.trim();249 var taille=z.length;250 var ouvrant = 0;251 for (var i = 0; i < taille; i++)252 {253 if(z.charAt(i)=="[")254 {255 ouvrant +=1;256 }257 258 }259 return ouvrant;260 261 }262 263 264 function parenthese_fermant() 265 {266 var z=document.getElementById('toto').value.trim();267 var taille=z.length;268 var fermant = 0;269 for (var i = 0; i < taille; i++)270 {271 if(z.charAt(i)=="]")272 {273 fermant +=1;274 }275 }276 return fermant;277 }278 var open=parenthese_ouvrant();279 var closed=parenthese_fermant();280 var open1=parenthese_ouvrant1();281 var closed1=parenthese_fermant1();282 /*alert("opened"+ open +"; cloesd"+closed);*/283 284 if(!$(form).find('input[name="name"]').val().length) {285 msg1.html('<p class="error1">Please enter your formula name !</p>');286 $(form).find('input[name="name"]').focus();287 return false;288 }289 else if(!$(form).find('input[name="name"]').val().match(/^[a-zA-Z0-9_\(\)]+$/i)) {290 msg1.html('<p class="error1">Please enter a valid formula name !</p>');291 $(form).find('input[name="name"]').focus();292 return false;293 }294 295 /* verification de la parie formule */296 if((f1==0)&&(f2==0)&&(f3==0)&&(f4==0)) {297 msg2.html('<p class="error2">This, it can\'t be a formula !!!</p>');298 document.getElementById('toto').focus();299 return false;300 301 }302 303 304 if(z=="") {305 msg2.html('<p class="error2">Please enter your formula !</p>');306 document.getElementById('toto').focus();307 return false;308 }309 if(!z.match(/^[a-zA-Z0-9\ \_\-\*\/\+\%\[\]\(\)]+$/gi)) {310 msg2.html('<p class="error2">Please enter a valid formula </p>');311 document.getElementById('toto').focus();312 return false;313 }314 315 316 317 if(open>closed) {318 msg2.html('<p class="error2">Closing bracket "]" missing !!</p>');319 document.getElementById('toto').focus();320 return false;321 }322 323 if(open<closed) {324 msg2.html('<p class="error2">Opening bracket "[" missing !!</p>');325 document.getElementById('toto').focus();326 return false;327 }328 329 if(open1>closed1) {330 msg2.html('<p class="error2">Closing parenthesis missing !!</p>');331 document.getElementById('toto').focus();332 return false;333 }334 335 if(open1<closed1) {336 msg2.html('<p class="error2">Opening parenthesis missing !!</p>');337 document.getElementById('toto').focus();338 return false;339 }340 341 ///////////////////342 if(val1==-1) {343 msg2.html('<p class="error2">"[" must be preceded by [ or + or - or * or / !!</p>');344 document.getElementById('toto').focus();345 return false;346 }347 348 if(val2==-1) {349 msg2.html('<p class="error2">"]" must be succesed by ] or + or - or * or / !!</p>');350 document.getElementById('toto').focus();351 return false;352 }353 354 if(val3==-1) {355 msg2.html('<p class="error2">")" must be succesed by ] or + or - or * or / !!</p>');356 document.getElementById('toto').focus();357 return false;358 }359 360 361 /////////////////362 if(z=="+") {363 msg2.html('<p class="error2">" + " only can\'t be a formula!!!</p>');364 document.getElementById('toto').focus();365 return false;366 }367 if(z=="=") {368 msg2.html('<p class="error2">Please enter a valid formula " = " !!!</p>');369 document.getElementById('toto').focus();370 return false;371 }372 if(z=="-") {373 msg2.html('<p class="error2">" - " only can\'t be a formula!!!</p>');374 document.getElementById('toto').focus();375 return false;376 }377 if(z=="*") {378 msg2.html('<p class="error2">" * " only can\'t be a formula!!!</p>');379 document.getElementById('toto').focus();380 return false;381 }382 if(z=="/") {383 msg2.html('<p class="error2">" / " only can\'t be a formula!!!</p>');384 document.getElementById('toto').focus();385 return false;386 }387 if(z=="[") {388 msg2.html('<p class="error2"> "[" only can\'t be a formula!!!</p>');389 document.getElementById('toto').focus();390 return false;391 }392 if(z=="]") {393 msg2.html('<p class="error2">" ] " only can\'t be a formula!!!</p>');394 document.getElementById('toto').focus();395 return false;396 }397 398 if(z.charAt(0)=="+") {399 msg2.html('<p class="error2">Incorrect beginning of formula " + " !!!</p>');400 document.getElementById('toto').focus();401 return false;402 }403 if(z.charAt(0)=="-") {404 msg2.html('<p class="error2">Incorrect beginning of formula " - " !!!</p>');405 document.getElementById('toto').focus();406 return false;407 }408 if(z.charAt(0)=="*") {409 msg2.html('<p class="error2">Incorrect beginning of formula " * " !!!</p>');410 document.getElementById('toto').focus();411 return false;412 }413 if(z.charAt(0)=="/") {414 msg2.html('<p class="error2">Incorrect beginning of formula " / " !!!</p>');415 document.getElementById('toto').focus();416 return false;417 }418 if(z.charAt(0)==")") {419 msg2.html('<p class="error2">Incorrect beginning of formula " ) " !!!</p>');420 document.getElementById('toto').focus();421 return false;422 }423 if(z.charAt(0)=="(") {424 msg2.html('<p class="error2">Incorrect beginning of formula " ( " !!!</p>');425 document.getElementById('toto').focus();426 return false;427 }428 if(z.charAt(0)=="]") {429 msg2.html('<p class="error2">Incorrect beginning of formula " ] " !!!</p>');430 document.getElementById('toto').focus();431 return false;432 }433 434 if(z.indexOf("++")>-1) {435 msg2.html('<p class="error2">the operation " ++ " is not allowed !</p>');436 document.getElementById('toto').focus();437 return false;438 }439 440 if(z.indexOf("--")>-1) {441 msg2.html('<p class="error2">the operation " -- " is not allowed !</p>');442 document.getElementById('toto').focus();443 return false;444 }445 446 if(z.indexOf("**")>-1) {447 msg2.html('<p class="error2">the operation " ** " is not allowed !</p>');448 document.getElementById('toto').focus();449 return false;450 }451 452 if(z.indexOf("//")>-1) {453 msg2.html('<p class="error2">the operation " // " is not allowed !</p>');454 document.getElementById('toto').focus();455 return false;456 }457 458 459 if(z.indexOf("+-")>-1) {460 msg2.html('<p class="error2">the operation " +- " is not allowed !</p>');461 document.getElementById('toto').focus();462 return false;463 }464 465 if(z.indexOf("+*")>-1) {466 msg2.html('<p class="error2">the operation " +* " is not allowed !</p>');467 document.getElementById('toto').focus();468 return false;469 }470 471 if(z.indexOf("+/")>-1) {472 msg2.html('<p class="error2">the operation " +/ " is not allowed !</p>');473 document.getElementById('toto').focus();474 return false;475 }476 477 if(z.indexOf("-+")>-1) {478 msg2.html('<p class="error2">the operation " -+ " is not allowed !</p>');479 document.getElementById('toto').focus();480 return false;481 }482 483 if(z.indexOf("-*")>-1) {484 msg2.html('<p class="error2">the operation " -* " is not allowed !</p>');485 document.getElementById('toto').focus();486 return false;487 }488 489 if(z.indexOf("-/")>-1) {490 msg2.html('<p class="error2">the operation " -/ " is not allowed !</p>');491 document.getElementById('toto').focus();492 return false;493 }494 495 if(z.indexOf("*+")>-1) {496 msg2.html('<p class="error2">the operation " *+ " is not allowed !</p>');497 document.getElementById('toto').focus();498 return false;499 }500 501 if(z.indexOf("*-")>-1) {502 msg2.html('<p class="error2">the operation " *- " is not allowed !</p>');503 document.getElementById('toto').focus();504 return false;505 }506 507 if(z.indexOf("*/")>-1) {508 msg2.html('<p class="error2">the operation " */ " is not allowed !</p>');509 document.getElementById('toto').focus();510 return false;511 }512 513 if(z.indexOf("/+")>-1) {514 msg2.html('<p class="error2">the operation " /+ " is not allowed !</p>');515 document.getElementById('toto').focus();516 return false;517 }518 519 if(z.indexOf("/-")>-1) {520 msg2.html('<p class="error2">the operation " /- " is not allowed !</p>');521 document.getElementById('toto').focus();522 return false;523 }524 525 if(z.indexOf("/*")>-1) {526 msg2.html('<p class="error2">the operation " /* " is not allowed !</p>');527 document.getElementById('toto').focus();528 return false;529 }530 531 if(z.indexOf(")(")>-1) {532 msg2.html('<p class="error2">the operation " )( " is not allowed !</p>');533 document.getElementById('toto').focus();534 return false;535 }536 if(z.indexOf("][")>-1) {537 msg2.html('<p class="error2">the operation " ][ " is not allowed !</p>');538 document.getElementById('toto').focus();539 return false;540 }541 542 if(z.indexOf("()")>-1) {543 msg2.html('<p class="error2">the operation " () " is not allowed !</p>');544 document.getElementById('toto').focus();545 return false;546 }547 if(z.indexOf("[]")>-1) {548 msg2.html('<p class="error2">the operation " [] " is not allowed !</p>');549 document.getElementById('toto').focus();550 return false;551 }552 553 if(z.indexOf("(+)")>-1) {554 msg2.html('<p class="error2">the operation " (+) " is not allowed !</p>');555 document.getElementById('toto').focus();556 return false;557 }558 if(z.indexOf("[+]")>-1) {559 msg2.html('<p class="error2">the operation " [+] " is not allowed !</p>');560 document.getElementById('toto').focus();561 return false;562 }563 564 if(z.indexOf("[-]")>-1) {565 msg2.html('<p class="error2">the operation " [-] " is not allowed !</p>');566 document.getElementById('toto').focus();567 return false;568 }569 if(z.indexOf("(-)")>-1) {570 msg2.html('<p class="error2">the operation " (-) " is not allowed !</p>');571 document.getElementById('toto').focus();572 return false;573 }574 575 if(z.indexOf("(*)")>-1) {576 msg2.html('<p class="error2">the operation " (*) " is not allowed !</p>');577 document.getElementById('toto').focus();578 return false;579 }580 if(z.indexOf("[*]")>-1) {581 msg2.html('<p class="error2">the operation " [*] " is not allowed !</p>');582 document.getElementById('toto').focus();583 return false;584 }585 586 if(z.indexOf("(/)")>-1) {587 msg2.html('<p class="error2">the operation " (/) " is not allowed !</p>');588 document.getElementById('toto').focus();589 return false;590 }591 if(z.indexOf("[/]")>-1) {592 msg2.html('<p class="error2">the operation " [/] " is not allowed !</p>');593 document.getElementById('toto').focus();594 return false;595 }596 597 if(z.indexOf("(+")>-1) {598 msg2.html('<p class="error2">the operation " (+ " is not allowed !</p>');599 document.getElementById('toto').focus();600 return false;601 }602 if(z.indexOf("[+")>-1) {603 msg2.html('<p class="error2">the operation " [+ " is not allowed !</p>');604 document.getElementById('toto').focus();605 return false;606 }607 608 if(z.indexOf("(-")>-1) {609 msg2.html('<p class="error2">the operation " (- " is not allowed !</p>');610 document.getElementById('toto').focus();611 return false;612 }613 if(z.indexOf("[-")>-1) {614 msg2.html('<p class="error2">the operation " [- " is not allowed !</p>');615 document.getElementById('toto').focus();616 return false;617 }618 619 if(z.indexOf("(*")>-1) {620 msg2.html('<p class="error2">the operation " (* " is not allowed !</p>');621 document.getElementById('toto').focus();622 return false;623 }624 if(z.indexOf("[*")>-1) {625 msg2.html('<p class="error2">the operation " [* " is not allowed !</p>');626 document.getElementById('toto').focus();627 return false;628 }629 630 if(z.indexOf("(/")>-1) {631 msg2.html('<p class="error2">the operation " (/ " is not allowed !</p>');632 document.getElementById('toto').focus();633 return false;634 }635 if(z.indexOf("[/")>-1) {636 msg2.html('<p class="error2">the operation " [/ " is not allowed !</p>');637 document.getElementById('toto').focus();638 return false;639 }640 641 642 if(z.indexOf("+)")>-1) {643 msg2.html('<p class="error2">the operation " +) " is not allowed !</p>');644 document.getElementById('toto').focus();645 return false;646 }647 648 if(z.indexOf("-)")>-1) {649 msg2.html('<p class="error2">the operation " -) " is not allowed !</p>');650 document.getElementById('toto').focus();651 return false;652 }653 654 if(z.indexOf("+(")>-1) {655 msg2.html('<p class="error2">Please use " +[ " instead of " +( " !!!!</p>');656 document.getElementById('toto').focus();657 return false;658 }659 if(z.indexOf("-(")>-1) {660 msg2.html('<p class="error2">Please use " -[ " instead of " -( " !!!!</p>');661 document.getElementById('toto').focus();662 return false;663 }664 665 if(z.indexOf("*(")>-1) {666 msg2.html('<p class="error2">Please use " *[ " instead of " *( " !!!!</p>');667 document.getElementById('toto').focus();668 return false;669 }670 671 if(z.indexOf("/(")>-1) {672 msg2.html('<p class="error2">Please use " /[ " instead of " /( " !!!!</p>');673 document.getElementById('toto').focus();674 return false;675 }676 677 678 if(z.indexOf("*)")>-1) {679 msg2.html('<p class="error2">the operation " *) " is not allowed !</p>');680 document.getElementById('toto').focus();681 return false;682 }683 684 if(z.indexOf("/)")>-1) {685 msg2.html('<p class="error2">the operation " /) " is not allowed !</p>');686 document.getElementById('toto').focus();687 return false;688 }689 if(z.indexOf("+]")>-1) {690 msg2.html('<p class="error2">the operation " +] " is not allowed !</p>');691 document.getElementById('toto').focus();692 return false;693 }694 695 if(z.indexOf("-]")>-1) {696 msg2.html('<p class="error2">the operation " -] " is not allowed !</p>');697 document.getElementById('toto').focus();698 return false;699 }700 701 if(z.indexOf("*]")>-1) {702 msg2.html('<p class="error2">the operation " *] " is not allowed !</p>');703 document.getElementById('toto').focus();704 return false;705 }706 707 if(z.indexOf("/]")>-1) {708 msg2.html('<p class="error2">the operation " /] " is not allowed !</p>');709 document.getElementById('toto').focus();710 return false;711 }712 713 if(z.indexOf("))")>-1) {714 msg2.html('<p class="error2">the operation " )) " is not allowed !</p>');715 document.getElementById('toto').focus();716 return false;717 }718 if(z.indexOf("((")>-1) {719 msg2.html('<p class="error2">the operation " (( " is not allowed !</p>');720 document.getElementById('toto').focus();721 return false;722 }723 724 if(z.charAt(taille-1)=="+") {725 msg2.html('<p class="error2">Incorrect end of formula " + " !!!</p>');726 document.getElementById('toto').focus();727 return false;728 }729 if(z.charAt(taille-1)=="-") {730 msg2.html('<p class="error2">Incorrect end of formula " - " !!!</p>');731 document.getElementById('toto').focus();732 return false;733 }734 if(z.charAt(taille-1)=="*") {735 msg2.html('<p class="error2">Incorrect end of formula " * " !!!</p>');736 document.getElementById('toto').focus();737 return false;738 }739 if(z.charAt(taille-1)=="/") {740 msg2.html('<p class="error2">Incorrect end of formula " / " !!!</p>');741 document.getElementById('toto').focus();742 return false;743 }744 if(z.charAt(taille-1)=="[") {745 msg2.html('<p class="error2">Incorrect end of formula " [ " !!!</p>');746 document.getElementById('toto').focus();747 return false;748 }749 750 if(z.indexOf("+(")>-1) {751 msg2.html('<p class="error2">Please use " +[ " instead of " +( " !!!</p>');752 document.getElementById('toto').focus();753 return false;754 }755 if(z.indexOf("-(")>-1) {756 msg2.html('<p class="error2">Please use " -[ " instead of " -( " !!!</p>');757 document.getElementById('toto').focus();758 return false;759 }760 if(z.indexOf("*(")>-1) {761 msg2.html('<p class="error2">Please use " *[ " instead of " *( " !!!</p>');762 document.getElementById('toto').focus();763 return false;764 }765 if(z.indexOf("/(")>-1) {766 msg2.html('<p class="error2">Please use " /[ " instead of " /( " !!!</p>');767 document.getElementById('toto').focus();768 return false;769 }770 771 if(z.indexOf("([")>-1) {772 msg2.html('<p class="error2">The operation " ([ " is not allowed !</p>');773 document.getElementById('toto').focus();774 return false;775 }776 if(z.indexOf("])")>-1) {777 msg2.html('<p class="error2">The operation " ]) " is not allowed !</p>');778 document.getElementById('toto').focus();779 return false;780 }781 782 783 if(z.charAt(taille-1)==".") {784 msg2.html('<p class="error2">Incorrect end of formula " . " !!!</p>');785 document.getElementById('toto').focus();786 return false;787 }788 789 790 791 792 793 794 if(($(form).find('input[name="operator"]')[0].checked==false)&& ($(form).find('input[name="operator"]')[1].checked==false)&&795 ($(form).find('input[name="operator"]')[2].checked==false)&&($(form).find('input[name="operator"]')[3].checked==false)) {796 797 msg3.html('<p class="error3">Please choose an operator !</p>');798 return false;799 }800 801 return true;802}803$(function(){804$('form[name="formule"]').find('select[name="file"]').click(function() {805$('#number').show();806$('#opearande').show();807$('#kpi').show();808});...
tablaTipos.js
Source:tablaTipos.js
1const etiqueta= require("./etiqueta.js");2const valoresm = require("./values_manager.js");3const nodoTipo = require("../mng_ts/nodoTipo");4const booleano=0;5const entero=1;6const doble=2;7const caracter=3;8const cadena=4;9const error=5;10const vacio=6;11const objeto=7;12const nulo=8;13const arreglo=9;14const error2=50;15const allow=51;16const tipo_booleano = new nodoTipo(booleano,"boolean");17const tipo_entero = new nodoTipo(entero,"int");18const tipo_doble = new nodoTipo(doble,"double");19const tipo_caracter = new nodoTipo(caracter,"char");20const tipo_cadena = new nodoTipo(cadena,"String");21const tipo_error = new nodoTipo(error,"error");22const tipo_vacio = new nodoTipo(vacio,"void");23const tipo_nulo = new nodoTipo(nulo,"null");24const all=51;25const igual_booleano=52;26const igual_cadena=53;27const igual_dif=54;28const fin_cadena=557886;29const valor_nulo=557886;30const caracter_nulo=00;31const publico=200;32const protegido=201;33const privado=202;34const estatico=203;35const ffinal=204;36const abstracto=205;37const vieneSuper=-1;38const banderaSuper=false;39function getMod(m)40{41 if(m==publico)42 {43 return "PUBLIC";44 }else if(m==protegido)45 {46 return "PROTEGIDO";47 }else if(m==privado)48 {49 return "PRIVATE";50 }else if(m==estatico)51 {52 return "STATIC";53 }else if(m==ffinal)54 {55 return "FINAL";56 }else57 {58 return "ABSTRACT"59 }60}61//rol62const rol_variable=300;63const rol_metodo=301;64const rol_constructor=302;65const rol_main=303;66const rol_this=304;67function getTipoObjeto(nombre)68{69 return new nodoTipo(objeto,nombre);70}71const suma=72[73 /*0 */[error,error,error,error,cadena,error2,error,error,error,error],74 /*1 */[error,entero,doble,entero,cadena,error2,error,error,error,error],75 /*2 */[error,doble,doble,doble,cadena,error2,error,error,error,error],76 /*3 */[error,entero,doble,entero,cadena,error2,error,error,error,error],77 /*4 */[cadena,cadena,cadena,cadena,cadena,error2,error,error,error,error],78 /*5 */[error2,error2,error2,error2,error2,error2,error2,error2,error2,error2],79 /*6 */[error,error,error,error,error,error2,error,error,error,error],80 /*7 */[error,error,error,error,error,error2,error,error,error,error],81 /*8 */[error,error,error,error,error,error2,error,error,error,error],82 /*9 */[error,error,error,error,error,error2,error,error,error,error],83 /*10*/[error,error,error,error,error,error2,error,error,error,error]84];85//resta,multiplicacion,modulo,division tienen la misma tabla86const valores=87[88 [error,error,error,error,error,error2,error,error,error,error],89 [error,entero,doble,entero,error,error2,error,error,error,error],90 [error,doble,doble,doble,error,error2,error,error,error,error],91 [error,entero,doble,entero,error,error2,error,error,error,error],92 [error,error,error,error,error,error2,error,error,error,error],93 /*5 */[error2,error2,error2,error2,error2,error2,error2,error2,error2,error2],94 /*6 */[error,error,error,error,error,error2,error,error,error,error],95 /*7 */[error,error,error,error,error,error2,error,error,error,error],96 /*8 */[error,error,error,error,error,error2,error,error,error,error],97 /*9 */[error,error,error,error,error,error2,error,error,error,error],98 /*10*/[error,error,error,error,error,error2,error,error,error,error]99];100const potencia=101[102 [error,error,error,error,error,error2,error,error,error,error],103 [error,doble,doble,doble,error,error2,error,error,error,error],104 [error,doble,doble,doble,error,error2,error,error,error,error],105 [error,doble,doble,doble,error,error2,error,error,error,error],106 [error,error,error,error,error,error2,error,error,error,error],107/*5 */ [error2,error2,error2,error2,error2,error2,error2,error2,error2,error2],108 /*6 */[error,error,error,error,error,error2,error,error,error,error],109 /*7 */[error,error,error,error,error,error2,error,error,error,error],110 /*8 */[error,error,error,error,error,error2,error,error,error,error],111 /*9 */[error,error,error,error,error,error2,error,error,error,error],112 /*10*/[error,error,error,error,error,error2,error,error,error,error]113];114const relacional=115[116 [igual_booleano,error,error,error,error,error2,error,error,error,error],117 [error,all,all,all,error,error2,error,error,error,error],118 [error,all,all,all,error,error2,error,error,error,error],119 [error,all,all,all,error,error2,error,error,error,error],120 [error,error,error,error,igual_cadena,error2,error,error,igual_dif,error],121 /*5 */ [error2,error2,error2,error2,error2,error2,error2,error2,error2,error2],122 /*6 */[error,error,error,error,error,error2,error,error,error,error],123 /*7 */[error,error,error,error,error,error2,error,igual_dif,igual_dif,error],124 /*8 */[error,error,error,error,igual_dif,error2,error,igual_dif,igual_dif,igual_dif],125 /*9 */[error,error,error,error,error,error2,error,error,igual_dif,igual_dif],126];127const casteo=128[129 [allow,error,error,error,error,error2],130 [error,allow,error,allow,error,error2],131 [error,allow,allow,allow,error,error2],132 [error,error,error,allow,error,error2],133 [error,error,error,error,allow,error2],134 /*5 */ [error2,error2,error2,error2,error2,error2]135];136function AsignValid(tipo1,tipo2)137{138 var bandera=true;139 if((tipo1.indice==cadena||tipo1.indice==objeto||tipo1.indice==arreglo)&&tipo2.indice==nulo)140 {141 return true;142 }143 else if(tipo1.indice==tipo2.indice&&tipo1.indice==arreglo)144 {145 return AsignValid(tipo1.tipoArr,tipo2.tipoArr)&&tipo1.dimen==tipo2.dimen;146 }147 else if(tipo1.indice==objeto&&tipo1.indice==tipo2.indice)148 {149 if(tipo1.nombre==tipo2.nombre)150 {151 return true;152 }153 return false;154 }else if(tipo1.indice>6||tipo2.indice>6)155 {156 bandera=false;157 }else158 {159 160 var op=casteo[tipo1.indice][tipo2.indice];161 if(op==error)162 {163 bandera=false;164 }165 } 166 return bandera;167}168function etiquetaToTemp(sim,traductor)169{170 if(sim.aux instanceof etiqueta)171 {172 var tw=valoresm.getTemporal();173 for(var i=0;i<sim.aux.verdadero.length;i++)174 {175 traductor.imprimir_L(sim.aux.verdadero[i]+":");176 }177 var salida=valoresm.getEtiqueta();178 traductor.imprimir(tw+"=1;");179 traductor.imprimir("goto "+salida+";");180 for(var i=0;i<sim.aux.falso.length;i++)181 {182 traductor.imprimir_L(sim.aux.falso[i]+":");183 }184 traductor.imprimir(tw+"=0;");185 traductor.imprimir_L(salida+":");186 sim.aux=tw;187 }188}189module.exports.suma=suma;190module.exports.valores=valores;191module.exports.potencia=potencia;192module.exports.booleano=booleano;193module.exports.entero=entero;194module.exports.doble=doble;195module.exports.caracter=caracter;196module.exports.cadena=cadena;197module.exports.error=error;198module.exports.vacio=vacio;199module.exports.error2=error2;200module.exports.tipo_booleano=tipo_booleano;201module.exports.tipo_entero=tipo_entero;202module.exports.tipo_doble=tipo_doble;203module.exports.tipo_caracter=tipo_caracter;204module.exports.tipo_cadena=tipo_cadena;205module.exports.tipo_error=tipo_error;206module.exports.tipo_vacio=tipo_vacio;207module.exports.tipo_nulo=tipo_nulo;208module.exports.all=all;209module.exports.igual_booleano=igual_booleano;210module.exports.igual_cadena=igual_cadena;211module.exports.igual_dif=igual_dif;212module.exports.relacional=relacional;213module.exports.fin_cadena=fin_cadena;214module.exports.valor_nulo=valor_nulo;215module.exports.publico=publico;216module.exports.protegido=protegido;217module.exports.privado=privado;218module.exports.estatico=estatico;219module.exports.ffinal=ffinal;220module.exports.abstracto=abstracto;221module.exports.objeto=objeto;222module.exports.getTipoObjeto=getTipoObjeto;223module.exports.rol_variable=rol_variable;224module.exports.rol_metodo=rol_metodo;225module.exports.rol_constructor=rol_constructor;226module.exports.rol_main=rol_main;227module.exports.rol_this=rol_this;228module.exports.caracter_nulo=caracter_nulo;229module.exports.allow=allow;230module.exports.casteo=casteo;231module.exports.AsignValid=AsignValid;232module.exports.etiquetaToTemp=etiquetaToTemp;233module.exports.getMod=getMod;234module.exports.nulo=nulo;235module.exports.arreglo=arreglo;236module.exports.vieneSuper=vieneSuper;237module.exports.banderaSuper=banderaSuper;...
validacion.js
Source:validacion.js
1$(document).ready(function () {2 //Hide all error messages3 $('#nameError').hide();4 $('#nameError2').hide();5 $('#lastnameError').hide();6 $('#lastnameError2').hide();7 $('#emailError').hide();8 $('#emailError2').hide();9 $('#passError').hide();10 $('#passError2').hide();11 $('#cPassError').hide();12 //Regex13 var reEmail = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,4}$/m;14 var reName = /^[A-Za-z+ +]{1,20}$/m;15 var reLastName = /^[A-Za-z+ +]{1,20}$/m;16 var rePass = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$/m;17 //Every time we release a key checks validation18 $('input').keyup(function () {19 //Take all the values of inputs20 let name = document.getElementById('name').value21 let lastname = document.getElementById('lastname').value22 let email = document.getElementById('email').value23 let password = document.getElementById('password').value24 let confirmpassword = document.getElementById('password-confirm').value25 //Dont have any empty imput26 if (name === '') {27 $('#Registrarse').prop('disabled', true);28 $('#nameError').show();29 $('#nameError2').hide();30 $('#lastnameError').hide();31 $('#lastnameError2').hide();32 $('#emailError').hide();33 $('#emailError2').hide();34 $('#passError').hide();35 $('#passError2').hide();36 $('#cPassError').hide();37 }38 //Name regex validation39 else if(name.match(reName) === null){40 $('#Registrarse').prop('disabled', true);41 $('#nameError2').show();42 $('#nameError').hide();43 $('#lastnameError').hide();44 $('#lastnameError2').hide();45 $('#emailError').hide();46 $('#emailError2').hide();47 $('#passError').hide();48 $('#passError2').hide();49 $('#cPassError').hide();50 }51 else if(lastname === ''){52 $('#Registrarse').prop('disabled', true);53 $('#emailError').hide();54 $('#nameError').hide();55 $('#nameError2').hide();56 $('#lastnameError').show();57 $('#lastnameError2').hide();58 $('#emailError2').hide();59 $('#passError').hide();60 $('#passError2').hide();61 $('#cPassError').hide();62 }63 //LastName regex validation64 else if(lastname.match(reLastName) === null){65 $('#Registrarse').prop('disabled', true);66 $('#nameError2').hide();67 $('#nameError').hide();68 $('#lastnameError').hide();69 $('#lastnameError2').show();70 $('#emailError').hide();71 $('#emailError2').hide();72 $('#passError').hide();73 $('#passError2').hide();74 $('#cPassError').hide();75 }76 else if(email === ''){77 $('#Registrarse').prop('disabled', true);78 $('#emailError').show();79 $('#nameError').hide();80 $('#nameError2').hide();81 $('#lastnameError').hide();82 $('#lastnameError2').hide();83 $('#emailError2').hide();84 $('#passError').hide();85 $('#passError2').hide();86 $('#cPassError').hide();87 }88 //Email regex validation89 else if (email.match(reEmail) === null){90 $('#Registrarse').prop('disabled', true);91 $('#emailError2').show();92 $('#nameError').hide();93 $('#lastnameError').hide();94 $('#lastnameError2').hide();95 $('#emailError').hide();96 $('#passError').hide();97 $('#passError2').hide();98 $('#cPassError').hide();99 }100 else if(password === ''){101 $('#Registrarse').prop('disabled', true);102 $('#passError').show();103 $('#nameError').hide();104 $('#nameError2').hide();105 $('#lastnameError').hide();106 $('#lastnameError2').hide();107 $('#emailError').hide();108 $('#emailError2').hide();109 $('#passError2').hide();110 $('#cPassError').hide();111 }112 //Password regex validation113 else if(password.match(rePass) === null){114 $('#Registrarse').prop('disabled', true);115 $('#passError2').show();116 $('#nameError').hide();117 $('#nameError2').hide();118 $('#lastnameError').hide();119 $('#lastnameError2').hide();120 $('#emailError').hide();121 $('#emailError2').hide();122 $('#passError').hide();123 $('#cPassError').hide();124 }125 //Confirm password must be same as password126 else if(password !== confirmpassword){127 $('#Registrarse').prop('disabled', true);128 $('#cPassError').show();129 $('#nameError').hide();130 $('#nameError2').hide();131 $('#lastnameError').hide();132 $('#lastnameError2').hide();133 $('#emailError').hide();134 $('#emailError2').hide();135 $('#passError').hide();136 $('#passError2').hide();137 }138 else {139 $('#Registrarse').prop('disabled', false);140 $('#nameError').hide();141 $('#nameError2').hide();142 $('#lastnameError').hide();143 $('#lastnameError2').hide();144 $('#emailError').hide();145 $('#emailError2').hide();146 $('#passError').hide();147 $('#passError2').hide();148 $('#cPassError').hide();149 }150 });...
Using AI Code Generation
1var wpt = require('wpt');2wpt.error2("test error message");3var wpt = require('wpt');4wpt.error2("test error message");5var wpt = require('wpt');6wpt.error2("test error message");7var wpt = require('wpt');8wpt.error2("test error message");9var wpt = require('wpt');10wpt.error2("test error message");11var wpt = require('wpt');12wpt.error2("test error message");13var wpt = require('wpt');14wpt.error2("test error message");15var wpt = require('wpt');16wpt.error2("test error message");17var wpt = require('wpt');18wpt.error2("test error message");19var wpt = require('wpt');20wpt.error2("test error message");21var wpt = require('wpt');22wpt.error2("test error message");23var wpt = require('wpt');24wpt.error2("test error message");25var wpt = require('wpt');26wpt.error2("test error message");27var wpt = require('wpt');28wpt.error2("test error message");
Using AI Code Generation
1var wpt = require('wpt');2wpt.error2('This is a test error message');3var wpt = require('wpt');4wpt.error2('This is a test error message');5var wpt = require('wpt');6wpt.error2('This is a test error message');7var wpt = require('wpt');8wpt.error2('This is a test error message');9var wpt = require('wpt');10wpt.error2('This is a test error message');11var wpt = require('wpt');12wpt.error2('This is a test error message');13var wpt = require('wpt');14wpt.error2('This is a test error message');15var wpt = require('wpt');16wpt.error2('This is a test error message');17var wpt = require('wpt');18wpt.error2('This is a test error message');19var wpt = require('wpt');20wpt.error2('This is a test error message');21var wpt = require('wpt');22wpt.error2('This is a test error message');23var wpt = require('wpt');24wpt.error2('This is a test error message');25var wpt = require('wpt');26wpt.error2('This is a test error message');
Using AI Code Generation
1var wpt = require('wpt');2wpt.error2('test', function(err, data) {3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log('Data: ' + data);7 }8});9var wpt = require('wpt');10wpt.error2('test', function(err, data) {11 if (err) {12 console.log('Error: ' + err);13 } else {14 console.log('Data: ' + data);15 }16});17var wpt = require('wpt');18wpt.error2('test', function(err, data) {19 if (err) {20 console.log('Error: ' + err);21 } else {22 console.log('Data: ' + data);23 }24});25var wpt = require('wpt');26wpt.error2('test', function(err, data) {27 if (err) {28 console.log('Error: ' + err);29 } else {30 console.log('Data: ' + data);31 }32});33var wpt = require('wpt');34wpt.error2('test', function(err, data) {35 if (err) {36 console.log('Error: ' + err);37 } else {38 console.log('Data: ' + data);39 }40});41var wpt = require('wpt');42wpt.error2('test', function(err, data) {43 if (err) {44 console.log('Error: ' + err);45 } else {46 console.log('Data: ' + data);47 }48});49var wpt = require('wpt');50wpt.error2('test', function(err, data) {51 if (err) {52 console.log('Error: ' + err);53 } else {54 console.log('Data: ' + data);55 }56});
Using AI Code Generation
1var wpt = require('webpagetest');2var test = wpt('www.webpagetest.org');3var options = {4 videoParams: {5 }6};7test.runTest(options, function(err, data) {8 console.log(data);9 test.getTestResults(data.data.testId, function(err, data) {10 console.log(data);11 });12});13var wpt = require('webpagetest');14var test = wpt('www.webpagetest.org');15var options = {16 videoParams: {17 }18};19test.runTest(options, function(err, data) {20 console.log(data);21 test.getTestResults(data.data.testId, function(err, data) {22 console.log(data);23 });24});25var wpt = require('webpagetest');26var test = wpt('www.webpagetest.org');27var options = {28 videoParams: {29 }30};31test.runTest(options, function(err, data) {32 console.log(data);33 test.getTestResults(data.data.testId, function(err, data) {34 console.log(data);
Using AI Code Generation
1var wpt = require('wpt');2wpt.error2('test', function(err, data) {3 console.log(err);4 console.log(data);5});6var wpt = require('wpt');7wpt.error('test', function(err, data) {8 console.log(err);9 console.log(data);10});11var wpt = require('wpt');12wpt.getLocations(function(err, data) {13 console.log(err);14 console.log(data);15});16var wpt = require('wpt');17wpt.getTesters(function(err, data) {18 console.log(err);19 console.log(data);20});21var wpt = require('wpt');22wpt.getTesters(function(err, data) {23 console.log(err);24 console.log(data);25});26var wpt = require('wpt');27wpt.getTesters(function(err, data) {28 console.log(err);29 console.log(data);30});31var wpt = require('wpt');32wpt.getTesters(function(err, data) {33 console.log(err);34 console.log(data);35});36var wpt = require('wpt');37wpt.getTesters(function(err, data) {38 console.log(err);39 console.log(data);40});41var wpt = require('wpt');42wpt.getTesters(function(err, data) {43 console.log(err);44 console.log(data);45});46var wpt = require('wpt');47wpt.getTesters(function(err, data) {48 console.log(err);49 console.log(data);50});
Using AI Code Generation
1var wpt = require('wpt');2wpt.error2('test', function(err, result) {3 console.log(result);4});5var wpt = require('wpt');6wpt.error2('test', function(err, result) {7 console.log(result);8});9var wpt = require('wpt');10wpt.error2('test', function(err, result) {11 console.log(result);12});13var wpt = require('wpt');14wpt.error2('test', function(err, result) {15 console.log(result);16});17var wpt = require('wpt');18wpt.error2('test', function(err, result) {19 console.log(result);20});21var wpt = require('wpt');22wpt.error2('test', function(err, result) {23 console.log(result);24});25var wpt = require('wpt');26wpt.error2('test', function(err, result) {27 console.log(result);28});29var wpt = require('wpt');30wpt.error2('test', function(err, result) {31 console.log(result);32});33var wpt = require('wpt');34wpt.error2('test', function(err, result) {35 console.log(result);36});37var wpt = require('wpt');38wpt.error2('test', function(err, result) {39 console.log(result);40});41var wpt = require('wpt');42wpt.error2('test', function(err, result) {43 console.log(result);44});
Using AI Code Generation
1var wpt = require('wpt');2wpt.error2('test error2');3wpt.error2(message, [options]);4var wpt = require('wpt');5wpt.error2('test error2');6var wpt = require('wpt');7var error = new Error('test error2');8wpt.error2('test error2', {9});10 at Object.<anonymous> (/Users/username/Projects/wpt/test.js:4:7)11 at Module._compile (module.js:652:30)12 at Object.Module._extensions..js (module.js:663:10)13 at Module.load (module.js:565:32)14 at tryModuleLoad (module.js:505:12)15 at Function.Module._load (module.js:497:3)16 at Function.Module.runMain (module.js:693:10)17 at startup (bootstrap_node.js:188:16)18wpt.log(message, [options]);19var wpt = require('wpt');20wpt.log('test log');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!