Best JavaScript code snippet using playwright-internal
material-walkthrough.js
Source:material-walkthrough.js
...270 $.walk = function (walkPoints, callback) {271 $.walk._points = walkPoints;272 $.walk._currentIndex = 0;273 $.walk._callback = callback;274 $(walkPoints[0].target).walk(walkPoints[0]);275 };276 /**277 * Global variable that holds the current walk configuration.278 * @type {WalkPoint[]}279 */280 $.walk._points = null;281 /**282 * Global variable that holds the current point index in _walkPoints array.283 * @type {number}284 */285 $.walk._currentIndex = 0;286 /**287 * Global variable that holds the MutationObserver that listen body modifications.288 * @type {MutationObserver}...
map.js
Source:map.js
1var __extends = (this && this.__extends) || (function () {2 var extendStatics = Object.setPrototypeOf ||3 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||4 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };5 return function (d, b) {6 extendStatics(d, b);7 function __() { this.constructor = d; }8 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());9 };10})();11var mapJason = [12 { x: 0, y: 0, walkAble: false },13 { x: 64, y: 0, walkAble: false },14 { x: 128, y: 0, walkAble: false },15 { x: 192, y: 0, walkAble: false },16 { x: 256, y: 0, walkAble: false },17 { x: 320, y: 0, walkAble: false },18 { x: 384, y: 0, walkAble: false },19 { x: 448, y: 0, walkAble: false },20 { x: 512, y: 0, walkAble: false },21 { x: 576, y: 0, walkAble: false },22 { x: 0, y: 64, walkAble: false },23 { x: 64, y: 64, walkAble: false },24 { x: 128, y: 64, walkAble: false },25 { x: 192, y: 64, walkAble: false },26 { x: 256, y: 64, walkAble: false },27 { x: 320, y: 64, walkAble: false },28 { x: 384, y: 64, walkAble: false },29 { x: 448, y: 64, walkAble: false },30 { x: 512, y: 64, walkAble: false },31 { x: 576, y: 64, walkAble: false },32 { x: 0, y: 128, walkAble: false },33 { x: 64, y: 128, walkAble: false },34 { x: 128, y: 128, walkAble: false },35 { x: 192, y: 128, walkAble: false },36 { x: 256, y: 128, walkAble: false },37 { x: 320, y: 128, walkAble: false },38 { x: 384, y: 128, walkAble: false },39 { x: 448, y: 128, walkAble: false },40 { x: 512, y: 128, walkAble: false },41 { x: 576, y: 128, walkAble: false },42 { x: 0, y: 192, walkAble: false },43 { x: 64, y: 192, walkAble: false },44 { x: 128, y: 192, walkAble: false },45 { x: 192, y: 192, walkAble: false },46 { x: 256, y: 192, walkAble: false },47 { x: 320, y: 192, walkAble: false },48 { x: 384, y: 192, walkAble: false },49 { x: 448, y: 192, walkAble: false },50 { x: 512, y: 192, walkAble: false },51 { x: 576, y: 192, walkAble: false },52 { x: 0, y: 256, walkAble: false },53 { x: 64, y: 256, walkAble: false },54 { x: 128, y: 256, walkAble: false },55 { x: 192, y: 256, walkAble: false },56 { x: 256, y: 256, walkAble: false },57 { x: 320, y: 256, walkAble: false },58 { x: 384, y: 256, walkAble: false },59 { x: 448, y: 256, walkAble: false },60 { x: 512, y: 256, walkAble: false },61 { x: 576, y: 256, walkAble: false },62 { x: 0, y: 320, walkAble: false },63 { x: 64, y: 320, walkAble: false },64 { x: 128, y: 320, walkAble: false },65 { x: 192, y: 320, walkAble: false },66 { x: 256, y: 320, walkAble: false },67 { x: 320, y: 320, walkAble: false },68 { x: 384, y: 320, walkAble: false },69 { x: 448, y: 320, walkAble: false },70 { x: 512, y: 320, walkAble: false },71 { x: 576, y: 320, walkAble: false },72 { x: 0, y: 384, walkAble: false },73 { x: 64, y: 384, walkAble: false },74 { x: 128, y: 384, walkAble: false },75 { x: 192, y: 384, walkAble: false },76 { x: 256, y: 384, walkAble: false },77 { x: 320, y: 384, walkAble: false },78 { x: 384, y: 384, walkAble: false },79 { x: 448, y: 384, walkAble: false },80 { x: 512, y: 384, walkAble: false },81 { x: 576, y: 384, walkAble: false },82 { x: 0, y: 448, walkAble: false },83 { x: 64, y: 448, walkAble: false },84 { x: 128, y: 448, walkAble: false },85 { x: 192, y: 448, walkAble: false },86 { x: 256, y: 448, walkAble: false },87 { x: 320, y: 448, walkAble: false },88 { x: 384, y: 448, walkAble: false },89 { x: 448, y: 448, walkAble: false },90 { x: 512, y: 448, walkAble: false },91 { x: 576, y: 448, walkAble: false },92 { x: 0, y: 512, walkAble: false },93 { x: 64, y: 512, walkAble: false },94 { x: 128, y: 512, walkAble: false },95 { x: 192, y: 512, walkAble: false },96 { x: 256, y: 512, walkAble: false },97 { x: 320, y: 512, walkAble: false },98 { x: 384, y: 512, walkAble: false },99 { x: 448, y: 512, walkAble: false },100 { x: 512, y: 512, walkAble: false },101 { x: 576, y: 512, walkAble: false },102 { x: 0, y: 576, walkAble: false },103 { x: 64, y: 576, walkAble: false },104 { x: 128, y: 576, walkAble: false },105 { x: 192, y: 576, walkAble: false },106 { x: 256, y: 576, walkAble: false },107 { x: 320, y: 576, walkAble: false },108 { x: 384, y: 576, walkAble: false },109 { x: 448, y: 576, walkAble: false },110 { x: 512, y: 576, walkAble: false },111 { x: 576, y: 576, walkAble: false },112];113var ROW = 10;114var LIST = 10;115var STONEPROBBILITY = 0.2;116var ONETILESIZE = 64;117var manhadun = 0;118var ojilide = 1;119var duijiaoxian = 2;120var tile = (function (_super) {121 __extends(tile, _super);122 function tile() {123 var _this = _super.call(this) || this;124 _this.bitmap = new engine.Bitmap();125 _this.bitmap.x = 0;126 _this.bitmap.y = 0;127 _this.addChild(_this.bitmap);128 _this.weight = 0;129 _this.preTile = null;130 _this.touchEnabled = true;131 return _this;132 }133 return tile;134}(engine.DisplayObjectContainer));135var MainMap = (function (_super) {136 __extends(MainMap, _super);137 function MainMap() {138 var _this = _super.call(this) || this;139 _this.myMap = new Array();140 _this.path = new Array();141 for (var i = 0; i < ROW * LIST; i++) {142 if (Math.random() <= STONEPROBBILITY) {143 mapJason[i].walkAble = false;144 }145 else {146 mapJason[i].walkAble = true;147 }148 }149 //人ç©åå§ä½ç½®ä¸è½ä¸ºéç¢ç©150 mapJason[0].walkAble = true;151 mapJason[22].walkAble = true;152 mapJason[44].walkAble = true;153 mapJason[99].walkAble = true;154 for (var i = 0; i < ROW * LIST; i++) {155 _this.myMap[i] = new tile();156 _this.myMap[i].walkAble = mapJason[i].walkAble;157 _this.myMap[i].x = mapJason[i].x;158 _this.myMap[i].y = mapJason[i].y;159 if (_this.myMap[i].walkAble) {160 _this.myMap[i].bitmap.texture = "path.jpg";161 }162 else {163 _this.myMap[i].bitmap.texture = "wall.jpg";164 }165 _this.addChild(_this.myMap[i]);166 }167 return _this;168 }169 MainMap.prototype.estimulate = function (start, end, method) {170 if (method == 0) {171 return Math.abs(end.x / ONETILESIZE - start.x / ONETILESIZE) + Math.abs(end.y / ONETILESIZE - start.y / ONETILESIZE);172 }173 if (method == 1) {174 return Math.sqrt((start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y));175 }176 if (method == 2) {177 return Math.sqrt((start.x - Math.abs(end.x - start.x) / 2) * (start.x - Math.abs(end.x - start.x) / 2) + (start.y - end.y / 2) * (start.y - end.y / 2)) + Math.abs(end.x - start.x) / 2;178 }179 };180 MainMap.prototype.sortWeight = function (a, b) {181 return a.weight - b.weight;182 };183 MainMap.prototype.generatePath = function (start, end) {184 //æ¸
空路å¾185 var x = this.path.length;186 for (var i = 0; i < x; i++) {187 this.path.pop();188 }189 this.path.pop();190 //èµ·ç»ç¹æ¯å¦ç¸å191 if (start != end) {192 for (var temp = end; temp != start; temp = temp.preTile) {193 this.path.push(temp);194 }195 }196 else if (start = end) {197 this.path.push(start);198 }199 this.path.reverse();200 };201 MainMap.prototype.findWay = function (startTile, endTile) {202 startTile = this.myMap[startTile.y * ROW + startTile.x];203 endTile = this.myMap[endTile.y * ROW + endTile.x];204 if (endTile.walkAble == false) {205 console.log("(" + endTile.x + "," + endTile.y + ")" + "ä¸å¯è¾¾");206 return false;207 }208 else if (startTile == endTile) {209 console.log("èµ·ç¹ç»ç¹ç¸å" + " ä¸ç§»å¨");210 this.generatePath(startTile, endTile);211 return true;212 }213 var currentTile = startTile;214 currentTile.weight = 0;215 currentTile.preTile = null;216 var openList = new Array();217 var closedList = new Array();218 while (currentTile != endTile) {219 closedList.push(currentTile);220 var tempOpenList = new Array();221 for (var i = currentTile.x - 1 * ONETILESIZE; i < currentTile.x + 2 * ONETILESIZE; i += ONETILESIZE) {222 for (var j = currentTile.y - 1 * ONETILESIZE; j < currentTile.y + 2 * ONETILESIZE; j += ONETILESIZE) {223 //å¤ææ¯å¦è¶
åºå°å¾224 if (i < 0 || j < 0 || j > 9 * ONETILESIZE || i > 9 * ONETILESIZE) {225 continue;226 }227 //å¤ææ线æ¯å¦å¯èµ°228 if (i == currentTile.x - 1 * ONETILESIZE && j == currentTile.y - 1 * ONETILESIZE) {229 if (this.myMap[(j / ONETILESIZE) * ROW + i / ONETILESIZE + 1].walkAble == false && this.myMap[((j / ONETILESIZE) + 1) * ROW + i / ONETILESIZE].walkAble == false) {230 continue;231 }232 }233 else if (i == currentTile.x - 1 * ONETILESIZE && j == currentTile.y + 1 * ONETILESIZE) {234 if (this.myMap[(j / ONETILESIZE) * ROW + i / ONETILESIZE + 1].walkAble == false && this.myMap[((j / ONETILESIZE) - 1) * ROW + i / ONETILESIZE].walkAble == false) {235 continue;236 }237 }238 else if (i == currentTile.x + 1 * ONETILESIZE && j == currentTile.y - 1 * ONETILESIZE) {239 if (this.myMap[(j / ONETILESIZE) * ROW + i / ONETILESIZE - 1].walkAble == false && this.myMap[((j / ONETILESIZE) + 1) * ROW + i / ONETILESIZE].walkAble == false) {240 continue;241 }242 }243 else if (i == currentTile.x + 1 * ONETILESIZE && j == currentTile.y + 1 * ONETILESIZE) {244 if (this.myMap[(j / ONETILESIZE) * ROW + i / ONETILESIZE - 1].walkAble == false && this.myMap[((j / ONETILESIZE) - 1) * ROW + i / ONETILESIZE].walkAble == false) {245 continue;246 }247 }248 //计ç®Gå½æ°æ¥è¿249 var dg = 0;250 if ((i == currentTile.x - 1 * ONETILESIZE && j == currentTile.y) || (i == currentTile.x + 1 * ONETILESIZE && j == currentTile.y) || (i == currentTile.x && j == currentTile.y - 1 * ONETILESIZE) || (i == currentTile.x && j == currentTile.y + 1 * ONETILESIZE)) {251 dg = 1;252 }253 else {254 dg = 1.4;255 }256 var testTile = this.myMap[(j / ONETILESIZE) * ROW + i / ONETILESIZE];257 // console.log("å½åå¤æç ååæ ï¼" + "(" + i / ONETILESIZE + "," + j / ONETILESIZE + ")");258 //å¤ææ¯å¦ä¸ºå½åå°é¢259 if (testTile == currentTile) {260 continue;261 }262 else if (testTile.walkAble == false) {263 continue;264 }265 else if (testTile.walkAble) {266 //testTileå°è¾¾endtile267 if (testTile == endTile) {268 endTile.preTile = currentTile;269 // console.log("(" + endTile.x + "," + endTile.y + ")" + "已达å°");270 this.generatePath(startTile, endTile);271 return true;272 }273 else if (openList.indexOf(testTile) == -1 && closedList.indexOf(testTile) == -1) {274 tempOpenList.push(testTile);275 // console.log("openlist +"+"("+testTile.x+","+testTile.y+")");276 testTile.weight = currentTile.weight + dg + this.estimulate(testTile, endTile, ojilide);277 testTile.preTile = currentTile;278 }279 }280 }281 }282 if (openList.indexOf(currentTile) != -1) {283 var p = openList.indexOf(currentTile);284 for (var i = p; i < openList.length - 1; i++) {285 openList[i] = openList[i + 1];286 }287 openList.pop();288 // console.log("openlist -"+"("+currentTile.x+","+currentTile.y+")");289 }290 if (tempOpenList.length != 0) {291 tempOpenList.sort(this.sortWeight);292 currentTile = tempOpenList.shift();293 ;294 for (var i = 0; i < tempOpenList.length; i++) {295 openList.push(tempOpenList[i]);296 }297 // console.log("æ¤æ¬¡å¤ææå°æå¼ï¼" + currentTile.weight);298 // console.log("æ¤æ¬¡éæ©ç¹åæ ï¼ï¼" + currentTile.x + "," + currentTile.y + ")");299 }300 else if (openList.length != 0) {301 openList.sort(this.sortWeight);302 currentTile = openList[0];303 // console.log("å½åç¹å·²ç»æ è·¯å¯èµ°");304 // console.log("éæ©å¼æ¾å表ä¸çæå°æå¼ï¼" + currentTile.weight);305 // console.log("å¼æ¾å表ä¸éæ©ç¹åæ ï¼ï¼" + currentTile.x + "," + currentTile.y + ")");306 }307 else {308 console.log("å½åå¤æå表为空ä¸å¼æ¾å表为空ï¼æªæ¾å°è·¯å¾");309 return false;310 }311 }312 };313 MainMap.prototype.getPath = function () {314 if (this.path.length != 0) {315 return this.path;316 }317 else {318 console.log("ææ¶æ è·¯");319 return null;320 }321 };322 return MainMap;...
ESTreeWalker.js
Source:ESTreeWalker.js
...40 console.assert(typeof after === "function");41 this._before = before;42 this._after = after;43 }44 walk(node)45 {46 this._walk(node, null);47 }48 // Private49 _walk(node, parent)50 {51 if (!node)52 return;53 node.parent = parent;54 this._before(node);55 this._walkChildren(node);56 this._after(node);57 }58 _walkArray(array, parent)59 {60 for (let i = 0; i < array.length; ++i)61 this._walk(array[i], parent);62 }63 _walkChildren(node)64 {65 switch (node.type) {66 case "AssignmentExpression":67 this._walk(node.left, node);68 this._walk(node.right, node);69 break;70 case "ArrayExpression":71 case "ArrayPattern":72 this._walkArray(node.elements, node);73 break;74 case "AssignmentPattern":75 this._walk(node.left, node);76 this._walk(node.right, node);77 break;78 case "AwaitExpression":79 this._walk(node.argument, node);80 break;81 case "BlockStatement":82 this._walkArray(node.body, node);83 break;84 case "BinaryExpression":85 this._walk(node.left, node);86 this._walk(node.right, node);87 break;88 case "BreakStatement":89 case "ContinueStatement":90 this._walk(node.label, node);91 break;92 case "CallExpression":93 this._walk(node.callee, node);94 this._walkArray(node.arguments, node);95 break;96 case "CatchClause":97 this._walk(node.param, node);98 this._walk(node.body, node);99 break;100 case "ClassBody":101 this._walkArray(node.body, node);102 break;103 case "ClassDeclaration":104 case "ClassExpression":105 this._walk(node.id, node);106 this._walk(node.superClass, node);107 this._walk(node.body, node);108 break;109 case "DoWhileStatement":110 this._walk(node.body, node);111 this._walk(node.test, node);112 break;113 case "ExpressionStatement":114 this._walk(node.expression, node);115 break;116 case "ForStatement":117 this._walk(node.init, node);118 this._walk(node.test, node);119 this._walk(node.update, node);120 this._walk(node.body, node);121 break;122 case "ForInStatement":123 case "ForOfStatement":124 this._walk(node.left, node);125 this._walk(node.right, node);126 this._walk(node.body, node);127 break;128 case "FunctionDeclaration":129 case "FunctionExpression":130 case "ArrowFunctionExpression":131 this._walk(node.id, node);132 this._walkArray(node.params, node);133 this._walk(node.body, node);134 break;135 case "IfStatement":136 this._walk(node.test, node);137 this._walk(node.consequent, node);138 this._walk(node.alternate, node);139 break;140 case "LabeledStatement":141 this._walk(node.label, node);142 this._walk(node.body, node);143 break;144 case "LogicalExpression":145 this._walk(node.left, node);146 this._walk(node.right, node);147 break;148 case "MemberExpression":149 this._walk(node.object, node);150 this._walk(node.property, node);151 break;152 case "MethodDefinition":153 this._walk(node.key, node);154 this._walk(node.value, node);155 break;156 case "NewExpression":157 this._walk(node.callee, node);158 this._walkArray(node.arguments, node);159 break;160 case "ObjectExpression":161 case "ObjectPattern":162 this._walkArray(node.properties, node);163 break;164 case "Program":165 this._walkArray(node.body, node);166 break;167 case "Property":168 this._walk(node.key, node);169 this._walk(node.value, node);170 break;171 case "RestElement":172 this._walk(node.argument, node);173 break;174 case "RestProperty":175 this._walk(node.argument, node);176 break;177 case "ReturnStatement":178 this._walk(node.argument, node);179 break;180 case "SequenceExpression":181 this._walkArray(node.expressions, node);182 break;183 case "SpreadElement":184 this._walk(node.argument, node);185 break;186 case "SpreadProperty":187 this._walk(node.argument, node);188 break;189 case "SwitchStatement":190 this._walk(node.discriminant, node);191 this._walkArray(node.cases, node);192 break;193 case "SwitchCase":194 this._walk(node.test, node);195 this._walkArray(node.consequent, node);196 break;197 case "ConditionalExpression":198 this._walk(node.test, node);199 this._walk(node.consequent, node);200 this._walk(node.alternate, node);201 break;202 case "TaggedTemplateExpression":203 this._walk(node.tag, node);204 this._walk(node.quasi, node);205 break;206 case "ThrowStatement":207 this._walk(node.argument, node);208 break;209 case "TryStatement":210 this._walk(node.block, node);211 this._walk(node.handler, node);212 this._walk(node.finalizer, node);213 break;214 case "UnaryExpression":215 this._walk(node.argument, node);216 break;217 case "UpdateExpression":218 this._walk(node.argument, node);219 break;220 case "VariableDeclaration":221 this._walkArray(node.declarations, node);222 break;223 case "VariableDeclarator":224 this._walk(node.id, node);225 this._walk(node.init, node);226 break;227 case "WhileStatement":228 this._walk(node.test, node);229 this._walk(node.body, node);230 break;231 case "WithStatement":232 this._walk(node.object, node);233 this._walk(node.body, node);234 break;235 case "YieldExpression":236 this._walk(node.argument, node);237 break;238 case "ExportAllDeclaration":239 this._walk(node.source, node);240 break;241 case "ExportNamedDeclaration":242 this._walk(node.declaration, node);243 this._walkArray(node.specifiers, node);244 this._walk(node.source, node);245 break;246 case "ExportDefaultDeclaration":247 this._walk(node.declaration, node);248 break;249 case "ExportSpecifier":250 this._walk(node.local, node);251 this._walk(node.exported, node);252 break;253 case "ImportDeclaration":254 this._walkArray(node.specifiers, node);255 this._walk(node.source, node);256 break;257 case "ImportDefaultSpecifier":258 this._walk(node.local, node);259 break;260 case "ImportNamespaceSpecifier":261 this._walk(node.local, node);262 break;263 case "ImportSpecifier":264 this._walk(node.imported, node);265 this._walk(node.local, node);266 break;267 case "MetaProperty":268 this._walk(node.meta, node);269 this._walk(node.property, node);270 break;271 // Special case. We want to walk in program order,272 // so walk quasi, expression, quasi, expression, etc.273 case "TemplateLiteral":274 for (var i = 0; i < node.expressions.length; ++i) {275 this._walk(node.quasis[i], node);276 this._walk(node.expressions[i], node);277 }278 break;279 // Leaf nodes.280 case "DebuggerStatement":281 case "EmptyStatement":282 case "Identifier":283 case "Import":284 case "Literal":285 case "Super":286 case "ThisExpression":287 case "TemplateElement":288 break;289 default:290 console.error("ESTreeWalker unhandled node type", node.type);...
walk.controller.js
Source:walk.controller.js
1const Walk = require("../models/walk.model.js");2const sql = require("../models/db.js");3//Create and Save a new Post4exports.create = (req, res) => {5 // Validate request6 if (!req.body) {7 res.status(400).send({8 message: "Content can not be empty!"9 });10 }11 // Create a Walk12 const walk = new Walk({13 walkPlaceName: req.body.walkPlaceName, //æ¥éå稱14 walkCity: req.body.walkCity, //æ¥éå°å15 walkAddress: req.body.walkAddress, //æ¥éå°å16 walkDetial: req.body.walkDetial, //æ¥éä»ç´¹17 walkTel: req.body.walkTel, //æ¥éé»è©±18 walkLength: req.body.walkLength, //æ¥éé·åº¦19 walkTime: req.body.walkTime, //æ¥é總è±è²»æé20 walkPic1: req.body.walkPic1, //æ¥éç
§ç21 walkPic2: req.body.walkPic2, //æ¥éç
§ç22 addressLat: req.body.addressLat, //æ¥éèµ·å§ç·¯åº¦23 addressLng: req.body.addressLng, //æ¥éèµ·å§ç¶åº¦24 iconLat1: req.body.iconLat1, //é幣緯度25 iconLng1: req.body.iconLng1, //éå¹£ç¶åº¦26 iconLat2: req.body.iconLat2, //é幣緯度27 iconLng2: req.body.iconLng2, //éå¹£ç¶åº¦28 iconLat3: req.body.iconLat3, //é幣緯度29 iconLng3: req.body.iconLng3, //éå¹£ç¶åº¦30 iconLat4: req.body.iconLat4, //é幣緯度31 iconLng4: req.body.iconLng4, //éå¹£ç¶åº¦32 visited: req.body.visited, //ç覽人次33 walkArea: req.body.walkArea // å°å34 });35 // Save WalkPlace in the database36 Walk.create(walk, (err, succ, data) => {37 if (err) {38 res.status(500).send({39 message:40 err.message || "æ°å¢å¤±æ"41 });42 } else if (succ) {43 res.status(200).send({44 data,45 message:46 succ.message || "æåæ°å¢ä¸çè³æ"47 });48 }49 });50};51//æ¯é 顯示20çè³æ52exports.findAndPagination = (req, res) => {53 let curPage = parseInt(req.query.curPage) ? req.query.curPage : 1;54 let pageSize = parseInt(req.query.pageSize) ? req.query.pageSize : 20;55 sql.query('SELECT * FROM walk_place_lists ', (error, data) => {56 if (error) {57 throw error58 } else {59 sql.query('SELECT * FROM walk_place_lists LIMIT ' + ((curPage - 1) * pageSize) + ','60 + pageSize, (err, result) => {61 //第幾çè³æç´¢å¼ç¯å62 const minItem = (curPage * pageSize) - pageSize + 163 const maxItem = (curPage * pageSize)64 const pageTotal = Math.ceil(data.length / pageSize);65 const temp = []66 data.forEach((item, i) => {67 let itemNum = i68 if (itemNum >= minItem && itemNum <= maxItem) {69 //console.log(i, item)70 temp.push(item)71 }72 })73 if (err) {74 throw err75 } else {76 res.status(200)77 res.json({78 data: temp,79 pagination: {80 curPage: parseInt(curPage),81 pageSize: pageSize,82 total: data.length,83 //list: result,84 totalPages: Math.ceil(data.length / pageSize),85 has_pre: curPage > 1,86 has_next: curPage < pageTotal87 },88 })89 }90 });91 }92 })93};94//Fine All WalkPlace95exports.findAll = (req, res) => {96 Walk.getAll((err, data) => {97 if (err)98 res.status(500).send({99 message: err.message || "é¯èª¤é£ç·"100 });101 else res.send(data);102 });103};104exports.findSome = (req, res) => {105 Walk.getSome((err, data) => {106 if (err)107 res.status(500).send({108 message: err.message || "é¯èª¤é£ç·"109 });110 else res.send(data);111 });112};113// Find a single WalkPlace with a walkId114exports.findOne = (req, res) => {115 Walk.findById(req.params.walkId, (err, data) => {116 if (err) {117 if (err.kind === "not_found") {118 res.status(404).send({119 message: `Not found Walk with walkId ${req.params.walkId}.`120 });121 } else {122 res.status(500).send({123 message: "Error retrieving Walk with walkId " + req.params.walkId124 });125 }126 } else res.send(data);127 });128};129// Update a WalkPlace identified by the walkId in the request130exports.update = (req, res, succ) => {131 // Validate Request132 if (!req.body) {133 res.status(400).send({134 message: "Content can not be empty!"135 });136 }137 Walk.updateById(138 req.params.walkId,139 new Walk(req.body),140 (err, data) => {141 if (err) {142 if (err.kind === "not_found") {143 res.status(404).send({144 message: `æ¾ä¸å° ${req.params.walkId}.`145 });146 } else if (res.status(500)) {147 res.status(500).send({148 message: "æ´æ°å¤±æ " + req.params.walkId149 });150 }151 } else if (succ) {152 res.status(200).send({153 message:154 succ.message || "æåæ´æ°ä¸çè³æ",155 data,156 });157 }158 }159 );160};161// Delete a WalkPlace with the specified walkId in the request162exports.delete = (req, res) => {163 Walk.remove(req.params.walkId, (err, data) => {164 if (err) {165 if (err.kind === "not_found") {166 res.status(404).send({167 message: `Not found Walk with id ${req.params.walkId}.`168 });169 } else {170 res.status(500).send({171 message: "Could not delete Walk with id " + req.params.walkId172 });173 }174 } else res.send({ message: `å·²åªé¤` });175 });...
Character.js
Source:Character.js
1// Define our player character classes2var Character = IgeEntity.extend({3 classId: 'Character',4 init: function () {5 var self = this;6 IgeEntity.prototype.init.call(this);7 // Setup the entity8 self.addComponent(IgeAnimationComponent)9 .addComponent(IgeVelocityComponent)10 .depth(1);11 // Load the character texture file12 this._characterTexture = new IgeCellSheet('../assets/textures/sprites/vx_chara02_c.png', 12, 8);13 // Wait for the texture to load14 this._characterTexture.on('loaded', function () {15 self.texture(self._characterTexture)16 .dimensionsFromCell();17 }, false, true);18 },19 /**20 * Sets the type of character which determines the character's21 * animation sequences and appearance.22 * @param {Number} type From 0 to 7, determines the character's23 * appearance.24 * @return {*}25 */26 setType: function (type) {27 switch (type) {28 case 0:29 this.animation.define('walkDown', [1, 2, 3, 2], 8, -1)30 .animation.define('walkLeft', [13, 14, 15, 14], 8, -1)31 .animation.define('walkRight', [25, 26, 27, 26], 8, -1)32 .animation.define('walkUp', [37, 38, 39, 38], 8, -1)33 .cell(1);34 this._restCell = 1;35 break;36 case 1:37 this.animation.define('walkDown', [4, 5, 6, 5], 8, -1)38 .animation.define('walkLeft', [16, 17, 18, 17], 8, -1)39 .animation.define('walkRight', [28, 29, 30, 29], 8, -1)40 .animation.define('walkUp', [40, 41, 42, 41], 8, -1)41 .cell(4);42 this._restCell = 4;43 break;44 case 2:45 this.animation.define('walkDown', [7, 8, 9, 8], 8, -1)46 .animation.define('walkLeft', [19, 20, 21, 20], 8, -1)47 .animation.define('walkRight', [31, 32, 33, 32], 8, -1)48 .animation.define('walkUp', [43, 44, 45, 44], 8, -1)49 .cell(7);50 this._restCell = 7;51 break;52 case 3:53 this.animation.define('walkDown', [10, 11, 12, 11], 8, -1)54 .animation.define('walkLeft', [22, 23, 24, 23], 8, -1)55 .animation.define('walkRight', [34, 35, 36, 35], 8, -1)56 .animation.define('walkUp', [46, 47, 48, 47], 8, -1)57 .cell(10);58 this._restCell = 10;59 break;60 case 4:61 this.animation.define('walkDown', [49, 50, 51, 50], 8, -1)62 .animation.define('walkLeft', [61, 62, 63, 62], 8, -1)63 .animation.define('walkRight', [73, 74, 75, 74], 8, -1)64 .animation.define('walkUp', [85, 86, 87, 86], 8, -1)65 .cell(49);66 this._restCell = 49;67 break;68 case 5:69 this.animation.define('walkDown', [52, 53, 54, 53], 8, -1)70 .animation.define('walkLeft', [64, 65, 66, 65], 8, -1)71 .animation.define('walkRight', [76, 77, 78, 77], 8, -1)72 .animation.define('walkUp', [88, 89, 90, 89], 8, -1)73 .cell(52);74 this._restCell = 52;75 break;76 case 6:77 this.animation.define('walkDown', [55, 56, 57, 56], 8, -1)78 .animation.define('walkLeft', [67, 68, 69, 68], 8, -1)79 .animation.define('walkRight', [79, 80, 81, 80], 8, -1)80 .animation.define('walkUp', [91, 92, 93, 92], 8, -1)81 .cell(55);82 this._restCell = 55;83 break;84 case 7:85 this.animation.define('walkDown', [58, 59, 60, 59], 8, -1)86 .animation.define('walkLeft', [70, 71, 72, 71], 8, -1)87 .animation.define('walkRight', [82, 83, 84, 83], 8, -1)88 .animation.define('walkUp', [94, 95, 96, 95], 8, -1)89 .cell(58);90 this._restCell = 58;91 break;92 }93 this._characterType = type;94 return this;95 },96 /**97 * Tweens the character to the specified world co-ordinates.98 * @param x99 * @param y100 * @return {*}101 */102 walkTo: function (x, y) {103 var self = this,104 distX = x - this.translate().x(),105 distY = y - this.translate().y(),106 distance = Math.distance(107 this.translate().x(),108 this.translate().y(),109 x,110 y111 ),112 speed = 0.1,113 time = (distance / speed);114 // Set the animation based on direction115 if (Math.abs(distX) > Math.abs(distY)) {116 // Moving horizontal117 if (distX < 0) {118 // Moving left119 this.animation.select('walkLeft');120 } else {121 // Moving right122 this.animation.select('walkRight');123 }124 } else {125 // Moving vertical126 if (distY < 0) {127 // Moving up128 this.animation.select('walkUp');129 } else {130 // Moving down131 this.animation.select('walkDown');132 }133 }134 // Start tweening the little person to their destination135 this._translate.tween()136 .stopAll()137 .properties({x: x, y: y})138 .duration(time)139 .afterTween(function () {140 self.animation.stop();141 // And you could make him reset back142 // to his original animation frame with:143 //self.cell(10);144 })145 .start();146 return this;147 },148 tick: function (ctx) {149 // Set the depth to the y co-ordinate which basically150 // makes the entity appear further in the foreground151 // the closer they become to the bottom of the screen152 this.depth(this._translate.y);153 IgeEntity.prototype.tick.call(this, ctx);154 },155 destroy: function () {156 // Destroy the texture object157 if (this._characterTexture) {158 this._characterTexture.destroy();159 }160 // Call the super class161 IgeEntity.prototype.destroy.call(this);162 }163});...
walk.model.js
Source:walk.model.js
1const sql = require("./db.js");2const Walk = function (walk) {3 this.walkId = walk.walkId; //Id4 this.walkPlaceName = walk.walkPlaceName; //æ¥éå稱5 this.walkCity = walk.walkCity; //æ¥éå°å6 this.walkAddress = walk.walkAddress; //æ¥éå°å7 this.walkDetial = walk.walkDetial; //æ¥éä»ç´¹8 this.walkTel = walk.walkTel; //æ¥éé»è©±9 this.walkLength = walk.walkLength; //æ¥éé·åº¦10 this.walkTime = walk.walkTime; //æ¥é總è±è²»æé11 this.walkPic1 = walk.walkPic1; //æ¥éç
§ç12 this.walkPic2 = walk.walkPic2; //æ¥éç
§ç13 this.addressLat = walk.addressLat; //æ¥éèµ·å§ç·¯åº¦14 this.addressLng = walk.addressLng; //æ¥éèµ·å§ç¶åº¦15 this.iconLat1 = walk.iconLat1; //é幣緯度16 this.iconLng1 = walk.iconLng1; //éå¹£ç¶åº¦17 this.iconLat2 = walk.iconLat2; //é幣緯度18 this.iconLng2 = walk.iconLng2; //éå¹£ç¶åº¦19 this.iconLat3 = walk.iconLat3; //é幣緯度20 this.iconLng3 = walk.iconLng3; //éå¹£ç¶åº¦21 this.iconLat4 = walk.iconLat4; //é幣緯度22 this.iconLng4 = walk.iconLng4; //éå¹£ç¶åº¦23 this.visited = walk.visited; //ç覽人次24 this.walkArea = walk.walkArea //å°å25}26//Post27Walk.create = (newWalkPlace, result) => {28 sql.query('INSERT INTO walk_place_lists SET ?', newWalkPlace, (err, res) => {29 if (err) {30 console.log("error: ", err);31 result(null, err);32 return;33 }34 console.log("æ°å¢ä¸çæ¥éè³æ", { id: res.walkId, ...newWalkPlace });35 result(null, { id: res.walkId, ...newWalkPlace });36 });37};38//Get walksPlace with walkId39Walk.findById = (walkId, result) => {40 sql.query(`SELECT * FROM walk_place_lists WHERE walkId = ${walkId}`, (err, res) => {41 if (err) {42 console.log("error: ", err);43 result(err, null);44 return;45 }46 if (res.length) {47 console.log("found walkId: ", res[0]);48 result(null, res[0]);49 return;50 }51 // not found walkId with the walkId52 result({ kind: "not_found" }, null);53 });54};55//Get56Walk.getAll = result => {57 sql.query('SELECT * FROM walk_place_lists', (err, res) => {58 if (err) {59 console.log("error: ", err);60 result(null, err);61 return;62 }63 console.log("walk: ", res);64 result(null, res);65 });66};67Walk.getSome = result => {68 sql.query('SELECT * FROM `walk_place_lists` WHERE `walkPlaceName`="ä½å
èé½å¥é¢"', (err, res) => {69 if (err) {70 console.log("error: ", err);71 result(null, err);72 return;73 }74 console.log("walk: ", res);75 result(null, res);76 });77};78//Put79Walk.updateById = (walkId, walk, result) => {80 81 sql.query(82 "UPDATE walk_place_lists SET walkPlaceName = ?, walkCity = ?, walkAddress = ? , walkDetial = ?, walkTel = ?, walkLength = ?, walkTime = ?, walkPic1 = ?, walkPic2 = ?, addressLat = ?, addressLng = ?, iconLat1 = ?, iconLng1 = ?, iconLat2 = ?, iconLng2 = ?, iconLat3 = ?, iconLng3 = ?, iconLat4 = ?, iconLng4 = ?, visited = ?, walkArea = ? WHERE walkId = ? ORDER BY `walk_place_lists`.`walkId` ASC",83 [walk.walkPlaceName, walk.walkCity, walk.walkAddress, walk.walkDetial, walk.walkTel,84 walk.walkLength, walk.walkTime, walk.walkPic1, walk.walkPic2, walk.addressLat,85 walk.addressLng, walk.iconLat1, walk.iconLng1, walk.iconLat2, walk.iconLng2,86 walk.iconLat3, walk.iconLng3, walk.iconLat4, walk.iconLng4, walk.visited, walk.walkArea, walkId],87 (err,res) => {88 if (err) {89 console.log("error: ", err);90 result(null, err);91 return;92 }93 if (res.affectedRows == 0) {94 // not found walk with the walkId95 result({ kind: "not_found" }, null);96 return;97 }98 99 console.log("updated Walk: ", { walkId: walkId, ...walk });100 result(null, { walkId: walkId, ...walk });101 }102 );103};104Walk.remove = (walkId, result) => {105 sql.query("DELETE FROM walk_place_lists WHERE walkId = ?", walkId, (err, res) => {106 if (err) {107 console.log("error: ", err);108 result(null, err);109 return;110 }111 if (res.affectedRows == 0) {112 // not found walk_place with the walkId113 result({ kind: "not_found" }, null);114 return;115 }116 console.log("deleted walk_place with walkId: ", walkId);117 result(null, res);118 });119};...
context.js
Source:context.js
1import React, {createContext, useContext, useMemo, useReducer} from "react";2import {useHistory} from "react-router";3import {appIndexDb} from "../../AppDatabase";4import config from "../../config"5export const FORM_WALK_IN_ELIGIBILITY_CRITERIA = "eligibility_criteria";6export const FORM_WALK_IN_VERIFY_MOBILE = "verify_mobile";7export const FORM_WALK_IN_VERIFY_OTP = "verify_otp";8export const FORM_WALK_IN_ENROLL_FORM = "form";9export const FORM_WALK_IN_VERIFY_FORM = "verify_form";10export const FORM_WALK_IN_ENROLL_PAYMENTS = "payments";11export const FORM_WALK_IN_ENROLL_CONFIRMATION = "confirm";12export const INVALID_ELIGIBILITY_CRITERIA = "invalid_eligibility_criteria"13export const WALK_IN_ROUTE = "walkInEnroll";14const WalkInEnrollmentContext = createContext(null);15export const initialWalkInEnrollmentState = {16 comorbidities: [],17 yob: "",18 choice: "yes",19 currentForm: FORM_WALK_IN_ELIGIBILITY_CRITERIA,20 nextForm: FORM_WALK_IN_ELIGIBILITY_CRITERIA,21 programId: "",22 programName: "",23 nationalId: "",24 identity: "",25 name: "",26 gender: "",27 district: "",28 state: "",29 contact: "",30 email: "",31 confirmEmail: "",32 status: null,33 locality: "",34 pincode: "",35 phone: "",36 beneficiaryPhone: "",37 appointments: [],38};39export function WalkInEnrollmentProvider(props) {40 const [state, dispatch] = useReducer(walkInEnrollmentReducer, initialWalkInEnrollmentState);41 const value = useMemo(() => [state, dispatch], [state]);42 return <WalkInEnrollmentContext.Provider value={value} {...props} />43}44function walkInEnrollmentReducer(state, action) {45 switch (action.type) {46 case FORM_WALK_IN_ELIGIBILITY_CRITERIA:47 case FORM_WALK_IN_VERIFY_MOBILE:48 case FORM_WALK_IN_VERIFY_OTP:49 case FORM_WALK_IN_VERIFY_FORM:50 case FORM_WALK_IN_ENROLL_CONFIRMATION:51 case INVALID_ELIGIBILITY_CRITERIA:52 case FORM_WALK_IN_ENROLL_PAYMENTS: {53 return {54 ...state,55 ...action.payload56 };57 }58 case FORM_WALK_IN_ENROLL_FORM: {59 const newState = {60 ...state,61 ...action.payload62 };63 newState.address = {64 addressLine1: "",65 addressLine2: "",66 district: action.payload.district,67 state: action.payload.state,68 pincode: action.payload.pincode69 };70 return newState71 }72 default:73 return state;74 }75}76export function useWalkInEnrollment() {77 const context = useContext(WalkInEnrollmentContext);78 const history = useHistory();79 if (!context) {80 throw new Error(`useWalkInEnrollment must be used within a WalkInEnrollmentProvider`)81 }82 const [state, dispatch] = context;83 const goNext = function (current, next, payload) {84 payload.currentForm = current;85 payload.nextForm = next;86 dispatch({type: current, payload: payload});87 if (next) {88 if (next === '/') {89 history.replace(config.urlPath, null)90 } else {91 history.push(config.urlPath + '/' + WALK_IN_ROUTE + '/' + next)92 }93 }94 };95 const goBack = function () {96 history.goBack()97 };98 const saveWalkInEnrollment = async function (paymentMode) {99 state.paymentMode = paymentMode ?? "NA";100 return appIndexDb.saveWalkInEnrollments(state)101 };102 return {103 state,104 dispatch,105 goNext,106 goBack,107 saveWalkInEnrollment108 }...
css_text_shadow_mouse_move_effect.js
Source:css_text_shadow_mouse_move_effect.js
1import React, { createRef, useEffect, useState, Component } from "react";2import ReactDOM from "react-dom";3import PropTypes from "prop-types";4import "../../styles/css_text.scss";5import { Redirect, withRouter } from "react-router-dom/cjs/react-router-dom.min";6import ohlala from "../../img/oh-la-la.jpeg";7import { Label } from "react-konva";8export default class cssTextShadowMouseMoveEffect extends React.Component {9 constructor(props) {10 super(props);11 //this.player = this.handlePlayer.bind(this);12 this.sliderImages = [];13 this.state = {14 add_items: null,15 items_list: null,16 items: []17 };18 this.heroRef = createRef();19 this.textRef = createRef();20 }21 componentDidMount(props) {}22 shadow(e) {23 const walk = 100; //100px24 const { offsetWidth: width, offsetHeight: height } = this.heroRef.current;25 let { offsetX: x, offsetY: y } = e.nativeEvent;26 //console.log(width, height, x, y);27 //console.log(this.heroRef.current, e.target);28 if (this.heroRef.current !== e.target) {29 x = x + e.target.offsetLeft;30 y = y + e.target.offsetTop;31 }32 //console.log(x, y);33 const xWalk = Math.round((x / width) * walk - walk / 2);34 const yWalk = Math.round((y / height) * walk - walk / 2);35 //console.log(xWalk, yWalk);36 this.textRef.current.style.textShadow = `37 ${xWalk}px ${yWalk}px 0 rgba(255,0,255,0.7),38 ${xWalk * -1}px ${yWalk}px 0 rgba(0,255,255,0.7),39 ${yWalk}px ${xWalk * -1}px 0 rgba(0,255,0,0.7),40 ${yWalk * -1}px ${xWalk}px 0 rgba(0,0,255,0.7)`;41 }42 shadowTouch(e) {43 const walk = 100; //100px44 const { offsetWidth: width, offsetHeight: height } = this.heroRef.current;45 let { pageX: x, pageY: y } = e.touches[0];46 //console.log(width, height, x, y);47 //console.log(this.heroRef.current, e.target);48 if (this.heroRef.current !== e.target) {49 x = x + e.target.offsetLeft;50 y = y + e.target.offsetTop;51 }52 //console.log(x, y);53 const xWalk = Math.round((x / width) * walk - walk / 2);54 const yWalk = Math.round((y / height) * walk - walk / 2);55 //console.log(xWalk, yWalk);56 this.textRef.current.style.textShadow = `57 ${xWalk}px ${yWalk}px 0 rgba(255,0,255,0.7),58 ${xWalk * -1}px ${yWalk}px 0 rgba(0,255,255,0.7),59 ${yWalk}px ${xWalk * -1}px 0 rgba(0,255,0,0.7),60 ${yWalk * -1}px ${xWalk}px 0 rgba(0,0,255,0.7)`;61 }62 debounce(func, wait = 50, immediate = true) {63 var timeout;64 return function() {65 var context = this,66 args = arguments;67 var later = function() {68 timeout = null;69 if (!immediate) func.apply(context, args);70 };71 var callNow = immediate && !timeout;72 clearTimeout(timeout);73 timeout = setTimeout(later, wait);74 if (callNow) func.apply(context, args);75 };76 }77 render() {78 // eslint-disable-line no-console79 return (80 <div81 className="cssTextShadowMouseMoveEffect hero updateBG"82 ref={this.heroRef}83 onMouseMove={e => {84 this.debounce(this.shadow(e));85 }}86 onTouchMove={e => this.shadowTouch(e)}>87 <h1 className="text-center mt-5 bg-primary card">CSS Text Shadow Mouse Move Effect</h1>88 <h2 contentEditable ref={this.textRef}>89 ð¥WOAH!90 </h2>91 </div>92 );93 }94}95cssTextShadowMouseMoveEffect.propTypes = {96 boxesSelected: PropTypes.string...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 const input = await page.$('input[name="q"]');7 await input.type('Playwright');8 await page.keyboard.press('Enter');9 await page.waitForNavigation();10 const results = await page.$$('div.g');11 console.log(results.length);12 await browser.close();13})();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const input = await page.$('input[name="q"]');7 await input.type('Hello World');8 await page.screenshot({ path: `example.png` });9 await browser.close();10})();
Using AI Code Generation
1const { chromium } = require('playwright');2const fs = require('fs');3const path = require('path');4(async () => {5 const browser = await chromium.launch();6 const page = await browser.newPage();7 const element = await page.$('text=Docs');8 const filePath = path.join(__dirname, 'element.png');9 await element.screenshot({ path: filePath });10 await browser.close();11 console.log(`See screenshot: ${filePath}`);12})();13const { chromium } = require('playwright');14const fs = require('fs');15const path = require('path');16(async () => {17 const browser = await chromium.launch();18 const page = await browser.newPage();19 const element = await page.$('text=Docs');20 const filePath = path.join(__dirname, 'element.png');21 await element.screenshot({ path: filePath });22 await browser.close();23 console.log(`See screenshot: ${filePath}`);24})();
Using AI Code Generation
1const {chromium} = require('playwright');2(async () => {3 const browser = await chromium.launch({headless: false});4 const page = await browser.newPage();5 const [response] = await Promise.all([6 page.click('text=About'),7 ]);8 console.log(response.status());9 await page.waitForTimeout(3000);10 await browser.close();11})();
Using AI Code Generation
1const { test, expect } = require('@playwright/test');2test('test', async ({ page }) => {3 const elements = await page.$$('text=Get Started');4 await elements[0].click();5 await page.waitForNavigation();6 const elements2 = await page.$$('text=Docs');7 await elements2[0].click();8 await page.waitForNavigation();9 const elements3 = await page.$$('text=Playwright API');10 await elements3[0].click();11 await page.waitForNavigation();12 const elements4 = await page.$$('text=class: Page');13 await elements4[0].click();14 await page.waitForNavigation();15 const elements5 = await page.$$('text=page.$');16 await elements5[0].click();17 await page.waitForNavigation();18 const elements6 = await page.$$('text=page.$$');19 await elements6[0].click();20 await page.waitForNavigation();21 const elements7 = await page.$$('text=page.$eval');22 await elements7[0].click();23 await page.waitForNavigation();24 const elements8 = await page.$$('text=page.$$eval');25 await elements8[0].click();26 await page.waitForNavigation();27 const elements9 = await page.$$('text=page.$x');28 await elements9[0].click();29 await page.waitForNavigation();30 const elements10 = await page.$$('text=page.$eval');31 await elements10[0].click();32 await page.waitForNavigation();33 const elements11 = await page.$$('text=page.$eval');34 await elements11[0].click();35 await page.waitForNavigation();36 const elements12 = await page.$$('text=page.$eval');37 await elements12[0].click();38 await page.waitForNavigation();39 const elements13 = await page.$$('text=page.$eval');40 await elements13[0].click();41 await page.waitForNavigation();42 const elements14 = await page.$$('text=page.$eval');43 await elements14[0].click();44 await page.waitForNavigation();45 const elements15 = await page.$$('text=page.$eval');46 await elements15[0].click();47 await page.waitForNavigation();48 const elements16 = await page.$$('text=page.$eval');
Using AI Code Generation
1(async () => {2 const browser = await chromium.launch();3 const page = await browser.newPage();4 await page.waitForTimeout(5000);5 const button = await page.$('button');6 await button.click();7 await page.waitForTimeout(5000);8 const button2 = await page.$('button');9 await button2.click();10 await page.waitForTimeout(5000);11 const button3 = await page.$('button');12 await button3.click();13 await page.waitForTimeout(5000);14 const button4 = await page.$('button');15 await button4.click();16 await page.waitForTimeout(5000);17 const button5 = await page.$('button');18 await button5.click();19 await page.waitForTimeout(5000);20 const button6 = await page.$('button');21 await button6.click();22 await page.waitForTimeout(5000);23 const button7 = await page.$('button');24 await button7.click();25 await page.waitForTimeout(5000);26 const button8 = await page.$('button');27 await button8.click();28 await page.waitForTimeout(5000);29 const button9 = await page.$('button');30 await button9.click();
Using AI Code Generation
1const { walk } = require('@playwright/test/lib/utils/fileServer');2const path = require('path');3const server = await walk(path.join(__dirname, 'static'));4const page = await context.newPage();5await page.goto(server.PREFIX + '/index.html');6await page.click('button');7const popup = await page.waitForEvent('popup');8await popup.fill('input', 'My name is John');9await popup.click('button');10const text = await popup.textContent('p');11expect(text).toBe('Hello My name is John!');12await browser.close();
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!