Best JavaScript code snippet using appium-xcuitest-driver
abstract_interpreter.js
Source:abstract_interpreter.js
...409 right = this.typecheck(value.right);410 if (left === null || right === null || left === undefined || right === undefined) {411 return null;412 } else if (left.type != right.type) {413 this.report["Incompatible types"].push({"left": left, "right": right, "operation": value.op.name, "position": this.getLocation(value)});414 } else {415 return left;416 }417 default:418 return null;419 }420}421AbstractInterpreter.prototype.walkAttributeChain = function(attribute) {422 if (attribute._astname == "Attribute") {423 var result = this.walkAttributeChain(attribute.value);424 var methodName = attribute.attr.v;425 if (methodName == "items") {426 var dict = this.typecheck(attribute.value);427 if (dict != null && dict.type == "Dict") {428 return {429 "type": "List",430 "subtype": {431 "type": "Tuple",432 "subtypes": [dict.key_type, dict.value_type]433 }434 }435 } else {436 return null;437 }438 } else if (methodName == "split") {439 var a_string = this.typecheck(attribute.value);440 if (a_string != null && a_string.type == "Str") {441 return {442 "type": "List",443 "empty": "false",444 "subtype": {445 "type": "Str",446 }447 }448 } else {449 return null;450 }451 } else if (result == null) {452 return null;453 } else if (methodName in result) {454 return result[methodName];455 } else {456 this.report["Unknown functions"].push({"name": methodName, "position": this.getLocation(attribute)});457 return null;458 }459 } else if (attribute._astname == "Name") {460 var functionName = attribute.id.v;461 if (functionName in AbstractInterpreter.MODULES) {462 return AbstractInterpreter.MODULES[attribute.id.v];463 } else if (functionName in this.BUILTINS) {464 return this.BUILTINS[functionName].returns;465 } else {466 this.report["Unknown functions"].push({"name": functionName, "position": this.getLocation(attribute)});467 return null;468 }469 }470}471AbstractInterpreter.prototype.getLocation = function(node) {472 return {"column": node.col_offset, "line": node.lineno};473}474AbstractInterpreter.prototype.visit_AugAssign = function(node) {475 var typeValue = this.typecheck(node.value);476 this.visit(node.value);477 this.visit(node.target);478 var walked = this.walk(node.target);479 for (var i = 0, len = walked.length; i < len; i++) {480 var targetChild = walked[i];481 if (targetChild._astname == "Tuple") {482 // TODO: Check if is an iterable (list, tuple, dict, set) literal or variable483 } else if (targetChild._astname == "Name") {484 this.updateVariable(targetChild.id.v, typeValue, this.getLocation(node));485 }486 }487}488AbstractInterpreter.prototype.visit_Call = function(node) {489 if (node.func._astname == "Attribute") {490 if (node.func.attr.v == "append") {491 if (node.args.length >= 1) {492 var valueType = this.typecheck(node.args[0]);493 if (node.func.value._astname == "Name") {494 var target = node.func.value.id.v;495 this.appendVariable(target, valueType, this.getLocation(node));496 this.visitList(node.keywords);497 this.visitList(node.args);498 if (node.kwargs != null) {499 this.visit(node.kwargs);500 }501 if (node.starargs != null) {502 this.visit(node.starargs);503 }504 } else {505 this.generic_visit(node);506 }507 } else {508 this.generic_visit(node);509 }510 } else {511 this.generic_visit(node);512 }513 } else {514 //console.log(node);515 this.generic_visit(node);516 }517}518/*519AbstractInterpreter.prototype.visit_Print = function(node) {520 for (var i = 0, len = node.values.length; i < len; i++) {521 var value = node.values[i];522 this.visit(value);523 }524 //this.generic_visit(node);525}*/526AbstractInterpreter.prototype.visit_Assign = function(node) {527 var typeValue = this.typecheck(node.value),528 loc = this.getLocation(node),529 that = this;530 this.visit(node.value);531 this.visitList(node.targets);532 for (var i = 0, len = node.targets.length; i < len; i++) {533 var recursivelyVisitAssign = function(target, currentTypeValue) {534 if (target._astname === "Name" && target.ctx.prototype._astname === "Store") {535 that.setVariable(target.id.v, currentTypeValue, loc);536 } else if (target._astname == 'Tuple' || target._astname == "List") {537 for (var i = 0, len = target.elts.length; i < len; i++) {538 recursivelyVisitAssign(target.elts[i], 539 that.unpackSequenceType(currentTypeValue, i), 540 loc);541 }542 } else {543 that.visit(target);544 }545 }546 recursivelyVisitAssign(node.targets[i], typeValue);547 }548 549}550AbstractInterpreter.prototype.visit_With = function(node) {551 this.visit(node.context_expr);552 this.visitList(node.optional_vars);553 var typeValue = this.typecheck(node.context_expr),554 loc = this.getLocation(node),555 that = this;556 var recursivelyVisitVars = function(target, currentTypeValue) {557 if (target._astname === "Name" && target.ctx.prototype._astname === "Store") {558 that.setVariable(target.id.v, currentTypeValue, loc);559 } else if (target._astname == 'Tuple' || target._astname == "List") {560 for (var i = 0, len = target.elts.length; i < len; i++) {561 recursivelyVisitVars(target.elts[i], 562 that.unpackSequenceType(currentTypeValue, i), 563 loc);564 }565 } else {566 that.visit(target);567 }568 }569 recursivelyVisitVars(node.optional_vars, typeValue);570 // Handle the bodies571 for (var i = 0, len = node.body.length; i < len; i++) {572 this.visit(node.body[i]);573 }574}575AbstractInterpreter.prototype.visit_Import = function(node) {576 for (var i = 0, len = node.names.length; i < len; i++) {577 var module = node.names[i];578 var asname = module.asname === null ? module.name : module.asname;579 this.setVariable(asname.v, {"type": "Module"}, this.getLocation(node))580 }581}582AbstractInterpreter.prototype.visit_ImportFrom = function(node) {583 for (var i = 0, len = node.names.length; i < len; i++) {584 if (node.module === null) {585 var alias = node.names[i];586 var asname = alias.asname === null ? alias.name : alias.asname;587 this.setVariable(asname.v, {"type": "Any"}, this.getLocation(node));588 } else {589 var moduleName = node.module.v;590 var alias = node.names[i];591 var asname = alias.asname === null ? alias.name : alias.asname;592 var type = AbstractInterpreter.MODULES[moduleName];593 this.setVariable(asname.v, type, this.getLocation(node));594 }595 }596}597AbstractInterpreter.prototype.visit_Name = function(node) {598 //console.log(node);599 //TODO:600 if (node.ctx.prototype._astname === "Load") {601 this.readVariable(node.id.v, this.getLocation(node));602 }603 this.generic_visit(node);604}605AbstractInterpreter.prototype.visit_BinOp = function(node) {606 this.typecheck(node);607 this.generic_visit(node);608}609AbstractInterpreter.prototype.visit_FunctionDef = function(node) {610 var functionName = node.name.v;611 this.setVariable(functionName, {"type": "Function"}, this.getLocation(node))612 // Manage scope613 var oldScope = this.currentScope;614 this.scopeContexts[functionName] = this.currentScope;615 this.currentScope = functionName;616 // Process arguments617 var args = node.args.args;618 for (var i = 0; i < args.length; i++) {619 var arg = args[i];620 var name = Sk.ffi.remapToJs(arg.id);621 this.setVariable(name, {"type": "Argument"}, this.getLocation(node))622 }623 this.generic_visit(node);624 // Return scope625 this.currentScope = oldScope;626}627AbstractInterpreter.prototype.visit_Return = function(node) {628 if (this.currentScope === null) {629 this.report['Return outside function'].push({"position": this.getLocation(node)})630 }631 this.setReturnVariable(this.currentScope, 632 node.value ? this.typecheck(node.value) : {"type": "None"}, 633 this.getLocation(node));634 this.generic_visit(node);635}636AbstractInterpreter.prototype.visit_ClassDef = function(node) {637 this.setVariable(node.name.v, {"type": "Class"}, this.getLocation(node))638 this.generic_visit(node);639}640AbstractInterpreter.prototype.visit_If = function(node) {641 // Visit the conditional642 this.visit(node.test);643 644 // Update branch management645 this.branchStackId += 1;646 var branchId = this.branchStackId;647 648 var cb = this.currentBranch,649 cbName = this.currentBranchName,650 branches = {"if": [], 651 "else": [], 652 "id": branchId, 653 "method": "branch",654 "parentName": this.currentBranchName};655 cb.push(branches)656 657 // Visit the bodies658 this.currentBranch = branches["if"];659 this.currentBranchName = branchId + 'i';660 for (var i = 0, len = node.body.length; i < len; i++) {661 this.visit(node.body[i]);662 }663 this.currentBranch = branches["else"];664 this.currentBranchName = branchId + 'e';665 for (var i = 0, len = node.orelse.length; i < len; i++) {666 this.visit(node.orelse[i]);667 }668 this.currentBranch = cb;669 this.currentBranchName = cbName;670}671AbstractInterpreter.prototype.visit_While = function(node) {672 this.visit_If(node);673 // This probably doesn't work for orelse bodies, but who actually uses those.674}675AbstractInterpreter.prototype.unpackSequence = function(type) {676 if (type.type == "List" && !type.empty) {677 return type.subtype;678 } else if (type.type == "Str") {679 return {"type": "Str"};680 }681}682AbstractInterpreter.prototype.unpackSequenceType = function(type, i) {683 if (type == null) {684 return null;685 } else if (type.type == "Tuple") {686 return type.subtypes[i];687 }688}689AbstractInterpreter.prototype.visit_For = function(node) {690 this.loopStackId += 1;691 // Handle the iteration list692 var walked = this.walk(node.iter),693 iterationList = null;694 for (var i = 0, len = walked.length; i < len; i++) {695 var child = walked[i];696 if (child._astname === "Name" && child.ctx.prototype._astname === "Load") {697 iterationList = child.id.v;698 if (this.isTypeEmptyList(child.id.v)) {699 this.report["Empty iterations"].push({"name": child.id.v, "position": this.getLocation(node)});700 }701 if (!(this.isTypeSequence(child.id.v))) {702 this.report["Non-list iterations"].push({"name": child.id.v, "position": this.getLocation(node)});703 }704 this.iterateVariable(child.id.v, this.getLocation(node));705 } else if (child._astname === "List" && child.elts.length === 0) {706 this.report["Empty iterations"].push({"name": "[]", "position": this.getLocation(node)});707 } else {708 this.visit(child);709 }710 }711 var iterType = this.typecheck(node.iter),712 iterSubtype = null;713 if (iterType !== null) {714 iterSubtype = this.unpackSequence(iterType);715 }716 717 // Handle the iteration variable718 var iterationVariable = null;719 var that = this;720 var recursivelyVisitIteration = function(subnode, subtype, loc) {721 if (subnode._astname === "Name" && subnode.ctx.prototype._astname === "Store") {722 if (iterationVariable == null) {723 iterationVariable = subnode.id.v;724 }725 that.setIterVariable(subnode.id.v, subtype, loc);726 } else if (subnode._astname == 'Tuple' || subnode._astname == "List") {727 for (var i = 0, len = subnode.elts.length; i < len; i++) {728 recursivelyVisitIteration(subnode.elts[i], that.unpackSequenceType(subtype, i), loc);729 }730 } else {731 this.visit(subnode);732 }733 };734 recursivelyVisitIteration(node.target, iterSubtype, this.getLocation(node));735 736 if (iterationVariable && iterationList && iterationList == iterationVariable) {737 this.report["Iteration variable is iteration list"].push({"name": iterationList, "position": this.getLocation(node)});738 }739 // Handle the bodies740 for (var i = 0, len = node.body.length; i < len; i++) {741 this.visit(node.body[i]);742 }743 for (var i = 0, len = node.orelse.length; i < len; i++) {744 this.visit(node.orelse[i]);745 }746}747AbstractInterpreter.prototype.visit_ListComp = function(node) {748 this.loopStackId += 1;749 var generators = node.generators;750 for (var i = 0, len = generators.length; i < len; i++) {751 this.visit(generators[i]);752 }753 var elt = node.elt;754 this.visit(elt);755}756AbstractInterpreter.prototype.visit_comprehension = function(node) {757 // Handle the iteration list758 var walked = this.walk(node.iter),759 iterationList = null;760 for (var i = 0, len = walked.length; i < len; i++) {761 var child = walked[i];762 if (child._astname === "Name" && child.ctx.prototype._astname === "Load") {763 iterationList = child.id.v;764 if (this.isTypeEmptyList(child.id.v)) {765 this.report["Empty iterations"].push({"name": child.id.v, "position": this.getLocation(node)});766 }767 if (!(this.isTypeSequence(child.id.v))) {768 this.report["Non-list iterations"].push({"name": child.id.v, "position": this.getLocation(node)});769 }770 this.iterateVariable(child.id.v, this.getLocation(node));771 } else if (child._astname === "List" && child.elts.length === 0) {772 this.report["Empty iterations"].push({"name": child.id.v, "position": this.getLocation(node)});773 } else {774 this.visit(child);775 }776 }777 var iterType = this.typecheck(node.iter),778 iterSubtype = null;779 if (iterType !== null) {780 iterSubtype = this.unpackSequence(iterType);781 }782 783 // Handle the iteration variable784 walked = this.walk(node.target);785 var iterationVariable = null;786 for (var i = 0, len = walked.length; i < len; i++) {787 var child = walked[i];788 if (child._astname === "Name" && child.ctx.prototype._astname === "Store") {789 iterationVariable = node.target.id.v;790 this.setIterVariable(node.target.id.v, iterSubtype, this.getLocation(node));791 } else {792 this.visit(child);793 }794 }795 796 if (iterationVariable && iterationList && iterationList == iterationVariable) {797 this.report["Iteration variable is iteration list"].push({"name": iterationList, "position": this.getLocation(node)});798 }799 // Handle the bodies800 for (var i = 0, len = node.ifs; i < len; i++) {801 this.visit(node.ifs[i]);802 }803}804var filename = '__main__.py';805//var python_source = 'sum([1,2])/len([4,5,])\ntotal=0\ntotal=total+1\nimport weather\nimport matplotlib.pyplot as plt\ncelsius_temperatures = []\nexisting=weather.get_forecasts("Miami, FL")\nfor t in existing:\n celsius = (t - 32) / 2\n celsius_temperatures.append(celsius)\nplt.plot(celsius_temperatures)\nplt.title("Temperatures in Miami")\nplt.show()';806var python_source = ''+807 'b=0\n'+808 'if X:\n'+809 '\ta=0\n'+810 '\tc=0\n'+811 'else:\n'+...
man.js
Source:man.js
1ManData.prototype = new DrawData();2ManData.prototype.constructor = ManData;3ManData.uber = DrawData.prototype;4function ManData(x, y, box) {5 this.x = x;6 this.y = y;7 this.box = box;8 this.obj = document.createElementNS(this.xmlns,'g');9 this.box.appendChild(this.obj);10 this.head = new CircleData(20,20,10,this.obj);11 this.body = new LineData(new Point(20,30),new Point(20,60),1,this.obj);12 this.hand = [new LineData(new Point(20,30),new Point(10,45),1,this.obj),new LineData(new Point(20,30),new Point(30,45),1,this.obj)];13 this.walking_func = null;14 15 this.leg = [16 new CurveData(new Point(20,60),new Point(10,75),new Point(17,65),new Point(13,71),this.obj),17 new CurveData(new Point(20,60),new Point(30,75),new Point(23,64),new Point(27,70),this.obj)18 ];19 this.walk_flag = [20 [new Point(20,60),new Point(10,75),new Point(17,65),new Point(13,71)],//¤@°¦¸}ªººÝÂI©M±±¨îªº°ò·ÇÂI21 [new Point(20,60),new Point(30,75),new Point(23,64),new Point(27,70)],//¥t¤@°¦¸}ªººÝÂI©M±±¨îªº°ò·ÇÂI22 [23 [new Point(15,80),new Point(20,85)],24 [new Point(0,70),new Point(20,70)],25 [new Point(15,72),new Point(20,80)],26 ],27 ];28 //new CurveData(new Point(10,50), new Point(50,50), new Point(20,20), new Point(15,50),document.getElementById("draw_frame"));29 /*30 test1.p1 = new Point(50,10); //20 6031 test1.p2 = new Point(50,50); //20 10032 test1.ctr1 = new Point(20,20); //-10 7033 test1.ctr2 = new Point(50,15); //20 6534 */35 this.obj.appendChild(this.body.obj);36 this.obj.appendChild(this.head.obj);37 this.obj.appendChild(this.hand[0].obj);38 this.obj.appendChild(this.hand[1].obj);39 this.obj.appendChild(this.leg[0].obj);40 this.obj.appendChild(this.leg[1].obj);41}42ManData.prototype.getlocation = function () {43 return new Point(this.x, this.y);44}45ManData.prototype.stop_walk = function () {46 clearInterval(this.walking_func);47 this.walk_flag = [48 [new Point(20,60),new Point(10,75),new Point(17,65),new Point(13,71)],49 [new Point(20,60),new Point(30,75),new Point(23,64),new Point(27,70)],50 [51 [new Point(15,80),new Point(20,85)],52 [new Point(0,70),new Point(20,70)],53 [new Point(15,72),new Point(20,80)],54 ],55 ];56}57ManData.prototype.start_walk = function () {//¥u¬O¸}³¡¦³°Ê§@58 //²Ä¤GºÝÂI59 var route3 = new Liner_Vector(new Point(15,80),new Point(20,85));60 //²Ä¤@±±¨îÂI61 var route = new Liner_Vector(new Point(0,70),new Point(20,70));62 //²Ä¤G±±¨îÂI63 var route2 = new Liner_Vector(new Point(15,72),new Point(20,80));64 65 //²Ä¤GºÝÂI66 var route3_1 = new Liner_Vector(new Point(15,80),new Point(20,85));67 //²Ä¤@±±¨îÂI68 var route_1 = new Liner_Vector(new Point(0,70),new Point(20,70));69 //²Ä¤G±±¨îÂI70 var route2_1 = new Liner_Vector(new Point(15,72),new Point(20,80));71 72 this.leg[0].p1 = new Point(20,60);//20 6073 this.leg[0].p2 = new Point(20,100);//20 10074 this.leg[0].ctr1 = new Point(-10,70);//-10 7075 this.leg[0].ctr2 = new Point(20,65);//20 6576 77 this.leg[1].p1 = new Point(20,60);78 this.leg[1].p2 = new Point(20,100);79 this.leg[1].ctr1 = new Point(-10,70);80 this.leg[1].ctr2 = new Point(20,65);81 82 var part = 0;83 var part_1 = part+100;84 var temp_man = this;85 this.walking_func = setInterval(frame, 10);86 function frame() {87 if (false/*part == 200*/) {88 //clearInterval(id);89 } else {90 part++;91 part_1 = part + 100;92 //p1,p2,ctr1,ctr293 var tmp_pt = route.get_part((part%200)/100);94 var temp_leg = part%200;95 if(temp_leg >= 100)temp_leg = 200-temp_leg;96 var tmp_pt3 = route3.get_part(temp_leg/100);97 var tmp_pt2 = route2.get_part((part%200)/100);98 if((part%200) > 100){99 tmp_pt = route.get_part((200-(part%200))/100);100 tmp_pt2 = route2.get_part((200-(part%200))/100);101 }102 temp_man.walk_flag[0][1] = tmp_pt3;103 //temp_man.leg[0].p2 = tmp_pt3;104 105 temp_man.walk_flag[0][2] = tmp_pt;106 //temp_man.leg[0].ctr1 = tmp_pt;107 108 temp_man.walk_flag[0][3] = tmp_pt2;109 //temp_man.leg[0].ctr2 = tmp_pt2;110 temp_man.draw();111 112 tmp_pt = route_1.get_part((part_1%200)/100);113 temp_leg = part_1%200;114 if(temp_leg >= 100)temp_leg = 200-temp_leg;115 tmp_pt3 = route3_1.get_part(temp_leg/100);116 tmp_pt2 = route2_1.get_part((part_1%200)/100);117 if((part_1%200) > 100){118 tmp_pt = route_1.get_part((200-(part_1%200))/100);119 tmp_pt2 = route2_1.get_part((200-(part_1%200))/100);120 }121 temp_man.walk_flag[1][1] = tmp_pt3;122 //temp_man.leg[1].p2 = tmp_pt3;123 124 temp_man.walk_flag[1][2] = tmp_pt;125 //temp_man.leg[1].ctr1 = tmp_pt;126 127 temp_man.walk_flag[1][3] = tmp_pt2;128 //temp_man.leg[1].ctr2 = tmp_pt2;129 temp_man.draw();130 }131 }132}133ManData.prototype.draw = function () {//±N¦UºØªF¦è¡]¦h«¬¡^µe¨ì¿Ã¹õ¤W134 this.head.x = 20 + this.x;135 this.head.y = 20 + this.y;136 137 this.body.p1 = (new Point(20,30)).add(this.getlocation());138 this.body.p2 = (new Point(20,60)).add(this.getlocation());139 this.hand[0].p1 = (new Point(20,30)).add(this.getlocation());140 this.hand[0].p2 = (new Point(10,45)).add(this.getlocation());141 this.hand[1].p1 = (new Point(20,30)).add(this.getlocation());142 this.hand[1].p2 = (new Point(30,45)).add(this.getlocation());143 144 145 for(var i=0; i<2; i++){146 this.leg[i].p1 = this.walk_flag[i][0].add(this.getlocation());147 this.leg[i].p2 = this.walk_flag[i][1].add(this.getlocation());148 this.leg[i].ctr1 = this.walk_flag[i][2].add(this.getlocation());149 this.leg[i].ctr2 = this.walk_flag[i][3].add(this.getlocation());150 }151 this.head.draw();152 this.body.draw();153 this.hand[0].draw();154 this.hand[1].draw();155 this.leg[0].draw();156 this.leg[1].draw();157}158ManData.prototype.show_message = function () {159 alert(this.x + ", " + this.y + ", r=" + this.r);...
SubCircuitInstance.js
Source:SubCircuitInstance.js
...26 }27 if (component.getType() == INPUT_PIN_CODE) {28 let inputPin = component;29 this.myInternalInputs.push(component);30 let newPublicInput = new ReceivingPin(this.getLocation().x,this.getLocation().y + (50 * this.myPublicInputs.length),SIGNAL_NONE);31 this.myPublicInputs.push(newPublicInput);32 inputPin.setPublicSource(newPublicInput);33 }34 else if (component.getType() == OUTPUT_PIN_CODE) {35 let outputPin = component;36 let outputReceiver = outputPin.getPins()[0];37 outputPin.getPins()[0].addListener(this);38 this.myInternalOutputs.push(outputReceiver);39 this.myPublicOutputs.push(new GeneratingPin(this.myLocation.x + 50,this.myLocation.y + (50 * this.myPublicOutputs.length),SIGNAL_NONE));40 }41 }42 this.myHeight = max(this.myPublicOutputs.length * 50,50);43 this.myTemplate = template;44 }45 //Overridden method46 //This reacts to changes in the internal output pins by making sure47 // that the external output pins always match them.48 reactToPinChange(otherPin) {49 let index = findListIndex(otherPin,this.myInternalOutputs);50 if (index != -1) {51 this.myPublicOutputs[index].setSignal(otherPin.getSignal());52 }53 }54 getClone() {55 return this.myTemplate.generateInstance(this.myLocation.x,this.myLocation.y);56 }57 getJSON() {58 return {59 type :this.COMPONENT_TYPE,60 name : this.myName,61 x : this.getLocation().x,62 y : this.getLocation().y63 }64 }65 pointInBounds(x,y) {66 console.log("Checking subcircuit bounds");67 let myX = this.getLocation().x;68 let myY = this.getLocation().y;69 return (x > myX && x < myX + this.myWidth &&70 y > myY && y < myY + this.myHeight);71 }72 resetConnections() {73 this.myPublicInputs = [];74 for (let input of this.myInternalInputs) {75 let newPublicInput = new ReceivingPin(this.getLocation().x,this.getLocation().y + (50 * this.myPublicInputs.length),SIGNAL_NONE);76 this.myPublicInputs.push(newPublicInput);77 input.setPublicSource(newPublicInput);78 }79 for (let output of this.myPublicOutputs) {80 output.clearListeners();81 }82 }...
select-location.js
Source:select-location.js
...17 methods: {18 setLocation(data) {19 localStorage._area = JSON.stringify(data);20 this.title = '';21 this.$emit('select', this.getLocation());22 },23 getLocation() {24 return localStorage._area ? JSON.parse(localStorage._area) : [];25 },26 confirm(data) {27 this.setLocation(data);28 this.show = false;29 },30 cancel() {31 this.show = false;32 },33 container() {34 return document.getElementsByTagName('body')[0];35 },36 clear() {37 localStorage.removeItem('_area');38 },39 update() {40 //åå¾å°å41 if (this.getLocation().length <= 0) {42 // $.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', () => {43 // // alert(remote_ip_info.country);//å½å®¶ 44 // // alert(remote_ip_info.province);//ç份 45 // // alert(remote_ip_info.city);//åå¸ 46 // let location = remote_ip_info;47 // let city = location.city;48 // let value = '';49 // let city_list = this.areaList.city_list;50 // for (let x in city_list) {51 // if (city_list[x].indexOf(city) >= 0) {52 // value = x;53 // this.title = city_list[x];54 // break;55 // }56 // }57 // this.active = value;58 // });59 } else {60 this.title = '';61 }62 },63 getLabel() {64 if (this.title.length <= 0) {65 if (this.getLocation().length >= 3) {66 return this.getLocation()[2].name;67 } else {68 return 'éæ©å°å';69 }70 } else {71 return this.title;72 }73 }74 },75 computed: {76 label() {77 if (this.title.length <= 0) {78 if (this.getLocation().length >= 3) {79 return this.getLocation()[2].name;80 } else {81 return 'éæ©å°å';82 }83 } else {84 return this.title;85 }86 }87 },88 //è¿æ»¤å¨89 filters: {},90 mounted() {91 // this.clear();92 this.update();93 this.$nextTick(() => { })...
main.js
Source:main.js
...12 this.width = width13 this.height = height14 }15 bounce() {16 if ((this.getLocation().y >= height) || (this.getLocation().y < 0)) {17 this.setSpeed(this.getSpeed() * -1)18 }19 this.setLocation({20 x: this.getLocation().x,21 y: this.getLocation().y + this.getSpeed()22 })23 if (this.lifespan > 0) this.lifespan--;24 }25 getWidth() {26 return this.width;27 }28 setWidth(width) {29 this.width = width;30 }31 getHeight() {32 return this.height;33 }34 setHeight(height) {35 this.height = height;...
Employee.js
Source:Employee.js
...20 this.getLocation=function () {21 return this.location;22 };23 this.getSalary = function () {24 if(this.getLocation() ==="Manager") {25 this.salary=500;26 } else if (this.getLocation()==="Sale") {27 this.salary=300;28 }else if (this.getLocation()==="Maketting") {29 this.salary=200;30 }31 return this.salary;32 };33 this.setName = function (name) {34 this.name = name;35 };36 this.setCMND = function (cmnd) {37 this.cmnd = cmnd;38 };39 this.setBirthday = function (birthday) {40 this.birthday = birthday;41 };42 this.setPhone = function (phone) {...
Geolocation.js
Source:Geolocation.js
1import React, { Component } from 'react';2import PropTypes from 'prop-types';3import { Button } from 'react-bootstrap';4import Text from '../../text';5const positionOptions = {6 timeout: Infinity,7 maximumAge: 0,8 enableHighAccuracy: true9};10class Geolocation extends Component {11 constructor(props) {12 super(props);13 this.getLocation = this.getLocation.bind(this);14 }15 getLocation() {16 navigator.geolocation.getCurrentPosition((position) => {17 this.props.onGetLocation(position.coords);18 }, null, positionOptions);19 }20 render() {21 if (!navigator.geolocation) {22 return (23 <Button className="w-100" variant="primary" disabled>24 <Text phrase="Form.geolocation.disabled" />25 </Button>26 );27 }28 return (29 <Button className="w-100" variant="primary" onClick={this.getLocation}>30 <Text phrase="Form.geolocation.enabled" />31 </Button>32 );33 }34}35Geolocation.propTypes = {36 onGetLocation: PropTypes.func.isRequired37};...
index.js
Source:index.js
1import React from 'react';2import ReactDOM from 'react-dom';3import SeasonDisplay from './SesasonDisplay';4import Loading from './Loading';5class App extends React.Component {6 constructor(props) {7 super(props);8 this.state = {9 lat: null,10 loading: null,11 errorMessage: null12 };13 this.getLocation = this.getLocation.bind(this);14 }15 getLocation() {16 this.setState({ loading: true });17 window.navigator.geolocation.getCurrentPosition(18 pos => this.setState({19 lat: pos.coords.latitude,20 loading: false,21 errorMessage: null22 }),23 err => this.setState({24 errorMessage: err.message,25 loading: false26 })27 )28 }29 render() {30 const { lat, loading, errorMessage } = this.state;31 return (32 <div className="season-display" onClick={this.getLocation}>33 {lat && <SeasonDisplay lat={lat} />}34 {loading && <Loading message='Please accept location request' />}35 {errorMessage && <h1>{errorMessage}</h1>}36 </div>37 )38 }39};...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7var location = client.getLocation('xpath',
Using AI Code Generation
1const {By, Key, until} = require('selenium-webdriver');2const driver = new webdriver.Builder()3 .forBrowser('selenium')4 .build();5driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);6driver.wait(until.titleIs('webdriver - Google Search'), 1000);7driver.quit();8const {By, Key, until} = require('selenium-webdriver');9const driver = new webdriver.Builder()10 .forBrowser('selenium')11 .build();12driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);13driver.wait(until.titleIs('webdriver - Google Search'), 1000);14driver.quit();15const {By, Key, until} = require('selenium-webdriver');16const driver = new webdriver.Builder()17 .forBrowser('selenium')18 .build();19driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);20driver.wait(until.titleIs('webdriver - Google Search'), 1000);21driver.quit();22const {By, Key, until} = require('selenium-webdriver');23const driver = new webdriver.Builder()24 .forBrowser('selenium')25 .build();26driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);27driver.wait(until.titleIs('webdriver - Google Search'), 1000);28driver.quit();29const {By, Key, until} = require('selenium-webdriver');30const driver = new webdriver.Builder()31 .forBrowser('selenium')32 .build();33driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);34driver.wait(until.titleIs('webdriver - Google Search'), 1000);35driver.quit();
Using AI Code Generation
1var location = await driver.getLocation();2await driver.setLocation(location.latitude, location.longitude, location.altitude);3var orientation = await driver.getOrientation();4await driver.setOrientation(orientation);5var networkConnection = await driver.getNetworkConnection();6await driver.setNetworkConnection(networkConnection);7var performanceData = await driver.getPerformanceData("com.apple.WebKit.WebContent", "cpuinfo", 100);8var performanceDataTypes = await driver.getPerformanceDataTypes();9var performanceDataSize = await driver.getPerformanceDataSize("com.apple.WebKit.WebContent", "cpuinfo");10var settings = await driver.getSettings();11await driver.updateSettings(settings);12var supportedPerformanceDataTypes = await driver.getSupportedPerformanceDataTypes();13var systemBars = await driver.getSystemBars();14await driver.hideSystemBars();15await driver.showSystemBars();16var timeouts = await driver.getTimeouts();
Using AI Code Generation
1const { driver } = require('appium-xcuitest-driver');2const { util } = require('appium-support');3const { ios } = require('appium-ios-driver');4async function getLocation() {5 const {latitude, longitude} = await driver.getLocation();6 console.log(`Latitude: ${latitude}, Longitude: ${longitude}`);7}8const { driver } = require('appium-xcuitest-driver');9const { util } = require('appium-support');10const { ios } = require('appium-ios-driver');11async function getLocation() {12 const {latitude, longitude} = await driver.getLocation();13 console.log(`Latitude: ${latitude}, Longitude: ${longitude}`);14}15async function setLocation() {16 await driver.setLocation({latitude: 0, longitude: 0});17}18async function getDeviceTime() {19 const time = await driver.getDeviceTime();20 console.log(`Device time: ${time}`);21}22async function getDeviceTime() {23 const time = await driver.getDeviceTime();24 console.log(`Device time: ${time}`);25}26async function getDeviceTime() {27 const time = await driver.getDeviceTime();28 console.log(`Device time: ${time}`);29}30async function getDeviceTime() {31 const time = await driver.getDeviceTime();32 console.log(`Device time: ${time}`);33}34async function getDeviceTime() {35 const time = await driver.getDeviceTime();36 console.log(`Device time: ${time}`);37}38async function getDeviceTime() {39 const time = await driver.getDeviceTime();40 console.log(`Device time: ${time}`);41}42async function getDeviceTime() {43 const time = await driver.getDeviceTime();44 console.log(`Device time: ${time}`);45}46async function getDeviceTime() {47 const time = await driver.getDeviceTime();48 console.log(`Device time: ${time}`);49}50async function getDeviceTime() {51 const time = await driver.getDeviceTime();52 console.log(`Device time: ${time}`);53}54async function getDeviceTime() {55 const time = await driver.getDeviceTime();56 console.log(`Device time: ${time}`);57}58async function getDeviceTime() {59 const time = await driver.getDeviceTime();60 console.log(`Device time: ${time}`);61}62async function getDeviceTime() {
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!!