How to use getPath method in storybook-root

Best JavaScript code snippet using storybook-root

v3_epoly.js

Source:v3_epoly.js Github

copy

Full Screen

...85 var j=0;86 var oddNodes = false;87 var x = point.lng();88 var y = point.lat();89 for (var i=0; i < this.getPath().getLength(); i++) {90 j++;91 if (j == this.getPath().getLength()) {j = 0;}92 if (((this.getPath().getAt(i).lat() < y) && (this.getPath().getAt(j).lat() >= y))93 || ((this.getPath().getAt(j).lat() < y) && (this.getPath().getAt(i).lat() >= y))) {94 if ( this.getPath().getAt(i).lng() + (y - this.getPath().getAt(i).lat())95 / (this.getPath().getAt(j).lat()-this.getPath().getAt(i).lat())96 * (this.getPath().getAt(j).lng() - this.getPath().getAt(i).lng())<x ) {97 oddNodes = !oddNodes98 }99 }100 }101 return oddNodes;102}103// === A method which returns the approximate area of a non-intersecting polygon in square metres ===104// === It doesn't fully account for spherical geometry, so will be inaccurate for large polygons ===105// === The polygon must not intersect itself ===106google.maps.Polygon.prototype.Area = function() {107 var a = 0;108 var j = 0;109 var b = this.Bounds();110 var x0 = b.getSouthWest().lng();111 var y0 = b.getSouthWest().lat();112 for (var i=0; i < this.getPath().getLength(); i++) {113 j++;114 if (j == this.getPath().getLength()) {j = 0;}115 var x1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(this.getPath().getAt(i).lat(),x0));116 var x2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(this.getPath().getAt(j).lat(),x0));117 var y1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(y0,this.getPath().getAt(i).lng()));118 var y2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(y0,this.getPath().getAt(j).lng()));119 a += x1*y2 - x2*y1;120 }121 return Math.abs(a * 0.5);122}123// === A method which returns the length of a path in metres ===124google.maps.Polygon.prototype.Distance = function() {125 var dist = 0;126 for (var i=1; i < this.getPath().getLength(); i++) {127 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));128 }129 return dist;130}131// === A method which returns the bounds as a GLatLngBounds ===132google.maps.Polygon.prototype.Bounds = function() {133 var bounds = new google.maps.LatLngBounds();134 for (var i=0; i < this.getPath().getLength(); i++) {135 bounds.extend(this.getPath().getAt(i));136 }137 return bounds;138}139// === A method which returns a GLatLng of a point a given distance along the path ===140// === Returns null if the path is shorter than the specified distance ===141google.maps.Polygon.prototype.GetPointAtDistance = function(metres) {142 // some awkward special cases143 if (metres == 0) return this.getPath().getAt(0);144 if (metres < 0) return null;145 if (this.getPath().getLength() < 2) return null;146 var dist=0;147 var olddist=0;148 for (var i=1; (i < this.getPath().getLength() && dist < metres); i++) {149 olddist = dist;150 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));151 }152 if (dist < metres) {153 return null;154 }155 var p1= this.getPath().getAt(i-2);156 var p2= this.getPath().getAt(i-1);157 var m = (metres-olddist)/(dist-olddist);158 return new google.maps.LatLng( p1.lat() + (p2.lat()-p1.lat())*m, p1.lng() + (p2.lng()-p1.lng())*m);159}160// === A method which returns an array of GLatLngs of points a given interval along the path ===161google.maps.Polygon.prototype.GetPointsAtDistance = function(metres) {162 var next = metres;163 var points = [];164 // some awkward special cases165 if (metres <= 0) return points;166 var dist=0;167 var olddist=0;168 for (var i=1; (i < this.getPath().getLength()); i++) {169 olddist = dist;170 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));171 while (dist > next) {172 var p1= this.getPath().getAt(i-1);173 var p2= this.getPath().getAt(i);174 var m = (next-olddist)/(dist-olddist);175 points.push(new google.maps.LatLng( p1.lat() + (p2.lat()-p1.lat())*m, p1.lng() + (p2.lng()-p1.lng())*m));176 next += metres; 177 }178 }179 return points;180}181// === A method which returns the Vertex number at a given distance along the path ===182// === Returns null if the path is shorter than the specified distance ===183google.maps.Polygon.prototype.GetIndexAtDistance = function(metres) {184 // some awkward special cases185 if (metres == 0) return this.getPath().getAt(0);186 if (metres < 0) return null;187 var dist=0;188 var olddist=0;189 for (var i=1; (i < this.getPath().getLength() && dist < metres); i++) {190 olddist = dist;191 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));192 }193 if (dist < metres) {return null;}194 return i;195}196// === A function which returns the bearing between two vertices in decgrees from 0 to 360===197// === If v1 is null, it returns the bearing between the first and last vertex ===198// === If v1 is present but v2 is null, returns the bearing from v1 to the next vertex ===199// === If either vertex is out of range, returns void ===200google.maps.Polygon.prototype.Bearing = function(v1,v2) {201 if (v1 == null) {202 v1 = 0;203 v2 = this.getPath().getLength()-1;204 } else if (v2 == null) {205 v2 = v1+1;206 }207 if ((v1 < 0) || (v1 >= this.getPath().getLength()) || (v2 < 0) || (v2 >= this.getPath().getLength())) {208 return;209 }210 var from = this.getPath().getAt(v1);211 var to = this.getPath().getAt(v2);212 if (from.equals(to)) {213 return 0;214 }215 var lat1 = from.latRadians();216 var lon1 = from.lngRadians();217 var lat2 = to.latRadians();218 var lon2 = to.lngRadians();219 var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ), Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 ) * Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) );220 if ( angle < 0.0 ) angle += Math.PI * 2.0;221 angle = angle * 180.0 / Math.PI;222 return parseFloat(angle.toFixed(1));223}224// === Copy all the above functions to GPolyline ===225google.maps.Polyline.prototype.Contains = google.maps.Polygon.prototype.Contains;...

Full Screen

Full Screen

polygon_edit.js

Source:polygon_edit.js Github

copy

Full Screen

...32 var vertexGhostMouseOut = function () {33 this.setIcon(imgGhostVertex);34 };35 var vertexGhostDrag = function () {36 if (ghostPath.getPath().getLength() === 0) {37 if (this.marker.inex < self.getPath().getLength() - 1) {38 ghostPath.setPath([this.marker.getPosition(), this.getPosition(), self.getPath().getAt(this.marker.inex + 1)]);39 } else {40 if (this.marker.inex === self.getPath().getLength() - 1) {41 ghostPath.setPath([this.marker.getPosition(), this.getPosition(), self.getPath().getAt(0)]);42 }43 }44 } 45 ghostPath.getPath().setAt(1, this.getPosition());46 };47 var moveGhostMarkers = function (marker) {48 var Vertex = self.getPath().getAt(marker.inex);49 if (marker.inex === 0) {50 var prevVertex = self.getPath().getAt(self.getPath().getLength() - 1);51 } else {52 var prevVertex = self.getPath().getAt(marker.inex - 1);53 }54 if ((typeof(Vertex) !== "undefined") && (typeof(Vertex.ghostMarker) !== "undefined")) {55 if (typeof(google.maps.geometry) === "undefined") {56 if (marker.inex < self.getPath().getLength() - 1) {57 Vertex.ghostMarker.setPosition(new google.maps.LatLng(Vertex.lat() + 0.5 * (self.getPath().getAt(marker.inex + 1).lat() - Vertex.lat()), Vertex.lng() + 0.5 * (self.getPath().getAt(marker.inex + 1).lng() - Vertex.lng())));58 } else {59 if (marker.inex === self.getPath().getLength() - 1) {60 Vertex.ghostMarker.setPosition(new google.maps.LatLng(Vertex.lat() + 0.5 * (self.getPath().getAt(0).lat() - Vertex.lat()), Vertex.lng() + 0.5 * (self.getPath().getAt(0).lng() - Vertex.lng())));61 }62 }63 } else {64 if (marker.inex < self.getPath().getLength() - 1) {65 Vertex.ghostMarker.setPosition(google.maps.geometry.spherical.interpolate(Vertex, self.getPath().getAt(marker.inex + 1), 0.5));66 } else {67 if (marker.inex === self.getPath().getLength() - 1) {68 Vertex.ghostMarker.setPosition(google.maps.geometry.spherical.interpolate(Vertex, self.getPath().getAt(0), 0.5));69 }70 }71 }72 } 73 if ((typeof(prevVertex) !== "undefined") && (typeof(prevVertex.ghostMarker) !== "undefined")) {74 if (typeof(google.maps.geometry) === "undefined") {75 prevVertex.ghostMarker.setPosition(new google.maps.LatLng(prevVertex.lat() + 0.5 * (marker.getPosition().lat() - prevVertex.lat()), prevVertex.lng() + 0.5 * (marker.getPosition().lng() - prevVertex.lng())));76 } else {77 prevVertex.ghostMarker.setPosition(google.maps.geometry.spherical.interpolate(prevVertex, marker.getPosition(), 0.5));78 }79 }80 };81 var vertexGhostDragEnd = function () {82 ghostPath.getPath().forEach(function () {83 ghostPath.getPath().pop();84 });85 self.getPath().insertAt(this.marker.inex + 1, this.getPosition());86 createMarkerVertex(self.getPath().getAt(this.marker.inex + 1)).inex = this.marker.inex + 1;87 moveGhostMarkers(this.marker);88 createGhostMarkerVertex(self.getPath().getAt(this.marker.inex + 1));89 self.getPath().forEach(function (vertex, inex) {90 if (vertex.marker) {91 vertex.marker.inex = inex;92 }93 });94 };95 var createGhostMarkerVertex = function (point) {96 if (point.marker.inex < self.getPath().getLength() - 1) {97 var markerGhostVertex = new google.maps.Marker({98 position : (typeof(google.maps.geometry) === "undefined") ? new google.maps.LatLng(99 point.lat() + 0.5 * (self.getPath().getAt(point.marker.inex + 1).lat() - point.lat()),100 point.lng() + 0.5 * (self.getPath().getAt(point.marker.inex + 1).lng() - point.lng()))101 :google.maps.geometry.spherical.interpolate(point, self.getPath().getAt(point.marker.inex + 1), 0.5),102 map : self.getMap(),103 icon : imgGhostVertex,104 draggable : true,105 raiseOnDrag : false106 });107 google.maps.event.addListener(markerGhostVertex, "mouseover", vertexGhostMouseOver);108 google.maps.event.addListener(markerGhostVertex, "mouseout", vertexGhostMouseOut);109 google.maps.event.addListener(markerGhostVertex, "drag", vertexGhostDrag);110 google.maps.event.addListener(markerGhostVertex, "dragend", vertexGhostDragEnd);111 point.ghostMarker = markerGhostVertex;112 markerGhostVertex.marker = point.marker;113 return markerGhostVertex;114 } else {115 if (point.marker.inex === self.getPath().getLength() - 1) {116 var markerGhostVertex = new google.maps.Marker({117 position : (typeof(google.maps.geometry) === "undefined") ? new google.maps.LatLng(118 point.lat() + 0.5 * (self.getPath().getAt(0).lat() - point.lat()),119 point.lng() + 0.5 * (self.getPath().getAt(0).lng() - point.lng()))120 :google.maps.geometry.spherical.interpolate(point, self.getPath().getAt(0), 0.5),121 map : self.getMap(),122 icon : imgGhostVertex,123 draggable : true,124 raiseOnDrag : false125 });126 google.maps.event.addListener(markerGhostVertex, "mouseover", vertexGhostMouseOver);127 google.maps.event.addListener(markerGhostVertex, "mouseout", vertexGhostMouseOut);128 google.maps.event.addListener(markerGhostVertex, "drag", vertexGhostDrag);129 google.maps.event.addListener(markerGhostVertex, "dragend", vertexGhostDragEnd);130 point.ghostMarker = markerGhostVertex;131 markerGhostVertex.marker = point.marker;132 return markerGhostVertex;133 }134 }135 return null;136 };137 }138 var imgVertex = new google.maps.MarkerImage('css/vertex.png',139 new google.maps.Size(11, 11), new google.maps.Point(0, 0),140 new google.maps.Point(6, 6));141 var imgVertexOver = new google.maps.MarkerImage('css/vertexOver.png',142 new google.maps.Size(11, 11), new google.maps.Point(0, 0),143 new google.maps.Point(6, 6));144 var vertexMouseOver = function () {145 this.setIcon(imgVertexOver);146 };147 var vertexMouseOut = function () {148 this.setIcon(imgVertex);149 };150 var vertexDrag = function () {151 var movedVertex = this.getPosition();152 movedVertex.marker = this;153 movedVertex.ghostMarker = self.getPath().getAt(this.inex).ghostMarker;154 self.getPath().setAt(this.inex, movedVertex);155 if (flag) {156 moveGhostMarkers(this);157 }158 };159 var vertexRightClick = function () {160 if (flag) {161 var Vertex = self.getPath().getAt(this.inex);162 if (this.inex === 0) {163 var prevVertex = self.getPath().getAt(self.getPath().getLength() - 1);164 } else {165 var prevVertex = self.getPath().getAt(this.inex - 1);166 }167 if (typeof(Vertex.ghostMarker) !== "undefined") {168 Vertex.ghostMarker.setMap(null);169 }170 self.getPath().removeAt(this.inex);171 self.getPath().forEach(function (vertex, inex) {172 if (vertex.marker) {173 vertex.marker.inex = inex;174 }175 });176 if (typeof(prevVertex) !== "undefined") {177 if (this.inex <= self.getPath().getLength() ) {178 moveGhostMarkers(prevVertex.marker);179 } else {180 prevVertex.ghostMarker.setMap(null);181 prevVertex.ghostMarker = undefined;182 }183 }184 } 185 else {186 self.getPath().removeAt(this.inex);187 }188 this.setMap(null);189 if (self.getPath().getLength() === 1) {190 prevVertex.ghostMarker.setMap(null);191 self.getPath().pop().marker.setMap(null);192 }193 };194 var createMarkerVertex = function (point) {195 var markerVertex = new google.maps.Marker({196 position : point,197 map : self.getMap(),198 icon : imgVertex,199 draggable : true,200 raiseOnDrag : false201 });202 google.maps.event.addListener(markerVertex, "mouseover", vertexMouseOver);203 google.maps.event.addListener(markerVertex, "mouseout", vertexMouseOut);204 google.maps.event.addListener(markerVertex, "drag", vertexDrag);205 google.maps.event.addListener(markerVertex, "rightclick", vertexRightClick);206 point.marker = markerVertex;207 return markerVertex;208 };209 this.getPath().forEach(function (vertex, inex) {210 createMarkerVertex(vertex).inex = inex;211 if (flag) {212 createGhostMarkerVertex(vertex);213 }214 });215 };216}217if (typeof(google.maps.Polygon.prototype.stopEdit) === "undefined") {218 /**219 * Stops editing Polygon220 */221 google.maps.Polygon.prototype.stopEdit = function () {222 this.getPath().forEach(function (vertex, inex) {223 if (vertex.marker) {224 vertex.marker.setMap(null);225 vertex.marker = undefined;226 }227 if (vertex.ghostMarker) {228 vertex.ghostMarker.setMap(null);229 vertex.ghostMarker = undefined;230 }231 });232 }; ...

Full Screen

Full Screen

dirUtils.js

Source:dirUtils.js Github

copy

Full Screen

...188 return rv;189 },190 191 getPrefsDir :192 function () { return this.getPath(NS_APP_PREFS_50_DIR); },193 getChromeDir :194 function () { return this.getPath(NS_APP_CHROME_DIR); },195 getMozHomeDir : 196 function () { return this.getPath(NS_APP_USER_PROFILES_ROOT_DIR); },197 getMozUserHomeDir :198 function () { return this.getPath(NS_APP_USER_PROFILE_50_DIR); },199 getAppRegDir : 200 function () { return this.getPath(NS_APP_APPLICATION_REGISTRY_FILE); },201 getAppDefaultDir : 202 function () { return this.getPath(NS_APP_DEFAULTS_50_DIR); },203 getAppDefaultPrefDir :204 function () { return this.getPath(NS_APP_PREF_DEFAULTS_50_DIR); },205 getProfileDefaultsLocDir : 206 function () { return this.getPath(NS_APP_PROFILE_DEFAULTS_50_DIR); },207 getProfileDefaultsDir :208 function () { return this.getPath(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR); },209 getAppResDir :210 function () { return this.getPath(NS_APP_RES_DIR); },211 getAppPluginsDir : 212 function () { return this.getPath(NS_APP_PLUGINS_DIR); },213 getSearchPluginsDir : 214 function () { return this.getPath(NS_APP_SEARCH_DIR); },215 getPrefsFile : 216 function () { return this.getPath(NS_APP_PREFS_50_FILE); },217 getUserChromeDir : 218 function () { return this.getPath(NS_APP_USER_CHROME_DIR); },219 getLocalStore :220 function () { return this.getPath(NS_APP_LOCALSTORE_50_FILE); },221 getHistoryFile : 222 function () { return this.getPath(NS_APP_HISTORY_50_FILE); },223 getPanelsFile :224 function () { return this.getPath(NS_APP_USER_PANELS_50_FILE); },225 getMimeTypes :226 function () { return this.getPath(NS_APP_USER_MIMETYPES_50_FILE); },227 getBookmarks : 228 function () { return this.getPath(NS_APP_BOOKMARKS_50_FILE); },229 getSearchFile : 230 function () { return this.getPath(NS_APP_SEARCH_50_FILE); },231 getUserMailDir : 232 function () { return this.getPath(NS_APP_MAIL_50_DIR); },233 getUserImapDir : 234 function () { return this.getPath(NS_APP_IMAP_MAIL_50_DIR); },235 getUserNewsDir :236 function () { return this.getPath(NS_APP_NEWS_50_DIR); },237 getMessengerFolderCache :238 function () { return this.getPath(NS_APP_MESSENGER_FOLDER_CACHE_50_DIR); },239 getCurProcDir : 240 function () { return this.getPath(NS_OS_CURRENT_PROCESS_DIR); },241 getHomeDir : 242 function () { return this.getPath(NS_OS_HOME_DIR); },243 getDesktopDir : 244 function () 245 { 246 include(jslib_system);247 var sys = new System;248 var os = sys.os;249 var key = "";250 var rv;251 if (os == "win32")252 key = "DeskP";253 else if (os == "macosx")254 key = "UsrDsk";255 else256 key = NS_OS_DESKTOP_DIR;257 rv = this.getPath(key);258 if (rv < 0)259 rv = null;260 return rv;261 },262 getTmpDir :263 function () { return this.getPath(NS_OS_TEMP_DIR); },264 getComponentsDir : 265 function () { return this.getPath(NS_XPCOM_COMPONENT_DIR); },266 get help () 267 {268 var help =269 "\n\nFunction and Attribute List:\n" +270 "\n" +271 " getPrefsDir()\n" +272 " getChromeDir()\n" +273 " getMozHomeDir()\n" +274 " getMozUserHomeDir()\n" +275 " getAppRegDir()\n" +276 " getAppDefaultDir()\n" +277 " getAppDefaultPrefDir()\n" +278 " getProfileDefaultsLocDir()\n" +279 " getProfileDefaultsDir()\n" +...

Full Screen

Full Screen

epoly.js

Source:epoly.js Github

copy

Full Screen

...27 var j = 0;28 var oddNodes = false;29 var x = point.lng();30 var y = point.lat();31 for (var i = 0; i < this.getPath().getLength(); i++) {32 j++;33 if (j == this.getPath().getLength()) {34 j = 0;35 }36 if (((this.getPath().getAt(i).lat() < y) && (this.getPath().getAt(j).lat() >= y)) || ((this.getPath().getAt(j).lat() < y) && (this.getPath().getAt(i).lat() >= y))) {37 if (this.getPath().getAt(i).lng() + (y - this.getPath().getAt(i).lat()) / (this.getPath().getAt(j).lat() - this.getPath().getAt(i).lat()) * (this.getPath().getAt(j).lng() - this.getPath().getAt(i).lng()) < x) {38 oddNodes = !oddNodes39 }40 }41 }42 return oddNodes;43}44// === A method which returns the approximate area of a non-intersecting polygon in square metres ===45// === It doesn't fully account for spherical geometry, so will be inaccurate for large polygons ===46// === The polygon must not intersect itself ===47google.maps.Polygon.prototype.Area = function() {48 var a = 0;49 var j = 0;50 var b = this.Bounds();51 var x0 = b.getSouthWest().lng();52 var y0 = b.getSouthWest().lat();53 for (var i = 0; i < this.getPath().getLength(); i++) {54 j++;55 if (j == this.getPath().getLength()) {56 j = 0;57 }58 var x1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(this.getPath().getAt(i).lat(), x0));59 var x2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(this.getPath().getAt(j).lat(), x0));60 var y1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(y0, this.getPath().getAt(i).lng()));61 var y2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(y0, this.getPath().getAt(j).lng()));62 a += x1 * y2 - x2 * y1;63 }64 return Math.abs(a * 0.5);65}66// === A method which returns the length of a path in metres ===67google.maps.Polygon.prototype.Distance = function() {68 var dist = 0;69 for (var i = 1; i < this.getPath().getLength(); i++) {70 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i - 1));71 }72 return dist;73}74// === A method which returns the bounds as a GLatLngBounds ===75google.maps.Polygon.prototype.Bounds = function() {76 var bounds = new google.maps.LatLngBounds();77 for (var i = 0; i < this.getPath().getLength(); i++) {78 bounds.extend(this.getPath().getAt(i));79 }80 return bounds;81}82// === A method which returns a GLatLng of a point a given distance along the path ===83// === Returns null if the path is shorter than the specified distance ===84google.maps.Polygon.prototype.GetPointAtDistance = function(metres) {85 // some awkward special cases86 if (metres == 0) return this.getPath().getAt(0);87 if (metres < 0) return null;88 if (this.getPath().getLength() < 2) return null;89 var dist = 0;90 var olddist = 0;91 for (var i = 1;92 (i < this.getPath().getLength() && dist < metres); i++) {93 olddist = dist;94 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i - 1));95 }96 if (dist < metres) {97 return null;98 }99 var p1 = this.getPath().getAt(i - 2);100 var p2 = this.getPath().getAt(i - 1);101 var m = (metres - olddist) / (dist - olddist);102 return new google.maps.LatLng(p1.lat() + (p2.lat() - p1.lat()) * m, p1.lng() + (p2.lng() - p1.lng()) * m);103}104// === A method which returns an array of GLatLngs of points a given interval along the path ===105google.maps.Polygon.prototype.GetPointsAtDistance = function(metres) {106 var next = metres;107 var points = [];108 // some awkward special cases109 if (metres <= 0) return points;110 var dist = 0;111 var olddist = 0;112 for (var i = 1;113 (i < this.getPath().getLength()); i++) {114 olddist = dist;115 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i - 1));116 while (dist > next) {117 var p1 = this.getPath().getAt(i - 1);118 var p2 = this.getPath().getAt(i);119 var m = (next - olddist) / (dist - olddist);120 points.push(new google.maps.LatLng(p1.lat() + (p2.lat() - p1.lat()) * m, p1.lng() + (p2.lng() - p1.lng()) * m));121 next += metres;122 }123 }124 return points;125}126// === A method which returns the Vertex number at a given distance along the path ===127// === Returns null if the path is shorter than the specified distance ===128google.maps.Polygon.prototype.GetIndexAtDistance = function(metres) {129 // some awkward special cases130 if (metres == 0) return this.getPath().getAt(0);131 if (metres < 0) return null;132 var dist = 0;133 var olddist = 0;134 for (var i = 1;135 (i < this.getPath().getLength() && dist < metres); i++) {136 olddist = dist;137 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i - 1));138 }139 if (dist < metres) {140 return null;141 }142 return i;143}144// === A function which returns the bearing between two vertices in decgrees from 0 to 360===145// === If v1 is null, it returns the bearing between the first and last vertex ===146// === If v1 is present but v2 is null, returns the bearing from v1 to the next vertex ===147// === If either vertex is out of range, returns void ===148google.maps.Polygon.prototype.Bearing = function(v1, v2) {149 if (v1 == null) {150 v1 = 0;151 v2 = this.getPath().getLength() - 1;152 } else if (v2 == null) {153 v2 = v1 + 1;154 }155 if ((v1 < 0) || (v1 >= this.getPath().getLength()) || (v2 < 0) || (v2 >= this.getPath().getLength())) {156 return;157 }158 var from = this.getPath().getAt(v1);159 var to = this.getPath().getAt(v2);160 if (from.equals(to)) {161 return 0;162 }163 var lat1 = from.latRadians();164 var lon1 = from.lngRadians();165 var lat2 = to.latRadians();166 var lon2 = to.lngRadians();167 var angle = -Math.atan2(Math.sin(lon1 - lon2) * Math.cos(lat2), Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon1 - lon2));168 if (angle < 0.0) angle += Math.PI * 2.0;169 angle = angle * 180.0 / Math.PI;170 return parseFloat(angle.toFixed(1));171}172// === Copy all the above functions to GPolyline ===173google.maps.Polyline.prototype.Contains = google.maps.Polygon.prototype.Contains;...

Full Screen

Full Screen

scope.js

Source:scope.js Github

copy

Full Screen

1import traverse from "../lib";2import { parse } from "@babel/parser";3function getPath(code, options) {4 const ast = parse(code, options);5 let path;6 traverse(ast, {7 Program: function(_path) {8 path = _path;9 _path.stop();10 },11 });12 return path;13}14function getIdentifierPath(code) {15 const ast = parse(code);16 let nodePath;17 traverse(ast, {18 Identifier: function(path) {19 nodePath = path;20 path.stop();21 },22 });23 return nodePath;24}25describe("scope", function() {26 describe("binding paths", function() {27 it("function declaration id", function() {28 expect(29 getPath("function foo() {}").scope.getBinding("foo").path.type,30 ).toBe("FunctionDeclaration");31 });32 it("function expression id", function() {33 expect(34 getPath("(function foo() {})")35 .get("body")[0]36 .get("expression")37 .scope.getBinding("foo").path.type,38 ).toBe("FunctionExpression");39 });40 it("function param", function() {41 expect(42 getPath("(function (foo) {})")43 .get("body")[0]44 .get("expression")45 .scope.getBinding("foo").path.type,46 ).toBe("Identifier");47 });48 it("variable declaration", function() {49 expect(getPath("var foo = null;").scope.getBinding("foo").path.type).toBe(50 "VariableDeclarator",51 );52 expect(53 getPath("var { foo } = null;").scope.getBinding("foo").path.type,54 ).toBe("VariableDeclarator");55 expect(56 getPath("var [ foo ] = null;").scope.getBinding("foo").path.type,57 ).toBe("VariableDeclarator");58 expect(59 getPath("var { bar: [ foo ] } = null;").scope.getBinding("foo").path60 .type,61 ).toBe("VariableDeclarator");62 });63 it("declare var", function() {64 expect(65 getPath("declare var foo;", { plugins: ["flow"] }).scope.getBinding(66 "foo",67 ).path.type,68 ).toBe("DeclareVariable");69 });70 it("declare function", function() {71 expect(72 getPath("declare function foo(): void;", {73 plugins: ["flow"],74 }).scope.getBinding("foo").path.type,75 ).toBe("DeclareFunction");76 });77 it("declare module", function() {78 expect(79 getPath("declare module foo {};", {80 plugins: ["flow"],81 }).scope.getBinding("foo").path.type,82 ).toBe("DeclareModule");83 });84 it("declare type alias", function() {85 expect(86 getPath("declare type foo = string;", {87 plugins: ["flow"],88 }).scope.getBinding("foo").path.type,89 ).toBe("DeclareTypeAlias");90 });91 it("declare opaque type", function() {92 expect(93 getPath("declare opaque type foo;", {94 plugins: ["flow"],95 }).scope.getBinding("foo").path.type,96 ).toBe("DeclareOpaqueType");97 });98 it("declare interface", function() {99 expect(100 getPath("declare interface Foo {};", {101 plugins: ["flow"],102 }).scope.getBinding("Foo").path.type,103 ).toBe("DeclareInterface");104 });105 it("type alias", function() {106 expect(107 getPath("type foo = string;", {108 plugins: ["flow"],109 }).scope.getBinding("foo").path.type,110 ).toBe("TypeAlias");111 });112 it("opaque type alias", function() {113 expect(114 getPath("opaque type foo = string;", {115 plugins: ["flow"],116 }).scope.getBinding("foo").path.type,117 ).toBe("OpaqueType");118 });119 it("interface", function() {120 expect(121 getPath("interface Foo {};", {122 plugins: ["flow"],123 }).scope.getBinding("Foo").path.type,124 ).toBe("InterfaceDeclaration");125 });126 it("import type", function() {127 expect(128 getPath("import type {Foo} from 'foo';", {129 plugins: ["flow"],130 }).scope.getBinding("Foo").path.type,131 ).toBe("ImportSpecifier");132 });133 it("variable constantness", function() {134 expect(getPath("var a = 1;").scope.getBinding("a").constant).toBe(true);135 expect(getPath("var a = 1; a = 2;").scope.getBinding("a").constant).toBe(136 false,137 );138 expect(getPath("var a = 1, a = 2;").scope.getBinding("a").constant).toBe(139 false,140 );141 expect(142 getPath("var a = 1; var a = 2;").scope.getBinding("a").constant,143 ).toBe(false);144 });145 it("purity", function() {146 expect(147 getPath("({ x: 1 })")148 .get("body")[0]149 .get("expression")150 .isPure(),151 ).toBeTruthy();152 expect(153 getPath("`${a}`")154 .get("body")[0]155 .get("expression")156 .isPure(),157 ).toBeFalsy();158 expect(159 getPath("let a = 1; `${a}`")160 .get("body")[1]161 .get("expression")162 .isPure(),163 ).toBeTruthy();164 expect(165 getPath("let a = 1; `${a++}`")166 .get("body")[1]167 .get("expression")168 .isPure(),169 ).toBeFalsy();170 expect(171 getPath("tagged`foo`")172 .get("body")[0]173 .get("expression")174 .isPure(),175 ).toBeFalsy();176 expect(177 getPath("String.raw`foo`")178 .get("body")[0]179 .get("expression")180 .isPure(),181 ).toBeTruthy();182 });183 test("label", function() {184 expect(getPath("foo: { }").scope.getBinding("foo")).toBeUndefined();185 expect(getPath("foo: { }").scope.getLabel("foo").type).toBe(186 "LabeledStatement",187 );188 expect(getPath("foo: { }").scope.getLabel("toString")).toBeUndefined();189 expect(190 getPath(191 `192 foo: { }193 `,194 ).scope.generateUid("foo"),195 ).toBe("_foo");196 });197 test("generateUid collision check with labels", function() {198 expect(199 getPath(200 `201 _foo: { }202 `,203 ).scope.generateUid("foo"),204 ).toBe("_foo2");205 expect(206 getPath(207 `208 _foo: { }209 _foo1: { }210 _foo2: { }211 `,212 ).scope.generateUid("foo"),213 ).toBe("_foo3");214 });215 it("reference paths", function() {216 const path = getIdentifierPath("function square(n) { return n * n}");217 const referencePaths = path.context.scope.bindings.n.referencePaths;218 expect(referencePaths).toHaveLength(2);219 expect(referencePaths[0].node.loc.start).toEqual({220 line: 1,...

Full Screen

Full Screen

library.js

Source:library.js Github

copy

Full Screen

1 function getPath(){2 var pathName = document.location.pathname;3 var index = pathName.substr(1).indexOf("/");4 var result = pathName.substr(0,index+1);5 return result;6 }7var LIBS = {8 // Chart libraries9 plot: [10 getPath()+"/resource/libs/misc/flot/jquery.flot.min.js",11 getPath()+"/resource/libs/misc/flot/jquery.flot.pie.min.js",12 getPath()+"/resource/libs/misc/flot/jquery.flot.stack.min.js",13 getPath()+"/resource/libs/misc/flot/jquery.flot.resize.min.js",14 getPath()+"/resource/libs/misc/flot/jquery.flot.curvedLines.js",15 getPath()+"/resource/libs/misc/flot/jquery.flot.tooltip.min.js",16 getPath()+"/resource/libs/misc/flot/jquery.flot.categories.min.js"17 ],18 chart: [19 '/resource/libs/misc/echarts/build/dist/echarts-all.js',20 '/resource/libs/misc/echarts/build/dist/theme.js',21 '/resource/libs/misc/echarts/build/dist/jquery.echarts.js'22 ],23 circleProgress: [24 getPath()+"/resource/libs/bower/jquery-circle-progress/dist/circle-progress.js"25 ],26 sparkline: [27 getPath()+"/resource/libs/misc/jquery.sparkline.min.js"28 ],29 maxlength: [30 getPath()+"/resource/libs/bower/bootstrap-maxlength/src/bootstrap-maxlength.js"31 ],32 tagsinput: [33 getPath()+"/resource/libs/bower/bootstrap-tagsinput/dist/bootstrap-tagsinput.css",34 getPath()+"/resource/libs/bower/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js",35 ],36 TouchSpin: [37 getPath()+"/resource/libs/bower/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.css",38 getPath()+"/resource/libs/bower/bootstrap-touchspin/dist/jquery.bootstrap-touchspin.min.js"39 ],40 selectpicker: [41 getPath()+"/resource/libs/bower/bootstrap-select/dist/css/bootstrap-select.min.css",42 getPath()+"/resource/libs/bower/bootstrap-select/dist/js/bootstrap-select.min.js"43 ],44 filestyle: [45 getPath()+"/resource/libs/bower/bootstrap-filestyle/src/bootstrap-filestyle.min.js"46 ],47 timepicker: [48 getPath()+"/resource/libs/bower/bootstrap-timepicker/js/bootstrap-timepicker.js"49 ],50 datetimepicker: [51 getPath()+"/resource/libs/bower/moment/moment.js",52 getPath()+"/resource/libs/bower/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css",53 getPath()+"/resource/libs/bower/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"54 ],55 select2: [56 getPath()+"/resource/libs/bower/select2/dist/css/select2.min.css",57 getPath()+"/resource/libs/bower/select2/dist/js/select2.full.min.js"58 ],59 vectorMap: [60 getPath()+"/resource/libs/misc/jvectormap/jquery-jvectormap.css",61 getPath()+"/resource/libs/misc/jvectormap/jquery-jvectormap.min.js",62 getPath()+"/resource/libs/misc/jvectormap/maps/jquery-jvectormap-us-mill.js",63 getPath()+"/resource/libs/misc/jvectormap/maps/jquery-jvectormap-world-mill.js",64 getPath()+"/resource/libs/misc/jvectormap/maps/jquery-jvectormap-africa-mill.js"65 ],66 summernote: [67 getPath()+"/resource/libs/bower/summernote/dist/summernote.css",68 getPath()+"/resource/libs/bower/summernote/dist/summernote.min.js"69 ],70 DataTable: [71 getPath()+"/resource/libs/misc/datatables/datatables.min.css",72 getPath()+"/resource/libs/misc/datatables/datatables.min.js"73 ],74 fullCalendar: [75 getPath()+"/resource/libs/bower/moment/moment.js",76 getPath()+"/resource/libs/bower/fullcalendar/dist/fullcalendar.min.css",77 getPath()+"/resource/libs/bower/fullcalendar/dist/fullcalendar.min.js"78 ],79 dropzone: [80 getPath()+"/resource/libs/bower/dropzone/dist/min/dropzone.min.css",81 getPath()+"/resource/libs/bower/dropzone/dist/min/dropzone.min.js"82 ],83 counterUp: [84 getPath()+"/resource/libs/bower/waypoints/lib/jquery.waypoints.min.js",85 getPath()+"/resource/libs/bower/counterup/jquery.counterup.min.js"86 ],87 others: [88 getPath()+"/resource/libs/bower/switchery/dist/switchery.min.css",89 getPath()+"/resource/libs/bower/switchery/dist/switchery.min.js",90 getPath()+"/resource/libs/bower/lightbox2/dist/css/lightbox.min.css",91 getPath()+"/resource/libs/bower/lightbox2/dist/js/lightbox.min.js"92 ]...

Full Screen

Full Screen

browser.js

Source:browser.js Github

copy

Full Screen

1const getPath = path => {2 return require(`@/assets/imgs/useragent/${path}`)3}4const browser = {5 'Arora': getPath('arora.svg'),6 'Avant': getPath('avant.svg'),7 '2345Explorer': getPath('2345Explorer.svg'),8 'Chrome': getPath('chrome.svg'),9 'Chrome Headless': getPath('chrome.svg'),10 'Chrome WebView': getPath('chrome.svg'),11 'Chromium': getPath('chromium.svg'),12 'Firefox': getPath('firefox.svg'),13 'Fennec': getPath('firefox.svg'),14 'IE': getPath('ie.svg'),15 'IEMobile': getPath('ie.svg'),16 'Edge': getPath('edge.svg'),17 'Opera': getPath('opera.svg'),18 'Opera Mini': getPath('opera.svg'),19 'Opera Mobi': getPath('opera.svg'),20 'Safari': getPath('safari.svg'),21 'Mobile Safari': getPath('safari.svg'),22 'UCBrowser': getPath('uc.svg'),23 'Vivaldi': getPath('vivaldi.svg'),24 'WeChat': getPath('wechat.svg'),25 'Yandex': getPath('yandex.svg'),26 'QQBrowser': getPath('QQBrowser.svg'),27 'QQBrowserLite': getPath('QQBrowser.svg'),28 'BIDUBrowser': getPath('baidu.svg'),29 'Baidu': getPath('baidu.svg'),30 'Basilisk': getPath('basilisk.svg'),31 'Camino': getPath('camino.svg'),32 'Comodo Dragon': getPath('comodo-dragon.svg'),33 'Epiphany': getPath('epiphany.svg'),34 'Facebook': getPath('facebook.svg'),35 'Falkon': getPath('falkon.svg'),36 'Firebird': getPath('firebird.svg'),37 'GoBrowser': getPath('GOBrowser.svg'),38 'ICE Browser': getPath('ICEBrowser.svg'),39 'IceDragon': getPath('ICEBrowser.svg'),40 'IceCat': getPath('IceCat.svg'),41 'Iceweasel': getPath('Iceweasel.svg'),42 'K-Meleon': getPath('K-Meleon.svg'),43 'Lunascape': getPath('lunascape.svg'),44 'Maxthon': getPath('maxthon.svg'),45 'Puffin': getPath('puffin.svg'),46 'Quark': getPath('quark.svg'),47 'QupZilla': getPath('qupZilla.svg'),48 'SeaMonkey': getPath('seaMonkey.svg'),49 'Sleipnir': getPath('sleipnir.svg'),50 'Waterfox': getPath('waterfox.svg'),51 'default': getPath('browser.svg')52}53const os = {54 'Windows_10': getPath('windows_win10.svg'),55 'Windows_8': getPath('windows_win8.svg'),56 'Windows_7': getPath('windows_win7.svg'),57 'Windows_XP': getPath('windows_winXP.svg'),58 'Android': getPath('android.svg'),59 'Arch': getPath('arch.svg'),60 'CentOS': getPath('centOS.svg'),61 'Fedora': getPath('fedora.svg'),62 'Firefox OS': getPath('firefox.svg'),63 'FreeBSD': getPath('freeBSD.svg'),64 'Debian': getPath('debian.svg'),65 'Fuchsia': getPath('fuchsia.svg'),66 'Gentoo': getPath('gentoo.svg'),67 'iOS': getPath('iOS.svg'),68 'Linux': getPath('linux.svg'),69 'Mac OS': getPath('iphone.svg'),70 'Mageia': getPath('mageia.svg'),71 'GNU': getPath('GNU.svg'),72 'default': getPath('system.svg')73}...

Full Screen

Full Screen

0330.js

Source:0330.js Github

copy

Full Screen

...26 }27 }28 const nextStepIndex = stepPath.length;29 if (nextSteps.length > 0 && nextStepIndex < stepCount) {30 return nextSteps.map(item => getPath(stepCount, [...stepPath, item])).reduce((last, current) => last + current, 0);31 }32 return count;33}34// console.log(getPath(2)) // 235// console.log(getPath(3)) // 536// console.log(getPath(4)) // 1237// console.log(getPath(5)) // 3038// console.log(getPath(6)) // 7339// console.log(getPath(7)) // 18340// console.log(getPath(8)) // 45641// console.log(getPath(9)) // 115142// console.log(getPath(10)) // 290043// console.log(getPath(11)) // 736144// console.log(getPath(12)) // 1868445// console.log(getPath(13)) // 4765246// console.log(getPath(14)) // 12158447// console.log(getPath(15)) // 31125948// console.log(getPath(16)) // 79731149// console.log(getPath(17)) // 204738450// console.log(getPath(18)) // 526069251// console.log(getPath(19)) // 1354271852var t1 = Date.now();53console.log(getPath(20)) // 3488423954var t2 = Date.now();55console.log(`耗时:${t2 - t1} ms`);56// console.log(getPath(21)) // 8999134457// console.log(getPath(22)) // 23228211058// console.log(getPath(23)) // 60028193259// console.log(getPath(24)) // 1552096361...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const storybookRootCause = require('storybook-root-cause');3const storybookConfigPath = path.resolve(__dirname, './.storybook');4const storybookPath = storybookRootCause.getPath(storybookConfigPath, 'Button');5console.log(storybookPath);6{ 7}8const path = require('path');9const storybookRootCause = require('storybook-root-cause');10const storybookConfigPath = path.resolve(__dirname, './.storybook');11const storybookPath = storybookRootCause.getStorybook(storybookConfigPath);12console.log(storybookPath);13 { 14 }15const path = require('path');16const storybookRootCause = require('storybook-root-cause');17const storybookConfigPath = path.resolve(__dirname, './.storybook');18const storybookPath = storybookRootCause.getStorybook(storybookConfigPath);19console.log(storybookPath);20 { 21 }22const path = require('path');23const storybookRootCause = require('storybook-root-cause');24const storybookConfigPath = path.resolve(__dirname, './.storybook');25const storybookPath = storybookRootCause.getStorybook(storybookConfigPath);26console.log(storybookPath);27 {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPath } = require('storybook-root-cause');2const path = getPath();3console.log(path);4const { getStorybook } = require('storybook-root-cause');5const storybook = getStorybook();6console.log(storybook);7const { getStorybook } = require('storybook-root-cause');8const storybook = getStorybook();9console.log(storybook);10const { getStorybook } = require('storybook-root-cause');11const storybook = getStorybook();12console.log(storybook);13const { getStorybook } = require('storybook-root-cause');14const storybook = getStorybook();15console.log(storybook);16const { getStorybook } = require('storybook-root-cause');17const storybook = getStorybook();18console.log(storybook);19const { getStorybook } = require('storybook-root-cause');20const storybook = getStorybook();21console.log(storybook);

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const root = require('storybook-root').default;3const path = require('path');4const root = require('storybook-root').default;5const path = require('path');6const root = require('storybook-root').default;7const path = require('path');8const root = require('storybook-root').default;9const path = require('path');10const root = require('storybook-root').default;11const path = require('path');12const root = require('storybook-root').default;13const path = require('path');14const root = require('storybook-root').default;15const path = require('path');16const root = require('storybook-root').default;17console.log(root.getPath('test.js', {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { getPath } from 'storybook-root-decorator';2const path = getPath();3console.log(path);4import { getPath } from 'storybook-root-decorator';5const path = getPath();6console.log(path);

Full Screen

Using AI Code Generation

copy

Full Screen

1import {getPath} from 'storybook-root';2const path = getPath();3import {startStorybook} from 'storybook-root';4startStorybook();5import {startStorybook} from 'storybook-root';6startStorybook({

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPath } = require('storybook-root');2const path = require('path');3const pathToStory = getPath('Button', 'Button');4const { getPaths } = require('storybook-root');5const path = require('path');6const paths = getPaths('Button');7const { getStories } = require('storybook-root');8const path = require('path');9const stories = getStories('Button');10const { getStory } = require('storybook-root');11const path = require('path');12const story = getStory('Button', 'Button');13const { getStorybookConfig } = require('storybook-root');14const path = require('path');15const storybookConfig = getStorybookConfig();16const { getStorybookConfigPath } = require('storybook-root');17const path = require('path');18const storybookConfigPath = getStorybookConfigPath();19const { getStorybookConfigDir } = require('storybook-root');20const path = require('path');21const storybookConfigDir = getStorybookConfigDir();22const { getStorybookConfigDir } = require('storybook-root');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPath } = require("storybook-root-cause");2const path = getPath("Button", "with text");3console.log(path);4const { getStory } = require("storybook-root-cause");5const story = getStory("Button", "with text");6console.log(story);7const { getStories } = require("storybook-root-cause");8const stories = getStories("Button");9console.log(stories);10const { getStories } = require("storybook-root-cause");11const stories = getStories("Button");12console.log(stories);13const { getStories } = require("storybook-root-cause");14const stories = getStories("Button");15console.log(stories);16const { getStories } = require("storybook-root-cause");17const stories = getStories("Button");18console.log(stories);19const { getStories } = require("storybook-root-cause");20const stories = getStories("Button");21console.log(stories);

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 storybook-root 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