Best JavaScript code snippet using protractor
readerUtils.js
Source:readerUtils.js
1/*2 * 读è
æä½çä¸äºæ¹æ³ ï¼æ¢å¤ éªè¯ æ失 è¡¥å ...ç3 * 4 */5 function getRdid(){6 var val=$('input:radio[name="id_radio"]:checked').val();7 if(val==null){8 return "";9 }10 else{11 return val;12 }13 }14 //1.æ¢å¤è¯»è
è¯15 var payed = 0.0;16 function renew() {//var rdId = getRdid();17 var rdId = getRdid();18 if(rdId == "") {19 showResult("请å
éæ©è¯»è
!");20 return;21 }22 $.ajax({23 type : "POST",24 url : "renew",25 data : {rdId: rdId,payed : payed},26 dataType : "json",27 success : function(jsonData){28 var success = jsonData.success;29 if(success == 0) {30 var checkfee = jsonData.checkfee;31 var servicefee = jsonData.servicefee;32 var idfee = jsonData.idfee;33 var deposity = jsonData.deposity;34 var rdDeposity = jsonData.rdDeposity;35 var totalfee = jsonData.totalfee;36 var tip = "";37 tip += " 读è
å½åæ¼éï¼" + rdDeposity + "å
";38 if(checkfee != 0) {39 tip += " éªè¯è´¹ï¼ " + checkfee + "å
";40 }41 if(servicefee != 0) {42 tip += " æå¡è´¹ ï¼" + servicefee + "å
";43 }44 if(idfee != 0) {45 tip += " å·¥æ¬è´¹ ï¼" + idfee + "å
";46 }47 if(deposity != 0) {48 tip += " æ¼é ï¼" + deposity + "å
";49 }50 if(totalfee != 0) {51 tip += " 计ç®åå
±åºäº¤" + totalfee + "å
ã";52 if(confirm(tip)) {53 payed = totalfee;54 renew();55 payed = 0.0;56 }57 }58 } else if(success == -1) {59 var totalfee = jsonData.totalfee;60 var prepay = jsonData.prepay;61 alert("读è
è´¦æ·ä½é¢("+ prepay +"å
), ä¸è¶³ä»¥å®ææ¤æ¬¡("+ totalfee +"å
)æ£è´¹!");62 payed = 0.0;63 return;64 } else if(success == 2) {65 showResult("该è¯ä¸éè¦æ¢å¤!");66 payed = 0.0;67 return;68 } else if(success == -2) {69 alert("è¯æä½æå!åæ¥å¤±è´¥");70 payed = 0.0;71 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;72 return;73 } else {74 alert("è¯æä½æå!");75 payed = 0.0;76 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;77 return;78 }79 80 },81 cache: false82 });83 }84 85 //读è
è¯æ³¨éæä½86 function rdLogout() {87 var rdId = getRdid();88 if(rdId == "") {89 showResult("请å
éæ©è¯»è
!");90 return;91 }92 var rdCFState = $("#rdstate").text();93 if(rdCFState=="注é"){94 if(!isContinue) {95 if(!confirm("该è¯å·²æ³¨éï¼è¯·æ£æ¥æ¯å¦å·²ç»è¢«æ³¨é, æ¯å¦ç»§ç»æ³¨éï¼"))return;96 isContinue = true;97 }98 }99 $.ajax({100 type : "POST",101 url : "logout",102 data : {rdId: rdId,payed : payed},103 dataType : "json",104 success : function(jsonData){105 var success = jsonData.success;106 if(success == 0) {107 var checkfee = jsonData.checkfee;108 var servicefee = jsonData.servicefee;109 var idfee = jsonData.idfee;110 var totalfee = jsonData.totalfee;111 var tip = "";112 if(checkfee != 0) {113 tip += " éªè¯è´¹ï¼ " + checkfee + "å
";114 }115 if(servicefee != 0) {116 tip += " æå¡è´¹ ï¼" + servicefee + "å
";117 }118 if(idfee != 0) {119 tip += " å·¥æ¬è´¹ ï¼" + idfee + "å
";120 }121 if(totalfee != 0) {122 tip += " 计ç®åå
±åºäº¤" + totalfee + "å
ã";123 if(confirm(tip)) {124 payed = totalfee;125 rdLogout();126 payed = 0.0;127 }128 }129 } else if(success == -1) {130 var totalfee = jsonData.totalfee;131 var prepay = jsonData.prepay;132 alert("读è
è´¦æ·ä½é¢("+ prepay +"å
), ä¸è¶³ä»¥å®ææ¤æ¬¡("+ totalfee +"å
)æ£è´¹!");133 payed = 0.0;134 return;135 } else if(success == 1) {136 alert("è¯æ³¨éæä½æå!");137 payed = 0.0;138 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;139 return;140 } else if(success == -2) {141 alert("è¯æ³¨éæä½æå!åæ¥å¤±è´¥ï¼");142 payed = 0.0;143 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;144 return;145 } else if(success == -3) {146 var message = jsonData.message;147 alert(message);148 return;149 }150 151 },152 cache: false153 });154 }155 //读è
è¯ä¿¡ç¨æææä½156 function credit() {157 var rdId = getRdid();158 if(rdId == "") {159 showResult("请å
éæ©è¯»è
!");160 return;161 }162// var rdCFState = $("#rdstate").text();163// if(rdCFState=="ä¿¡ç¨ææ"){164// if(!isContinue) {165// if(!confirm("该è¯å·²æ¯ä¿¡ç¨ææç¶æï¼è¯·æ£æ¥æ¯å¦å·²ç», æ¯å¦ç»§ç»æ³¨éï¼"))return;166// isContinue = true;167// }168// }169 $.ajax({170 type : "POST",171 url : "credit",172 data : {rdId: rdId,payed : payed},173 dataType : "json",174 success : function(jsonData){175 var success = jsonData.success;176 if(success == 0) {177 var checkfee = jsonData.checkfee;178 var servicefee = jsonData.servicefee;179 var idfee = jsonData.idfee;180 var totalfee = jsonData.totalfee;181 var tip = "";182 if(checkfee != 0) {183 tip += " éªè¯è´¹ï¼ " + checkfee + "å
";184 }185 if(servicefee != 0) {186 tip += " æå¡è´¹ ï¼" + servicefee + "å
";187 }188 if(idfee != 0) {189 tip += " å·¥æ¬è´¹ ï¼" + idfee + "å
";190 }191 if(totalfee != 0) {192 tip += " 计ç®åå
±åºäº¤" + totalfee + "å
ã";193 if(confirm(tip)) {194 payed = totalfee;195 rdLogout();196 payed = 0.0;197 }198 }199 } else if(success == -1) {200 var totalfee = jsonData.totalfee;201 var prepay = jsonData.prepay;202 alert("读è
è´¦æ·ä½é¢("+ prepay +"å
), ä¸è¶³ä»¥å®ææ¤æ¬¡("+ totalfee +"å
)æ£è´¹!");203 payed = 0.0;204 return;205 } else if(success == 1) {206 alert("è¯ä¿¡ç¨ææç¶ææä½æå!");207 payed = 0.0;208 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;209 return;210 } else if(success == -2) {211 alert("è¯ä¿¡ç¨ææç¶ææä½æå!åæ¥å¤±è´¥ï¼");212 payed = 0.0;213 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;214 return;215 } else if(success == -3) {216 var message = jsonData.message;217 alert(message);218 return;219 }220 221 },222 cache: false223 });224 }225 //éªè¯è¯»è
è¯226 function check() {//#cardOp cardDrop var rdId = $("#rdId").attr("value");227 var rdId = getRdid();228 if(rdId == "") {229 showResult("请å
éæ©è¯»è
!");230 return;231 }232 $.ajax({233 type : "POST",234 url : "check",235 data : {rdId: rdId, payed : payed},236 dataType : "json",237 success : function(jsonData){238 var success = jsonData.success;239 if(success == 0) {240 var checkfee = jsonData.checkfee;241 var servicefee = jsonData.servicefee;242 var idfee = jsonData.idfee;243 var totalfee = jsonData.totalfee;244 var tip = "";245 if(checkfee != 0) {246 tip += " éªè¯è´¹ï¼ " + checkfee + "å
";247 }248 if(servicefee != 0) {249 tip += " æå¡è´¹ ï¼" + servicefee + "å
";250 }251 if(idfee != 0) {252 tip += " å·¥æ¬è´¹ ï¼" + idfee + "å
";253 }254 if(totalfee != 0) {255 tip += " 计ç®åå
±åºäº¤" + totalfee + "å
ã";256 if(confirm(tip)) {257 payed = totalfee;258 check();259 payed = 0.0;260 }261 }262 } else if(success == -1) {263 var totalfee = jsonData.totalfee;264 var prepay = jsonData.prepay;265 alert("读è
è´¦æ·ä½é¢("+ prepay +"å
), ä¸è¶³ä»¥å®ææ¤æ¬¡("+ totalfee +"å
)æ£è´¹!");266 payed = 0.0;267 return;268 } else if(success == 1) {269 alert("éªè¯æä½æå!");270 payed = 0.0;271 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;272 return;273 } else if(success == -2) {274 alert("éªè¯æä½æå!åæ¥å¤±è´¥");275 payed = 0.0;276 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;277 return;278 }279 280 },281 cache: false282 });283 }284 285 function cardOperation(option) {//#cardOp cardDrop var rdId = $("#rdId").attr("value");286 var rdId = getRdid();287 if(rdId == "") {288 showResult("请å
éæ©è¯»è
!");289 return;290 }291 292 $.ajax({293 type : "POST",294 url : "cardOperation",295 data : {rdId: rdId, option : option},296 dataType : "json",297 success : function(jsonData){298 var success = jsonData.success;299 if(success == 1) {300 alert("è¯æä½æå!");301 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;302 return;303 } else if(success == 2) {304 showResult("该è¯æ é¡»è¿è¡æ¬æä½!");305 return;306 } else if(success == -2 ) {307 var message = jsonData.message;308 alert(message);309 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;310 }311 312 313 },314 cache: false315 });316 }317 318 //éè¯æä½319 function quit() {// var rdId = $("#rdId").attr("value");320 var rdId = getRdid();321 if(rdId == "") {322 showResult("请å
éæ©è¯»è
!");323 return;324 }325 var rdCFState = $("#rdstate").text();326 if(rdCFState=="注é"){327 if(!isContinue) {328 if(!confirm("该è¯å·²æ³¨éï¼è¯·æ£æ¥æ¯å¦å·²ç»è¢«éè¯, æ¯å¦ç»§ç»éè¯ï¼"))return;329 isContinue = true;330 }331 }332 $.ajax({333 type : "POST",334 url : "quit",335 data : {rdId: rdId,payed : payed},336 dataType : "json",337 success : function(jsonData){338 var success = jsonData.success;339 if(success == 0) {340 var checkfee = jsonData.checkfee;341 var servicefee = jsonData.servicefee;342 var idfee = jsonData.idfee;343 var totalfee = jsonData.totalfee;344 // message.append("\"prepay\":" + prepay + ", "); //åºéé¢ä»æ¬¾345 // message.append("\"deposity\":" + rdDeposity ); //æ¼é346 var prepay = jsonData.prepay;347 var deposity = jsonData.deposity;348 var tip = "åºäº¤ ";349 if(checkfee > 0) {350 tip += " éªè¯è´¹ã" + checkfee + "ãå
";351 }352 if(servicefee > 0) {353 tip += " æå¡è´¹ ã" + servicefee + "ãå
";354 }355 if(idfee > 0) {356 tip += " å·¥æ¬è´¹ ã" + idfee + "ãå
";357 }358 if(prepay > 0) {359 tip += " åºéè¿";360 tip += " ä¸å¡éä½é¢ã" + prepay + "ãå
";361 }362 if(deposity > 0) {363 tip += " åºéè¿";364 tip += " æ¼éã" + deposity + "ãå
";365 }366 if(totalfee > 0) {367 tip += " 计ç®åå
±åºäº¤" + totalfee + "å
ã";368 if(confirm(tip)) {369 payed = totalfee;370 quit();371 payed = 0.0;372 }373 } else {374 tip += " 计ç®åå
±åºéè¿" + (0 - totalfee) + "å
ã";375 if(confirm(tip)) {376 payed = totalfee;377 quit();378 payed = 0.0;379 }380 }381 382 } else if(success == -1) {383 var totalfee = jsonData.totalfee;384 var prepay = jsonData.prepay;385 alert("读è
è´¦æ·ä½é¢("+ prepay +"å
), ä¸è¶³ä»¥å®ææ¤æ¬¡("+ totalfee +"å
)æ£è´¹!");386 return;387 } else if(success == 1) {388 alert("éè¯æä½æå!");389 payed = 0.0;390 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;391 return;392 } else if(success == -2) {393 alert("éè¯æä½æå!åæ¥å¤±è´¥");394 payed = 0.0;395 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;396 return;397 } else if(success == -3) {398 var message = jsonData.message;399 alert(message);400 return;401 } else if(success == 2) {402 403 }404 405 },406 cache: false407 });408 }409 410 //åæ¥è¯»è
æä½411 function syncReader() {412 //var rdId = $("#rdId").attr("value");413 var rdId = getRdid();414 $("#syncButton").attr("disabled", "true");415 $("#syncButton").html("æ£å¨åæ¥...");416 417 if(rdId == "") {418 showResult("请å
éæ©è¯»è
!");419 $("#syncButton").removeAttr("disabled");420 $("#syncButton").html("æå¨åæ¥");421 return;422 }423 $.ajax({424 type : "POST",425 url : "syncReader/" + rdId,426 dataType : "json",427 success : function(jsonData){428 var success = jsonData.success;429 if(success == 1) {430 showResult("åæ¥æå!");431 $("#syncButton").removeAttr("disabled");432 $("#syncButton").html("æå¨åæ¥");433 return;434 } else if(success == 0) {435 var message = jsonData.message;436 showResult(message);437 $("#syncButton").removeAttr("disabled");438 $("#syncButton").html("æå¨åæ¥");439 return;440 } else {441 var message = jsonData.message;442 var exp = jsonData.exception;443 showResult(message + ", <br />å¼å¸¸ï¼" + exp);444 $("#syncButton").removeAttr("disabled");445 $("#syncButton").html("æå¨åæ¥");446 }447 },448 cache:false449 });450 }451 452 function searchReader() {453 var fieldValue = getRdid();454 var fieldName = "rdId";455 var obj = null;456 var params = {fieldName : fieldName,fieldValue : fieldValue};457 $.ajax({458 type : "POST",459 url : "searchReader",460 data : params,461 async: false, //设置åæ¥ å¼æ¥ajax åè°æ¯æ¿ä¸å°è¯¥å¯¹è±¡462 dataType : "json",463 success : function(backData){464 var result = backData.result;465 if(result && result=="none") {466 showResult("æªæ¥è¯¢å°è¯»è
ä¿¡æ¯ï¼");467 } else if(result && result=="more") {468 showResult("æ¥è¯¢ç»æ大äºä¸æ¡ï¼è¯·ç»åæ¥è¯¢æ¡ä»¶ï¼");469 } else {470 obj = eval(backData);//eval(backData);471 }472 },473 error : function(){474 showResult("æªæ¥è¯¢å°è¯»è
ä¿¡æ¯ï¼");475 }476 });477 return obj;478 }479 480 var isContinue = false;481 //读è
è¡¥åéæ© æ¯å¡è¡¥åè¿æ¯è¯å·è¡¥å 2014-12-12482 function repairSelect(){483 if(confirm("æ¯è¡¥å读è
è¯å·å?")){484 repair();485 return;486 }487 if(confirm("æ¯è¡¥å读è
å¡å·å?")){488 cardRepair();489 return;490 }491 }492 //è¡¥å å¨æ¥è¯çè´¦å·å¤å P493 var paySign = "0";494 var newRdid = "";495 function repair(){496 var rdId = getRdid();497 if(rdId == "") {498 showResult("请å
éæ©è¯»è
!");499 return;500 }501 var reader = searchReader();502 if(reader==null){503 showResult("æ¥æ¾ä¸å°è¯¥è¯»è
è¯ï¼");return;504 }505 var rdCFState=reader.rdCFState;506 //å°åå°æ°æ®åºæ¥è¯¢è¯¥è¯»è
ä¿¡æ¯507 if(!(rdCFState==3 || rdCFState==5)){508 showResult("åªææ失ã注éç¶æç读è
æè½è¡¥å读è
è¯ï¼");return;509 }510 if(rdCFState==5){511 if(!isContinue) {512 if(!confirm("该è¯å·²æ³¨éï¼è¯·æ£æ¥æ¯å¦å·²ç»è¡¥å读è
è¯, æ¯å¦ç»§ç»è¡¥åï¼"))return;513 isContinue = true;514 }515 }516 if(rdId.charAt(rdId.length-1)=="P"){517 if(!confirm("æ¤è¯»è
è¯å·²ç»æ¯è¡¥åè¯ï¼æ¯å¦ç»§ç»ï¼"))return;518 }519 //åºæ¬ä¿¡æ¯start520 var rdType = reader.rdType;521 var rdGlobal;522 var rdLibType;523 rdGlobal = reader.rdGlobal;524 rdLibType = reader.rdLibType;525 var libUser = reader.libUser;526 var rdStartDate = reader.rdStartDateStr;527 528 var rdEndDate = reader.rdEndDateStr;529 var rdInTime = reader.rdInTime;530 var rdLib = reader.rdLib;531 var rdSort1 = reader.rdSort1;532 var rdSort2 = reader.rdSort2;533 var rdSort3 = reader.rdSort3;534 var rdSort4 = reader.rdSort4;535 var rdSort5 = reader.rdSort5;536 537 var rdName = reader.rdName;538 var rdPasswd = reader.rdPasswd;539 var rdCertify = reader.rdCertify;540 var rdSex = reader.rdSex;541 var rdNation = reader.rdNation;542 var rdBornDate = reader.rdBornDateStr;543 var rdAge = reader.rdAge;544 var rdLoginId = reader.rdLoginId;545 var rdPhone = reader.rdPhone;546 var rdUnit = reader.rdUnit;547 var rdAddress = reader.rdAddress;548 var rdPostCode = reader.rdPostCode;549 var rdEmail = reader.rdEmail;550 var rdNative = reader.rdNative;551 var rdInterest = reader.rdInterest;552 var rdRemark = reader.rdRemark;553 var cardId = reader.cardId;554 //åºæ¬ä¿¡æ¯end555 if(newRdid == "") {556 newRdid = prompt("请è¾å
¥æ°è¯»è
è¯å·ï¼ç³»ç»é»è®¤å¦ä¸ï¼", rdId + "P");//æ´æ¢æ°è´¦å·557 var inputRdid = newRdid;558 if (inputRdid == "") {559 showResult("æ°è¯å·ä¸è½æ¯ç©º");560 return;561 } else if(inputRdid == null) {562 paySign = "0";563 return;564 }565 }566 567 var oldRdpasswd = reader.oldRdpasswd;568 var params = {rdId : rdId,rdCFState : rdCFState,rdType : rdType,rdGlobal : rdGlobal,rdLibType : rdLibType,569 rdStartDate : rdStartDate,rdEndDate : rdEndDate,rdInTime : rdInTime,rdLib : rdLib,rdSort1 : rdSort1,570 rdSort2 : rdSort2,rdSort3 : rdSort3,rdSort4 : rdSort4,rdSort5 : rdSort5,rdName : rdName,571 rdPasswd : rdPasswd,rdCertify : rdCertify,rdSex : rdSex,rdNation : rdNation,rdBornDate : rdBornDate,572 rdAge : rdAge,rdLoginId : rdLoginId,rdPhone : rdPhone,rdUnit : rdUnit,rdAddress : rdAddress,573 rdPostCode : rdPostCode,rdEmail : rdEmail,rdNative : rdNative,rdInterest : rdInterest, paySign:paySign, 574 libUser:libUser, rdRemark:rdRemark, newRdid: newRdid, cardId : cardId,oldRdpasswd: oldRdpasswd};575 $.ajax({576 type : "POST",577 url : "repair",578 data : params,579 dataType : "json",580 success : function(jsonData){581 var success = jsonData.success;582 if(success == 0) {583 var checkfee = jsonData.checkfee;584 var servicefee = jsonData.servicefee;585 var idfee = jsonData.idfee;586 var totalfee = jsonData.totalfee;587 var tip = "";588 if(checkfee != 0) {589 tip += " éªè¯è´¹ï¼ " + checkfee + "å
";590 }591 if(servicefee != 0) {592 tip += " æå¡è´¹ ï¼" + servicefee + "å
";593 }594 if(idfee != 0) {595 tip += " å·¥æ¬è´¹ ï¼" + idfee + "å
";596 }597 if(totalfee != 0) {598 tip += " å
±åºäº¤" + totalfee + "å
ã";599 if(confirm(tip)) {600 paySign = "1";601 602 repair();603 paySign = "0";604 newRdid == "";605 isContinue = false;606 }607 } else {608 paySign = "1";609 repair();610 paySign = "0";611 newRdid == "";612 isContinue = false;613 }614 } else if(success == -1) {615 var message = jsonData.message;616 showResult(message);617 isContinue = false;618 return;619 } else if(success == 2) {620 showResult("该è¯ä¸éè¦è¡¥å!");621 isContinue = false;622 return;623 } else if(success == -2) {624 showResult("è¯æä½æå!åæ¥å¤±è´¥");625 isContinue = false;626 window.location.href = "index";//"/sso/admin/reader/add/"+newRdid;627 return;628 } else {629 showResult("è¯æä½æå!");630 isContinue = false;631 window.location.href = "index";//"/sso/admin/reader/add/"+newRdid;632 return;633 }634 635 },636 cache: false637 });638 }639 640 //å¡è¡¥å cardRepair641 var newCardid = ""; //æ´æ¢çæ°å¡å·ï¼è¯å·ä¸å642 function cardRepair(){643 var rdId = getRdid();644 if(rdId == "") {645 showResult("请å
éæ©è¯»è
!");646 return;647 }648 var reader = searchReader();649 if(reader==null){650 showResult("æ¥æ¾ä¸å°è¯¥è¯»è
è¯ï¼");return;651 }652 var rdCFState=reader.rdCFState;653 //å°åå°æ°æ®åºæ¥è¯¢è¯¥è¯»è
ä¿¡æ¯654 if(!(rdCFState==3 || rdCFState==5)){655 showResult("åªææ失ã注éç¶æç读è
æè½è¡¥å读è
è¯ï¼");return;656 }657 if(rdCFState==5){658 if(!isContinue) {659 if(!confirm("该è¯å·²æ³¨éï¼è¯·æ£æ¥æ¯å¦å·²ç»è¡¥å读è
è¯, æ¯å¦ç»§ç»è¡¥åï¼"))return;660 isContinue = true;661 }662 }663 if(newCardid == "") {664 newCardid = prompt("请è¾å
¥è¯¥è¯»è
æ°å¡å·ï¼", ""); //æ´æ¢çæ°å¡å·ï¼è¯å·ä¸å665 if(newCardid==""){666 showResult("æ°å¡å·ä¸è½æ¯ç©º");667 return;668 } else if(newCardid == null) {669 paySign = "0";670 return;671 }672 }673 674 675 //åºæ¬ä¿¡æ¯start676 var rdType = reader.rdType;677 var rdGlobal;678 var rdLibType;679 rdGlobal = reader.rdGlobal;680 rdLibType = reader.rdLibType;681 var libUser = reader.libUser;682 var rdStartDate = reader.rdStartDateStr;683 684 var rdEndDate = reader.rdEndDateStr;685 var rdInTime = reader.rdInTime;686 var rdLib = reader.rdLib;687 var rdSort1 = reader.rdSort1;688 var rdSort2 = reader.rdSort2;689 var rdSort3 = reader.rdSort3;690 var rdSort4 = reader.rdSort4;691 var rdSort5 = reader.rdSort5;692 693 var rdName = reader.rdName;694 var rdPasswd = reader.rdPasswd;695 var rdCertify = reader.rdCertify;696 var rdSex = reader.rdSex;697 var rdNation = reader.rdNation;698 var rdBornDate = reader.rdBornDateStr;699 var rdAge = reader.rdAge;700 var rdLoginId = reader.rdLoginId;701 var rdPhone = reader.rdPhone;702 var rdUnit = reader.rdUnit;703 var rdAddress = reader.rdAddress;704 var rdPostCode = reader.rdPostCode;705 var rdEmail = reader.rdEmail;706 var rdNative = reader.rdNative;707 var rdInterest = reader.rdInterest;708 var rdRemark = reader.rdRemark;709 var cardId = reader.cardId;710 //åºæ¬ä¿¡æ¯end711 712 var newRdid = reader.newRdid;713 //var paySign = "0";714 var oldRdpasswd = reader.oldRdpasswd;715 716 var params = {rdId : rdId,rdCFState : rdCFState,rdType : rdType,rdGlobal : rdGlobal,rdLibType : rdLibType,717 rdStartDate : rdStartDate,rdEndDate : rdEndDate,rdInTime : rdInTime,rdLib : rdLib,rdSort1 : rdSort1,718 rdSort2 : rdSort2,rdSort3 : rdSort3,rdSort4 : rdSort4,rdSort5 : rdSort5,rdName : rdName,719 rdPasswd : rdPasswd,rdCertify : rdCertify,rdSex : rdSex,rdNation : rdNation,rdBornDate : rdBornDate,720 rdAge : rdAge,rdLoginId : rdLoginId,rdPhone : rdPhone,rdUnit : rdUnit,rdAddress : rdAddress,721 rdPostCode : rdPostCode,rdEmail : rdEmail,rdNative : rdNative,rdInterest : rdInterest, paySign:paySign, 722 libUser:libUser, rdRemark:rdRemark, newRdid: newRdid, cardId : cardId,oldRdpasswd: oldRdpasswd,newCardid:newCardid};723 $.ajax({724 type : "POST",725 url : "cardRepair",726 data : params,727 dataType : "json",728 success : function(jsonData){729 var success = jsonData.success;730 if(success == 0) {731 var checkfee = jsonData.checkfee;732 var servicefee = jsonData.servicefee;733 var idfee = jsonData.idfee;734 var totalfee = jsonData.totalfee;735 var tip = "";736 if(checkfee != 0) {737 tip += " éªè¯è´¹ï¼ " + checkfee + "å
";738 }739 if(servicefee != 0) {740 tip += " æå¡è´¹ ï¼" + servicefee + "å
";741 }742 if(idfee != 0) {743 tip += " å·¥æ¬è´¹ ï¼" + idfee + "å
";744 }745 if(totalfee != 0) {746 tip += " å
±åºäº¤" + totalfee + "å
ã";747 if(confirm(tip)) {748 paySign = "1";749 cardRepair();750 paySign = "0";751 newCardid = "";752 isContinue = false;753 }754 } else {755 paySign = "1";756 757 cardRepair();758 paySign = "0";759 newCardid = "";760 isContinue = false;761 }762 } else if(success == -1) {763 var message = jsonData.message;764 showResult(message);765 isContinue = false;766 return;767 } else if(success == 2) {768 showResult("该è¯ä¸éè¦æ¢å¤!");769 isContinue = false;770 return;771 } else if(success == -2) {772 showResult("è¯æä½æå!åæ¥å¤±è´¥");773 isContinue = false;774 window.location.href = "index";775 return;776 } else {777 showResult("è¯æä½æå!");778 isContinue = false;779 window.location.href = "index";780 return;781 }782 783 },784 cache: false785 });786 }787 788 //æ¢è¯789 function change(){790 var rdId = getRdid();791 if(rdId == "") {792 showResult("请å
éæ©è¯»è
!");793 return;794 }795 var reader = searchReader();796 if(reader==null){797 showResult("æ¥æ¾ä¸å°è¯¥è¯»è
è¯ï¼");return;798 }799 var rdCFState=reader.rdCFState;800 801 //åºæ¬ä¿¡æ¯start802 var rdType = reader.rdType;803 var rdGlobal = reader.rdGlobal;804 var rdLibType = reader.rdLibType;805 var libUser = reader.libUser;806 var rdStartDate = reader.rdStartDateStr;807 808 var rdEndDate = reader.rdEndDateStr;809 var rdInTime = reader.rdInTime;810 var rdLib = reader.rdLib;811 var rdSort1 = reader.rdSort1;812 var rdSort2 = reader.rdSort2;813 var rdSort3 = reader.rdSort3;814 var rdSort4 = reader.rdSort4;815 var rdSort5 = reader.rdSort5;816 817 var rdName = reader.rdName;818 var rdPasswd = reader.rdPasswd;819 var rdCertify = reader.rdCertify;820 var rdSex = reader.rdSex;821 var rdNation = reader.rdNation;822 var rdBornDate = reader.rdBornDateStr;823 var rdAge = reader.rdAge;824 var rdLoginId = reader.rdLoginId;825 var rdPhone = reader.rdPhone;826 var rdUnit = reader.rdUnit;827 var rdAddress = reader.rdAddress;828 var rdPostCode = reader.rdPostCode;829 var rdEmail = reader.rdEmail;830 var rdNative = reader.rdNative;831 var rdInterest = reader.rdInterest;832 var rdRemark = reader.rdRemark;833 var cardId = reader.cardId;834 //åºæ¬ä¿¡æ¯end835 836 //var paySign = reader.paySign;//$("#paySign").val();837 if(newRdid == "") {838 newRdid = prompt("请è¾å
¥æ°è¯»è
è¯å·ï¼ç³»ç»é»è®¤å¦ä¸ï¼", rdId + "P"); //å°è¾å
¥çå
容èµç»åéæ°è´¦å·839 if (newRdid == "") {840 showResult("æ°è¯å·ä¸è½æ¯ç©º");841 return;842 } else if(newRdid == null) {843 paySign = "0";844 return;845 }846 }847 var params = {rdId : rdId,rdCFState : rdCFState,rdType : rdType,rdGlobal : rdGlobal,rdLibType : rdLibType,848 rdStartDate : rdStartDate,rdEndDate : rdEndDate,rdInTime : rdInTime,rdLib : rdLib,rdSort1 : rdSort1,849 rdSort2 : rdSort2,rdSort3 : rdSort3,rdSort4 : rdSort4,rdSort5 : rdSort5,rdName : rdName,850 rdPasswd : rdPasswd,rdCertify : rdCertify,rdSex : rdSex,rdNation : rdNation,rdBornDate : rdBornDate,851 rdAge : rdAge,rdLoginId : rdLoginId,rdPhone : rdPhone,rdUnit : rdUnit,rdAddress : rdAddress,852 rdPostCode : rdPostCode,rdEmail : rdEmail,rdNative : rdNative,rdInterest : rdInterest, paySign:paySign, 853 libUser:libUser, rdRemark:rdRemark, newRdid: newRdid, cardId:cardId};854 $.ajax({855 type : "POST",856 url : "change",857 data : params,858 dataType : "json",859 success : function(jsonData){860 var success = jsonData.success;861 if(success == 0) {862 var checkfee = jsonData.checkfee;863 var servicefee = jsonData.servicefee;864 var idfee = jsonData.idfee;865 var totalfee = jsonData.totalfee;866 var tip = "";867 if(checkfee != 0) {868 tip += " éªè¯è´¹ï¼ " + checkfee + "å
";869 }870 if(servicefee != 0) {871 tip += " æå¡è´¹ ï¼" + servicefee + "å
";872 }873 if(idfee != 0) {874 tip += " å·¥æ¬è´¹ ï¼" + idfee + "å
";875 }876 if(totalfee != 0) {877 tip += " å
±åºäº¤" + totalfee + "å
ã";878 if(confirm(tip)) {879 paySign = "1";880 881 change();882 paySign = "0";883 newRdid = "";884 }885 } else {886 paySign = "1";887 888 change();889 paySign = "0";890 newRdid = "";891 }892 } else if(success == -1) {893 var message = jsonData.message;894 showResult(message);895 paySign = "0";896 newRdid = "";897 return;898 } else if(success == 2) {899 return;900 } else if(success == -2) {901 alert("è¯æä½æå!åæ¥å¤±è´¥");902 window.location.href = "index";//"/sso/admin/reader/add/"+newRdid;903 return;904 } else {905 alert("è¯æä½æå!");906 window.location.href = "index";//"/sso/admin/reader/add/"+newRdid;907 return;908 }909 910 },911 cache: false912 });913 }914 915 //延æ916 function defer() {917 var rdId = getRdid();918 if(rdId == "") {919 showResult("请å
éæ©è¯»è
!");920 return;921 }922 var reader = searchReader();923 if(reader==null){924 showResult("æ¥æ¾ä¸å°è¯¥è¯»è
è¯ï¼");return;925 }926 var rdCFState=reader.rdCFState;927 if(rdCFState==5){928 if(!isContinue) {929 showResult("注éç读è
è¯ä¸è½å»¶æï¼");return;930 //if(!confirm("该è¯å·²æ³¨éï¼è¯·æ£æ¥æ¯å¦å·²ç»è¢«æ³¨é, æ¯å¦ç»§ç»æ³¨éï¼"))return;931 //isContinue = true;932 }933 }934 935 //åºæ¬ä¿¡æ¯start936 var rdType = reader.rdType;937 var rdGlobal = reader.rdGlobal;938 var rdLibType = reader.rdLibType;939 var libUser = reader.libUser;940 var rdStartDate = reader.rdStartDateStr;941 942 var rdEndDate = reader.rdEndDateStr;943 var rdInTime = reader.rdInTime;944 var rdLib = reader.rdLib;945 var rdSort1 = reader.rdSort1;946 var rdSort2 = reader.rdSort2;947 var rdSort3 = reader.rdSort3;948 var rdSort4 = reader.rdSort4;949 var rdSort5 = reader.rdSort5;950 951 var rdName = reader.rdName;952 var rdPasswd = reader.rdPasswd;953 var rdCertify = reader.rdCertify;954 var rdSex = reader.rdSex;955 var rdNation = reader.rdNation;956 var rdBornDate = reader.rdBornDateStr;957 var rdAge = reader.rdAge;958 var rdLoginId = reader.rdLoginId;959 var rdPhone = reader.rdPhone;960 var rdUnit = reader.rdUnit;961 var rdAddress = reader.rdAddress;962 var rdPostCode = reader.rdPostCode;963 var rdEmail = reader.rdEmail;964 var rdNative = reader.rdNative;965 var rdInterest = reader.rdInterest;966 var rdRemark = reader.rdRemark;967 //åºæ¬ä¿¡æ¯end968 var deferDate = reader.deferDate;//延æçé»è®¤æ¶é´969 deferDate = prompt("请è¾å
¥å»¶æç»æ¢æ¥æï¼æ ¼å¼YYYY-MM-DDï¼ç³»ç»é»è®¤ä¸ºï¼å½åæ¥æ+读è
æææï¼", rdEndDate);//æ´æ°å»¶æé»è®¤æ¶é´970 var params = {rdId : rdId,rdCFState : rdCFState,rdType : rdType,rdGlobal : rdGlobal,rdLibType : rdLibType,971 rdStartDate : rdStartDate,rdEndDate : rdEndDate,rdInTime : rdInTime,rdLib : rdLib,rdSort1 : rdSort1,972 rdSort2 : rdSort2,rdSort3 : rdSort3,rdSort4 : rdSort4,rdSort5 : rdSort5,rdName : rdName,973 rdPasswd : rdPasswd,rdCertify : rdCertify,rdSex : rdSex,rdNation : rdNation,rdBornDate : rdBornDate,974 rdAge : rdAge,rdLoginId : rdLoginId,rdPhone : rdPhone,rdUnit : rdUnit,rdAddress : rdAddress,975 rdPostCode : rdPostCode,rdEmail : rdEmail,rdNative : rdNative,rdInterest : rdInterest, paySign:paySign, 976 libUser:libUser, rdRemark:rdRemark, deferDate:deferDate};977 $.ajax({978 type : "POST",979 url : "defer",980 data : params,981 dataType : "json",982 success : function(jsonData){983 var success = jsonData.success;984 if(success == 0) {985 var checkfee = jsonData.checkfee;986 var servicefee = jsonData.servicefee;987 var idfee = jsonData.idfee;988 var totalfee = jsonData.totalfee;989 var tip = "";990 if(checkfee != 0) {991 tip += " éªè¯è´¹ï¼ " + checkfee + "å
";992 }993 if(servicefee != 0) {994 tip += " æå¡è´¹ ï¼" + servicefee + "å
";995 }996 if(idfee != 0) {997 tip += " å·¥æ¬è´¹ ï¼" + idfee + "å
";998 }999 if(totalfee != 0) {1000 tip += " å
±åºäº¤" + totalfee + "å
ã";1001 if(confirm(tip)) {1002 paySign = "1";1003 deferDate = prompt("请è¾å
¥å»¶æç»æ¢æ¥æï¼æ ¼å¼YYYY-MM-DDï¼ç³»ç»é»è®¤ä¸ºï¼å½åæ¥æ+读è
æææï¼", rdEndDate);1004 if (inputDefer == "") {1005 showResult("ç»æ¢æ¥æä¸è½æ¯ç©º");1006 return;1007 } else if(inputDefer == null) {1008 paySign = "0";1009 return;1010 }1011 defer();1012 paySign = "0";1013 }1014 } else {1015 paySign = "1";1016 deferDate = prompt("请è¾å
¥å»¶æç»æ¢æ¥æï¼æ ¼å¼YYYY-MM-DDï¼ç³»ç»é»è®¤ä¸ºï¼å½åæ¥æ+读è
æææï¼", rdEndDate);1017 if (inputDefer == "") {1018 showResult("ç»æ¢æ¥æä¸è½æ¯ç©º");1019 return;1020 } else if(inputDefer == null) {1021 paySign = "0";1022 return;1023 }1024 defer();1025 paySign = "0";1026 }1027 } else if(success == -1) {1028 var message = jsonData.message;1029 showResult(message);1030 return;1031 } else if(success == -2) {1032 showResult("è¯æä½æå!åæ¥å¤±è´¥");1033 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;1034 1035 return;1036 } else {1037 showResult("è¯æä½æå!");1038 window.location.href = "index";//"/sso/admin/reader/add/"+rdId;1039 return;1040 }1041 1042 },1043 cache: false1044 });1045 }1046 1047 //计ç®å¹´é¾1048 function caculateAge(birthday) {1049 if(!birthday){1050 return;1051 }1052 birthday=new Date(birthday.replace(/-/g, "\/")); 1053 var d=new Date(); 1054 var age = d.getFullYear()-birthday.getFullYear()-((d.getMonth()<birthday.getMonth()|| d.getMonth()==birthday.getMonth() && d.getDate()<birthday.getDate())?1:0);1055 document.getElementById("rdAge").value = age;1056 }1057 ...
thumb.js
Source:thumb.js
1ARMCoreThumb = function (cpu) {2 this.cpu = cpu;3};4ARMCoreThumb.prototype.constructADC = function(rd, rm) {5 var cpu = this.cpu;6 var gprs = cpu.gprs;7 return function() {8 cpu.mmu.waitPrefetch(gprs[cpu.PC]);9 var m = (gprs[rm] >>> 0) + !!cpu.cpsrC;10 var oldD = gprs[rd];11 var d = (oldD >>> 0) + m;12 var oldDn = oldD >> 31;13 var dn = d >> 31;14 var mn = m >> 31;15 cpu.cpsrN = dn;16 cpu.cpsrZ = !(d & 0xFFFFFFFF);17 cpu.cpsrC = d > 0xFFFFFFFF;18 cpu.cpsrV = oldDn == mn && oldDn != dn && mn != dn;19 gprs[rd] = d;20 };21};22ARMCoreThumb.prototype.constructADD1 = function(rd, rn, immediate) {23 var cpu = this.cpu;24 var gprs = cpu.gprs;25 return function() {26 cpu.mmu.waitPrefetch(gprs[cpu.PC]);27 var d = (gprs[rn] >>> 0) + immediate;28 cpu.cpsrN = d >> 31;29 cpu.cpsrZ = !(d & 0xFFFFFFFF);30 cpu.cpsrC = d > 0xFFFFFFFF;31 cpu.cpsrV = !(gprs[rn] >> 31) && ((gprs[rn] >> 31 ^ d) >> 31) && (d >> 31);32 gprs[rd] = d;33 };34};35ARMCoreThumb.prototype.constructADD2 = function(rn, immediate) {36 var cpu = this.cpu;37 var gprs = cpu.gprs;38 return function() {39 cpu.mmu.waitPrefetch(gprs[cpu.PC]);40 var d = (gprs[rn] >>> 0) + immediate;41 cpu.cpsrN = d >> 31;42 cpu.cpsrZ = !(d & 0xFFFFFFFF);43 cpu.cpsrC = d > 0xFFFFFFFF;44 cpu.cpsrV = !(gprs[rn] >> 31) && ((gprs[rn] ^ d) >> 31) && ((immediate ^ d) >> 31);45 gprs[rn] = d;46 };47};48ARMCoreThumb.prototype.constructADD3 = function(rd, rn, rm) {49 var cpu = this.cpu;50 var gprs = cpu.gprs;51 return function() {52 cpu.mmu.waitPrefetch(gprs[cpu.PC]);53 var d = (gprs[rn] >>> 0) + (gprs[rm] >>> 0);54 cpu.cpsrN = d >> 31;55 cpu.cpsrZ = !(d & 0xFFFFFFFF);56 cpu.cpsrC = d > 0xFFFFFFFF;57 cpu.cpsrV = !((gprs[rn] ^ gprs[rm]) >> 31) && ((gprs[rn] ^ d) >> 31) && ((gprs[rm] ^ d) >> 31);58 gprs[rd] = d;59 };60};61ARMCoreThumb.prototype.constructADD4 = function(rd, rm) {62 var cpu = this.cpu;63 var gprs = cpu.gprs;64 return function() {65 cpu.mmu.waitPrefetch(gprs[cpu.PC]);66 gprs[rd] += gprs[rm];67 };68};69ARMCoreThumb.prototype.constructADD5 = function(rd, immediate) {70 var cpu = this.cpu;71 var gprs = cpu.gprs;72 return function() {73 cpu.mmu.waitPrefetch(gprs[cpu.PC]);74 gprs[rd] = (gprs[cpu.PC] & 0xFFFFFFFC) + immediate;75 };76};77ARMCoreThumb.prototype.constructADD6 = function(rd, immediate) {78 var cpu = this.cpu;79 var gprs = cpu.gprs;80 return function() {81 cpu.mmu.waitPrefetch(gprs[cpu.PC]);82 gprs[rd] = gprs[cpu.SP] + immediate;83 };84};85ARMCoreThumb.prototype.constructADD7 = function(immediate) {86 var cpu = this.cpu;87 var gprs = cpu.gprs;88 return function() {89 cpu.mmu.waitPrefetch(gprs[cpu.PC]);90 gprs[cpu.SP] += immediate;91 };92};93ARMCoreThumb.prototype.constructAND = function(rd, rm) {94 var cpu = this.cpu;95 var gprs = cpu.gprs;96 return function() {97 cpu.mmu.waitPrefetch(gprs[cpu.PC]);98 gprs[rd] = gprs[rd] & gprs[rm];99 cpu.cpsrN = gprs[rd] >> 31;100 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);101 };102};103ARMCoreThumb.prototype.constructASR1 = function(rd, rm, immediate) {104 var cpu = this.cpu;105 var gprs = cpu.gprs;106 return function() {107 cpu.mmu.waitPrefetch(gprs[cpu.PC]);108 if (immediate == 0) {109 cpu.cpsrC = gprs[rm] >> 31;110 if (cpu.cpsrC) {111 gprs[rd] = 0xFFFFFFFF;112 } else {113 gprs[rd] = 0;114 }115 } else {116 cpu.cpsrC = gprs[rm] & (1 << (immediate - 1));117 gprs[rd] = gprs[rm] >> immediate;118 }119 cpu.cpsrN = gprs[rd] >> 31;120 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);121 };122};123ARMCoreThumb.prototype.constructASR2 = function(rd, rm) {124 var cpu = this.cpu;125 var gprs = cpu.gprs;126 return function() {127 cpu.mmu.waitPrefetch(gprs[cpu.PC]);128 var rs = gprs[rm] & 0xFF;129 if (rs) {130 if (rs < 32) {131 cpu.cpsrC = gprs[rd] & (1 << (rs - 1));132 gprs[rd] >>= rs;133 } else {134 cpu.cpsrC = gprs[rd] >> 31;135 if (cpu.cpsrC) {136 gprs[rd] = 0xFFFFFFFF;137 } else {138 gprs[rd] = 0;139 }140 }141 }142 cpu.cpsrN = gprs[rd] >> 31;143 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);144 };145};146ARMCoreThumb.prototype.constructB1 = function(immediate, condOp) {147 var cpu = this.cpu;148 var gprs = cpu.gprs;149 return function() {150 cpu.mmu.waitPrefetch(gprs[cpu.PC]);151 if (condOp()) {152 gprs[cpu.PC] += immediate;153 }154 };155};156ARMCoreThumb.prototype.constructB2 = function(immediate) {157 var cpu = this.cpu;158 var gprs = cpu.gprs;159 return function() {160 cpu.mmu.waitPrefetch(gprs[cpu.PC]);161 gprs[cpu.PC] += immediate;162 };163};164ARMCoreThumb.prototype.constructBIC = function(rd, rm) {165 var cpu = this.cpu;166 var gprs = cpu.gprs;167 return function() {168 cpu.mmu.waitPrefetch(gprs[cpu.PC]);169 gprs[rd] = gprs[rd] & ~gprs[rm];170 cpu.cpsrN = gprs[rd] >> 31;171 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);172 };173};174ARMCoreThumb.prototype.constructBL1 = function(immediate) {175 var cpu = this.cpu;176 var gprs = cpu.gprs;177 return function() {178 cpu.mmu.waitPrefetch(gprs[cpu.PC]);179 gprs[cpu.LR] = gprs[cpu.PC] + immediate;180 }181};182ARMCoreThumb.prototype.constructBL2 = function(immediate) {183 var cpu = this.cpu;184 var gprs = cpu.gprs;185 return function() {186 cpu.mmu.waitPrefetch(gprs[cpu.PC]);187 var pc = gprs[cpu.PC];188 gprs[cpu.PC] = gprs[cpu.LR] + (immediate << 1);189 gprs[cpu.LR] = pc - 1;190 }191};192ARMCoreThumb.prototype.constructBX = function(rd, rm) {193 var cpu = this.cpu;194 var gprs = cpu.gprs;195 return function() {196 cpu.mmu.waitPrefetch(gprs[cpu.PC]);197 cpu.switchExecMode(gprs[rm] & 0x00000001);198 var misalign = 0;199 if (rm == 15) {200 misalign = gprs[rm] & 0x00000002;201 }202 gprs[cpu.PC] = gprs[rm] & 0xFFFFFFFE - misalign;203 };204};205ARMCoreThumb.prototype.constructCMN = function(rd, rm) {206 var cpu = this.cpu;207 var gprs = cpu.gprs;208 return function() {209 cpu.mmu.waitPrefetch(gprs[cpu.PC]);210 var aluOut = (gprs[rd] >>> 0) + (gprs[rm] >>> 0);211 cpu.cpsrN = aluOut >> 31;212 cpu.cpsrZ = !(aluOut & 0xFFFFFFFF);213 cpu.cpsrC = aluOut > 0xFFFFFFFF;214 cpu.cpsrV = (gprs[rd] >> 31) == (gprs[rm] >> 31) &&215 (gprs[rd] >> 31) != (aluOut >> 31) &&216 (gprs[rm] >> 31) != (aluOut >> 31);217 };218};219ARMCoreThumb.prototype.constructCMP1 = function(rn, immediate) {220 var cpu = this.cpu;221 var gprs = cpu.gprs;222 return function() {223 cpu.mmu.waitPrefetch(gprs[cpu.PC]);224 var aluOut = gprs[rn] - immediate;225 cpu.cpsrN = aluOut >> 31;226 cpu.cpsrZ = !(aluOut & 0xFFFFFFFF);227 cpu.cpsrC = (gprs[rn] >>> 0) >= immediate;228 cpu.cpsrV = (gprs[rn] >> 31) && ((gprs[rn] ^ aluOut) >> 31);229 };230}231ARMCoreThumb.prototype.constructCMP2 = function(rd, rm) {232 var cpu = this.cpu;233 var gprs = cpu.gprs;234 return function() {235 cpu.mmu.waitPrefetch(gprs[cpu.PC]);236 var d = gprs[rd];237 var m = gprs[rm];238 var aluOut = d - m;239 var an = aluOut >> 31;240 var dn = d >> 31;241 cpu.cpsrN = an;242 cpu.cpsrZ = !(aluOut & 0xFFFFFFFF);243 cpu.cpsrC = (d >>> 0) >= (m >>> 0);244 cpu.cpsrV = dn != (m >> 31) && dn != an;245 };246};247ARMCoreThumb.prototype.constructCMP3 = function(rd, rm) {248 var cpu = this.cpu;249 var gprs = cpu.gprs;250 return function() {251 cpu.mmu.waitPrefetch(gprs[cpu.PC]);252 var aluOut = gprs[rd] - gprs[rm];253 cpu.cpsrN = aluOut >> 31;254 cpu.cpsrZ = !(aluOut & 0xFFFFFFFF);255 cpu.cpsrC = (gprs[rd] >>> 0) >= (gprs[rm] >>> 0);256 cpu.cpsrV = ((gprs[rd] ^ gprs[rm]) >> 31) && ((gprs[rd] ^ aluOut) >> 31);257 };258};259ARMCoreThumb.prototype.constructEOR = function(rd, rm) {260 var cpu = this.cpu;261 var gprs = cpu.gprs;262 return function() {263 cpu.mmu.waitPrefetch(gprs[cpu.PC]);264 gprs[rd] = gprs[rd] ^ gprs[rm];265 cpu.cpsrN = gprs[rd] >> 31;266 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);267 };268};269ARMCoreThumb.prototype.constructLDMIA = function(rn, rs) {270 var cpu = this.cpu;271 var gprs = cpu.gprs;272 return function() {273 cpu.mmu.waitPrefetch(gprs[cpu.PC]);274 var address = gprs[rn];275 var total = 0;276 var m, i;277 for (m = 0x01, i = 0; i < 8; m <<= 1, ++i) {278 if (rs & m) {279 gprs[i] = cpu.mmu.load32(address);280 address += 4;281 ++total;282 }283 }284 cpu.mmu.waitMulti32(address, total);285 if (!((1 << rn) & rs)) {286 gprs[rn] = address;287 }288 };289};290ARMCoreThumb.prototype.constructLDR1 = function(rd, rn, immediate) {291 var cpu = this.cpu;292 var gprs = cpu.gprs;293 return function() {294 cpu.mmu.waitPrefetch(gprs[cpu.PC]);295 var n = gprs[rn] + immediate;296 gprs[rd] = cpu.mmu.load32(n);297 cpu.mmu.wait32(n);298 ++cpu.cycles;299 };300};301ARMCoreThumb.prototype.constructLDR2 = function(rd, rn, rm) {302 var cpu = this.cpu;303 var gprs = cpu.gprs;304 return function() {305 cpu.mmu.waitPrefetch(gprs[cpu.PC]);306 gprs[rd] = cpu.mmu.load32(gprs[rn] + gprs[rm]);307 cpu.mmu.wait32(gprs[rn] + gprs[rm]);308 ++cpu.cycles;309 }310};311ARMCoreThumb.prototype.constructLDR3 = function(rd, immediate) {312 var cpu = this.cpu;313 var gprs = cpu.gprs;314 return function() {315 cpu.mmu.waitPrefetch(gprs[cpu.PC]);316 gprs[rd] = cpu.mmu.load32((gprs[cpu.PC] & 0xFFFFFFFC) + immediate);317 cpu.mmu.wait32(gprs[cpu.PC]);318 ++cpu.cycles;319 };320};321ARMCoreThumb.prototype.constructLDR4 = function(rd, immediate) {322 var cpu = this.cpu;323 var gprs = cpu.gprs;324 return function() {325 cpu.mmu.waitPrefetch(gprs[cpu.PC]);326 gprs[rd] = cpu.mmu.load32(gprs[cpu.SP] + immediate);327 cpu.mmu.wait32(gprs[cpu.SP] + immediate);328 ++cpu.cycles;329 };330};331ARMCoreThumb.prototype.constructLDRB1 = function(rd, rn, immediate) {332 var cpu = this.cpu;333 var gprs = cpu.gprs;334 return function() {335 var n = gprs[rn] + immediate;336 cpu.mmu.waitPrefetch(gprs[cpu.PC]);337 gprs[rd] = cpu.mmu.loadU8(n);338 cpu.mmu.wait(n);339 ++cpu.cycles;340 };341};342ARMCoreThumb.prototype.constructLDRB2 = function(rd, rn, rm) {343 var cpu = this.cpu;344 var gprs = cpu.gprs;345 return function() {346 cpu.mmu.waitPrefetch(gprs[cpu.PC]);347 gprs[rd] = cpu.mmu.loadU8(gprs[rn] + gprs[rm]);348 cpu.mmu.wait(gprs[rn] + gprs[rm]);349 ++cpu.cycles;350 };351};352ARMCoreThumb.prototype.constructLDRH1 = function(rd, rn, immediate) {353 var cpu = this.cpu;354 var gprs = cpu.gprs;355 return function() {356 var n = gprs[rn] + immediate;357 cpu.mmu.waitPrefetch(gprs[cpu.PC]);358 gprs[rd] = cpu.mmu.loadU16(n);359 cpu.mmu.wait(n);360 ++cpu.cycles;361 };362};363ARMCoreThumb.prototype.constructLDRH2 = function(rd, rn, rm) {364 var cpu = this.cpu;365 var gprs = cpu.gprs;366 return function() {367 cpu.mmu.waitPrefetch(gprs[cpu.PC]);368 gprs[rd] = cpu.mmu.loadU16(gprs[rn] + gprs[rm]);369 cpu.mmu.wait(gprs[rn] + gprs[rm]);370 ++cpu.cycles;371 };372};373ARMCoreThumb.prototype.constructLDRSB = function(rd, rn, rm) {374 var cpu = this.cpu;375 var gprs = cpu.gprs;376 return function() {377 cpu.mmu.waitPrefetch(gprs[cpu.PC]);378 gprs[rd] = cpu.mmu.load8(gprs[rn] + gprs[rm]);379 cpu.mmu.wait(gprs[rn] + gprs[rm]);380 ++cpu.cycles;381 };382};383ARMCoreThumb.prototype.constructLDRSH = function(rd, rn, rm) {384 var cpu = this.cpu;385 var gprs = cpu.gprs;386 return function() {387 cpu.mmu.waitPrefetch(gprs[cpu.PC]);388 gprs[rd] = cpu.mmu.load16(gprs[rn] + gprs[rm]);389 cpu.mmu.wait(gprs[rn] + gprs[rm]);390 ++cpu.cycles;391 };392};393ARMCoreThumb.prototype.constructLSL1 = function(rd, rm, immediate) {394 var cpu = this.cpu;395 var gprs = cpu.gprs;396 return function() {397 cpu.mmu.waitPrefetch(gprs[cpu.PC]);398 if (immediate == 0) {399 gprs[rd] = gprs[rm];400 } else {401 cpu.cpsrC = gprs[rm] & (1 << (32 - immediate));402 gprs[rd] = gprs[rm] << immediate;403 }404 cpu.cpsrN = gprs[rd] >> 31;405 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);406 };407};408ARMCoreThumb.prototype.constructLSL2 = function(rd, rm) {409 var cpu = this.cpu;410 var gprs = cpu.gprs;411 return function() {412 cpu.mmu.waitPrefetch(gprs[cpu.PC]);413 var rs = gprs[rm] & 0xFF;414 if (rs) {415 if (rs < 32) {416 cpu.cpsrC = gprs[rd] & (1 << (32 - rs));417 gprs[rd] <<= rs;418 } else {419 if (rs > 32) {420 cpu.cpsrC = 0;421 } else {422 cpu.cpsrC = gprs[rd] & 0x00000001;423 }424 gprs[rd] = 0;425 }426 }427 cpu.cpsrN = gprs[rd] >> 31;428 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);429 };430};431ARMCoreThumb.prototype.constructLSR1 = function(rd, rm, immediate) {432 var cpu = this.cpu;433 var gprs = cpu.gprs;434 return function() {435 cpu.mmu.waitPrefetch(gprs[cpu.PC]);436 if (immediate == 0) {437 cpu.cpsrC = gprs[rm] >> 31;438 gprs[rd] = 0;439 } else {440 cpu.cpsrC = gprs[rm] & (1 << (immediate - 1));441 gprs[rd] = gprs[rm] >>> immediate;442 }443 cpu.cpsrN = 0;444 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);445 };446}447ARMCoreThumb.prototype.constructLSR2 = function(rd, rm) {448 var cpu = this.cpu;449 var gprs = cpu.gprs;450 return function() {451 cpu.mmu.waitPrefetch(gprs[cpu.PC]);452 var rs = gprs[rm] & 0xFF;453 if (rs) {454 if (rs < 32) {455 cpu.cpsrC = gprs[rd] & (1 << (rs - 1));456 gprs[rd] >>>= rs;457 } else {458 if (rs > 32) {459 cpu.cpsrC = 0;460 } else {461 cpu.cpsrC = gprs[rd] >> 31;462 }463 gprs[rd] = 0;464 }465 }466 cpu.cpsrN = gprs[rd] >> 31;467 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);468 };469};470ARMCoreThumb.prototype.constructMOV1 = function(rn, immediate) {471 var cpu = this.cpu;472 var gprs = cpu.gprs;473 return function() {474 cpu.mmu.waitPrefetch(gprs[cpu.PC]);475 gprs[rn] = immediate;476 cpu.cpsrN = immediate >> 31;477 cpu.cpsrZ = !(immediate & 0xFFFFFFFF);478 };479};480ARMCoreThumb.prototype.constructMOV2 = function(rd, rn, rm) {481 var cpu = this.cpu;482 var gprs = cpu.gprs;483 return function() {484 cpu.mmu.waitPrefetch(gprs[cpu.PC]);485 var d = gprs[rn];486 cpu.cpsrN = d >> 31;487 cpu.cpsrZ = !(d & 0xFFFFFFFF);488 cpu.cpsrC = 0;489 cpu.cpsrV = 0;490 gprs[rd] = d;491 };492};493ARMCoreThumb.prototype.constructMOV3 = function(rd, rm) {494 var cpu = this.cpu;495 var gprs = cpu.gprs;496 return function() {497 cpu.mmu.waitPrefetch(gprs[cpu.PC]);498 gprs[rd] = gprs[rm];499 };500};501ARMCoreThumb.prototype.constructMUL = function(rd, rm) {502 var cpu = this.cpu;503 var gprs = cpu.gprs;504 return function() {505 cpu.mmu.waitPrefetch(gprs[cpu.PC]);506 cpu.mmu.waitMul(gprs[rm]);507 if ((gprs[rm] & 0xFFFF0000) && (gprs[rd] & 0xFFFF0000)) {508 // Our data type is a double--we'll lose bits if we do it all at once!509 var hi = ((gprs[rd] & 0xFFFF0000) * gprs[rm]) & 0xFFFFFFFF;510 var lo = ((gprs[rd] & 0x0000FFFF) * gprs[rm]) & 0xFFFFFFFF;511 gprs[rd] = (hi + lo) & 0xFFFFFFFF;512 } else {513 gprs[rd] *= gprs[rm];514 }515 cpu.cpsrN = gprs[rd] >> 31;516 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);517 };518};519ARMCoreThumb.prototype.constructMVN = function(rd, rm) {520 var cpu = this.cpu;521 var gprs = cpu.gprs;522 return function() {523 cpu.mmu.waitPrefetch(gprs[cpu.PC]);524 gprs[rd] = ~gprs[rm];525 cpu.cpsrN = gprs[rd] >> 31;526 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);527 };528};529ARMCoreThumb.prototype.constructNEG = function(rd, rm) {530 var cpu = this.cpu;531 var gprs = cpu.gprs;532 return function() {533 cpu.mmu.waitPrefetch(gprs[cpu.PC]);534 var d = -gprs[rm];535 cpu.cpsrN = d >> 31;536 cpu.cpsrZ = !(d & 0xFFFFFFFF);537 cpu.cpsrC = 0 >= (d >>> 0);538 cpu.cpsrV = (gprs[rm] >> 31) && (d >> 31);539 gprs[rd] = d;540 };541};542ARMCoreThumb.prototype.constructORR = function(rd, rm) {543 var cpu = this.cpu;544 var gprs = cpu.gprs;545 return function() {546 cpu.mmu.waitPrefetch(gprs[cpu.PC]);547 gprs[rd] = gprs[rd] | gprs[rm];548 cpu.cpsrN = gprs[rd] >> 31;549 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);550 };551};552ARMCoreThumb.prototype.constructPOP = function(rs, r) {553 var cpu = this.cpu;554 var gprs = cpu.gprs;555 return function() {556 cpu.mmu.waitPrefetch(gprs[cpu.PC]);557 ++cpu.cycles;558 var address = gprs[cpu.SP];559 var total = 0;560 var m, i;561 for (m = 0x01, i = 0; i < 8; m <<= 1, ++i) {562 if (rs & m) {563 cpu.mmu.waitSeq32(address);564 gprs[i] = cpu.mmu.load32(address);565 address += 4;566 ++total;567 }568 }569 if (r) {570 gprs[cpu.PC] = cpu.mmu.load32(address) & 0xFFFFFFFE;571 address += 4;572 ++total;573 }574 cpu.mmu.waitMulti32(address, total);575 gprs[cpu.SP] = address;576 };577};578ARMCoreThumb.prototype.constructPUSH = function(rs, r) {579 var cpu = this.cpu;580 var gprs = cpu.gprs;581 return function() {582 var address = gprs[cpu.SP] - 4;583 var total = 0;584 cpu.mmu.waitPrefetch(gprs[cpu.PC]);585 if (r) {586 cpu.mmu.store32(address, gprs[cpu.LR]);587 address -= 4;588 ++total;589 }590 var m, i;591 for (m = 0x80, i = 7; m; m >>= 1, --i) {592 if (rs & m) {593 cpu.mmu.store32(address, gprs[i]);594 address -= 4;595 ++total;596 break;597 }598 }599 for (m >>= 1, --i; m; m >>= 1, --i) {600 if (rs & m) {601 cpu.mmu.store32(address, gprs[i]);602 address -= 4;603 ++total;604 }605 }606 cpu.mmu.waitMulti32(address, total);607 gprs[cpu.SP] = address + 4;608 };609};610ARMCoreThumb.prototype.constructROR = function(rd, rm) {611 var cpu = this.cpu;612 var gprs = cpu.gprs;613 return function() {614 cpu.mmu.waitPrefetch(gprs[cpu.PC]);615 var rs = gprs[rm] & 0xFF;616 if (rs) {617 var r4 = rs & 0x1F;618 if (r4 > 0) {619 cpu.cpsrC = gprs[rd] & (1 << (r4 - 1));620 gprs[rd] = (gprs[rd] >>> r4) | (gprs[rd] << (32 - r4));621 } else {622 cpu.cpsrC = gprs[rd] >> 31;623 }624 }625 cpu.cpsrN = gprs[rd] >> 31;626 cpu.cpsrZ = !(gprs[rd] & 0xFFFFFFFF);627 };628};629ARMCoreThumb.prototype.constructSBC = function(rd, rm) {630 var cpu = this.cpu;631 var gprs = cpu.gprs;632 return function() {633 cpu.mmu.waitPrefetch(gprs[cpu.PC]);634 var m = (gprs[rm] >>> 0) + !cpu.cpsrC;635 var d = (gprs[rd] >>> 0) - m;636 cpu.cpsrN = d >> 31;637 cpu.cpsrZ = !(d & 0xFFFFFFFF);638 cpu.cpsrC = (gprs[rd] >>> 0) >= (d >>> 0);639 cpu.cpsrV = ((gprs[rd] ^ m) >> 31) && ((gprs[rd] ^ d) >> 31);640 gprs[rd] = d;641 };642};643ARMCoreThumb.prototype.constructSTMIA = function(rn, rs) {644 var cpu = this.cpu;645 var gprs = cpu.gprs;646 return function() {647 cpu.mmu.wait(gprs[cpu.PC]);648 var address = gprs[rn];649 var total = 0;650 var m, i;651 for (m = 0x01, i = 0; i < 8; m <<= 1, ++i) {652 if (rs & m) {653 cpu.mmu.store32(address, gprs[i]);654 address += 4;655 ++total;656 break;657 }658 }659 for (m <<= 1, ++i; i < 8; m <<= 1, ++i) {660 if (rs & m) {661 cpu.mmu.store32(address, gprs[i]);662 address += 4;663 ++total;664 }665 }666 cpu.mmu.waitMulti32(address, total);667 gprs[rn] = address;668 };669};670ARMCoreThumb.prototype.constructSTR1 = function(rd, rn, immediate) {671 var cpu = this.cpu;672 var gprs = cpu.gprs;673 return function() {674 var n = gprs[rn] + immediate;675 cpu.mmu.store32(n, gprs[rd]);676 cpu.mmu.wait(gprs[cpu.PC]);677 cpu.mmu.wait32(n);678 };679};680ARMCoreThumb.prototype.constructSTR2 = function(rd, rn, rm) {681 var cpu = this.cpu;682 var gprs = cpu.gprs;683 return function() {684 cpu.mmu.store32(gprs[rn] + gprs[rm], gprs[rd]);685 cpu.mmu.wait(gprs[cpu.PC]);686 cpu.mmu.wait32(gprs[rn] + gprs[rm]);687 };688};689ARMCoreThumb.prototype.constructSTR3 = function(rd, immediate) {690 var cpu = this.cpu;691 var gprs = cpu.gprs;692 return function() {693 cpu.mmu.store32(gprs[cpu.SP] + immediate, gprs[rd]);694 cpu.mmu.wait(gprs[cpu.PC]);695 cpu.mmu.wait32(gprs[cpu.SP] + immediate);696 };697};698ARMCoreThumb.prototype.constructSTRB1 = function(rd, rn, immediate) {699 var cpu = this.cpu;700 var gprs = cpu.gprs;701 return function() {702 var n = gprs[rn] + immediate;703 cpu.mmu.store8(n, gprs[rd]);704 cpu.mmu.wait(gprs[cpu.PC]);705 cpu.mmu.wait(n);706 };707};708ARMCoreThumb.prototype.constructSTRB2 = function(rd, rn, rm) {709 var cpu = this.cpu;710 var gprs = cpu.gprs;711 return function() {712 cpu.mmu.store8(gprs[rn] + gprs[rm], gprs[rd]);713 cpu.mmu.wait(gprs[cpu.PC]);714 cpu.mmu.wait(gprs[rn] + gprs[rm]);715 }716};717ARMCoreThumb.prototype.constructSTRH1 = function(rd, rn, immediate) {718 var cpu = this.cpu;719 var gprs = cpu.gprs;720 return function() {721 var n = gprs[rn] + immediate;722 cpu.mmu.store16(n, gprs[rd]);723 cpu.mmu.wait(gprs[cpu.PC]);724 cpu.mmu.wait(n);725 };726};727ARMCoreThumb.prototype.constructSTRH2 = function(rd, rn, rm) {728 var cpu = this.cpu;729 var gprs = cpu.gprs;730 return function() {731 cpu.mmu.store16(gprs[rn] + gprs[rm], gprs[rd]);732 cpu.mmu.wait(gprs[cpu.PC]);733 cpu.mmu.wait(gprs[rn] + gprs[rm]);734 }735};736ARMCoreThumb.prototype.constructSUB1 = function(rd, rn, immediate) {737 var cpu = this.cpu;738 var gprs = cpu.gprs;739 return function() {740 cpu.mmu.waitPrefetch(gprs[cpu.PC]);741 var d = gprs[rn] - immediate;742 cpu.cpsrN = d >> 31;743 cpu.cpsrZ = !(d & 0xFFFFFFFF);744 cpu.cpsrC = (gprs[rn] >>> 0) >= immediate;745 cpu.cpsrV = (gprs[rn] >> 31) && ((gprs[rn] ^ d) >> 31);746 gprs[rd] = d;747 };748}749ARMCoreThumb.prototype.constructSUB2 = function(rn, immediate) {750 var cpu = this.cpu;751 var gprs = cpu.gprs;752 return function() {753 cpu.mmu.waitPrefetch(gprs[cpu.PC]);754 var d = gprs[rn] - immediate;755 cpu.cpsrN = d >> 31;756 cpu.cpsrZ = !(d & 0xFFFFFFFF);757 cpu.cpsrC = (gprs[rn] >>> 0) >= immediate;758 cpu.cpsrV = (gprs[rn] >> 31) && ((gprs[rn] ^ d) >> 31);759 gprs[rn] = d;760 };761};762ARMCoreThumb.prototype.constructSUB3 = function(rd, rn, rm) {763 var cpu = this.cpu;764 var gprs = cpu.gprs;765 return function() {766 cpu.mmu.waitPrefetch(gprs[cpu.PC]);767 var d = gprs[rn] - gprs[rm];768 cpu.cpsrN = d >> 31;769 cpu.cpsrZ = !(d & 0xFFFFFFFF);770 cpu.cpsrC = (gprs[rn] >>> 0) >= (gprs[rm] >>> 0);771 cpu.cpsrV = (gprs[rn] >> 31) != (gprs[rm] >> 31) &&772 (gprs[rn] >> 31) != (d >> 31);773 gprs[rd] = d;774 };775};776ARMCoreThumb.prototype.constructSWI = function(immediate) {777 var cpu = this.cpu;778 var gprs = cpu.gprs;779 return function() {780 cpu.irq.swi(immediate);781 cpu.mmu.waitPrefetch(gprs[cpu.PC]);782 }783};784ARMCoreThumb.prototype.constructTST = function(rd, rm) {785 var cpu = this.cpu;786 var gprs = cpu.gprs;787 return function() {788 cpu.mmu.waitPrefetch(gprs[cpu.PC]);789 var aluOut = gprs[rd] & gprs[rm];790 cpu.cpsrN = aluOut >> 31;791 cpu.cpsrZ = !(aluOut & 0xFFFFFFFF);792 };...
custom.js
Source:custom.js
1var modal = document.getElementById('rental-distance-wrapper');2var btn = document.getElementById("btn-rental-distance");3var span = document.getElementsByClassName("rd-close")[0];4btn.onclick = function () {5 modal.style.display = "block";6}7span.onclick = function () {8 modal.style.display = "none";9}10window.onclick = function (event) {11 if (event.target == modal) {12 modal.style.display = "none";13 }14}15jQuery(function($){16 jQuery(document).ready(function($) {17 function initialize() {18 var lat = $('#bt_ot_gmap_input_lat').val();19 var lng = $('#bt_ot_gmap_input_lng').val();20 var message = $('#rd-error');21 message.hide();22 var messageContent = '';23 if(lat == '' || lng == ''){24 messageContent += message.data('latlng');25 message.show();26 message.html('');27 message.html(messageContent);28 }else{29 var rdType = $('#rd-elm-type').val();30 if(rdType == '-1'){31 messageContent += message.data('type') + "<br />";32 }33 var rdRadius = $('#rd-elm-radius').val();34 if(rdRadius == ''){35 messageContent += message.data('radius') + "\n";36 }37 message.show();38 message.html('');39 message.html(messageContent);40 if(rdType != '-1' && rdRadius != '') {41 var pyrmont = {lat: parseFloat(lat), lng: parseFloat(lng)};42 map = new google.maps.Map(document.getElementById('rd-map'), {43 center: pyrmont,44 zoom: 1545 });46 infowindow = new google.maps.InfoWindow();47 var service = new google.maps.places.PlacesService(map);48 service.nearbySearch({49 location: pyrmont,50 radius: parseInt(rdRadius)*1000,51 type: [rdType]52 }, callback);53 }54 }55 }56 function callback(results, status) {57 $('#rd-select-result').hide();58 var overlay = $('#rd-result .overlay');59 //overlay.addClass('open');60 var lat = $('#bt_ot_gmap_input_lat').val();61 var lng = $('#bt_ot_gmap_input_lng').val();62 var message = $('#rd-error');63 var content = $('#rd-result .rd-result-content table tbody');64 content.html('');65 if (status === google.maps.places.PlacesServiceStatus.OK) {66 message.hide();67 var te = '';68 var placeID = [];69 for (var i = 0; i < results.length; i++) {70 te += '<tr data-placeid="'+ results[i].place_id +'" data-name="'+ results[i].name +'" data-vicinity="'+ results[i].vicinity +'" data-placeid="'+results[i].place_id+'">';71 te += '<td class="check-column"><input type="checkbox" value=""/></td>';72 te += '<td>'+ results[i].name +'</td>';73 te += '<td>'+ results[i].vicinity +'</td>';74 te += '<td class="rd-distance" data-placeid="'+results[i].place_id+'">...</td>';75 te += '</tr>';76 placeID.push(results[i].place_id);77 }78 content.html(te);79 $('#rd-select-result').show();80 /*$.ajax({81 url: ajaxurl,82 type: "POST",83 data: {84 action : "get_distance_placeid",85 lat : lat,86 lng : lng,87 placeid : placeID,88 },89 dataType: "json"90 }).done(function( resp ) {91 content.find('tr').each(function (ev) {92 $(this).find('.rd-distance').html(resp[$(this).find('.rd-distance').data('placeid')].distance);93 $(this).attr('data-distance', resp[$(this).find('.rd-distance').data('placeid')].distance);94 });95 overlay.removeClass('open');96 $('#rd-select-result').show();97 });*/98 }else{99 message.html(status);100 message.show();101 }102 }103 $('#rd-get-result').on('click', initialize);104 $('#rd-select-result').click(function (e) {105 var dataSelect = new Array();106 $('#rd-result .rd-result-content table tbody tr').each(function (ev) {107 var me = $(this);108 if(me.find('input').is(':checked')){109 dataSelect.push({110 'place_id': me.data('placeid'),111 'name': me.data('name'),112 'vicinity': me.data('vicinity'),113 'distance': me.data('distance')114 });115 }116 });117 if(dataSelect.length){118 var type = $('#rd-elm-type').val();119 var typeName = $('#rd-elm-type option[value="'+type+'"]').text();120 var te = '';121 if($('.' + type).length){122 $('#rd-item .item-wrapper.rdtype-' + type).html('');123 }else{124 $('#rd-item').append('<div class="'+type+'"><span class="rd-title">'+typeName+'</span><div class="item-wrapper rdtype-'+ type +'"></div></div>');125 }126 $.each(dataSelect, function (index, value) {127 te += value.name + '|' + value.distance + ',';128 $('#rd-item .item-wrapper.rdtype-' + type).append('<div class="item">'+ value.name +' - '+ value.distance +'<div class="close">+</div></div>');129 });130 //if($('input[name="st_rental_distance['+$('#rd-elm-type').val()+']"]').length){131 // $('input[name="st_rental_distance['+$('#rd-elm-type').val()+']"]').val(te);132 //}else{133 // $('#rd-item').append('<input name="st_rental_distance['+$('#rd-elm-type').val()+']" type="text" value="'+te+'" />');134 //}135 }136 });137 });...
chartV2Selection.js
Source:chartV2Selection.js
1function addSelectionFunctions (rawChartData) {2 var rd = rawChartData;3 rd.clearSaliencyMapSelections = function() {4 for (var i in rd.actions) {5 for (var j in rd.actions[i].bars) {6 rd.actions[i].bars[j].saliencyMapSelected = false;7 }8 }9 }10 rd.clearRewardBarSelections = function () {11 for (var i in rd.actions) {12 for (var j in rd.actions[i].bars) {13 rd.actions[i].bars[j].selected = false;14 }15 }16 }17 rd.clearHighlightSelections = function () {18 for (var i in rd.actions) {19 for (var j in rd.actions[i].bars) {20 rd.actions[i].bars[j].highlight = false;21 }22 }23 }24 rd.clearRewardBarSelections();25 rd.clearSaliencyMapSelections();26 rd.clearHighlightSelections();27 28 rd.getRewardBarSelectionCount = function () {29 var count = 0;30 for (var i in rd.actions) {31 for (var j in rd.actions[i].bars) {32 if (rd.actions[i].bars[j].selected) {33 count++;34 }35 }36 }37 return count;38 }39 rd.getSelectedBars = function(){40 result = [];41 for (var i in rd.actionRewardNames){42 var name = rd.actionRewardNames[i];43 var bar = rd.actionRewardForNameMap[name];44 if (bar.selected){45 result.push(bar);46 }47 }48 return result;49 }50 rd.selectSingleRewardBar = function (barName) {51 for (var i in rd.actions) {52 for (var j in rd.actions[i].bars) {53 if (rd.actions[i].bars[j].selected == true) {54 rd.actions[i].bars[j].selected = false;55 }56 if (rd.actions[i].bars[j].fullName == barName) {57 rd.actions[i].bars[j].selected = true;58 }59 }60 }61 }62 rd.highlightSimilarRewardBars = function (barName) {63 for (var i in rd.actions) {64 for (var j in rd.actions[i].bars) {65 if (rd.actions[i].bars[j].name == barName) {66 rd.actions[i].bars[j].highlight = true;67 }68 }69 }70 }71 rd.multiSelectRewardBar = function (barName) {72 for (var i in rd.actions) {73 for (var j in rd.actions[i].bars) {74 if (rd.actions[i].bars[j].fullName == barName) {75 rd.actions[i].bars[j].selected = !(rd.actions[i].bars[j].selected);76 }77 }78 }79 }80 rd.clearRewardBarSaliencyHighlightSelections = function () {81 for (var i in rd.actions) {82 for (var j in rd.actions[i].bars) {83 rd.actions[i].bars[j].saliencyMapSelected = false;84 }85 }86 }87 rd.highlightRewardBarSaliencyMap = function (barName) {88 for (var i in rd.actions) {89 for (var j in rd.actions[i].bars) {90 if (rd.actions[i].bars[j].saliencyMapSelected == true) {91 rd.actions[i].bars[j].saliencyMapSelected = false;92 }93 if (rd.actions[i].bars[j].fullName == barName) {94 rd.actions[i].bars[j].saliencyMapSelected = true;95 }96 }97 }98 }99 rd.clearShowSaliencies = function() {100 for (var i in this.actionRewardNames){101 var name = this.actionRewardNames[i];102 var bar = this.actionRewardForNameMap[name];103 bar.showSaliencyMap = false;104 }105 for (var i in this.actionNames){106 var name = this.actionNames[i];107 var bar = this.actionForNameMap[name];108 bar.showSaliencyMap = false;109 }110 }111 112 rd.showSalienciesForRewardName = function(name) {113 this.clearShowSaliencies();114 for (var i in this.actionRewardNames){115 var curName = this.actionRewardNames[i];116 var bar = this.actionRewardForNameMap[curName];117 if (bar.name == name){118 bar.showSaliencyMap = true;119 }120 }121 }122 rd.showSalienciesForActionName = function(name) {123 this.clearShowSaliencies();124 for (var i in this.actionNames){125 var curName = this.actionNames[i];126 var action = this.actionForNameMap[curName];127 if (action.name == name){128 action.showSaliencyMap = true;129 }130 }131 }132 rd.getBarsFlaggedForShowingSaliency = function(){133 var result = [];134 for (var i in this.actionRewardNames){135 var name = this.actionRewardNames[i];136 var bar = this.actionRewardForNameMap[name];137 if (bar.showSaliencyMap){138 result.push(bar);139 }140 }141 if (result.length != 0){142 return result;143 }144 //check the actions145 for (var i in this.actionNames){146 var name = this.actionNames[i];147 var bar = this.actionForNameMap[name];148 if (bar.showSaliencyMap){149 result.push(bar);150 }151 }152 return result;153 }154 return rd;...
test_thing_find.js
Source:test_thing_find.js
1/*2 * test_thing_find.js3 *4 * David Janes5 * IOTDB6 * 2015-12-277 *8 * Test the "find" function9 */10"use strict";11var assert = require("assert")12var attribute = require("./instrument/attribute")13var model = require("../model")14var _ = require("../helpers")15var constants = require("../constants")16var definitions = require("./instrument/definitions");17var attribute = require('./instrument/attribute');18require('./instrument/model_maker');19var T = model.make_model('T')20 .attribute(21 attribute.make_boolean('on')22 .property_value("iot:read", true)23 .property_value("iot:write", true)24 .property_value("iot:actuator", true)25 .code("actuator")26 )27 .attribute(28 attribute.make_boolean('on')29 .property_value("iot:read", true)30 .property_value("iot:sensor", true)31 .code("sensor")32 )33 .make();34/* --- tests --- */35describe('test_thing_find', function(){36 describe('semantic', function(){37 it('default', function() {38 var t = new T();39 var rd = t.find(":on");40 assert.strictEqual(rd.attribute.code(), "sensor");41 assert.ok(rd.attribute.is_sensor());42 assert.ok(!rd.attribute.is_actuator());43 });44 it('get', function() {45 var t = new T();46 var rd = t.find(":on", { mode: "get", });47 assert.strictEqual(rd.attribute.code(), "sensor");48 assert.ok(rd.attribute.is_sensor());49 assert.ok(!rd.attribute.is_actuator());50 });51 it('on', function() {52 var t = new T();53 var rd = t.find(":on", { mode: "on", });54 assert.strictEqual(rd.attribute.code(), "sensor");55 assert.ok(rd.attribute.is_sensor());56 assert.ok(!rd.attribute.is_actuator());57 });58 it('set', function() {59 var t = new T();60 var rd = t.find(":on", { mode: "set", });61 assert.strictEqual(rd.attribute.code(), "actuator");62 assert.ok(!rd.attribute.is_sensor());63 assert.ok(rd.attribute.is_actuator());64 });65 it('bad', function() {66 var t = new T();67 var rd = t.find(":nothing");68 assert.strictEqual(rd, undefined);69 });70 });71 describe('actual', function(){72 it('sensor', function() {73 var t = new T();74 var rd = t.find("/sensor");75 assert.strictEqual(rd.attribute.code(), "sensor");76 assert.ok(rd.attribute.is_sensor());77 assert.ok(!rd.attribute.is_actuator());78 });79 it('actuator', function() {80 var t = new T();81 var rd = t.find("/actuator");82 assert.strictEqual(rd.attribute.code(), "actuator");83 assert.ok(!rd.attribute.is_sensor());84 assert.ok(rd.attribute.is_actuator());85 });86 });87 describe('dictionary', function(){88 it('default', function() {89 var t = new T();90 var rd = t.find({91 "iot:purpose": "iot-purpose:on",92 });93 assert.strictEqual(rd.attribute.code(), "sensor");94 assert.ok(rd.attribute.is_sensor());95 assert.ok(!rd.attribute.is_actuator());96 });97 it('as-sensor', function() {98 var t = new T();99 var rd = t.find({100 "iot:purpose": "iot-purpose:on",101 "iot:sensor": true,102 });103 assert.strictEqual(rd.attribute.code(), "sensor");104 assert.ok(rd.attribute.is_sensor());105 assert.ok(!rd.attribute.is_actuator());106 });107 it('as-actuator', function() {108 var t = new T();109 var rd = t.find({110 "iot:purpose": "iot-purpose:on",111 "iot:actuator": true,112 });113 assert.strictEqual(rd.attribute.code(), "actuator");114 assert.ok(!rd.attribute.is_sensor());115 assert.ok(rd.attribute.is_actuator());116 });117 it('bad (no expansion)', function() {118 var t = new T();119 var rd = t.find({120 "iot:purpose": "iot-purpose:on",121 "iot:actuator": true,122 }, { expand: false });123 assert.strictEqual(rd, undefined);124 });125 it('bad (does not exist)', function() {126 var t = new T();127 var rd = t.find({128 "iot:purpose": "iot-purpose:nothing",129 });130 assert.strictEqual(rd, undefined);131 });132 });...
xv__frmbufrd__l2_8h.js
Source:xv__frmbufrd__l2_8h.js
1var xv__frmbufrd__l2_8h =2[3 [ "XVFrmbufRd_IsBGRA8Enabled", "group__v__frmbuf__rd.html#ga2c2bebae6f7834405800452a2718b08e", null ],4 [ "XVFrmbufRd_IsBGRX8Enabled", "group__v__frmbuf__rd.html#gad50076dd94381ee2f9c61b1a352f50e3", null ],5 [ "XVFrmbufRd_IsRGB8Enabled", "group__v__frmbuf__rd.html#gabc7912a72ad9069eaa2c8c256227f48d", null ],6 [ "XVFrmbufRd_IsRGBA8Enabled", "group__v__frmbuf__rd.html#gac5d79c8d6a806d8c60ab88c791701b51", null ],7 [ "XVFrmbufRd_IsRGBX10Enabled", "group__v__frmbuf__rd.html#gae8683607b1d600806035f9ef05a91f2c", null ],8 [ "XVFrmbufRd_IsRGBX8Enabled", "group__v__frmbuf__rd.html#gafb80fe345462edfe56db7d6c2c813029", null ],9 [ "XVFrmbufRd_IsUYVY8Enabled", "group__v__frmbuf__rd.html#ga1af870973f8df08f89bb851afdf0c1e7", null ],10 [ "XVFrmbufRd_IsY10Enabled", "group__v__frmbuf__rd.html#ga5c0ebf78eace360414715ab292640627", null ],11 [ "XVFrmbufRd_IsY8Enabled", "group__v__frmbuf__rd.html#ga7f2ef61429f951abf67553c2c95f07d3", null ],12 [ "XVFrmbufRd_IsY_UV10_420Enabled", "group__v__frmbuf__rd.html#ga55124ca10ab9195da4de482995457192", null ],13 [ "XVFrmbufRd_IsY_UV10Enabled", "group__v__frmbuf__rd.html#ga030eebfec7b471edeb9755266947fe4d", null ],14 [ "XVFrmbufRd_IsY_UV8_420Enabled", "group__v__frmbuf__rd.html#gaf0cefbd264457a557168b17addba390d", null ],15 [ "XVFrmbufRd_IsY_UV8Enabled", "group__v__frmbuf__rd.html#gaed865a631e64e4cc89eb450aebceded7", null ],16 [ "XVFrmbufRd_IsYUV8Enabled", "group__v__frmbuf__rd.html#ga74c5c26e350751452b4235baf9fbe39d", null ],17 [ "XVFrmbufRd_IsYUVA8Enabled", "group__v__frmbuf__rd.html#gacd3e8dd739743f9aa9fd2b20b9338036", null ],18 [ "XVFrmbufRd_IsYUVX10Enabled", "group__v__frmbuf__rd.html#gaf92d92dd3a05e355415f6870e393535b", null ],19 [ "XVFrmbufRd_IsYUVX8Enabled", "group__v__frmbuf__rd.html#ga52b216d384a061ba296a2534e3e1539b", null ],20 [ "XVFrmbufRd_IsYUYV8Enabled", "group__v__frmbuf__rd.html#gadb8283b37d9794b80e2a831b427ae3ff", null ],21 [ "XVFrmbufRd_Callback", "group__v__frmbuf__rd.html#ga5e4ccfa0ba3b6f432160225b9b7fb618", null ],22 [ "XVFrmbufRd_DbgReportStatus", "group__v__frmbuf__rd.html#ga80af786a199e9d406016cbe77c6cce9a", null ],23 [ "XVFrmbufRd_GetBufferAddr", "group__v__frmbuf__rd.html#gaeac91da19a88ff2480eae16be554b1f2", null ],24 [ "XVFrmbufRd_GetChromaBufferAddr", "group__v__frmbuf__rd.html#ga7475f43a7f18a159c1714849fe170c3b", null ],25 [ "XVFrmbufRd_GetVideoStream", "group__v__frmbuf__rd.html#ga9eff8d479c00720638897ed3aaacdd32", null ],26 [ "XVFrmbufRd_Initialize", "group__v__frmbuf__rd.html#gaed42e419ae477b01e8677cabe9d07edc", null ],27 [ "XVFrmbufRd_InterruptDisable", "group__v__frmbuf__rd.html#ga73851e64e0b63262b7577c37988269ab", null ],28 [ "XVFrmbufRd_InterruptEnable", "group__v__frmbuf__rd.html#ga47816c9ecac20831e543d4b301467772", null ],29 [ "XVFrmbufRd_InterruptHandler", "group__v__frmbuf__rd.html#gab2c3dd4bfc1f4acf08353543704c836b", null ],30 [ "XVFrmbufRd_SetBufferAddr", "group__v__frmbuf__rd.html#gab166d212d55646b832a8f7c301e5f2ac", null ],31 [ "XVFrmbufRd_SetCallback", "group__v__frmbuf__rd.html#ga61d2548b42528cd739c6b3568b29621a", null ],32 [ "XVFrmbufRd_SetChromaBufferAddr", "group__v__frmbuf__rd.html#ga395f9c364ef8378189bf0464d2130d59", null ],33 [ "XVFrmbufRd_SetMemFormat", "group__v__frmbuf__rd.html#ga8d3a4c93e59a529e936c21169f738202", null ],34 [ "XVFrmbufRd_Start", "group__v__frmbuf__rd.html#ga0e9f4473b9679d84441160c08b461d9b", null ],35 [ "XVFrmbufRd_Stop", "group__v__frmbuf__rd.html#gaf95f5597208997861ca3b2de238821e1", null ]...
App.js
Source:App.js
1import React, { Component } from 'react';2import OpeningsBox from './containers/OpeningsBox';3import './App.css';4class App extends Component {5 render() {6 const films = [7 {name: "Sausage Party", url:"http://www.imdb.com/title/tt1700841?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=1970868962&pf_rd_r=10B79GWTXE5MERRSR82F&pf_rd_s=right-2&pf_rd_t=15061&pf_rd_i=homepage&ref_=hm_otw_t0", showTimesURL: "http://www.imdb.com/showtimes/title/tt1700841?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=1970868962&pf_rd_r=10B79GWTXE5MERRSR82F&pf_rd_s=right-2&pf_rd_t=15061&pf_rd_i=homepage&ref_=hm_otw_gs"},8 {name: "Café Society", url:"http://www.imdb.com/title/tt4513674?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=1970868962&pf_rd_r=10B79GWTXE5MERRSR82F&pf_rd_s=right-2&pf_rd_t=15061&pf_rd_i=homepage&ref_=hm_otw_t1", showTimesURL: "http://www.imdb.com/showtimes/title/tt4513674?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=1970868962&pf_rd_r=10B79GWTXE5MERRSR82F&pf_rd_s=right-2&pf_rd_t=15061&pf_rd_i=homepage&ref_=hm_otw_gs"},9 {name: "Sausage Party", url:"http://www.imdb.com/title/tt1700841?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=1970868962&pf_rd_r=10B79GWTXE5MERRSR82F&pf_rd_s=right-2&pf_rd_t=15061&pf_rd_i=homepage&ref_=hm_otw_t0", showTimesURL: "http://www.imdb.com/showtimes/title/tt1700841?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=1970868962&pf_rd_r=10B79GWTXE5MERRSR82F&pf_rd_s=right-2&pf_rd_t=15061&pf_rd_i=homepage&ref_=hm_otw_gs"},10 {name: "Café Society", url:"http://www.imdb.com/title/tt4513674?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=1970868962&pf_rd_r=10B79GWTXE5MERRSR82F&pf_rd_s=right-2&pf_rd_t=15061&pf_rd_i=homepage&ref_=hm_otw_t1", showTimesURL: "http://www.imdb.com/showtimes/title/tt4513674?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=1970868962&pf_rd_r=10B79GWTXE5MERRSR82F&pf_rd_s=right-2&pf_rd_t=15061&pf_rd_i=homepage&ref_=hm_otw_gs"}11 ];12 return (13 <OpeningsBox films={films} />14 );15 }16}...
ramda-decimal.js
Source:ramda-decimal.js
1const { Decimal } = require('decimal.js');2const R = require('ramda');3const RD = {};4RD.ZERO = new Decimal(0);5RD.decimal = R.curry(6 (x) => new Decimal(x),7);8RD.lt = R.curry(9 (x, y) => RD.decimal(x)10 .lt(y),11);12RD.gt = R.curry(13 (x, y) => RD.decimal(x)14 .gt(y),15);16RD.fixed = R.curry(17 (dp, rm, x) => RD.decimal(x)18 .toFixed(dp, rm),19);20RD.multiply = R.curry(21 (x, y) => RD.decimal(x)22 .times(y),23);24RD.divide = R.curry(25 (x, y) => RD.decimal(x)26 .dividedBy(y),27);28RD.add = R.curry(29 (x, y) => RD.decimal(x)30 .plus(y),31);32RD.sum = R.reduce(RD.add, RD.ZERO);33RD.subtract = R.curry(34 (x, y) => RD.decimal(x)35 .minus(y),36);37RD.max = R.curry(38 (x, y) => Decimal.max(x, y),39);40RD.min = R.curry(41 (x, y) => Decimal.min(x, y),42);43RD.isPositive = (x) => {44 if (R.isNil(x)) return false;45 const num = new Decimal(x);46 return num.isPositive(0);47};48const rounding = R.pick([49 'ROUND_UP',50 'ROUND_DOWN',51 'ROUND_CEIL',52 'ROUND_FLOOR',53 'ROUND_HALF_UP',54 'ROUND_HALF_DOWN',55 'ROUND_HALF_EVEN',56 'ROUND_HALF_CEIL',57 'ROUND_HALF_FLOOR',58 'EUCLID',59], Decimal);60module.exports = {61 ...RD,62 ...rounding,...
Using AI Code Generation
1describe('Protractor Demo App', function() {2 it('should add one and two', function() {3 element(by.model('first')).sendKeys(1);4 element(by.model('second')).sendKeys(2);5 element(by.id('gobutton')).click();6 });7});8describe('Protractor Demo App', function() {9 it('should add one and two', function() {10 element(by.model('first')).sendKeys(1);11 element(by.model('second')).sendKeys(2);12 element(by.id('gobutton')).click();13 });14});15describe('Protractor Demo App', function() {16 it('should add one and two', function() {17 element(by.model('first')).sendKeys(1);18 element(by.model('second')).sendKeys(2);19 element(by.id('gobutton')).click();20 });21});22describe('Protractor Demo App', function() {23 it('should add one and two', function() {24 element(by.model('first')).sendKeys(1);25 element(by.model('second')).sendKeys(2);26 element(by.id('gobutton')).click();27 });28});29describe('Protractor Demo App', function() {30 it('should add one and two', function() {31 element(by.model('first')).sendKeys(1);32 element(by.model('second')).sendKeys(2);33 element(by.id('gobutton')).click();34 expect(element(by.binding('latest')).getText
Using AI Code Generation
1describe('Protractor Demo App', function() {2 it('should add one and two', function() {3 element(by.model('first')).sendKeys(1);4 element(by.model('second')).sendKeys(2);5 element(by.id('gobutton')).click();6 });7});8describe('Protractor Demo App', function() {9 it('should add one and two', function() {10 element(by.model('first')).sendKeys(1);11 element(by.model('second')).sendKeys(2);12 element(by.id('gobutton')).click();13 });14});15describe('Protractor Demo App', function() {16 it('should add one and two', function() {17 element(by.model('first')).sendKeys(1);18 element(by.model('second')).sendKeys(2);19 element(by.id('gobutton')).click();20 });21});22describe('Protractor Demo App', function() {23 it('should add one and two', function() {24 element(by.model('first')).sendKeys(1);25 element(by.model('second')).sendKeys(2);26 element(by.id('gobutton')).click();27 });28});29describe('Protractor Demo App', function() {30 it('should add one and two', function() {31 element(by.model('first')).sendKeys(1);32 element(by.model('second')).sendKeys(2);33 element(by.id('gobutton')).click();34 expect(element
Using AI Code Generation
1var rd = require('rd');2var fs = require('fs');3var path = require('path');4var util = require('util');5var webdriver = require('selenium-webdriver');6var By = webdriver.By;7var until = webdriver.until;8var driver = new webdriver.Builder()9 .forBrowser('chrome')10 .build();11rd.eachFileFilterSync('./testcases', /\.js$/, function (f, s) {12 console.log(f);13 var testcases = require(f);14 for (var i = 0; i < testcases.length; i++) {15 var testcase = testcases[i];16 console.log(testcase);17 for (var j = 0; j < testcase.steps.length; j++) {18 var step = testcase.steps[j];19 console.log(step);20 if (step.type == 'click') {21 driver.findElement(By.id(step.id)).click();22 } else if (step.type == 'input') {23 driver.findElement(By.id(step.id)).sendKeys(step.value);24 } else if (step.type == 'wait') {25 driver.wait(until.elementLocated(By.id(step.id)), 5000);26 } else if (step.type == 'assert') {27 driver.findElement(By.id(step.id)).getText().then(function (text) {28 console.log(text);29 console.log(step.value);30 if (text != step.value) {31 console.log('assert failed');32 }33 });34 }35 }36 }37});38driver.quit();
Using AI Code Generation
1var rd = require('./rd.js');2describe('Protractor Demo App', function() {3 it('should have a title', function() {4 expect(browser.getTitle()).toEqual('AngularJS — Superheroic JavaScript MVW Framework');5 });6});7describe('Rd Demo App', function() {8 it('should have a title', function() {9 expect(rd.getTitle()).toEqual('AngularJS — Superheroic JavaScript MVW Framework');10 });11});12var protractor = require('protractor');13var browser = protractor.browser;14var by = protractor.by;15var element = protractor.element;16exports.get = browser.get;17exports.getTitle = browser.getTitle;18exports.findElement = browser.findElement;19exports.element = element;20exports.by = by;
Using AI Code Generation
1var rd = require('rd');2var fs = require('fs');3var path = require('path');4var mkdirp = require('mkdirp');5var async = require('async');6var glob = require('glob');7var request = require('request');8var mkdirp = require('mkdirp');9var async = require('async');10var glob = require('glob');11var request = require('request');12var mkdirp = require('mkdirp');13var async = require('async');14var glob = require('glob');15var request = require('request');16var mkdirp = require('mkdirp');17var async = require('async');18var glob = require('glob');19var request = require('request');20var mkdirp = require('mkdirp');21var async = require('async');22var glob = require('glob');23var request = require('request');24var mkdirp = require('mkdirp');25var async = require('async');26var glob = require('glob');27var request = require('request');28var mkdirp = require('mkdirp');
Using AI Code Generation
1var EC = protractor.ExpectedConditions;2describe('Test Suite', function() {3 it('Test Case', function() {4 browser.wait(EC.titleContains('Google'), 5000);5 browser.getTitle().then(function(title) {6 console.log(title);7 });8 });9});
Using AI Code Generation
1var rd = require('rd');2var path = require('path');3var fs = require('fs');4var protractorPath = path.resolve(__dirname, '../node_modules/protractor');5var protractorLibPath = path.resolve(protractorPath, 'lib');6var rdOptions = {7 filter: function(f) {8 return f.match(/\.js$/);9 }10};11rd.eachFileFilterSync(protractorLibPath, rdOptions, function(f, s) {12 var content = fs.readFileSync(f, 'utf-8');13 console.log(f);14});
Using AI Code Generation
1this.getRdValue = function (rdName) {2 return element(by.model(rdName)).getAttribute('value');3};4this.setRdValue = function (rdName, rdValue) {5 return element(by.model(rdName)).sendKeys(rdValue);6};7this.clickRdButton = function (rdName) {8 return element(by.model(rdName)).click();9};10it('should get the value of a field', function() {11 testPage.getRdValue('field1').then(function(value) {12 expect(value).toEqual('field1 value');13 });14});15it('should set the value of a field', function() {16 testPage.setRdValue('field1', 'new value');17 testPage.getRdValue('field1').then(function(value) {18 expect(value).toEqual('new value');19 });20});21it('should click on a button', function() {22 testPage.clickRdButton('button1');23 testPage.getRdValue('field2').then(function(value) {24 expect(value).toEqual('button1 clicked');25 });26});27this.isRdDisabled = function (rdName) {28 return element(by.model(rdName)).getAttribute('disabled');29};30it('should check if a field is disabled', function() {31 testPage.isRdDisabled('field1').then(function(value) {32 expect(value).toEqual(null);33 });34});
Protractor is developed by Google Developers to test Angular and AngularJS code. Today, it is used to test non-Angular applications as well. It performs a real-world user-like test against your application in a real browser. It comes under an end-to-end testing framework. As of now, Selenium Protractor has proved to be a popular framework for end-to-end automation for AngularJS.
Let’s talk about what it does:
Protractor is a JavaScript framework, end-to-end test automation framework for Angular and AngularJS applications.
Protractor Selenium provides new locator methods that actually make it easier to find elements in the DOM.
Two files are required to execute Protractor Selenium tests for end-to-end automation: Specs & Config. Go through the link above to understand in a better way.
To carry out extensive, automated cross browser testing, you can't imagine installing thousands of the available browsers on your own workstation. The only way to increase browser usage is through remote execution on the cloud. To execute your automation test scripts across a variety of platforms and browser versions, LambdaTest offers more than 3000 browsers.
We recommend Selenium for end-to-end automation for AngularJS because both are maintained and owned by Google, and they build JavaScript test automation framework to handle AngularJS components in a way that better matches how developers use it.
For scripting, selenium locators are essential since if they're off, your automation scripts won't run. Therefore, in any testing framework, these Selenium locators are the foundation of your Selenium test automation efforts.
To make sure that your Selenium automation tests function as intended, debugging can be an effective option. Check the blog to know more.
If you are not familiar with writing Selenium test automation on Protractor, here is a blog for you to get you understand in depth.
Selenium tests are asynchronous and there are various reasons for a timeout to occur in a Protractor test. Find out how to handle timeouts in this Protractor tutorial.
In this Protractor tutorial, learn how to handle frames or iframes in Selenium with Protractor for automated browser testing.
Handle alerts and popups in Protractor more efficiently. It can be confusing. Here's a simple guide to understand how to handle alerts and popups in Selenium.
Get 100 minutes of automation test minutes FREE!!