From 4b8e613ada033903b902dbcf223feb2afa9e3bd2 Mon Sep 17 00:00:00 2001 From: Eric Theise Date: Mon, 1 Jan 2024 14:32:49 -0800 Subject: [PATCH] Replacing var with let or const. --- js/jsmapcss/eval.pegjs | 4 ++-- js/locationfilter.js | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/js/jsmapcss/eval.pegjs b/js/jsmapcss/eval.pegjs index 9e75607c..ee99f48b 100644 --- a/js/jsmapcss/eval.pegjs +++ b/js/jsmapcss/eval.pegjs @@ -30,7 +30,7 @@ Expression Operand = head:Term tail:(_ ("." / "+" / "-") _ Term)* { - var result = head, i; + let result = head, i; for (i = 0; i < tail.length; i++) { if (tail[i][1] === ".") { result = ""+(result + tail[i][3]); } @@ -43,7 +43,7 @@ Operand Term = head:Factor tail:(_ ("*" / "/") _ Factor)* { - var result = head, i; + let result = head, i; for (i = 0; i < tail.length; i++) { if (tail[i][1] === "*") { result = ""+(result * tail[i][3]); } diff --git a/js/locationfilter.js b/js/locationfilter.js index c07e6054..d79bcd98 100644 --- a/js/locationfilter.js +++ b/js/locationfilter.js @@ -13,7 +13,7 @@ * Version: 0.1 */ L.LatLngBounds.prototype.modify = function (map, amount) { - var sw = this.getSouthWest(), + let sw = this.getSouthWest(), ne = this.getNorthEast(), swPoint = map.latLngToLayerPoint(sw), nePoint = map.latLngToLayerPoint(ne); @@ -71,7 +71,7 @@ L.LocationFilter = L.Control.extend({ /* Draw a rectangle */ _drawRectangle: function (bounds, options) { options = options || {}; - var defaultOptions = { + const defaultOptions = { stroke: false, fill: true, fillColor: "black", @@ -79,14 +79,14 @@ L.LocationFilter = L.Control.extend({ clickable: false }; options = L.Util.extend(defaultOptions, options); - var rect = new L.Rectangle(bounds, options); + const rect = new L.Rectangle(bounds, options); rect.addTo(this._layer); return rect; }, /* Draw a draggable marker */ _drawImageMarker: function (point, options) { - var marker = new L.Marker(point, { + const marker = new L.Marker(point, { icon: new L.DivIcon({ iconAnchor: options.anchor, iconSize: options.size, @@ -102,14 +102,14 @@ L.LocationFilter = L.Control.extend({ filter corners and redraws the filter when the move marker is moved */ _drawMoveMarker: function (point) { - var that = this; + const that = this; this._moveMarker = this._drawImageMarker(point, { className: "location-filter move-marker", anchor: [-10, -10], size: [13, 13] }); this._moveMarker.on("drag", function (e) { - var markerPos = that._moveMarker.getLatLng(), + const markerPos = that._moveMarker.getLatLng(), latDelta = markerPos.lat - that._nw.lat, lngDelta = markerPos.lng - that._nw.lng; that._nw = new L.LatLng( @@ -151,9 +151,9 @@ L.LocationFilter = L.Control.extend({ given in options.moveAlong to match the position of the moved marker. Update filter corners and redraw the filter */ _setupResizeMarkerTracking: function (marker, options) { - var that = this; + const that = this; marker.on("drag", function (e) { - var curPosition = marker.getLatLng(), + const curPosition = marker.getLatLng(), latMarker = options.moveAlong.lat, lngMarker = options.moveAlong.lng; // Move follower markers when this marker is moved @@ -164,7 +164,7 @@ L.LocationFilter = L.Control.extend({ new L.LatLng(lngMarker.getLatLng().lat, curPosition.lng, true) ); // Sort marker positions in nw, ne, sw, se order - var corners = [ + const corners = [ that._nwMarker.getLatLng(), that._neMarker.getLatLng(), that._swMarker.getLatLng(), @@ -187,7 +187,7 @@ L.LocationFilter = L.Control.extend({ /* Emit a change event whenever dragend is triggered on the given marker */ _setupDragendListener: function (marker) { - var that = this; + const that = this; marker.on("dragend", function (e) { // that.fire("change", {bounds: that.getBounds()}); }); @@ -196,7 +196,7 @@ L.LocationFilter = L.Control.extend({ /* Create bounds for the mask rectangles and the location filter rectangle */ _calculateBounds: function () { - var mapBounds = this._map.getBounds(), + const mapBounds = this._map.getBounds(), outerBounds = new L.LatLngBounds( new L.LatLng( mapBounds.getSouthWest().lat - 0.1, @@ -326,7 +326,7 @@ L.LocationFilter = L.Control.extend({ } // Initialize corners - var bounds; + let bounds; if (this._sw && this._ne) { bounds = new L.LatLngBounds(this._sw, this._ne); } else if (this.options.bounds) { @@ -345,7 +345,7 @@ L.LocationFilter = L.Control.extend({ this._draw(); // Set up map move event listener - var that = this; + const that = this; this._moveHandler = function () { that._draw(); }; @@ -355,7 +355,7 @@ L.LocationFilter = L.Control.extend({ this._layer.addTo(this._map); // Zoom out the map if necessary - var mapBounds = this._map.getBounds(); + const mapBounds = this._map.getBounds(); bounds = new L.LatLngBounds(this._sw, this._ne).modify(this._map, 10); if ( !mapBounds.contains(bounds.getSouthWest()) ||