Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add eslint react plugin #1173

Benjamin Kingbadb1198c1be
diff --git a/.eslintrc b/.eslintrc
index dfd64b4e7..a7972a1ef 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -7,10 +7,11 @@
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
- "jsx": false
+ "jsx": true
}
},
- "extends": "standard",
+ "plugins": ["react"],
+ "extends": ["standard", "plugin:react/recommended"],
"rules": {
"semi": ["error", "always"],
"space-before-function-paren": "off",
@@ -18,7 +19,7 @@
},
"overrides": [
{
- "files": [ "web/**/*.js", "test/**/*.js" ],
+ "files": ["web/**/*.js", "test/**/*.js"],
"rules": {
"no-octal": "error",
"no-unused-vars": "error",
@@ -52,7 +53,12 @@
"no-trailing-spaces": "error",
"standard/computed-property-even-spacing": "error",
"wrap-iife": "error",
- "new-cap": "error"
+ "new-cap": "error",
+ "semi": ["error", "always"],
+ "space-before-function-paren": "off",
+ "react/no-danger": "warn",
+ "react/prop-types": "warn",
+ "react/no-did-update-set-state": "warn"
}
}
]
diff --git a/package-lock.json b/package-lock.json
index 62b39b246..ca1ceb093 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5000,6 +5000,34 @@
"integrity": "sha512-2WO+ZFh7vxUKRfR0cOIMrWgYKdR6S1AlOezw6pC52B6oYpd5WFghN+QHxvrRdZMtbo8h3dfUZ2o1rWb0UPbKtg==",
"dev": true
},
+ "eslint-plugin-react": {
+ "version": "5.2.2",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-5.2.2.tgz",
+ "integrity": "sha1-fbBo4fVIf2hx5N7vNqOBwwPqwWE=",
+ "dev": true,
+ "requires": {
+ "doctrine": "1.5.0",
+ "jsx-ast-utils": "1.4.1"
+ },
+ "dependencies": {
+ "doctrine": {
+ "version": "1.5.0",
+ "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz",
+ "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=",
+ "dev": true,
+ "requires": {
+ "esutils": "2.0.2",
+ "isarray": "1.0.0"
+ }
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
+ "dev": true
+ }
+ }
+ },
"eslint-plugin-standard": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz",
@@ -8886,6 +8914,12 @@
"verror": "1.10.0"
}
},
+ "jsx-ast-utils": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz",
+ "integrity": "sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE=",
+ "dev": true
+ },
"kdbush": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/kdbush/-/kdbush-1.0.1.tgz",
diff --git a/package.json b/package.json
index b51c61e1f..7f116bada 100644
--- a/package.json
+++ b/package.json
@@ -74,10 +74,10 @@
"autoprefixer": "7.1.1",
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.3",
+ "babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
- "babel-plugin-transform-object-rest-spread": "^6.26.0",
"babelify": "^7.3.0",
"browserify": "^14.4.0",
"browserify-css": "^0.13.1",
@@ -94,6 +94,7 @@
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
+ "eslint-plugin-react": "^5.2.2",
"eslint-plugin-standard": "^3.0.1",
"express": "4.15.2",
"geckodriver": "1.2.0",
diff --git a/web/js/animation/gif.js b/web/js/animation/gif.js
index 2368580b9..f41a5d0e8 100644
--- a/web/js/animation/gif.js
+++ b/web/js/animation/gif.js
@@ -1,61 +1,61 @@
-import $ from 'jquery';
-import 'jquery-jcrop';
-import React from 'react';
-import ReactDOM from 'react-dom';
-import GifStream from './gif-stream';
-import lodashFind from 'lodash/find';
-import lodashEach from 'lodash/each';
-import lodashRound from 'lodash/round';
-import lodashThrottle from 'lodash/throttle';
-import lodashCapitalize from 'lodash/capitalize';
-import canvg from 'canvg-browser';
-import FileSaver from 'file-saver';
-import googleAnalytics from '../components/util/google-analytics';
-import GifResSelection from '../components/animation-widget/gif-panel';
+import $ from "jquery";
+import "jquery-jcrop";
+import React from "react";
+import ReactDOM from "react-dom";
+import GifStream from "./gif-stream";
+import lodashFind from "lodash/find";
+import lodashEach from "lodash/each";
+import lodashRound from "lodash/round";
+import lodashThrottle from "lodash/throttle";
+import lodashCapitalize from "lodash/capitalize";
+import canvg from "canvg-browser";
+import FileSaver from "file-saver";
+import googleAnalytics from "../components/util/google-analytics";
+import GifResSelection from "../components/animation-widget/gif-panel";
import {
imageUtilGetLayerOpacities,
imageUtilCalculateResolution,
imageUtilGetLayers,
imageUtilGetCoordsFromPixelValues,
imageUtilGetConversionFactor
-} from '../image/util';
-import util from '../util/util';
-import wvui from '../ui/ui';
-import uiIndicator from '../ui/indicator';
+} from "../image/util";
+import util from "../util/util";
+import wvui from "../ui/ui";
+import uiIndicator from "../ui/indicator";
const gifStream = new GifStream();
const conversionConstant = 3.6; // we are saying that the gif compresses each total by about 3.6x
const maxGifSize = 250;
const GRATICULE_WARNING =
- 'The graticule layer cannot be used to take a snapshot. Would you ' +
- 'like to hide this layer?';
+ "The graticule layer cannot be used to take a snapshot. Would you " +
+ "like to hide this layer?";
const PALETTE_WARNING =
- 'One or more layers on the map have been modified (changed palette, ' +
- 'thresholds, etc.). These modifications cannot be used to take a ' +
- 'snapshot. Would you like to temporarily revert to the original ' +
- 'layer(s)?';
+ "One or more layers on the map have been modified (changed palette, " +
+ "thresholds, etc.). These modifications cannot be used to take a " +
+ "snapshot. Would you like to temporarily revert to the original " +
+ "layer(s)?";
const ROTATE_WARNING =
- 'Image may not be downloaded when rotated. Would you like to reset rotation?';
+ "Image may not be downloaded when rotated. Would you like to reset rotation?";
const resolutionsGeo = {
values: [
- { value: '0.125', text: '30m' },
- { value: '0.25', text: '60m' },
- { value: '0.5', text: '125m' },
- { value: '1', text: '250m' },
- { value: '2', text: '500m' },
- { value: '4', text: '1km' },
- { value: '20', text: '5km' },
- { value: '40', text: '10km' }
+ { value: "0.125", text: "30m" },
+ { value: "0.25", text: "60m" },
+ { value: "0.5", text: "125m" },
+ { value: "1", text: "250m" },
+ { value: "2", text: "500m" },
+ { value: "4", text: "1km" },
+ { value: "20", text: "5km" },
+ { value: "40", text: "10km" }
]
};
const resolutionsPolar = {
values: [
- { value: '1', text: '250m' },
- { value: '2', text: '500m' },
- { value: '4', text: '1km' },
- { value: '20', text: '5km' },
- { value: '40', text: '10km' }
+ { value: "1", text: "250m" },
+ { value: "2", text: "500m" },
+ { value: "4", text: "1km" },
+ { value: "20", text: "5km" },
+ { value: "40", text: "10km" }
]
};
@@ -96,20 +96,20 @@ export function animationGif(models, config, ui) {
*/
self.init = function() {
var options;
- models.anim.events.on('gif-click', setImageCoords);
- panelCase = document.createElement('div');
- panelCase.className = 'gif-dialog';
+ models.anim.events.on("gif-click", setImageCoords);
+ panelCase = document.createElement("div");
+ panelCase.className = "gif-dialog";
throttleSetDownloadButton = lodashThrottle(setDownloadButtonClass, 300, {
trailing: true
});
options = {
- resolution: '1',
+ resolution: "1",
onSelectionChange: onSelectionChange,
onClick: getGif,
valid: true,
resolutions:
- models.proj.selected.id === 'geographic'
+ models.proj.selected.id === "geographic"
? resolutionsGeo
: resolutionsPolar,
onCheck: onchecked,
@@ -128,8 +128,8 @@ export function animationGif(models, config, ui) {
var state = animModel.rangeState;
if (models.date.maxZoom < 4) {
- startDate = state.startDate.split('T')[0];
- endDate = state.endDate.split('T')[0];
+ startDate = state.startDate.split("T")[0];
+ endDate = state.endDate.split("T")[0];
} else {
startDate = state.startDate;
endDate = state.endDate;
@@ -138,7 +138,7 @@ export function animationGif(models, config, ui) {
return {
resolution: resolution,
resolutions:
- models.proj.selected.id === 'geographic'
+ models.proj.selected.id === "geographic"
? resolutionsGeo
: resolutionsPolar,
valid: fileSizeValid(),
@@ -157,7 +157,7 @@ export function animationGif(models, config, ui) {
if (!animationCoordinates) return;
var numDays, stateObj, dimensions, isGeoProjection;
- isGeoProjection = models.proj.selected.id === 'geographic';
+ isGeoProjection = models.proj.selected.id === "geographic";
resolution = selectedRes;
stateObj = animModel.rangeState;
numDays = util.getNumberOfDays(
@@ -208,14 +208,14 @@ export function animationGif(models, config, ui) {
var setDownloadButtonClass = function() {
var $iconCase;
var boo;
- $iconCase = $('.wv-dl-gif-bt-case');
+ $iconCase = $(".wv-dl-gif-bt-case");
if (!$iconCase.length) return;
boo = fileSizeValid();
- if (!boo && !$iconCase.hasClass('disabled')) {
- $iconCase.addClass('disabled');
- } else if (boo && $iconCase.hasClass('disabled')) {
- $iconCase.removeClass('disabled');
+ if (!boo && !$iconCase.hasClass("disabled")) {
+ $iconCase.addClass("disabled");
+ } else if (boo && $iconCase.hasClass("disabled")) {
+ $iconCase.removeClass("disabled");
}
};
@@ -247,30 +247,30 @@ export function animationGif(models, config, ui) {
loader = uiIndicator.loading();
build = function(stamp, dateStamp, stampHeight) {
var buildProgressBar = function() {
- $progress = $('<progress />') // display progress for GIF creation
- .attr('class', 'wv-gif-progress');
+ $progress = $("<progress />") // display progress for GIF creation
+ .attr("class", "wv-gif-progress");
wvui
.getDialog()
.append($progress)
.dialog({
// dialog for progress
- title: 'Collecting Images...',
+ title: "Collecting Images...",
width: 300,
height: 100
});
- $progress.attr('value', 0);
+ $progress.attr("value", 0);
};
var onGifProgress = function(captureProgress) {
- $('#timeline-footer').removeClass('wv-anim-active');
- models.anim.rangeState.state = 'off';
+ $("#timeline-footer").removeClass("wv-anim-active");
+ models.anim.rangeState.state = "off";
if (!progressing) {
buildProgressBar();
progressing = true;
uiIndicator.hide(loader);
- $progress.parent().dialog('option', 'title', 'Creating GIF...'); // set dialog title
+ $progress.parent().dialog("option", "title", "Creating GIF..."); // set dialog title
}
- $progress.attr('value', captureProgress / 100); // before value set, it is in indeterminate state
+ $progress.attr("value", captureProgress / 100); // before value set, it is in indeterminate state
};
imageArra = getImageArray(startDate, endDate, interval);
@@ -288,20 +288,20 @@ export function animationGif(models, config, ui) {
waterMarkHeight: stamp.height,
waterMark: stampHeight > 20 ? stamp : null,
waterMarkWidth: stamp.width,
- fontSize: dateStamp.fontSize + 'px',
+ fontSize: dateStamp.fontSize + "px",
textXCoordinate: dateStamp.x,
textYCoordinate: dateStamp.y, // date location based on Dimensions
textAlign: dateStamp.align, // If textXCoordinate is null this takes precedence
- textBaseline: 'top', // If textYCoordinate is null this takes precedence
- fontColor: '#fff',
- fontWeight: '300',
- fontFamily: 'Open Sans, sans-serif',
+ textBaseline: "top", // If textYCoordinate is null this takes precedence
+ fontColor: "#fff",
+ fontWeight: "300",
+ fontFamily: "Open Sans, sans-serif",
progressCallback: onGifProgress,
showFrameText: stampHeight > 20,
extraLastFrameDelay: 1000,
- text: '',
+ text: "",
stroke: {
- color: '#000',
+ color: "#000",
pixels: dateStamp.fontSize * 0.05
},
pause: 1
@@ -311,7 +311,7 @@ export function animationGif(models, config, ui) {
};
stampProps = getStampProps(stampWidthRatio, breakPointOne, stampWidth);
newImage = svgToPng(
- 'brand/images/wv-logo-w-shadow.svg',
+ "brand/images/wv-logo-w-shadow.svg",
stampProps.stampHeight
);
@@ -320,7 +320,7 @@ export function animationGif(models, config, ui) {
var svgToPng = function(svgURL, stampHeight) {
var newImage;
- var canvasEl = document.createElement('canvas');
+ var canvasEl = document.createElement("canvas");
var canvgOptions = {
log: false,
ignoreMouse: true,
@@ -328,7 +328,7 @@ export function animationGif(models, config, ui) {
};
canvg(canvasEl, svgURL, canvgOptions);
newImage = new Image();
- newImage.src = canvasEl.toDataURL('image/png');
+ newImage.src = canvasEl.toDataURL("image/png");
newImage.width = canvasEl.width;
newImage.height = canvasEl.height;
@@ -349,7 +349,7 @@ export function animationGif(models, config, ui) {
lastRequestedDimensions.h > stampHeight * 1.5
? lodashRound(stampHeight * 0.65)
: 0;
- dateStamp.align = 'left';
+ dateStamp.align = "left";
dateStamp.x = imgWidth * 0.01;
dateStamp.y = imgHeight - (dateStamp.fontSize + imgHeight * 0.01) - 4;
} else {
@@ -367,7 +367,7 @@ export function animationGif(models, config, ui) {
: 0;
dateStamp.y = imgHeight - (dateStamp.fontSize + imgHeight * 0.01) - 4;
dateStamp.x = imgWidth * 0.01;
- dateStamp.align = 'left';
+ dateStamp.align = "left";
}
return { stampHeight: stampHeight, dateStamp: dateStamp };
};
@@ -392,7 +392,7 @@ export function animationGif(models, config, ui) {
});
if (models.palettes.inUse()) {
wvui.ask({
- header: 'Notice',
+ header: "Notice",
message: PALETTE_WARNING,
onOk: function() {
models.palettes.clear();
@@ -403,15 +403,15 @@ export function animationGif(models, config, ui) {
}
if (
lodashFind(layers, {
- id: 'Graticule'
+ id: "Graticule"
}) &&
- models.proj.selected.id === 'geographic'
+ models.proj.selected.id === "geographic"
) {
wvui.ask({
- header: 'Notice',
+ header: "Notice",
message: GRATICULE_WARNING,
onOk: function() {
- models.layers.setVisibility('Graticule', false);
+ models.layers.setVisibility("Graticule", false);
self.getGif();
}
});
@@ -419,7 +419,7 @@ export function animationGif(models, config, ui) {
}
if (ui.map.selected.getView().getRotation() !== 0.0) {
wvui.ask({
- header: 'Reset rotation?',
+ header: "Reset rotation?",
message: ROTATE_WARNING,
onOk: function() {
resetRotation();
@@ -429,7 +429,7 @@ export function animationGif(models, config, ui) {
});
return;
}
- googleAnalytics.event('Animation', 'Click', 'Create GIF');
+ googleAnalytics.event("Animation", "Click", "Create GIF");
self.createGIF();
};
@@ -472,7 +472,7 @@ export function animationGif(models, config, ui) {
*
*/
var getDimensions = function(lonlat, proj, res) {
- var conversionFactor = proj === 'geographic' ? 0.002197 : 256;
+ var conversionFactor = proj === "geographic" ? 0.002197 : 256;
return [
Math.round(
Math.abs(lonlat[1][0] - lonlat[0][0]) / conversionFactor / Number(res)
@@ -520,8 +520,8 @@ export function animationGif(models, config, ui) {
host = config.features.imageDownload.host;
path = config.parameters.imagegen || config.features.imageDownload.path;
} else {
- host = 'https://gibs.earthdata.nasa.gov';
- path = 'image-download';
+ host = "https://gibs.earthdata.nasa.gov";
+ path = "image-download";
}
while (current <= toDate) {
@@ -537,30 +537,30 @@ export function animationGif(models, config, ui) {
opacities = imageUtilGetLayerOpacities(products);
url = util.format(
host +
- '/' +
+ "/" +
path +
- '?{1}&extent={2}&epsg={3}&layers={4}&opacities={5}&worldfile=false&format=image/jpeg&width={6}&height={7}',
- 'TIME={1}',
+ "?{1}&extent={2}&epsg={3}&layers={4}&opacities={5}&worldfile=false&format=image/jpeg&width={6}&height={7}",
+ "TIME={1}",
lonlat[0][0] +
- ',' +
+ "," +
lonlat[0][1] +
- ',' +
+ "," +
lonlat[1][0] +
- ',' +
+ "," +
lonlat[1][1],
epsg,
- layers.join(','),
- opacities.join(','),
+ layers.join(","),
+ opacities.join(","),
imgWidth,
imgHeight
);
src = util.format(url, strDate);
a.push({
src: src,
- text: showDates ? strDate : '',
+ text: showDates ? strDate : "",
delay: 1000 / interval
});
- if (ui.anim.ui.getInterval() === 'minute') {
+ if (ui.anim.ui.getInterval() === "minute") {
intervalAmount = 10;
} else {
intervalAmount = 1;
@@ -591,11 +591,11 @@ export function animationGif(models, config, ui) {
var headerMsg =
"<h3 class='wv-data-unavailable-header'>GIF Not Available</h3>";
var bodyMsg =
- 'Too many frames were selected. Please request less than 40 frames if you would like to generate a GIF';
+ "Too many frames were selected. Please request less than 40 frames if you would like to generate a GIF";
var callback = function() {
- $('#timeline-footer').toggleClass('wv-anim-active');
+ $("#timeline-footer").toggleClass("wv-anim-active");
};
- wvui.notify(headerMsg + bodyMsg, 'Notice', 600, callback);
+ wvui.notify(headerMsg + bodyMsg, "Notice", 600, callback);
};
/*
@@ -629,13 +629,13 @@ export function animationGif(models, config, ui) {
*/
var onGifComplete = function(obj) {
// callback function for when image is finished
- $('#timeline-footer').removeClass('wv-anim-active');
- models.anim.rangeState.state = 'off';
+ $("#timeline-footer").removeClass("wv-anim-active");
+ models.anim.rangeState.state = "off";
if (!obj.error) {
const blob = obj.blob;
$progress.remove();
progressing = false;
- var animatedImage = document.createElement('img');
+ var animatedImage = document.createElement("img");
const blobURL = URL.createObjectURL(blob);
animatedImage.src = blobURL;
animatedImage.width =
@@ -647,7 +647,7 @@ export function animationGif(models, config, ui) {
? window.innerHeight - 120
: lastRequestedDimensions.h;
var dlURL = util.format(
- 'nasa-worldview-{1}-to-{2}.gif',
+ "nasa-worldview-{1}-to-{2}.gif",
animModel.rangeState.startDate,
animModel.rangeState.endDate
);
@@ -655,71 +655,71 @@ export function animationGif(models, config, ui) {
// Create download link and apply button CSS
var $download = $(
- '<button><span class=ui-button-text>Download</span></button>'
+ "<button><span class=ui-button-text>Download</span></button>"
)
- .attr('class', 'wv-button')
+ .attr("class", "wv-button")
.hover(
function() {
- $(this).addClass('ui-state-hover');
+ $(this).addClass("ui-state-hover");
},
function() {
- $(this).removeClass('ui-state-hover');
+ $(this).removeClass("ui-state-hover");
}
)
.click(function(e) {
e.preventDefault();
FileSaver.saveAs(blob, dlURL);
- googleAnalytics.event('Animation', 'Download', 'GIF', downloadSize);
+ googleAnalytics.event("Animation", "Download", "GIF", downloadSize);
});
var $catalog =
"<div class='gif-results-dialog' style='height: " +
animatedImage.height +
"px; min-height: 210px;' >" +
- '<div>' +
- '<div><b>' +
- 'Size: ' +
- '</b></div>' +
- '<div>' +
+ "<div>" +
+ "<div><b>" +
+ "Size: " +
+ "</b></div>" +
+ "<div>" +
downloadSize +
- ' MB' +
- '</div>' +
- '</div>' +
- '<div>' +
- '<div><b>' +
- 'Speed: ' +
- '</b></div>' +
- '<div>' +
+ " MB" +
+ "</div>" +
+ "</div>" +
+ "<div>" +
+ "<div><b>" +
+ "Speed: " +
+ "</b></div>" +
+ "<div>" +
animModel.rangeState.speed +
- ' fps' +
- '</div>' +
- '</div>' +
- '<div>' +
- '<div><b>' +
- 'Date Range: ' +
- '</b></div>' +
- '<div>' +
+ " fps" +
+ "</div>" +
+ "</div>" +
+ "<div>" +
+ "<div><b>" +
+ "Date Range: " +
+ "</b></div>" +
+ "<div>" +
animModel.rangeState.startDate +
- '</div>' +
- '<div>' +
- ' - ' +
- '</div>' +
- '<div>' +
+ "</div>" +
+ "<div>" +
+ " - " +
+ "</div>" +
+ "<div>" +
animModel.rangeState.endDate +
- '</div>' +
- '</div>' +
- '<div>' +
- '<div><b>' +
- 'Increments: ' +
- '</b></div>' +
- '<div>' +
+ "</div>" +
+ "</div>" +
+ "<div>" +
+ "<div><b>" +
+ "Increments: " +
+ "</b></div>" +
+ "<div>" +
lodashCapitalize(ui.anim.widget.getIncrements()) +
- '</div>' +
- '</div>' +
- '</div>';
- var $dialogBodyCase = $('<div></div>');
- $dialogBodyCase.addClass('gif-results-dialog-case clearfix');
- $dialogBodyCase.css('padding', '10px 0');
+ "</div>" +
+ "</div>" +
+ "</div>";
+ var $dialogBodyCase = $("<div></div>");
+ $dialogBodyCase.addClass("gif-results-dialog-case clearfix");
+ $dialogBodyCase.css("padding", "10px 0");
$dialogBodyCase.append(animatedImage);
$dialogBodyCase.append($catalog);
// calculate the offset of the dialog position based on image size to display it properly
@@ -727,11 +727,11 @@ export function animationGif(models, config, ui) {
var posWidth = (lastRequestedDimensions.w * 1) / window.innerWidth;
var posHeight = (lastRequestedDimensions.h * 50) / window.innerHeight;
var atString =
- 'center-' +
+ "center-" +
posWidth.toFixed() +
- '% center-' +
+ "% center-" +
posHeight.toFixed() +
- '%';
+ "%";
// Create a dialog over the view and place the image there
var $imgDialog = wvui
@@ -739,20 +739,20 @@ export function animationGif(models, config, ui) {
.append($dialogBodyCase)
.append($download);
$imgDialog.dialog({
- dialogClass: 'wv-panel wv-gif-results',
- title: 'Your GIF',
+ dialogClass: "wv-panel wv-gif-results",
+ title: "Your GIF",
width: animatedImage.width + 204,
resizable: false,
maxWidth: window.innerWidth,
maxHeight: window.innerHeight,
close: function() {
- $imgDialog.find('img').remove();
- models.anim.rangeState.state = 'on';
- $('#timeline-footer').toggleClass('wv-anim-active');
+ $imgDialog.find("img").remove();
+ models.anim.rangeState.state = "on";
+ $("#timeline-footer").toggleClass("wv-anim-active");
},
position: {
// based on image size
- my: 'center center',
+ my: "center center",
at: atString,
of: window
}
@@ -761,12 +761,12 @@ export function animationGif(models, config, ui) {
var headerMsg =
"<h3 class='wv-data-unavailable-header'>GIF Not Available</h3>";
var bodyMsg =
- 'One or more of the frames requested was unable to be processed';
+ "One or more of the frames requested was unable to be processed";
uiIndicator.hide(loader);
var callback = function() {
- $('#timeline-footer').toggleClass('wv-anim-active');
+ $("#timeline-footer").toggleClass("wv-anim-active");
};
- wvui.notify(headerMsg + bodyMsg, 'Notice', 600, callback);
+ wvui.notify(headerMsg + bodyMsg, "Notice", 600, callback);
}
};
@@ -786,24 +786,24 @@ export function animationGif(models, config, ui) {
$dialogBox = wvui.getDialog();
$dialogBox.html(panelCase);
$dialogBox.css({
- paddingBottom: '10px'
+ paddingBottom: "10px"
});
$dialogBox.dialog({
- dialogClass: 'wv-panel wv-image',
- title: 'Create An Animated GIF',
- height: 'auto',
+ dialogClass: "wv-panel wv-image",
+ title: "Create An Animated GIF",
+ height: "auto",
width: width,
minHeight: 40,
minWidth: 287,
resizable: false,
show: {
- effect: 'slide',
- direction: 'right'
+ effect: "slide",
+ direction: "right"
},
position: {
- my: 'left top',
- at: 'right+10 top',
- of: $('.jcrop-tracker')
+ my: "left top",
+ at: "right+10 top",
+ of: $(".jcrop-tracker")
},
close: onCloseSelector
@@ -812,11 +812,11 @@ export function animationGif(models, config, ui) {
};
var onCloseSelector = function() {
- $('#wv-map').insertAfter('#productsHolder'); // retain map element before disabling jcrop
+ $("#wv-map").insertAfter("#productsHolder"); // retain map element before disabling jcrop
jcropAPI.destroy();
- $('#timeline-footer').toggleClass('wv-anim-active');
- if (models.proj.selected.id === 'geographic') {
- ui.map.events.trigger('selectiondone');
+ $("#timeline-footer").toggleClass("wv-anim-active");
+ if (models.proj.selected.id === "geographic") {
+ ui.map.events.trigger("selectiondone");
}
};
@@ -866,11 +866,11 @@ export function animationGif(models, config, ui) {
*
*/
var removeCrop = function() {
- $('#wv-map').insertAfter('#productsHolder'); // retain map element before disabling jcrop
+ $("#wv-map").insertAfter("#productsHolder"); // retain map element before disabling jcrop
animationCoordinates = undefined;
jcropAPI.destroy();
- if (models.proj.selected.id === 'geographic') {
- ui.map.events.trigger('selectiondone');
+ if (models.proj.selected.id === "geographic") {
+ ui.map.events.trigger("selectiondone");
}
};
@@ -909,10 +909,10 @@ export function animationGif(models, config, ui) {
if ($dialog) {
$parent = $dialog.parent();
$parent.position({
- my: 'left top',
- at: 'right+10 top',
- collision: 'flipfit',
- of: $('.jcrop-tracker')
+ my: "left top",
+ at: "right+10 top",
+ collision: "flipfit",
+ of: $(".jcrop-tracker")
});
}
};
@@ -936,7 +936,7 @@ export function animationGif(models, config, ui) {
var fontSize = Math.abs(width / 4); // Font size is 25% width
fontSize = fontSize < 30 ? 30 : fontSize > 100 ? 100 : fontSize; // Set max and min font-size
- $el.css('font-size', fontSize);
+ $el.css("font-size", fontSize);
};
var onBoundingBoxChange = function(c, $dialog, $dlButton) {
@@ -984,14 +984,14 @@ export function animationGif(models, config, ui) {
];
}
- if (models.proj.selected.id === 'geographic') {
- ui.map.events.trigger('selecting');
+ if (models.proj.selected.id === "geographic") {
+ ui.map.events.trigger("selecting");
}
starterWidth = previousCoords[0] - previousCoords[2];
// Start the image cropping. Show the dialog
- $('#wv-map').Jcrop(
+ $("#wv-map").Jcrop(
{
- bgColor: 'black',
+ bgColor: "black",
bgOpacity: 0.3,
fullScreen: true,
setSelect: previousCoords,
@@ -1020,15 +1020,15 @@ export function animationGif(models, config, ui) {
$dlButton =
"<div class='wv-dl-gif-bt-case'>" +
"<i class='fa fa-download'>" +
- '</div>';
+ "</div>";
jcropAPI = this;
- $('#timeline-footer').toggleClass('wv-anim-active');
+ $("#timeline-footer").toggleClass("wv-anim-active");
$dialog = getSelectorDialog(342);
- $tracker = this.ui.selection.find('.jcrop-tracker');
+ $tracker = this.ui.selection.find(".jcrop-tracker");
$tracker.append($dlButton);
- $dlButton = $('.wv-dl-gif-bt-case i');
+ $dlButton = $(".wv-dl-gif-bt-case i");
setIconFontSize($dlButton, starterWidth);
- $dlButton.on('click', getGif);
+ $dlButton.on("click", getGif);
}
);
diff --git a/web/js/components/date-selector/date-selector.js b/web/js/components/date-selector/date-selector.js
index 082067216..d7e5e4ead 100644
--- a/web/js/components/date-selector/date-selector.js
+++ b/web/js/components/date-selector/date-selector.js
@@ -1,7 +1,7 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import DateInputColumn from './input';
-import util from '../../util/util';
+import React from "react";
+import PropTypes from "prop-types";
+import DateInputColumn from "./input";
+import util from "../../util/util";
/*
* A react component, is a draggable svg
@@ -68,11 +68,11 @@ class DateSelector extends React.Component {
today={new Date()}
date={this.state.date}
type="hour"
- inputId={this.props.idSuffix ? 'hour-' + this.props.idSuffix : ''}
+ inputId={this.props.idSuffix ? "hour-" + this.props.idSuffix : ""}
height={this.props.height}
width={this.props.width}
updateDate={this.updateDate.bind(this)}
- value={util.pad(this.state.date.getUTCHours(), 2, '0')}
+ value={util.pad(this.state.date.getUTCHours(), 2, "0")}
tabIndex={4}
focused={this.state.tab === 4}
nextTab={this.nextTab.bind(this)}
@@ -91,8 +91,8 @@ class DateSelector extends React.Component {
height={this.props.height}
width={this.props.width}
updateDate={this.updateDate.bind(this)}
- value={util.pad(this.state.date.getUTCMinutes(), 2, '0')}
- inputId={this.props.idSuffix ? 'minute-' + this.props.idSuffix : ''}
+ value={util.pad(this.state.date.getUTCMinutes(), 2, "0")}
+ inputId={this.props.idSuffix ? "minute-" + this.props.idSuffix : ""}
tabIndex={5}
focused={this.state.tab === 5}
nextTab={this.nextTab.bind(this)}
@@ -119,7 +119,7 @@ class DateSelector extends React.Component {
height={this.props.height}
width={this.props.width}
updateDate={this.updateDate.bind(this)}
- inputId={this.props.idSuffix ? 'year-' + this.props.idSuffix : ''}
+ inputId={this.props.idSuffix ? "year-" + this.props.idSuffix : ""}
tabIndex={1}
focused={this.state.tab === 1}
nextTab={this.nextTab.bind(this)}
@@ -135,7 +135,7 @@ class DateSelector extends React.Component {
date={this.state.date}
value={util.monthStringArray[this.state.date.getUTCMonth()]}
type="month"
- inputId={this.props.idSuffix ? 'month-' + this.props.idSuffix : ''}
+ inputId={this.props.idSuffix ? "month-" + this.props.idSuffix : ""}
height={this.props.height}
width={this.props.width}
updateDate={this.updateDate.bind(this)}
@@ -156,9 +156,9 @@ class DateSelector extends React.Component {
height={this.props.height}
width={this.props.width}
updateDate={this.updateDate.bind(this)}
- value={util.pad(this.state.date.getUTCDate(), 2, '0')}
+ value={util.pad(this.state.date.getUTCDate(), 2, "0")}
tabIndex={3}
- inputId={this.props.idSuffix ? 'day-' + this.props.idSuffix : ''}
+ inputId={this.props.idSuffix ? "day-" + this.props.idSuffix : ""}
focused={this.state.tab === 3}
nextTab={this.nextTab.bind(this)}
maxDate={this.props.maxDate}
diff --git a/web/js/components/date-selector/input.js b/web/js/components/date-selector/input.js
index a75e0c564..5b63c0767 100644
--- a/web/js/components/date-selector/input.js
+++ b/web/js/components/date-selector/input.js
@@ -1,8 +1,6 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import Util from '../util/util';
-
-const util = new Util();
+import React from "react";
+import PropTypes from "prop-types";
+import util from "../../util/util";
/*
* A react component, is a draggable svg
@@ -32,9 +30,9 @@ class DateInputColumn extends React.Component {
var size;
var type;
type = this.props.type;
- if (type === 'year') {
- size = '4';
- } else if (type === 'day') {
+ if (type === "year") {
+ size = "4";
+ } else if (type === "day") {
size = 2;
} else {
size = 3;
@@ -72,26 +70,26 @@ class DateInputColumn extends React.Component {
this.onClickDown();
return;
}
- if (e.type === 'focusout' || entered) {
- if (this.props.type === 'year' || this.props.type === 'day') {
+ if (e.type === "focusout" || entered) {
+ if (this.props.type === "year" || this.props.type === "day") {
if (!((keyCode >= 48 && keyCode <= 57) || entered || keyCode === 8)) {
return;
}
}
switch (this.props.type) {
- case 'year':
+ case "year":
newDate = this.yearValidation(value);
break;
- case 'month':
+ case "month":
newDate = this.monthValidation(value);
break;
- case 'day':
+ case "day":
newDate = this.dayValidation(value);
break;
- case 'hour':
+ case "hour":
newDate = this.hourValidation(value);
break;
- case 'minute':
+ case "minute":
newDate = this.minuteValidation(value);
break;
}
@@ -109,7 +107,7 @@ class DateInputColumn extends React.Component {
}
}
onClickUp() {
- if (this.props.type === 'minute') {
+ if (this.props.type === "minute") {
this.rollDate(10);
} else {
this.rollDate(1);
@@ -119,7 +117,7 @@ class DateInputColumn extends React.Component {
});
}
onClickDown() {
- if (this.props.type === 'minute') {
+ if (this.props.type === "minute") {
this.rollDate(-10);
} else {
this.rollDate(-1);
@@ -234,8 +232,8 @@ class DateInputColumn extends React.Component {
render() {
return (
<div
- className={'input-wrapper' + ' input-wrapper-' + this.props.type}
- style={this.state.valid ? {} : { borderColor: '#ff0000' }}
+ className={"input-wrapper" + " input-wrapper-" + this.props.type}
+ style={this.state.valid ? {} : { borderColor: "#ff0000" }}
>
<div
onClick={this.onClickUp.bind(this)}
@@ -261,7 +259,7 @@ class DateInputColumn extends React.Component {
onKeyDown={this.onKeyPress.bind(this) /* currently not working */}
onChange={this.onChange.bind(this)}
style={
- this.props.fontSize ? { fontSize: this.props.fontSize + 'px' } : {}
+ this.props.fontSize ? { fontSize: this.props.fontSize + "px" } : {}
}
step={this.props.step}
onBlur={this.blur.bind(this)}
diff --git a/web/js/components/layer/row.js b/web/js/components/layer/row.js
index 90aae3f3a..2dd452033 100644
--- a/web/js/components/layer/row.js
+++ b/web/js/components/layer/row.js
@@ -1,7 +1,7 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import { ListGroup, ListGroupItem } from 'reactstrap';
-import util from '../../util/util.js';
+import React from "react";
+import PropTypes from "prop-types";
+import { ListGroup, ListGroupItem } from "reactstrap";
+import util from "../../util/util.js";
/**
* A single layer search result row
@@ -67,81 +67,81 @@ class LayerRow extends React.Component {
*/
dateRangeText(layer) {
var startDate, startDateId, endDate, endDateId;
- var dateRange = '';
+ var dateRange = "";
if (layer.startDate) {
startDate = util.parseDate(layer.startDate);
- if (layer.period === 'subdaily') {
+ if (layer.period === "subdaily") {
startDate =
startDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(startDate) +
- ' ' +
+ " " +
startDate.getFullYear() +
- ' ' +
- util.pad(startDate.getHours(), 2, '0') +
- ':' +
- util.pad(startDate.getMinutes(), 2, '0');
- } else if (layer.period === 'yearly') {
+ " " +
+ util.pad(startDate.getHours(), 2, "0") +
+ ":" +
+ util.pad(startDate.getMinutes(), 2, "0");
+ } else if (layer.period === "yearly") {
startDate = startDate.getFullYear();
- } else if (layer.period === 'monthly') {
- startDate = util.giveMonth(startDate) + ' ' + startDate.getFullYear();
+ } else if (layer.period === "monthly") {
+ startDate = util.giveMonth(startDate) + " " + startDate.getFullYear();
} else {
startDate =
startDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(startDate) +
- ' ' +
+ " " +
startDate.getFullYear();
}
- if (layer.id) startDateId = layer.id + '-startDate';
+ if (layer.id) startDateId = layer.id + "-startDate";
if (layer.endDate) {
endDate = util.parseDate(layer.endDate);
- if (layer.period === 'subdaily') {
+ if (layer.period === "subdaily") {
endDate =
endDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(endDate) +
- ' ' +
+ " " +
endDate.getFullYear() +
- ' ' +
- util.pad(endDate.getHours(), 2, '0') +
- ':' +
- util.pad(endDate.getMinutes(), 2, '0');
- } else if (layer.period === 'yearly') {
+ " " +
+ util.pad(endDate.getHours(), 2, "0") +
+ ":" +
+ util.pad(endDate.getMinutes(), 2, "0");
+ } else if (layer.period === "yearly") {
endDate = new Date(endDate.setFullYear(endDate.getFullYear() - 1));
endDate = endDate.getFullYear();
- } else if (layer.period === 'monthly') {
+ } else if (layer.period === "monthly") {
endDate = new Date(endDate.setMonth(endDate.getMonth() - 1));
- endDate = util.giveMonth(endDate) + ' ' + endDate.getFullYear();
+ endDate = util.giveMonth(endDate) + " " + endDate.getFullYear();
} else {
if (
layer.dateRanges &&
- layer.dateRanges.slice(-1)[0].dateInterval !== '1'
+ layer.dateRanges.slice(-1)[0].dateInterval !== "1"
) {
endDate = new Date(endDate.setTime(endDate.getTime() - 86400000));
}
endDate =
endDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(endDate) +
- ' ' +
+ " " +
endDate.getFullYear();
}
} else {
- endDate = 'Present';
+ endDate = "Present";
}
- if (layer.id) endDateId = layer.id + '-endDate';
+ if (layer.id) endDateId = layer.id + "-endDate";
dateRange =
'Temporal coverage: <span class="layer-date-start" id=' +
startDateId +
- '>' +
+ ">" +
startDate +
'</span> - <span class="layer-end-date" id=' +
endDateId +
- '>' +
+ ">" +
endDate +
- '</span>';
+ "</span>";
}
return dateRange;
@@ -183,7 +183,7 @@ class LayerRow extends React.Component {
// check for any overlap
var previousEnd = util.parseDate(previous.endDate);
// Add dateInterval
- if (previous.dateInterval > 1 && period === 'daily') {
+ if (previous.dateInterval > 1 && period === "daily") {
previousEnd = new Date(
previousEnd.setTime(
previousEnd.getTime() +
@@ -191,13 +191,13 @@ class LayerRow extends React.Component {
)
);
}
- if (period === 'monthly') {
+ if (period === "monthly") {
previousEnd = new Date(
previousEnd.setMonth(
previousEnd.getMonth() + (previous.dateInterval - 1)
)
);
- } else if (period === 'yearly') {
+ } else if (period === "yearly") {
previousEnd = new Date(
previousEnd.setFullYear(
previousEnd.getFullYear() + (previous.dateInterval - 1)
@@ -246,7 +246,7 @@ class LayerRow extends React.Component {
var { layer } = this.props;
var { title, description, subtitle, metadata } = layer;
var listItems;
- var headerClass = 'layers-all-header has-checkbox';
+ var headerClass = "layers-all-header has-checkbox";
if (layer.dateRanges && layer.dateRanges.length > 1) {
let firstDateRange = true;
@@ -262,47 +262,47 @@ class LayerRow extends React.Component {
let listItemStartDate;
let listItemEndDate;
- if (layer.period === 'subdaily') {
+ if (layer.period === "subdaily") {
listItemStartDate =
startDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(startDate) +
- ' ' +
+ " " +
startDate.getFullYear() +
- ' ' +
- util.pad(startDate.getHours(), 2, '0') +
- ':' +
- util.pad(startDate.getMinutes(), 2, '0');
+ " " +
+ util.pad(startDate.getHours(), 2, "0") +
+ ":" +
+ util.pad(startDate.getMinutes(), 2, "0");
listItemEndDate =
endDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(endDate) +
- ' ' +
+ " " +
endDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(endDate) +
- ' ' +
+ " " +
endDate.getFullYear() +
- ' ' +
- util.pad(endDate.getHours(), 2, '0') +
- ':' +
- util.pad(endDate.getMinutes(), 2, '0');
+ " " +
+ util.pad(endDate.getHours(), 2, "0") +
+ ":" +
+ util.pad(endDate.getMinutes(), 2, "0");
if (firstDateRange) {
if (layer.endDate === undefined) {
- listItemEndDate = 'Present';
+ listItemEndDate = "Present";
}
firstDateRange = false;
}
return (
- <ListGroupItem key={l.startDate + ' - ' + l.endDate}>
- {listItemStartDate + ' - ' + listItemEndDate}
+ <ListGroupItem key={l.startDate + " - " + l.endDate}>
+ {listItemStartDate + " - " + listItemEndDate}
</ListGroupItem>
);
- } else if (layer.period === 'yearly') {
- if (l.dateInterval === '1' && l.startDate === l.endDate) {
+ } else if (layer.period === "yearly") {
+ if (l.dateInterval === "1" && l.startDate === l.endDate) {
listItemStartDate = startDate.getFullYear();
return (
@@ -312,7 +312,7 @@ class LayerRow extends React.Component {
);
} else {
listItemStartDate = startDate.getFullYear();
- if (l.dateInterval !== '1') {
+ if (l.dateInterval !== "1") {
listItemEndDate = new Date(
endDate.setFullYear(
endDate.getFullYear() - 1 + l.dateInterval
@@ -323,21 +323,21 @@ class LayerRow extends React.Component {
if (firstDateRange) {
if (layer.endDate === undefined) {
- listItemEndDate = 'Present';
+ listItemEndDate = "Present";
}
firstDateRange = false;
}
return (
<ListGroupItem key={l.startDate}>
- {listItemStartDate + ' - ' + listItemEndDate}
+ {listItemStartDate + " - " + listItemEndDate}
</ListGroupItem>
);
}
- } else if (layer.period === 'monthly') {
- if (l.dateInterval === '1' && l.startDate === l.endDate) {
+ } else if (layer.period === "monthly") {
+ if (l.dateInterval === "1" && l.startDate === l.endDate) {
listItemStartDate =
- util.giveMonth(startDate) + ' ' + startDate.getFullYear();
+ util.giveMonth(startDate) + " " + startDate.getFullYear();
return (
<ListGroupItem key={l.startDate}>
@@ -346,50 +346,50 @@ class LayerRow extends React.Component {
);
} else {
listItemStartDate =
- util.giveMonth(startDate) + ' ' + startDate.getFullYear();
- if (l.dateInterval !== '1') {
+ util.giveMonth(startDate) + " " + startDate.getFullYear();
+ if (l.dateInterval !== "1") {
listItemEndDate = new Date(
endDate.setMonth(endDate.getMonth() - 1 + l.dateInterval)
);
}
listItemEndDate =
- util.giveMonth(endDate) + ' ' + endDate.getFullYear();
+ util.giveMonth(endDate) + " " + endDate.getFullYear();
if (firstDateRange) {
if (layer.endDate === undefined) {
- listItemEndDate = 'Present';
+ listItemEndDate = "Present";
}
firstDateRange = false;
}
return (
<ListGroupItem key={l.startDate}>
- {listItemStartDate + ' - ' + listItemEndDate}
+ {listItemStartDate + " - " + listItemEndDate}
</ListGroupItem>
);
}
} else if (layer.period) {
- if (l.dateInterval === '1' && l.startDate === l.endDate) {
+ if (l.dateInterval === "1" && l.startDate === l.endDate) {
let listItemStartDate =
startDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(startDate) +
- ' ' +
+ " " +
startDate.getFullYear();
return (
- <ListGroupItem key={l.startDate + ' - ' + l.endDate}>
+ <ListGroupItem key={l.startDate + " - " + l.endDate}>
{listItemStartDate}
</ListGroupItem>
);
} else {
let listItemStartDate =
startDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(startDate) +
- ' ' +
+ " " +
startDate.getFullYear();
- if (l.dateInterval !== '1') {
+ if (l.dateInterval !== "1") {
listItemEndDate = new Date(
endDate.setTime(
endDate.getTime() - 86400000 + l.dateInterval * 86400000
@@ -398,21 +398,21 @@ class LayerRow extends React.Component {
}
listItemEndDate =
endDate.getDate() +
- ' ' +
+ " " +
util.giveMonth(endDate) +
- ' ' +
+ " " +
endDate.getFullYear();
if (firstDateRange) {
if (layer.endDate === undefined) {
- listItemEndDate = 'Present';
+ listItemEndDate = "Present";
}
firstDateRange = false;
}
return (
- <ListGroupItem key={l.startDate + ' - ' + l.endDate}>
- {listItemStartDate + ' - ' + listItemEndDate}
+ <ListGroupItem key={l.startDate + " - " + l.endDate}>
+ {listItemStartDate + " - " + listItemEndDate}
</ListGroupItem>
);
}
@@ -420,7 +420,7 @@ class LayerRow extends React.Component {
});
}
}
- if (checked) headerClass += ' checked';
+ if (checked) headerClass += " checked";
return (
<div className="layers-all-layer">
@@ -455,7 +455,7 @@ class LayerRow extends React.Component {
className="layer-date-ranges-button"
onClick={e => this.toggleDateRanges(e)}
>
- {' '}
+ {" "}
<sup>*View Dates</sup>
</a>
)}
diff --git a/web/js/components/sidebar/events/event.js b/web/js/components/sidebar/events/event.js
index 22a7c6725..af467f6ab 100644
--- a/web/js/components/sidebar/events/event.js
+++ b/web/js/components/sidebar/events/event.js
@@ -1,7 +1,7 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import util from '../../../util/util';
-import lodashFind from 'lodash/find';
+import React from "react";
+import PropTypes from "prop-types";
+import util from "../../../util/util";
+import lodashFind from "lodash/find";
class Event extends React.Component {
getDateLists() {
@@ -10,18 +10,18 @@ class Event extends React.Component {
return (
<ul
className="dates"
- style={!selectedDate ? { display: 'none' } : { display: 'block' }}
+ style={!selectedDate ? { display: "none" } : { display: "block" }}
>
{event.geometries.map((geometry, index) => {
- var date = geometry.date.split('T')[0];
+ var date = geometry.date.split("T")[0];
return (
- <li key={event.id + '-' + date} className="dates">
+ <li key={event.id + "-" + date} className="dates">
<a
onClick={this.onClick.bind(this, date, null)}
className={
selectedDate === date
- ? 'date item-selected active'
- : 'date item-selected '
+ ? "date item-selected active"
+ : "date item-selected "
}
>
{date}
@@ -58,9 +58,10 @@ class Event extends React.Component {
return (
<a
target="_blank"
+ rel="noopener noreferrer"
className="natural-event-link"
href={reference.url}
- key={event.id + '-' + reference.id}
+ key={event.id + "-" + reference.id}
onClick={e => {
e.stopPropagation();
}}
@@ -70,7 +71,7 @@ class Event extends React.Component {
</a>
);
} else {
- return source.title + ' ';
+ return source.title + " ";
}
});
}
@@ -80,26 +81,26 @@ class Event extends React.Component {
const eventDate = util.parseDateUTC(event.geometries[0].date);
var dateString =
util.giveWeekDay(eventDate) +
- ', ' +
+ ", " +
util.giveMonth(eventDate) +
- ' ' +
+ " " +
eventDate.getUTCDate();
if (eventDate.getUTCFullYear() !== util.today().getUTCFullYear()) {
- dateString += ', ' + eventDate.getUTCFullYear();
+ dateString += ", " + eventDate.getUTCFullYear();
}
return (
<li
className={
selectedDate
- ? 'item-selected selectorItem item item-visible'
+ ? "item-selected selectorItem item item-visible"
: isVisible
- ? 'selectorItem item'
- : 'selectorItem item hidden'
+ ? "selectorItem item"
+ : "selectorItem item hidden"
}
onClick={this.onClick.bind(this, null, !!selectedDate)}
>
<i
- className={'event-icon event-icon-' + event.categories[0].slug}
+ className={"event-icon event-icon-" + event.categories[0].slug}
title={event.categories[0].title}
/>
<h4 className="title">
diff --git a/web/js/components/sidebar/products/legend.js b/web/js/components/sidebar/products/legend.js
index fb19326c2..cd21369dc 100644
--- a/web/js/components/sidebar/products/legend.js
+++ b/web/js/components/sidebar/products/legend.js
@@ -1,7 +1,7 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import util from '../../../util/util';
-import lodashIsEqual from 'lodash/isEqual';
+import React from "react";
+import PropTypes from "prop-types";
+import util from "../../../util/util";
+import lodashIsEqual from "lodash/isEqual";
class Legend extends React.Component {
constructor(props) {
@@ -67,7 +67,7 @@ class Legend extends React.Component {
var boundingRec = e.target.getBoundingClientRect();
var x = e.clientX - boundingRec.left;
var y = e.clientY - boundingRec.top;
- var rgba = canvas.current.getContext('2d').getImageData(x, y, 1, 1).data;
+ var rgba = canvas.current.getContext("2d").getImageData(x, y, 1, 1).data;
var hex = util.rgbaToHex(rgba[0], rgba[1], rgba[2]);
this.setState({
@@ -93,12 +93,12 @@ class Legend extends React.Component {
* @param {Number} acceptableDifference
*/
getLegendObject(legend, hex, acceptableDifference) {
- var units = legend.units || '';
+ var units = legend.units || "";
for (var i = 0, len = legend.colors.length; i < len; i++) {
if (util.hexColorDelta(legend.colors[i], hex) < acceptableDifference) {
// If the two colors are close
return {
- label: legend.tooltips[i] + ' ' + units,
+ label: legend.tooltips[i] + " " + units,
len: len,
index: i
};
@@ -125,8 +125,8 @@ class Legend extends React.Component {
const { legends } = this.state;
legends.forEach((colorMap, index) => {
- if (colorMap.type === 'continuous' || colorMap.type === 'discrete') {
- let ctxStr = 'canvas_' + index;
+ if (colorMap.type === "continuous" || colorMap.type === "discrete") {
+ let ctxStr = "canvas_" + index;
if (this[ctxStr]) {
let newWidth = this[ctxStr].current.getBoundingClientRect().width;
if (newWidth !== this.state.width) {
@@ -146,7 +146,7 @@ class Legend extends React.Component {
* @param {*} colors | array of color values
*/
drawOnCanvas(ctxStr, checkerBoardPattern, colors) {
- var context = this[ctxStr].current.getContext('2d');
+ var context = this[ctxStr].current.getContext("2d");
const { height, width } = this.props;
context.fillStyle = checkerBoardPattern;
context.fillRect(0, 0, width, height);
@@ -171,11 +171,11 @@ class Legend extends React.Component {
var halfTextWidth = textWidth / 2 || 0;
var xOffset = boxWidth * index + boxWidth / 2 || 0;
if (halfTextWidth > xOffset) {
- return { left: '0', visibility: 'visible' };
+ return { left: "0", visibility: "visible" };
} else if (xOffset + halfTextWidth > width) {
- return { right: '0', visibility: 'visible' };
+ return { right: "0", visibility: "visible" };
}
- return { left: xOffset - halfTextWidth + 'px', visibility: 'visible' };
+ return { left: xOffset - halfTextWidth + "px", visibility: "visible" };
}
/**
* @param {*} xOffset | X px Location of running-data
@@ -186,11 +186,11 @@ class Legend extends React.Component {
var halfTextWidth = textWidth / 2 || 0;
if (halfTextWidth > xOffset) {
- return { left: '0' };
+ return { left: "0" };
} else if (xOffset + halfTextWidth > width) {
- return { right: '0' };
+ return { right: "0" };
}
- return { left: xOffset - halfTextWidth + 'px' };
+ return { left: xOffset - halfTextWidth + "px" };
}
/**
* Render scale-type legends
@@ -209,7 +209,7 @@ class Legend extends React.Component {
legendObj = this.getLegendObject(legend, colorHex, 5); // {label,len,index}
if (legendObj) {
percent = this.getPercent(legendObj.len, legendObj.index);
- textWidth = util.getTextWidth(legendObj.label, 'Lucida Sans');
+ textWidth = util.getTextWidth(legendObj.label, "Lucida Sans");
xOffset = this.state.width * percent;
}
}
@@ -217,15 +217,15 @@ class Legend extends React.Component {
var min = legend.minLabel || legend.tooltips[0];
var max = legend.maxLabel || legend.tooltips[toolTipLength];
- min = legend.units ? min + ' ' + legend.units : min;
- max = legend.units ? max + ' ' + legend.units : max;
+ min = legend.units ? min + " " + legend.units : min;
+ max = legend.units ? max + " " + legend.units : max;
return (
<div
className={
- legendObj ? 'wv-running wv-palettes-legend' : 'wv-palettes-legend'
+ legendObj ? "wv-running wv-palettes-legend" : "wv-palettes-legend"
}
- id={layer.id + '_' + legend.id + '_' + index}
- key={layer.id + '_' + legend.id + '_' + index}
+ id={layer.id + "_" + legend.id + "_" + index}
+ key={layer.id + "_" + legend.id + "_" + index}
>
{isMoreThanOneColorBar ? (
<div className="wv-palettes-title">{legend.title}</div>
@@ -235,22 +235,22 @@ class Legend extends React.Component {
<div className="colorbar-case">
<canvas
className="wv-palettes-colorbar"
- id={layer.id + '-' + legend.id + index + 'colorbar'}
+ id={layer.id + "-" + legend.id + index + "colorbar"}
width={width}
height={12}
- ref={this['canvas_' + index]}
+ ref={this["canvas_" + index]}
onMouseEnter={this.onMouseEnter.bind(this)}
onMouseLeave={this.hideValue.bind(this)}
onMouseMove={this.onHoverColorbar.bind(
this,
- this['canvas_' + index]
+ this["canvas_" + index]
)}
/>
<div
className="wv-running-bar"
style={{
left: isHoveringLegend ? 0 : xOffset,
- visibility: legendObj && !isHoveringLegend ? 'visible' : 'hidden'
+ visibility: legendObj && !isHoveringLegend ? "visible" : "hidden"
}}
/>
</div>
@@ -261,10 +261,10 @@ class Legend extends React.Component {
style={
isRunningData
? this.getRunningLabelStyle(xOffset, textWidth, this.state.width)
- : { display: 'none' }
+ : { display: "none" }
}
>
- {legendObj ? legendObj.label : ''}
+ {legendObj ? legendObj.label : ""}
</span>
</div>
);
@@ -292,32 +292,32 @@ class Legend extends React.Component {
if (isRunningData && colorHex) {
legendObj = this.getLegendObject(legend, colorHex, 40); // {label,len,index}
if (legendObj) {
- textWidth = util.getTextWidth(legendObj.label, 'Lucida Sans');
+ textWidth = util.getTextWidth(legendObj.label, "Lucida Sans");
}
}
return (
<div
className={
legendObj
- ? 'wv-running wv-palettes-legend wv-palettes-classes'
- : 'wv-palettes-legend wv-palettes-classes'
+ ? "wv-running wv-palettes-legend wv-palettes-classes"
+ : "wv-palettes-legend wv-palettes-classes"
}
- key={legend.id + '_' + index}
+ key={legend.id + "_" + index}
>
{legend.colors.map((color, index) => {
return (
- <React.Fragment key={legend.id + '-color-' + index}>
+ <React.Fragment key={legend.id + "-color-" + index}>
<span
className={
legendObj && legendObj.index === index
- ? 'wv-active wv-palettes-class'
- : 'wv-palettes-class'
+ ? "wv-active wv-palettes-class"
+ : "wv-palettes-class"
}
style={{ backgroundColor: util.hexToRGBA(color) }}
onMouseMove={this.onMove.bind(this, color)}
onMouseEnter={this.onMouseEnter.bind(this)}
onMouseLeave={this.hideValue.bind(this)}
- dangerouslySetInnerHTML={{ __html: '&nbsp' }}
+ dangerouslySetInnerHTML={{ __html: "&nbsp" }}
/>
{isRunningData && legendObj && index === legendObj.index ? (
<span
@@ -332,7 +332,7 @@ class Legend extends React.Component {
{legendObj.label}
</span>
) : (
- ''
+ ""
)}
</React.Fragment>
);
@@ -350,7 +350,7 @@ class Legend extends React.Component {
: {}
}
>
- {legendObj ? legendObj.label : ''}
+ {legendObj ? legendObj.label : ""}
</span>
</div>
);
@@ -361,10 +361,10 @@ class Legend extends React.Component {
renderLegends() {
const { legends } = this.state;
return legends.map((colorMap, index) => {
- if (colorMap.type === 'continuous' || colorMap.type === 'discrete') {
- this['canvas_' + index] = React.createRef();
+ if (colorMap.type === "continuous" || colorMap.type === "discrete") {
+ this["canvas_" + index] = React.createRef();
return this.renderScale(colorMap, index, legends.length > 1);
- } else if (colorMap.type === 'classification') {
+ } else if (colorMap.type === "classification") {
return this.renderClasses(colorMap, index);
}
});
@@ -377,11 +377,11 @@ class Legend extends React.Component {
<div
className={
isHoveringLegend
- ? 'active-lengend wv-palettes-panel'
- : 'wv-palettes-panel'
+ ? "active-lengend wv-palettes-panel"
+ : "wv-palettes-panel"
}
datalayer={layer.id}
- id={palette.id + '_panel'}
+ id={palette.id + "_panel"}
>
{this.renderLegends()}
</div>
diff --git a/web/js/image/panel.js b/web/js/image/panel.js
index 3652588d9..61a2a51ca 100644
--- a/web/js/image/panel.js
+++ b/web/js/image/panel.js
@@ -1,13 +1,13 @@
-import $ from 'jquery';
-import 'jquery-ui/button';
-import 'jquery-ui/dialog';
-import olProj from 'ol/proj';
-import ImageResSelection from '../components/image-panel/select';
-import googleAnalytics from '../components/util/google-analytics';
-import util from '../util/util';
-import wvui from '../ui/ui';
-import React from 'react';
-import ReactDOM from 'react-dom';
+import $ from "jquery";
+import "jquery-ui/button";
+import "jquery-ui/dialog";
+import olProj from "ol/proj";
+import ImageResSelection from "../components/image-panel/select";
+import googleAnalytics from "../components/util/google-analytics";
+import util from "../util/util";
+import wvui from "../ui/ui";
+import React from "react";
+import ReactDOM from "react-dom";
import {
imageUtilCalculateResolution,
@@ -15,42 +15,42 @@ import {
imageUtilGetCoordsFromPixelValues,
imageUtilGetLayers,
imageUtilGetConversionFactor
-} from './util';
+} from "./util";
const resolutionsGeo = {
values: [
- { value: '0.125', text: '30m' },
- { value: '0.25', text: '60m' },
- { value: '0.5', text: '125m' },
- { value: '1', text: '250m' },
- { value: '2', text: '500m' },
- { value: '4', text: '1km' },
- { value: '20', text: '5km' },
- { value: '40', text: '10km' }
+ { value: "0.125", text: "30m" },
+ { value: "0.25", text: "60m" },
+ { value: "0.5", text: "125m" },
+ { value: "1", text: "250m" },
+ { value: "2", text: "500m" },
+ { value: "4", text: "1km" },
+ { value: "20", text: "5km" },
+ { value: "40", text: "10km" }
]
};
const resolutionsPolar = {
values: [
- { value: '1', text: '250m' },
- { value: '2', text: '500m' },
- { value: '4', text: '1km' },
- { value: '20', text: '5km' },
- { value: '40', text: '10km' }
+ { value: "1", text: "250m" },
+ { value: "2", text: "500m" },
+ { value: "4", text: "1km" },
+ { value: "20", text: "5km" },
+ { value: "40", text: "10km" }
]
};
const fileTypesGeo = {
values: [
- { value: 'image/jpeg', text: 'JPEG' },
- { value: 'image/png', text: 'PNG' },
- { value: 'image/geotiff', text: 'GeoTIFF' },
- { value: 'image/kmz', text: 'KMZ' }
+ { value: "image/jpeg", text: "JPEG" },
+ { value: "image/png", text: "PNG" },
+ { value: "image/geotiff", text: "GeoTIFF" },
+ { value: "image/kmz", text: "KMZ" }
]
};
const fileTypesPolar = {
values: [
- { value: 'image/jpeg', text: 'JPEG' },
- { value: 'image/png', text: 'PNG' },
- { value: 'image/geotiff', text: 'GeoTIFF' }
+ { value: "image/jpeg", text: "JPEG" },
+ { value: "image/png", text: "PNG" },
+ { value: "image/geotiff", text: "GeoTIFF" }
]
};
@@ -61,17 +61,17 @@ export function imagePanel(models, ui, config, dialogConfig) {
var url;
var alignTo = config.alignTo;
var coords;
- var resolution = '1';
+ var resolution = "1";
var lastZoom = -1;
var htmlElements;
var host;
var path;
- var containerId = 'wv-image-button';
+ var containerId = "wv-image-button";
var id = containerId;
// state items as global vars
var lonlats;
- var imgWorldfile = 'false';
- var imgFormat = 'image/jpeg';
+ var imgWorldfile = "false";
+ var imgFormat = "image/jpeg";
var imgWidth;
var imgHeight;
var imgRes;
@@ -83,19 +83,19 @@ export function imagePanel(models, ui, config, dialogConfig) {
host = config.features.imageDownload.host;
path = config.parameters.imagegen || config.features.imageDownload.path;
} else {
- host = 'http://map2.vis.earthdata.nasa.gov';
- path = 'imagegen/index.php';
+ host = "http://map2.vis.earthdata.nasa.gov";
+ path = "imagegen/index.php";
}
- url = host + '/' + path + '?';
+ url = host + "/" + path + "?";
if (config.parameters.imagegen) {
- util.warn('Redirecting image download to: ' + url);
+ util.warn("Redirecting image download to: " + url);
}
var init = function() {
var options;
checkConfig();
- htmlElements = document.createElement('div');
+ htmlElements = document.createElement("div");
setProjectionGlobals();
options = {
resolution: resolution,
@@ -109,10 +109,10 @@ export function imagePanel(models, ui, config, dialogConfig) {
};
self.reactComponent = renderPanel(options, htmlElements);
- models.proj.events.on('select', setProjectionGlobals);
+ models.proj.events.on("select", setProjectionGlobals);
};
var setProjectionGlobals = function() {
- var isGeoProjection = models.proj.selected.id === 'geographic';
+ var isGeoProjection = models.proj.selected.id === "geographic";
var curZoom = Math.round(ui.map.selected.getView().getZoom());
imgRes = imageUtilCalculateResolution(
curZoom,
@@ -139,13 +139,13 @@ export function imagePanel(models, ui, config, dialogConfig) {
host = config.features.imageDownload.host;
path = config.parameters.imagegen || config.features.imageDownload.path;
} else {
- host = 'http://map2.vis.earthdata.nasa.gov';
- path = 'imagegen/index.php';
+ host = "http://map2.vis.earthdata.nasa.gov";
+ path = "imagegen/index.php";
}
- url = host + '/' + path + '?';
+ url = host + "/" + path + "?";
if (config.parameters.imagegen) {
- util.warn('Redirecting image download to: ' + url);
+ util.warn("Redirecting image download to: " + url);
}
};
var getUpdatedProps = function() {
@@ -178,7 +178,7 @@ export function imagePanel(models, ui, config, dialogConfig) {
*/
self.show = function() {
alignTo = {
- id: 'wv-image-button'
+ id: "wv-image-button"
};
container = document.getElementById(containerId);
@@ -186,14 +186,14 @@ export function imagePanel(models, ui, config, dialogConfig) {
throw new Error("Error: element '" + containerId + "' not found!");
}
- container.setAttribute('class', 'imagedownload');
+ container.setAttribute("class", "imagedownload");
var $dialog = wvui.getDialog().html(htmlElements);
$dialog.dialog(dialogConfig);
// $("#wv-image-resolution").buttonset();
// $("#wv-image-format").buttonset();
- $('#wv-image-download-button').button();
- $('.ui-dialog').zIndex(600);
+ $("#wv-image-download-button").button();
+ $(".ui-dialog").zIndex(600);
$(window).resize(setPosition);
// Auto-set default resolution to map's current zoom level; round it
@@ -203,7 +203,7 @@ export function imagePanel(models, ui, config, dialogConfig) {
// preserve their existing settings
if (curZoom !== lastZoom) {
lastZoom = curZoom;
- let isGeoProjection = models.proj.selected.id === 'geographic';
+ let isGeoProjection = models.proj.selected.id === "geographic";
imgRes = imageUtilCalculateResolution(
curZoom,
isGeoProjection,
@@ -213,13 +213,13 @@ export function imagePanel(models, ui, config, dialogConfig) {
}
wvui.positionDialog($dialog, {
- my: 'right top',
- at: 'right bottom+5',
- of: '#wv-image-button'
+ my: "right top",
+ at: "right bottom+5",
+ of: "#wv-image-button"
});
- $dialog.dialog('open');
+ $dialog.dialog("open");
- $('.wv-image-coords').show();
+ $(".wv-image-coords").show();
};
self.update = function(c) {
@@ -240,8 +240,8 @@ export function imagePanel(models, ui, config, dialogConfig) {
lonlats = imageUtilGetCoordsFromPixelValues(pixels, map);
- geolonlat1 = olProj.transform(lonlats[0], crs, 'EPSG:4326');
- geolonlat2 = olProj.transform(lonlats[1], crs, 'EPSG:4326');
+ geolonlat1 = olProj.transform(lonlats[0], crs, "EPSG:4326");
+ geolonlat2 = olProj.transform(lonlats[1], crs, "EPSG:4326");
minLon = geolonlat1[0];
maxLon = geolonlat2[0];
@@ -287,10 +287,10 @@ export function imagePanel(models, ui, config, dialogConfig) {
topRightCoordinates
) {
if (x2 - x1 < 150) {
- bottomLeftCoordinates = '';
- topRightCoordinates = '';
+ bottomLeftCoordinates = "";
+ topRightCoordinates = "";
}
- $('#wv-image-top')
+ $("#wv-image-top")
.css({
left: x1 - 10,
top: y1 - 20,
@@ -298,7 +298,7 @@ export function imagePanel(models, ui, config, dialogConfig) {
})
.html(topRightCoordinates);
- $('#wv-image-bottom')
+ $("#wv-image-bottom")
.css({
left: x1,
top: y2,
@@ -327,12 +327,12 @@ export function imagePanel(models, ui, config, dialogConfig) {
};
var setPosition = function() {
- var offset = $('#' + alignTo.id).offset();
+ var offset = $("#" + alignTo.id).offset();
var left =
offset.left +
- parseInt($('#' + alignTo.id).css('width')) -
- parseInt($('#' + id).css('width'));
- $('#' + id).css('left', left + 'px');
+ parseInt($("#" + alignTo.id).css("width")) -
+ parseInt($("#" + id).css("width"));
+ $("#" + id).css("left", left + "px");
};
var createDownloadURL = function(
@@ -349,21 +349,21 @@ export function imagePanel(models, ui, config, dialogConfig) {
time.setUTCHours(0, 0, 0, 0);
layers = imageUtilGetLayers(products, models.proj.selected.id);
// Julian date, padded with two zeros (to ensure the julian date is always in DDD format).
- jStart = util.parseDateUTC(time.getUTCFullYear() + '-01-01');
- jDate = '00' + (1 + Math.ceil((time.getTime() - jStart) / 86400000));
- dlURL += 'TIME=' + time.getUTCFullYear() + jDate.substr(jDate.length - 3);
+ jStart = util.parseDateUTC(time.getUTCFullYear() + "-01-01");
+ jDate = "00" + (1 + Math.ceil((time.getTime() - jStart) / 86400000));
+ dlURL += "TIME=" + time.getUTCFullYear() + jDate.substr(jDate.length - 3);
dlURL +=
- '&extent=' +
+ "&extent=" +
lonlats[0][0] +
- ',' +
+ "," +
lonlats[0][1] +
- ',' +
+ "," +
lonlats[1][0] +
- ',' +
+ "," +
lonlats[1][1];
- dlURL += '&epsg=' + epsg;
- dlURL += '&layers=' + layers.join(',');
- dlURL += '&opacities=' + opacities.join(',');
+ dlURL += "&epsg=" + epsg;
+ dlURL += "&layers=" + layers.join(",");
+ dlURL += "&opacities=" + opacities.join(",");
return dlURL;
};
@@ -384,32 +384,32 @@ export function imagePanel(models, ui, config, dialogConfig) {
imageUtilGetLayerOpacities(products),
url
);
- googleAnalytics.event('Image Download', 'Click', 'Download');
+ googleAnalytics.event("Image Download", "Click", "Download");
util.metrics(
- 'lc=' +
+ "lc=" +
encodeURIComponent(
dlURL +
- '&worldfile=' +
+ "&worldfile=" +
imgWorldfile +
- '&format=' +
+ "&format=" +
imgFormat +
- '&width=' +
+ "&width=" +
imgWidth +
- '&height=' +
+ "&height=" +
imgHeight
)
);
window.open(
dlURL +
- '&worldfile=' +
+ "&worldfile=" +
imgWorldfile +
- '&format=' +
+ "&format=" +
imgFormat +
- '&width=' +
+ "&width=" +
imgWidth +
- '&height=' +
+ "&height=" +
imgHeight,
- '_blank'
+ "_blank"
);
};
diff --git a/web/js/link/ui.js b/web/js/link/ui.js
index 856ad0cb2..2d4def974 100644
--- a/web/js/link/ui.js
+++ b/web/js/link/ui.js
@@ -1,32 +1,32 @@
-import $ from 'jquery';
-import 'jquery-ui/button';
-import 'jquery-ui/dialog';
-import 'icheck';
-import lodashThrottle from 'lodash/throttle';
-import React from 'react';
-import ReactDOM from 'react-dom';
-import Clipboard from 'clipboard';
-import Share from '../components/share/share';
-import googleAnalytics from '../components/util/google-analytics';
+import $ from "jquery";
+import "jquery-ui/button";
+import "jquery-ui/dialog";
+import "icheck";
+import lodashThrottle from "lodash/throttle";
+import React from "react";
+import ReactDOM from "react-dom";
+import Clipboard from "clipboard";
+import Share from "../components/share/share";
+import googleAnalytics from "../components/util/google-analytics";
-import util from '../util/util';
-import wvui from '../ui/ui';
+import util from "../util/util";
+import wvui from "../ui/ui";
export function linkUi(models, config) {
var self = {};
- var id = 'wv-link-button';
- var selector = '#' + id;
+ var id = "wv-link-button";
+ var selector = "#" + id;
var $button, $label;
- var clipboard = new Clipboard('.copy-btn');
+ var clipboard = new Clipboard(".copy-btn");
var init = function() {
- $button = $('<input></input>')
- .attr('type', 'checkbox')
- .attr('id', 'wv-link-button-check');
- $label = $('<label></label>')
- .attr('for', 'wv-link-button-check')
- .attr('title', 'Share this map');
- var $icon = $('<i></i>').addClass('fa fa-share-square-o fa-2x');
+ $button = $("<input></input>")
+ .attr("type", "checkbox")
+ .attr("id", "wv-link-button-check");
+ $label = $("<label></label>")
+ .attr("for", "wv-link-button-check")
+ .attr("title", "Share this map");
+ var $icon = $("<i></i>").addClass("fa fa-share-square-o fa-2x");
$label.append($icon);
$(selector).append($label);
$(selector).append($button);
@@ -35,15 +35,15 @@ export function linkUi(models, config) {
text: false
})
.click(function() {
- var checked = $('#wv-link-button-check').prop('checked');
- googleAnalytics.event('Link', 'Click', 'Share link Button');
+ var checked = $("#wv-link-button-check").prop("checked");
+ googleAnalytics.event("Link", "Click", "Share link Button");
if (checked) {
self.show();
} else {
wvui.closeDialog();
}
});
- models.link.events.on('update', replaceHistoryState);
+ models.link.events.on("update", replaceHistoryState);
};
// Calls toQueryString to fetch updated state and returns URL
@@ -51,9 +51,9 @@ export function linkUi(models, config) {
function() {
if (util.browser.history) {
window.history.replaceState(
- '',
- '@OFFICIAL_NAME@',
- '?' + models.link.toQueryString()
+ "",
+ "@OFFICIAL_NAME@",
+ "?" + models.link.toQueryString()
);
}
},
@@ -67,14 +67,14 @@ export function linkUi(models, config) {
// Facebook: https://developers.facebook.com/docs/sharing/reference/share-dialog#redirect
var facebookUrlParams = function(appId, href, redirectUri, display) {
return (
- 'https://www.facebook.com/dialog/share?' +
- 'app_id=' +
+ "https://www.facebook.com/dialog/share?" +
+ "app_id=" +
encodeURIComponent(appId) +
- '&href=' +
+ "&href=" +
encodeURIComponent(href) +
- '&redirect_uri=' +
+ "&redirect_uri=" +
encodeURIComponent(redirectUri) +
- '&display=' +
+ "&display=" +
encodeURIComponent(display)
);
};
@@ -82,10 +82,10 @@ export function linkUi(models, config) {
// Twitter: https://dev.twitter.com/web/tweet-button/parameters#web-intent-example
var twitterUrlParams = function(url, text) {
return (
- 'https://twitter.com/intent/tweet?' +
- 'url=' +
+ "https://twitter.com/intent/tweet?" +
+ "url=" +
encodeURIComponent(url) +
- '&text=' +
+ "&text=" +
encodeURIComponent(text)
);
};
@@ -93,10 +93,10 @@ export function linkUi(models, config) {
// Reddit: https://www.reddit.com/r/nasa/submit?url=[URL]&title=[TITLE]
var redditUrlParams = function(url, title) {
return (
- 'https://www.reddit.com/r/nasa/submit?' +
- 'url=' +
+ "https://www.reddit.com/r/nasa/submit?" +
+ "url=" +
encodeURIComponent(url) +
- '&title=' +
+ "&title=" +
encodeURIComponent(title)
);
};
@@ -104,27 +104,27 @@ export function linkUi(models, config) {
// Email: mailto:?subject=[SUBJECT]&body=[BODY]
var emailUrlParams = function(subject, body) {
return (
- 'mailto:?' +
- 'subject=' +
+ "mailto:?" +
+ "subject=" +
encodeURIComponent(subject) +
- '&body=' +
+ "&body=" +
encodeURIComponent(body)
);
};
var getSharelink = function(type, url) {
- var shareMessage = 'Check out what I found in NASA Worldview!';
- var twMessage = 'Check out what I found in #NASAWorldview -';
- var emailBody = shareMessage + ' - ' + url;
+ var shareMessage = "Check out what I found in NASA Worldview!";
+ var twMessage = "Check out what I found in #NASAWorldview -";
+ var emailBody = shareMessage + " - " + url;
switch (type) {
- case 'twitter':
+ case "twitter":
return twitterUrlParams(url, twMessage);
- case 'facebook':
- return facebookUrlParams('121285908450463', url, url, 'popup');
- case 'reddit':
+ case "facebook":
+ return facebookUrlParams("121285908450463", url, url, "popup");
+ case "reddit":
return redditUrlParams(url, shareMessage);
- case 'email':
+ case "email":
return emailUrlParams(shareMessage, emailBody);
}
return undefined;
@@ -138,10 +138,10 @@ export function linkUi(models, config) {
var promise = models.link.shorten();
// If a short link can be generated, replace the full link.
- if (type === 'twitter' || type === 'email') {
+ if (type === "twitter" || type === "email") {
win = window;
- if (type === 'twitter') {
- win = window.open('', '_blank');
+ if (type === "twitter") {
+ win = window.open("", "_blank");
}
promise
.done(function(result) {
@@ -153,11 +153,11 @@ export function linkUi(models, config) {
.fail(function() {
href = getSharelink(type, shareLink);
openPromisedSocial(href, win);
- console.warn('Unable to shorten URL, full link generated.');
+ console.warn("Unable to shorten URL, full link generated.");
});
} else {
href = getSharelink(type, shareLink);
- window.open(href, '_blank');
+ window.open(href, "_blank");
}
};
@@ -169,20 +169,20 @@ export function linkUi(models, config) {
"<input type='text' value='' name='permalink_content' id='permalink_content' readonly/>" +
"<span class='input-group-button hide-icon' data-balloon-visible data-tooltip='Copied!' data-tooltip-pos='up' data-tooltip-length='xsmall'>" +
"<button title='Copy to clipboard' class='copy-btn' data-clipboard-target='#permalink_content'>COPY</button>" +
- '</span>' +
- '</div>';
+ "</span>" +
+ "</div>";
if (config.features.urlShortening) {
item +=
"<span autofocus></span><div id='wv-link-shorten'>" +
"<input type='checkbox' value='' id='wv-link-shorten-check' />" +
"<label id='wv-link-shorten-label' for='wv-link-shorten-check'>Shorten link</label>" +
- '</div>';
+ "</div>";
}
- item += '</div>';
+ item += "</div>";
- var dialogWidth = '300';
+ var dialogWidth = "300";
if (util.browser.small) {
- dialogWidth = '242';
+ dialogWidth = "242";
}
var Widget = self.initWidget();
@@ -193,64 +193,64 @@ export function linkUi(models, config) {
// If selected during the animation, the cursor will go to the
// end of the input box
var updateLink = function() {
- $('#permalink_content').val(models.link.get());
- $('#wv-link-shorten-check').iCheck('uncheck');
- $('#permalink_content').focus();
- $('#permalink_content').select();
+ $("#permalink_content").val(models.link.get());
+ $("#wv-link-shorten-check").iCheck("uncheck");
+ $("#permalink_content").focus();
+ $("#permalink_content").select();
};
- models.link.events.on('update', updateLink);
+ models.link.events.on("update", updateLink);
$dialog
.dialog({
- dialogClass: 'wv-panel wv-link-panel',
- title: 'Copy link to share:',
+ dialogClass: "wv-panel wv-link-panel",
+ title: "Copy link to share:",
show: {
- effect: 'slide',
- direction: 'up'
+ effect: "slide",
+ direction: "up"
},
width: dialogWidth,
- height: 'auto',
+ height: "auto",
minHeight: 10,
draggable: false,
resizable: false,
autoOpen: false
})
- .on('dialogcreate', $dialog.prepend(item))
- .on('dialogclose', function() {
- $('#wv-link-button-check').prop('checked', false);
- $button.button('refresh');
- models.link.events.off('update', updateLink);
+ .on("dialogcreate", $dialog.prepend(item))
+ .on("dialogclose", function() {
+ $("#wv-link-button-check").prop("checked", false);
+ $button.button("refresh");
+ models.link.events.off("update", updateLink);
});
if (util.browser.small) {
wvui.positionDialog($dialog, {
- my: 'right top',
- at: 'right-58 bottom+5',
- of: '#wv-toolbar'
+ my: "right top",
+ at: "right-58 bottom+5",
+ of: "#wv-toolbar"
});
} else {
wvui.positionDialog($dialog, {
- my: 'right top',
- at: 'right bottom+5',
+ my: "right top",
+ at: "right bottom+5",
of: $label
});
}
- $('.ui-dialog').zIndex(600);
+ $(".ui-dialog").zIndex(600);
- $('#permalink_content').val(models.link.get());
- $dialog.dialog('open');
+ $("#permalink_content").val(models.link.get());
+ $dialog.dialog("open");
setTimeout(updateLink, 500);
- $('#wv-link-shorten-check').on('change', function() {
- var checked = $('#wv-link-shorten-check').prop('checked');
+ $("#wv-link-shorten-check").on("change", function() {
+ var checked = $("#wv-link-shorten-check").prop("checked");
if (checked) {
var promise = models.link.shorten();
- googleAnalytics.event('Link', 'Check', 'Shorten');
- $('#permalink_content').val('Please wait...');
+ googleAnalytics.event("Link", "Check", "Shorten");
+ $("#permalink_content").val("Please wait...");
promise
.done(function(result) {
if (result.status_code === 200) {
- $('#permalink_content').val(result.data.url);
+ $("#permalink_content").val(result.data.url);
} else {
error(result.status_code, result.status_txt);
}
@@ -259,48 +259,48 @@ export function linkUi(models, config) {
error(textStatus, errorThrown);
});
} else {
- $('#permalink_content').val(models.link.get());
- googleAnalytics.event('Link', 'Check', 'Lengthen');
+ $("#permalink_content").val(models.link.get());
+ googleAnalytics.event("Link", "Check", "Lengthen");
}
- $('#permalink_content').focus();
- $('#permalink_content').select();
+ $("#permalink_content").focus();
+ $("#permalink_content").select();
});
var error = function() {
- console.warn('Unable to shorten URL');
+ console.warn("Unable to shorten URL");
console.warn.apply(console, arguments);
wvui.notify(
- 'Unable to shorten the permalink at this time. ' +
- 'Please try again later.'
+ "Unable to shorten the permalink at this time. " +
+ "Please try again later."
);
};
- $('#wv-link-shorten-check').prop('checked', false);
+ $("#wv-link-shorten-check").prop("checked", false);
- clipboard.on('success', function(e) {
+ clipboard.on("success", function(e) {
e.clearSelection();
- $('.wv-link .input-group-button').removeClass('hide-icon');
+ $(".wv-link .input-group-button").removeClass("hide-icon");
setTimeout(function() {
- $('.wv-link .input-group-button').addClass('hide-icon');
+ $(".wv-link .input-group-button").addClass("hide-icon");
}, 1000);
});
- clipboard.on('error', function(e) {
- console.error('Link could not be copied!');
- console.error('Action:', e.action);
- console.error('Trigger:', e.trigger);
+ clipboard.on("error", function(e) {
+ console.error("Link could not be copied!");
+ console.error("Action:", e.action);
+ console.error("Trigger:", e.trigger);
});
};
self.initWidget = function() {
return React.createElement(Share, {
clickFunction: clickFunction,
- fbLink: '#',
- twLink: '#',
- rdLink: '#',
- emailLink: '#'
+ fbLink: "#",
+ twLink: "#",
+ rdLink: "#",
+ emailLink: "#"
});
};
diff --git a/web/js/map/datelinebuilder.js b/web/js/map/datelinebuilder.js
index a01da6f57..1f218bddb 100644
--- a/web/js/map/datelinebuilder.js
+++ b/web/js/map/datelinebuilder.js
@@ -1,10 +1,10 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import OlOverlay from 'ol/overlay';
+import React from "react";
+import ReactDOM from "react-dom";
+import OlOverlay from "ol/overlay";
-import util from '../util/util';
-import DateLine from '../components/dateline/dateline';
-import LineText from '../components/dateline/text';
+import util from "../util/util";
+import DateLine from "../components/dateline/dateline";
+import LineText from "../components/dateline/text";
var map,
overlay1,
@@ -38,7 +38,7 @@ export function mapDateLineBuilder(models, config) {
drawDatelines(map, date);
proj = models.proj.selected.id;
- Parent.events.on('moveend', function() {
+ Parent.events.on("moveend", function() {
if (!isGeoProjection()) {
return;
}
@@ -46,27 +46,27 @@ export function mapDateLineBuilder(models, config) {
dimensions = position(map);
update(dimensions);
});
- Parent.events.on('drag', function() {
+ Parent.events.on("drag", function() {
if (!isGeoProjection()) {
return;
}
updateLineVisibility(false);
});
- Parent.events.on('movestart', function() {
+ Parent.events.on("movestart", function() {
if (!isGeoProjection()) {
return;
}
updateLineVisibility(false);
});
- models.date.events.on('select', function() {
+ models.date.events.on("select", function() {
updateDate(models.date[models.date.activeDate]);
});
- models.proj.events.on('select', function() {
+ models.proj.events.on("select", function() {
proj = models.proj.selected.id;
});
};
var isGeoProjection = function() {
- if (proj === 'geographic') {
+ if (proj === "geographic") {
return true;
}
return false;
@@ -124,7 +124,7 @@ export function mapDateLineBuilder(models, config) {
*/
var setTextDefaults = function(ReactComponent, reactCase, date) {
var props = {
- dateLeft: util.toISOStringDate(util.dateAdd(date, 'day', 1)),
+ dateLeft: util.toISOStringDate(util.dateAdd(date, "day", 1)),
dateRight: util.toISOStringDate(date)
};
return ReactDOM.render(
@@ -164,10 +164,10 @@ export function mapDateLineBuilder(models, config) {
var drawDatelines = function(map, date) {
var height, leftLineCase, rightLineCase, leftTextCase, rightTextCase;
- leftLineCase = document.createElement('div');
- rightLineCase = document.createElement('div');
- leftTextCase = document.createElement('div');
- rightTextCase = document.createElement('div');
+ leftLineCase = document.createElement("div");
+ rightLineCase = document.createElement("div");
+ leftTextCase = document.createElement("div");
+ rightTextCase = document.createElement("div");
height = 0;
overlay1 = drawOverlay([-180, 90], leftLineCase);
@@ -184,7 +184,7 @@ export function mapDateLineBuilder(models, config) {
textRight = setTextDefaults(
LineText,
rightTextCase,
- util.dateAdd(date, 'day', -1)
+ util.dateAdd(date, "day", -1)
);
lineLeft = setLineDefaults(
DateLine,
@@ -256,12 +256,12 @@ export function mapDateLineBuilder(models, config) {
var updateDate = function(date) {
var leftState, rightState;
leftState = {
- dateLeft: util.toISOStringDate(util.dateAdd(date, 'day', 1)),
+ dateLeft: util.toISOStringDate(util.dateAdd(date, "day", 1)),
dateRight: util.toISOStringDate(date)
};
rightState = {
dateLeft: util.toISOStringDate(date),
- dateRight: util.toISOStringDate(util.dateAdd(date, 'day', -1))
+ dateRight: util.toISOStringDate(util.dateAdd(date, "day", -1))
};
textLeft.setState(leftState);
textRight.setState(rightState);