Skip to content

Commit

Permalink
Replacing var with let or const.
Browse files Browse the repository at this point in the history
  • Loading branch information
erictheise committed Jan 1, 2024
1 parent 5b0ced1 commit 4b8e613
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions js/jsmapcss/eval.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -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]); }
Expand All @@ -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]); }
Expand Down
28 changes: 14 additions & 14 deletions js/locationfilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Version: 0.1
*/
L.LatLngBounds.prototype.modify = function (map, amount) {

Check failure on line 15 in js/locationfilter.js

View workflow job for this annotation

GitHub Actions / build

'L' is not defined
var sw = this.getSouthWest(),
let sw = this.getSouthWest(),
ne = this.getNorthEast(),
swPoint = map.latLngToLayerPoint(sw),

Check warning on line 18 in js/locationfilter.js

View workflow job for this annotation

GitHub Actions / build

'swPoint' is never reassigned. Use 'const' instead
nePoint = map.latLngToLayerPoint(ne);

Check warning on line 19 in js/locationfilter.js

View workflow job for this annotation

GitHub Actions / build

'nePoint' is never reassigned. Use 'const' instead
Expand Down Expand Up @@ -71,22 +71,22 @@ L.LocationFilter = L.Control.extend({
/* Draw a rectangle */
_drawRectangle: function (bounds, options) {
options = options || {};
var defaultOptions = {
const defaultOptions = {
stroke: false,
fill: true,
fillColor: "black",
fillOpacity: 0.3,
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,
Expand All @@ -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) {

Check warning on line 111 in js/locationfilter.js

View workflow job for this annotation

GitHub Actions / build

Unexpected function expression
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(
Expand Down Expand Up @@ -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) {

Check warning on line 155 in js/locationfilter.js

View workflow job for this annotation

GitHub Actions / build

Unexpected function expression
var curPosition = marker.getLatLng(),
const curPosition = marker.getLatLng(),
latMarker = options.moveAlong.lat,
lngMarker = options.moveAlong.lng;
// Move follower markers when this marker is moved
Expand All @@ -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(),
Expand All @@ -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) {

Check warning on line 191 in js/locationfilter.js

View workflow job for this annotation

GitHub Actions / build

Unexpected function expression
// that.fire("change", {bounds: that.getBounds()});
});
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
};
Expand All @@ -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()) ||
Expand Down

0 comments on commit 4b8e613

Please sign in to comment.