How to use walk method in ATX

Best Python code snippet using ATX

material-walkthrough.js

Source:material-walkthrough.js Github

copy

Full Screen

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

Full Screen

Full Screen

map.js

Source:map.js Github

copy

Full Screen

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

Full Screen

Full Screen

ESTreeWalker.js

Source:ESTreeWalker.js Github

copy

Full Screen

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

Full Screen

Full Screen

walk.controller.js

Source:walk.controller.js Github

copy

Full Screen

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

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful