Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

refactor coordinate display to react, add top level react component

Mike McGann23a8419172bd
diff --git a/package.json b/package.json
index 0c4a469be..b63ed8355 100644
--- a/package.json
+++ b/package.json
@@ -84,6 +84,7 @@
"cheerio": "^1.0.0-rc.2",
"chromedriver": "2.25.1",
"clean-webpack-plugin": "^0.1.19",
+ "copy-webpack-plugin": "^4.5.2",
"cross-env": "^5.2.0",
"css-hot-loader": "^1.4.1",
"css-loader": "^1.0.0",
@@ -199,5 +200,8 @@
"transformIgnorePatterns": [
"node_modules/(?!(ol)/)"
]
+ },
+ "prettier": {
+ "singleQuote": true
}
}
diff --git a/web/css/map.css b/web/css/map.css
index 90a6ec2bb..0102226dc 100644
--- a/web/css/map.css
+++ b/web/css/map.css
@@ -144,7 +144,6 @@
border: none;
border-radius: 0;
background: none;
- display: none;
cursor: pointer;
height: 35px;
padding: 0 0 0 5px;
@@ -164,7 +163,6 @@
}
.wv-coords-map span.map-coord {
- display: none !important;
line-height: 35px;
float: left;
height: 35px;
@@ -209,3 +207,4 @@
background: url("../images/map/latlon.png") no-repeat;
background-position: -14px;
}
+
diff --git a/web/index.html b/web/index.html
index 627cad896..c5324ece7 100644
--- a/web/index.html
+++ b/web/index.html
@@ -46,64 +46,6 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
<body>
<div data-role="page" id="app">
- <div data-role="content">
- <ul id="wv-toolbar">
- <li id="wv-link-button" class="wv-toolbar-button"></li>
- <li id="wv-proj-button" class="wv-toolbar-button"></li>
- <li id="wv-image-button" class="wv-toolbar-button"></li>
- <li id="wv-info-button" class="wv-toolbar-button wv-status-hide"></li>
- </ul>
- <section id="wv-sidebar">
- </section>
- <div id="wv-map" class="wv-map"></div>
- <div id="eventsHolder"></div>
- <div id="imagedownload"></div>
- <div id="dlMap"></div>
-
- <div id="timewheels" style="display:none"></div>
-
- <section id="timeline" class="timeline-inner clearfix" style="display: none">
- <div id="timeline-header">
- <div id="date-selector-main"></div>
- <div id="zoom-buttons-group">
- <div id="zoom-btn-container">
- <span id="current-zoom" class="zoom-btn zoom-btn-active" data-zoom="3">Days</span>
- <div class="wv-tooltip">
- <div id="timeline-zoom" class="timeline-zoom">
- <span id="zoom-years" class="zoom-btn zoom-btn-inactive zoom-years" data-zoom="1">Years</span>
- <span id="zoom-months" class="zoom-btn zoom-btn-inactive zoom-months" data-zoom="2">Months</span>
- <span id="zoom-days" class="zoom-btn zoom-btn-inactive zoom-days" data-zoom="3">Days</span>
- <span id="zoom-minutes" class="zoom-btn zoom-btn-inactive zoom-minutes" data-zoom="4">Minutes</span>
- </div>
- </div>
- </div>
- <div class="button-action-group" id="left-arrow-group" title="Click and hold to animate backwards">
- <svg id="timeline-svg" width="24" height="30">
- <path d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z" class="arrow"></path>
- </svg>
- </div>
- <div class="button-action-group" id="right-arrow-group" title="Click and hold to animate forwards">
- <svg width="24" height="30">
- <path d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z" class="arrow"></path>
- </svg>
- </div>
- </div>
- <div class="button-action-group animate-button" id="animate-button" title="Set up animation">
- <i id="wv-animate" class="fa fa-video-camera wv-animate"></i>
- </div>
-
- </div>
- <div id="timeline-footer">
- <div id="wv-animation-widet-case"> </div>
- </div>
- <div id="timeline-hide">
- <svg class="hamburger" width="10" height="9">
- <path d="M 0,0 0,1 10,1 10,0 0,0 z M 0,4 0,5 10,5 10,4 0,4 z M 0,8 0,9 10,9 10,8 0,8 z"></path>
- </svg>
- </div>
- </section>
-
- </div>
</div>
<section id="layer-modal" class="layer-modal">
<header id="layer-modal-header" class="layer-modal-header"></header>
diff --git a/web/js/app.js b/web/js/app.js
new file mode 100644
index 000000000..7d881ac6e
--- /dev/null
+++ b/web/js/app.js
@@ -0,0 +1,579 @@
+import React from 'react';
+
+import 'babel-polyfill'; // Needed for worldview-components in IE and older browsers
+import $ from 'jquery';
+import lodashEach from 'lodash/each';
+import googleAnalytics from './components/util/google-analytics';
+
+// Utils
+import util from './util/util';
+
+// Date
+import { parse as dateParser } from './date/date';
+import { dateModel } from './date/model';
+import { dateLabel } from './date/label';
+import dateWheels from './date/wheels';
+
+// Timeline
+import { timeline } from './date/timeline';
+import { timelineData } from './date/timeline-data';
+import { timelineConfig } from './date/config';
+import { timelineZoom } from './date/timeline-zoom';
+import { timelineTicks } from './date/timeline-ticks';
+import { timelinePick } from './date/timeline-pick';
+import { timelinePan } from './date/timeline-pan';
+import { timelineInput } from './date/timeline-input';
+import { timelineCompare } from './date/compare-picks';
+
+// Layers
+import {
+ parse as layerParser,
+ validate as layerValidate
+} from './layers/layers';
+import { layersModel } from './layers/model';
+import { layersModal } from './layers/modal';
+
+import { layersActive } from './layers/active';
+
+import { sidebarUi } from './sidebar/ui';
+
+// Map
+import { mapParser } from './map/map';
+import { mapModel } from './map/model';
+import { mapui } from './map/ui';
+import { MapRotate } from './map/rotation';
+import { MapRunningData } from './map/runningdata';
+import { mapLayerBuilder } from './map/layerbuilder';
+import { mapDateLineBuilder } from './map/datelinebuilder';
+import { mapPrecacheTile } from './map/precachetile';
+import { mapAnimate } from './map/animate';
+import OlCoordinates from './components/map/ol-coordinates';
+
+// Animation
+import { parse as animationParser } from './animation/anim';
+import { animationModel } from './animation/model';
+import { animationUi } from './animation/ui';
+import { animationWidget } from './animation/widget';
+import { animationRangeSelect } from './animation/range-select';
+import { animationGif } from './animation/gif';
+
+// Palettes
+import palettes from './palettes/palettes';
+import { palettesModel } from './palettes/model';
+
+// Data
+import { dataParser } from './data/data';
+import { dataModel } from './data/model';
+import { dataUi } from './data/ui';
+
+// NaturalEvents
+import naturalEventsModel from './natural-events/model';
+import naturalEventsUI from './natural-events/ui';
+import naturalEventsRequest from './natural-events/request';
+
+// Image
+import { imageRubberband } from './image/rubberband';
+import { imagePanel } from './image/panel';
+
+// Notifications
+import { notificationsUi } from './notifications/ui';
+
+// UI
+import loadingIndicator from './ui/indicator';
+
+// Link
+import { linkModel } from './link/model';
+import { linkUi } from './link/ui';
+
+// Projections
+import { parse as projectionParser } from './projection/projection';
+import { projectionModel } from './projection/model';
+import { projectionUi } from './projection/ui';
+
+// A|B comparison
+import { compareModel } from './compare/model';
+// Other
+import { debugConfig, debugLayers } from './debug';
+import Brand from './brand';
+import tour from './tour';
+import { uiInfo } from './ui/info';
+
+// Dependency CSS
+import '../../node_modules/bootstrap/dist/css/bootstrap.css';
+import 'font-awesome-webpack';
+import '../../node_modules/jquery-ui-bundle/jquery-ui.structure.css';
+import '../../node_modules/jquery-ui-bundle/jquery-ui.theme.css';
+import '../../node_modules/icheck/skins/square/grey.css';
+import '../../node_modules/icheck/skins/square/red.css';
+import '../../node_modules/icheck/skins/line/red.css';
+import '../../node_modules/jscrollpane/style/jquery.jscrollpane.css';
+import '../../node_modules/perfect-scrollbar/dist/css/perfect-scrollbar.css';
+import '../ext/mobiscroll-2.6.0/mobiscroll.css';
+import '../../node_modules/jquery.joyride/jquery.joyride.css';
+import '../../node_modules/jquery-jcrop/css/jquery.Jcrop.css';
+import '../../node_modules/ol/ol.css';
+import '../../node_modules/nouislider/src/jquery.nouislider.css';
+import '../../node_modules/simplebar/dist/simplebar.css';
+
+// App CSS
+import '../css/fonts.css';
+import '../css/reset.css';
+import '../css/compare.css';
+import '../css/jquery-ui-override.css';
+import '../css/util.css';
+import '../css/toolbar.css';
+import '../css/alert.css';
+import '../css/sidebar-panel.css';
+import '../css/button.css';
+import '../css/checkbox.css';
+import '../css/map.css';
+import '../css/link.css';
+import '../css/palettes.css';
+import '../css/image.css';
+import '../css/debug.css';
+import '../css/projection.css';
+import '../css/date.css';
+import '../css/menuPicker.css';
+import '../css/tour.css';
+import '../css/products.css';
+import '../css/indicator.css';
+import '../css/events.css';
+import '../css/dataDownload.css';
+import '../css/sidebar.css';
+import '../css/layers.css';
+import '../css/scrollbar.css';
+import '../css/timeline.css';
+import '../css/anim.widget.css';
+import '../css/dateselector.css';
+import '../css/tooltip.css';
+import '../css/mobile.css';
+import '../pages/css/document.css';
+
+import { polyfill } from './polyfill';
+polyfill(); // Polyfills some browser features
+
+class App extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ maps: null
+ };
+ this.onload();
+ }
+
+ render() {
+ return (
+ <div data-role="content">
+ <ul id="wv-toolbar">
+ <li id="wv-link-button" className="wv-toolbar-button" />
+ <li id="wv-proj-button" className="wv-toolbar-button" />
+ <li id="wv-image-button" className="wv-toolbar-button" />
+ <li
+ id="wv-info-button"
+ className="wv-toolbar-button wv-status-hide"
+ />
+ </ul>
+ <section id="wv-sidebar" />
+ <div id="wv-map" className="wv-map" />
+ <div id="eventsHolder" />
+ <div id="imagedownload" />
+ <div id="dlMap" />
+
+ <div id="timewheels" style={{ display: 'none' }} />
+
+ <section
+ id="timeline"
+ className="timeline-inner clearfix"
+ style={{ display: 'none' }}
+ >
+ <div id="timeline-header">
+ <div id="date-selector-main" />
+ <div id="zoom-buttons-group">
+ <div id="zoom-btn-container">
+ <span
+ id="current-zoom"
+ className="zoom-btn zoom-btn-active"
+ data-zoom="3"
+ >
+ Days
+ </span>
+ <div className="wv-tooltip">
+ <div id="timeline-zoom" className="timeline-zoom">
+ <span
+ id="zoom-years"
+ className="zoom-btn zoom-btn-inactive zoom-years"
+ data-zoom="1"
+ >
+ Years
+ </span>
+ <span
+ id="zoom-months"
+ className="zoom-btn zoom-btn-inactive zoom-months"
+ data-zoom="2"
+ >
+ Months
+ </span>
+ <span
+ id="zoom-days"
+ className="zoom-btn zoom-btn-inactive zoom-days"
+ data-zoom="3"
+ >
+ Days
+ </span>
+ <span
+ id="zoom-minutes"
+ className="zoom-btn zoom-btn-inactive zoom-minutes"
+ data-zoom="4"
+ >
+ Minutes
+ </span>
+ </div>
+ </div>
+ </div>
+ <div
+ className="button-action-group"
+ id="left-arrow-group"
+ title="Click and hold to animate backwards"
+ >
+ <svg id="timeline-svg" width="24" height="30">
+ <path
+ d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"
+ className="arrow"
+ />
+ </svg>
+ </div>
+ <div
+ className="button-action-group"
+ id="right-arrow-group"
+ title="Click and hold to animate forwards"
+ >
+ <svg width="24" height="30">
+ <path
+ d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"
+ className="arrow"
+ />
+ </svg>
+ </div>
+ </div>
+ <div
+ className="button-action-group animate-button"
+ id="animate-button"
+ title="Set up animation"
+ >
+ <i id="wv-animate" className="fa fa-video-camera wv-animate" />
+ </div>
+ </div>
+ <div id="timeline-footer">
+ <div id="wv-animation-widet-case"> </div>
+ </div>
+ <div id="timeline-hide">
+ <svg className="hamburger" width="10" height="9">
+ <path d="M 0,0 0,1 10,1 10,0 0,0 z M 0,4 0,5 10,5 10,4 0,4 z M 0,8 0,9 10,9 10,8 0,8 z" />
+ </svg>
+ </div>
+ </section>
+ <OlCoordinates maps={this.state.maps} />
+ </div>
+ );
+ }
+
+ onload() {
+ const self = this;
+ var errors = [];
+ var requirements;
+ var startTime;
+ var wvx = {};
+ var config;
+ var parsers;
+ var state = util.fromQueryString(location.search);
+ var parameters = util.fromQueryString(location.search);
+
+ var main = function() {
+ if (parameters.elapsed) {
+ startTime = new Date().getTime();
+ } else {
+ elapsed = function() {};
+ }
+ elapsed('start');
+ loadConfig();
+ };
+
+ var loadConfig = function() {
+ elapsed('loading config');
+ var configURI = Brand.url('config/wv.json');
+ var promise = $.getJSON(configURI);
+ promise.done(util.wrap(onConfigLoaded)).fail(util.error);
+ loadingIndicator.delayed(promise, 1000);
+ };
+
+ var onConfigLoaded = function(data) {
+ elapsed('config loaded');
+ config = data;
+ config.parameters = parameters;
+
+ // Attach to wvx object for debugging
+ wvx.config = config;
+
+ debugConfig(config);
+
+ // Load any additional scripts as needed
+ if (config.scripts) {
+ lodashEach(config.scripts, function(script) {
+ $.getScript(script);
+ });
+ }
+
+ layerValidate(errors, config);
+
+ parsers = [
+ projectionParser,
+ layerParser,
+ dateParser,
+ mapParser,
+ palettes.parse
+ ];
+ if (config.features.dataDownload) {
+ parsers.push(dataParser);
+ }
+ if (config.features.animation) {
+ parsers.push(animationParser);
+ }
+ lodashEach(parsers, function(parser) {
+ parser(state, errors, config);
+ });
+ requirements = [palettes.requirements(state, config)];
+
+ $.when
+ .apply(null, requirements)
+ .then(util.wrap(init))
+ .fail(util.error);
+ };
+
+ var init = function() {
+ elapsed('init');
+ // If at the beginning of the day, wait on the previous day until GIBS
+ // catches up (about three hours)
+ var initialDate;
+ if (config.defaults.startDate) {
+ initialDate = util.parseDateUTC(config.defaults.startDate);
+ } else {
+ initialDate = util.now();
+ if (initialDate.getUTCHours() < 3) {
+ initialDate.setUTCDate(initialDate.getUTCDate() - 1);
+ }
+ }
+
+ // Models
+ var models = {
+ wv: {
+ events: util.events()
+ }
+ };
+ var ui = {};
+ // Attach to wvx object for debugging
+ wvx.models = models;
+ wvx.ui = ui;
+
+ models.proj = projectionModel(config);
+ models.palettes = palettesModel(models, config);
+ models.layers = layersModel(models, config);
+ models.date = dateModel(models, config, {
+ initial: initialDate
+ });
+ models.map = mapModel(models, config);
+ models.link = linkModel(config);
+ if (config.features.compare) {
+ models.compare = compareModel(models, config);
+ models.link.register(models.compare);
+ }
+ models.link
+ .register(models.proj)
+ .register(models.layers)
+ .register(models.date)
+ .register(models.palettes)
+ .register(models.map);
+ models.link.load(state);
+ if (config.features.googleAnalytics) {
+ googleAnalytics.init(config.features.googleAnalytics.id); // Insert google tracking
+ }
+
+ // HACK: Map needs to be created before the data download model
+ var mapComponents = {
+ Rotation: MapRotate,
+ Runningdata: MapRunningData,
+ Layerbuilder: mapLayerBuilder,
+ Dateline: mapDateLineBuilder,
+ Precache: mapPrecacheTile
+ };
+ ui.map = mapui(models, config, mapComponents);
+ self.setState({
+ maps: ui.map.proj
+ });
+ ui.map.animate = mapAnimate(models, config, ui);
+ if (config.features.animation) {
+ models.anim = animationModel(models, config);
+ models.link.register(models.anim);
+ }
+ if (config.features.dataDownload) {
+ models.data = dataModel(models, config);
+ models.link.register(models.data);
+ }
+ if (config.features.naturalEvents) {
+ models.naturalEvents = naturalEventsModel(models, config, ui);
+ models.link.register(models.naturalEvents);
+ }
+ // HACK: Map needs permalink state loaded before starting. But
+ // data download now needs it too.
+ models.link.load(state); // needs to be loaded twice
+
+ elapsed('ui');
+ // Create widgets
+ ui.proj = projectionUi(models, config);
+ ui.tour = tour(models, ui, config);
+ ui.sidebar = sidebarUi(models, config, ui);
+ ui.activeLayers = layersActive(models, ui, config);
+ ui.addModal = layersModal(models, ui, config);
+
+ // Test via a getter in the options object to see if the passive property is accessed
+ ui.supportsPassive = false;
+ try {
+ var opts = Object.defineProperty({}, 'passive', {
+ get: function() {
+ ui.supportsPassive = true;
+ }
+ });
+ window.addEventListener('testPassive', null, opts);
+ window.removeEventListener('testPassive', null, opts);
+ } catch (e) {}
+
+ function timelineInit() {
+ ui.timeline = timeline(models, config, ui);
+ ui.timeline.data = timelineData(models, config, ui);
+ ui.timeline.zoom = timelineZoom(models, config, ui);
+ ui.timeline.ticks = timelineTicks(models, config, ui);
+ ui.timeline.pick = timelinePick(models, config, ui);
+ ui.timeline.pan = timelinePan(models, config, ui);
+ ui.timeline.config = timelineConfig(models, config, ui);
+ ui.timeline.input = timelineInput(models, config, ui);
+ if (config.features.animation) {
+ ui.anim = {};
+ ui.anim.rangeselect = animationRangeSelect(models, config, ui); // SETS STATE: NEEDS TO LOAD BEFORE ANIMATION WIDGET
+ ui.anim.widget = animationWidget(models, config, ui);
+ ui.anim.gif = animationGif(models, config, ui);
+ ui.anim.ui = animationUi(models, ui);
+ }
+ if (config.features.compare) {
+ ui.timeline.compare = timelineCompare(models, config, ui);
+ }
+
+ ui.dateLabel = dateLabel(models);
+ }
+ if (config.startDate) {
+ if (!util.browser.small) {
+ // If mobile device, do not build timeline
+ timelineInit();
+ }
+ ui.dateWheels = dateWheels(models, config);
+ }
+
+ ui.rubberband = imageRubberband(models, ui, config);
+ ui.image = imagePanel(models, ui, config);
+ if (config.features.dataDownload) {
+ ui.data = dataUi(models, ui, config);
+ }
+ if (config.features.naturalEvents) {
+ var request = naturalEventsRequest(models, ui, config);
+ ui.naturalEvents = naturalEventsUI(models, ui, config, request);
+ }
+ ui.link = linkUi(models, config);
+ ui.info = uiInfo(ui, config);
+ if (config.features.alert) {
+ ui.alert = notificationsUi(ui, config);
+ }
+
+ // FIXME: Old hack
+ $(window).resize(function() {
+ if (util.browser.small) {
+ $('#productsHoldertabs li.first a').trigger('click');
+ }
+ if (!ui.timeline) {
+ timelineInit();
+ }
+ });
+
+ document.activeElement.blur();
+ $('input').blur();
+ $('#eventsHolder').hide();
+
+ if (config.features.dataDownload) {
+ models.data.events.on('queryResults', function() {
+ ui.data.onViewChange();
+ });
+ ui.map.events.on('extent', function() {
+ ui.data.onViewChange();
+ });
+ // FIXME: This is a hack
+ models.map.events.on('projection', models.data.updateProjection);
+ }
+ // Sink all focus on inputs if click unhandled
+ $(document).click(function(event) {
+ if (event.target.nodeName !== 'INPUT') {
+ $('input').blur();
+ }
+ });
+
+ // Console notifications
+ if (Brand.release()) {
+ console.info(
+ Brand.NAME +
+ ' - Version ' +
+ Brand.VERSION +
+ ' - ' +
+ Brand.BUILD_TIMESTAMP
+ );
+ } else {
+ console.warn('Development version');
+ }
+ debugLayers(ui, models, config);
+
+ errorReport();
+
+ models.wv.events.trigger('startup');
+ elapsed('done');
+
+ // Reset Worldview when clicking on logo
+ $(document).click(function(e) {
+ if (e.target.id === 'wv-logo') resetWorldview(e);
+ });
+ };
+
+ var resetWorldview = function(e) {
+ e.preventDefault();
+ if (window.location.search === '') return; // Nothing to reset
+ var msg =
+ 'Do you want to reset Worldview to its defaults? You will lose your current state.';
+ if (confirm(msg)) document.location.href = '/';
+ };
+
+ var errorReport = function() {
+ var layersRemoved = 0;
+
+ lodashEach(errors, function(error) {
+ var cause = error.cause ? ': ' + error.cause : '';
+ util.warn(error.message + cause);
+ if (error.layerRemoved) {
+ layersRemoved = layersRemoved + 1;
+ }
+ });
+ };
+
+ var elapsed = function(message) {
+ if (!parameters.elapsed) return;
+ var t = new Date().getTime() - startTime;
+ console.log(t, message);
+ };
+ util.wrap(main)();
+ }
+}
+
+export default App;
diff --git a/web/js/components/map/coordinates.js b/web/js/components/map/coordinates.js
new file mode 100644
index 000000000..1b589eed3
--- /dev/null
+++ b/web/js/components/map/coordinates.js
@@ -0,0 +1,57 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import util from '../../util/util';
+
+// previous : next
+const formatOrder = {
+ 'latlon-dd': 'latlon-dm',
+ 'latlon-dm': 'latlon-dms',
+ 'latlon-dms': 'latlon-dd'
+};
+
+class Coordinates extends React.Component {
+ constructor(props) {
+ super(props);
+ this.changeFormat = this.changeFormat.bind(this);
+ }
+
+ changeFormat(event) {
+ let thisFormat = this.props.format;
+ let nextFormat = formatOrder[thisFormat];
+ this.props.onFormatChange(nextFormat);
+ }
+
+ render() {
+ if (this.props.latitude === null) {
+ return null;
+ }
+ if (this.props.longitude === null) {
+ return null;
+ }
+
+ let coords = util.formatCoordinate(
+ [this.props.longitude, this.props.latitude],
+ this.props.format
+ );
+
+ return (
+ <div className='wv-coords-map wv-coords-map-btn'
+ onClick={this.changeFormat}>
+ <span className='map-coord'>{coords} {this.props.crs}</span>
+ <div className='coord-btn'>
+ <i className='coord-switch'/>
+ </div>
+ </div>
+ );
+ }
+}
+
+Coordinates.propTypes = {
+ format: PropTypes.string,
+ latitude: PropTypes.number,
+ longitude: PropTypes.number,
+ crs: PropTypes.string,
+ onFormatChange: PropTypes.func.isRequired
+};
+
+export default Coordinates;
diff --git a/web/js/components/map/ol-coordinates.js b/web/js/components/map/ol-coordinates.js
new file mode 100644
index 000000000..19d06004f
--- /dev/null
+++ b/web/js/components/map/ol-coordinates.js
@@ -0,0 +1,106 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import Coordinates from './coordinates';
+import util from '../../util/util';
+import olProj from 'ol/proj';
+import throttle from 'lodash/throttle';
+
+class OlCoordinates extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ latitude: null,
+ longitude: null,
+ crs: null,
+ format: null
+ };
+ this.mouseMove = throttle(this.mouseMove, 100).bind(this);
+ this.mouseOut = this.mouseOut.bind(this);
+ this.changeFormat = this.changeFormat.bind(this);
+ }
+
+ componentDidUpdate(prevProps) {
+ if (this.props.maps && prevProps.maps !== this.props.maps) {
+ this.registerMouseListeners();
+ }
+ }
+
+ registerMouseListeners() {
+ Object.values(this.props.maps).forEach(map => {
+ let target = map.getTarget();
+ let mapElement = document.getElementById(target);
+ let crs = map.getView().getProjection().getCode();
+ mapElement.addEventListener('mousemove', event =>
+ this.mouseMove(map, crs, event)
+ );
+ mapElement.addEventListener('mouseout', this.mouseOut);
+ });
+ }
+
+ mouseMove(map, crs, event) {
+ let pixels = map.getEventPixel(event);
+ let coord = map.getCoordinateFromPixel(pixels);
+ if (!coord) {
+ this.clearCoord();
+ return;
+ }
+
+ let pcoord = olProj.transform(coord, crs, 'EPSG:4326');
+ let [lon, lat] = pcoord;
+ if (lon < -180 || lon > 180 || lat < -90 || lat > 90) {
+ this.clearCoord();
+ return;
+ }
+
+ this.setState({
+ format: util.getCoordinateFormat(),
+ latitude: pcoord[0],
+ longitude: pcoord[1],
+ crs
+ });
+ }
+
+ mouseOut(event) {
+ // Ignore when the mouse goes over the coordinate display. Clearing
+ // the coordinates in this situation causes a flicker.
+ if (event.relatedTarget) {
+ let element = event.relatedTarget;
+ if (element.classList.contains('map-coord')) {
+ return;
+ }
+ }
+ this.clearCoord();
+ }
+
+ clearCoord() {
+ this.setState({ latitude: null, longitude: null });
+ }
+
+ changeFormat(format) {
+ util.setCoordinateFormat(format);
+ this.setState({ format });
+ }
+
+ render() {
+ // if mobile return
+ if (util.browser.small) {
+ return;
+ }
+
+ return (
+ <Coordinates
+ format={this.state.format}
+ latitude={this.state.latitude}
+ longitude={this.state.longitude}
+ crs={this.state.crs}
+ onFormatChange={this.changeFormat}
+ />
+ );
+ }
+}
+
+OlCoordinates.propTypes = {
+ maps: PropTypes.object
+};
+
+export default OlCoordinates;
diff --git a/web/js/main.js b/web/js/main.js
index 0747a5ac9..e8c37df8b 100644
--- a/web/js/main.js
+++ b/web/js/main.js
@@ -1,445 +1,8 @@
-import 'babel-polyfill'; // Needed for worldview-components in IE and older browsers
-import $ from 'jquery';
-import lodashEach from 'lodash/each';
-import googleAnalytics from './components/util/google-analytics';
-
-// Utils
-import util from './util/util';
-
-// Date
-import { parse as dateParser } from './date/date';
-import { dateModel } from './date/model';
-import { dateLabel } from './date/label';
-import dateWheels from './date/wheels';
-
-// Timeline
-import { timeline } from './date/timeline';
-import { timelineData } from './date/timeline-data';
-import { timelineConfig } from './date/config';
-import { timelineZoom } from './date/timeline-zoom';
-import { timelineTicks } from './date/timeline-ticks';
-import { timelinePick } from './date/timeline-pick';
-import { timelinePan } from './date/timeline-pan';
-import { timelineInput } from './date/timeline-input';
-import { timelineCompare } from './date/compare-picks';
-
-// Layers
-import {
- parse as layerParser,
- validate as layerValidate
-} from './layers/layers';
-import { layersModel } from './layers/model';
-import { layersModal } from './layers/modal';
-
-import { layersActive } from './layers/active';
-
-import { sidebarUi } from './sidebar/ui';
-
-// Map
-import { mapParser } from './map/map';
-import { mapModel } from './map/model';
-import { mapui } from './map/ui';
-import { MapRotate } from './map/rotation';
-import { MapRunningData } from './map/runningdata';
-import { mapLayerBuilder } from './map/layerbuilder';
-import { mapDateLineBuilder } from './map/datelinebuilder';
-import { mapPrecacheTile } from './map/precachetile';
-import { mapAnimate } from './map/animate';
-
-// Animation
-import { parse as animationParser } from './animation/anim';
-import { animationModel } from './animation/model';
-import { animationUi } from './animation/ui';
-import { animationWidget } from './animation/widget';
-import { animationRangeSelect } from './animation/range-select';
-import { animationGif } from './animation/gif';
-
-// Palettes
-import palettes from './palettes/palettes';
-import { palettesModel } from './palettes/model';
-
-// Data
-import { dataParser } from './data/data';
-import { dataModel } from './data/model';
-import { dataUi } from './data/ui';
-
-// NaturalEvents
-import naturalEventsModel from './natural-events/model';
-import naturalEventsUI from './natural-events/ui';
-import naturalEventsRequest from './natural-events/request';
-
-// Image
-import { imageRubberband } from './image/rubberband';
-import { imagePanel } from './image/panel';
-
-// Notifications
-import { notificationsUi } from './notifications/ui';
-
-// UI
-import loadingIndicator from './ui/indicator';
-
-// Link
-import { linkModel } from './link/model';
-import { linkUi } from './link/ui';
-
-// Projections
-import { parse as projectionParser } from './projection/projection';
-import { projectionModel } from './projection/model';
-import { projectionUi } from './projection/ui';
-
-// A|B comparison
-import { compareModel } from './compare/model';
-// Other
-import { debugConfig, debugLayers } from './debug';
-import Brand from './brand';
-import tour from './tour';
-import { uiInfo } from './ui/info';
-
-// Dependency CSS
-import '../../node_modules/bootstrap/dist/css/bootstrap.css';
-import 'font-awesome-webpack';
-import '../../node_modules/jquery-ui-bundle/jquery-ui.structure.css';
-import '../../node_modules/jquery-ui-bundle/jquery-ui.theme.css';
-import '../../node_modules/icheck/skins/square/grey.css';
-import '../../node_modules/icheck/skins/square/red.css';
-import '../../node_modules/icheck/skins/line/red.css';
-import '../../node_modules/jscrollpane/style/jquery.jscrollpane.css';
-import '../../node_modules/perfect-scrollbar/dist/css/perfect-scrollbar.css';
-import '../ext/mobiscroll-2.6.0/mobiscroll.css';
-import '../../node_modules/jquery.joyride/jquery.joyride.css';
-import '../../node_modules/jquery-jcrop/css/jquery.Jcrop.css';
-import '../../node_modules/ol/ol.css';
-import '../../node_modules/nouislider/src/jquery.nouislider.css';
-import '../../node_modules/simplebar/dist/simplebar.css';
-
-// App CSS
-import '../css/fonts.css';
-import '../css/reset.css';
-import '../css/compare.css';
-import '../css/jquery-ui-override.css';
-import '../css/util.css';
-import '../css/toolbar.css';
-import '../css/alert.css';
-import '../css/sidebar-panel.css';
-import '../css/button.css';
-import '../css/checkbox.css';
-import '../css/map.css';
-import '../css/link.css';
-import '../css/palettes.css';
-import '../css/image.css';
-import '../css/debug.css';
-import '../css/projection.css';
-import '../css/date.css';
-import '../css/menuPicker.css';
-import '../css/tour.css';
-import '../css/products.css';
-import '../css/indicator.css';
-import '../css/events.css';
-import '../css/dataDownload.css';
-import '../css/sidebar.css';
-import '../css/layers.css';
-import '../css/scrollbar.css';
-import '../css/timeline.css';
-import '../css/anim.widget.css';
-import '../css/dateselector.css';
-import '../css/tooltip.css';
-import '../css/mobile.css';
-import '../pages/css/document.css';
-
-import { polyfill } from './polyfill';
-polyfill(); // Polyfills some browser features
+import React from 'react';
+import ReactDOM from 'react-dom';
+import App from './app';
// Document ready function
window.onload = () => {
- var errors = [];
- var requirements;
- var startTime;
- var wvx = {};
- var config;
- var parsers;
- var state = util.fromQueryString(location.search);
- var parameters = util.fromQueryString(location.search);
-
- var main = function() {
- if (parameters.elapsed) {
- startTime = new Date().getTime();
- } else {
- elapsed = function() {};
- }
- elapsed('start');
- loadConfig();
- };
-
- var loadConfig = function() {
- elapsed('loading config');
- var configURI = Brand.url('config/wv.json');
- var promise = $.getJSON(configURI);
- promise.done(util.wrap(onConfigLoaded)).fail(util.error);
- loadingIndicator.delayed(promise, 1000);
- };
-
- var onConfigLoaded = function(data) {
- elapsed('config loaded');
- config = data;
- config.parameters = parameters;
-
- // Attach to wvx object for debugging
- wvx.config = config;
-
- debugConfig(config);
-
- // Load any additional scripts as needed
- if (config.scripts) {
- lodashEach(config.scripts, function(script) {
- $.getScript(script);
- });
- }
-
- layerValidate(errors, config);
-
- parsers = [
- projectionParser,
- layerParser,
- dateParser,
- mapParser,
- palettes.parse
- ];
- if (config.features.dataDownload) {
- parsers.push(dataParser);
- }
- if (config.features.animation) {
- parsers.push(animationParser);
- }
- lodashEach(parsers, function(parser) {
- parser(state, errors, config);
- });
- requirements = [palettes.requirements(state, config)];
-
- $.when
- .apply(null, requirements)
- .then(util.wrap(init))
- .fail(util.error);
- };
-
- var init = function() {
- elapsed('init');
- // If at the beginning of the day, wait on the previous day until GIBS
- // catches up (about three hours)
- var initialDate;
- if (config.defaults.startDate) {
- initialDate = util.parseDateUTC(config.defaults.startDate);
- } else {
- initialDate = util.now();
- if (initialDate.getUTCHours() < 3) {
- initialDate.setUTCDate(initialDate.getUTCDate() - 1);
- }
- }
-
- // Models
- var models = {
- wv: {
- events: util.events()
- }
- };
- var ui = {};
- // Attach to wvx object for debugging
- wvx.models = models;
- wvx.ui = ui;
-
- models.proj = projectionModel(config);
- models.palettes = palettesModel(models, config);
- models.layers = layersModel(models, config);
- models.date = dateModel(models, config, {
- initial: initialDate
- });
- models.map = mapModel(models, config);
- models.link = linkModel(config);
- if (config.features.compare) {
- models.compare = compareModel(models, config);
- models.link.register(models.compare);
- }
- models.link
- .register(models.proj)
- .register(models.layers)
- .register(models.date)
- .register(models.palettes)
- .register(models.map);
- models.link.load(state);
- if (config.features.googleAnalytics) {
- googleAnalytics.init(config.features.googleAnalytics.id); // Insert google tracking
- }
-
- // HACK: Map needs to be created before the data download model
- var mapComponents = {
- Rotation: MapRotate,
- Runningdata: MapRunningData,
- Layerbuilder: mapLayerBuilder,
- Dateline: mapDateLineBuilder,
- Precache: mapPrecacheTile
- };
- ui.map = mapui(models, config, mapComponents);
- ui.map.animate = mapAnimate(models, config, ui);
- if (config.features.animation) {
- models.anim = animationModel(models, config);
- models.link.register(models.anim);
- }
- if (config.features.dataDownload) {
- models.data = dataModel(models, config);
- models.link.register(models.data);
- }
- if (config.features.naturalEvents) {
- models.naturalEvents = naturalEventsModel(models, config, ui);
- models.link.register(models.naturalEvents);
- }
- // HACK: Map needs permalink state loaded before starting. But
- // data download now needs it too.
- models.link.load(state); // needs to be loaded twice
-
- elapsed('ui');
- // Create widgets
- ui.proj = projectionUi(models, config);
- ui.tour = tour(models, ui, config);
- ui.sidebar = sidebarUi(models, config, ui);
- ui.activeLayers = layersActive(models, ui, config);
- ui.addModal = layersModal(models, ui, config);
-
- // Test via a getter in the options object to see if the passive property is accessed
- ui.supportsPassive = false;
- try {
- var opts = Object.defineProperty({}, 'passive', {
- get: function() {
- ui.supportsPassive = true;
- }
- });
- window.addEventListener('testPassive', null, opts);
- window.removeEventListener('testPassive', null, opts);
- } catch (e) {}
-
- function timelineInit() {
- ui.timeline = timeline(models, config, ui);
- ui.timeline.data = timelineData(models, config, ui);
- ui.timeline.zoom = timelineZoom(models, config, ui);
- ui.timeline.ticks = timelineTicks(models, config, ui);
- ui.timeline.pick = timelinePick(models, config, ui);
- ui.timeline.pan = timelinePan(models, config, ui);
- ui.timeline.config = timelineConfig(models, config, ui);
- ui.timeline.input = timelineInput(models, config, ui);
- if (config.features.animation) {
- ui.anim = {};
- ui.anim.rangeselect = animationRangeSelect(models, config, ui); // SETS STATE: NEEDS TO LOAD BEFORE ANIMATION WIDGET
- ui.anim.widget = animationWidget(models, config, ui);
- ui.anim.gif = animationGif(models, config, ui);
- ui.anim.ui = animationUi(models, ui);
- }
- if (config.features.compare) {
- ui.timeline.compare = timelineCompare(models, config, ui);
- }
-
- ui.dateLabel = dateLabel(models);
- }
- if (config.startDate) {
- if (!util.browser.small) {
- // If mobile device, do not build timeline
- timelineInit();
- }
- ui.dateWheels = dateWheels(models, config);
- }
-
- ui.rubberband = imageRubberband(models, ui, config);
- ui.image = imagePanel(models, ui, config);
- if (config.features.dataDownload) {
- ui.data = dataUi(models, ui, config);
- }
- if (config.features.naturalEvents) {
- var request = naturalEventsRequest(models, ui, config);
- ui.naturalEvents = naturalEventsUI(models, ui, config, request);
- }
- ui.link = linkUi(models, config);
- ui.info = uiInfo(ui, config);
- if (config.features.alert) {
- ui.alert = notificationsUi(ui, config);
- }
-
- // FIXME: Old hack
- $(window).resize(function() {
- if (util.browser.small) {
- $('#productsHoldertabs li.first a').trigger('click');
- }
- if (!ui.timeline) {
- timelineInit();
- }
- });
-
- document.activeElement.blur();
- $('input').blur();
- $('#eventsHolder').hide();
-
- if (config.features.dataDownload) {
- models.data.events.on('queryResults', function() {
- ui.data.onViewChange();
- });
- ui.map.events.on('extent', function() {
- ui.data.onViewChange();
- });
- // FIXME: This is a hack
- models.map.events.on('projection', models.data.updateProjection);
- }
- // Sink all focus on inputs if click unhandled
- $(document).click(function(event) {
- if (event.target.nodeName !== 'INPUT') {
- $('input').blur();
- }
- });
-
- // Console notifications
- if (Brand.release()) {
- console.info(
- Brand.NAME +
- ' - Version ' +
- Brand.VERSION +
- ' - ' +
- Brand.BUILD_TIMESTAMP
- );
- } else {
- console.warn('Development version');
- }
- debugLayers(ui, models, config);
-
- errorReport();
-
- models.wv.events.trigger('startup');
- elapsed('done');
-
- // Reset Worldview when clicking on logo
- $(document).click(function(e) {
- if (e.target.id === 'wv-logo') resetWorldview(e);
- });
- };
-
- var resetWorldview = function(e) {
- e.preventDefault();
- if (window.location.search === '') return; // Nothing to reset
- var msg =
- 'Do you want to reset Worldview to its defaults? You will lose your current state.';
- if (confirm(msg)) document.location.href = '/';
- };
-
- var errorReport = function() {
- var layersRemoved = 0;
-
- lodashEach(errors, function(error) {
- var cause = error.cause ? ': ' + error.cause : '';
- util.warn(error.message + cause);
- if (error.layerRemoved) {
- layersRemoved = layersRemoved + 1;
- }
- });
- };
-
- var elapsed = function(message) {
- if (!parameters.elapsed) return;
- var t = new Date().getTime() - startTime;
- console.log(t, message);
- };
- util.wrap(main)();
+ ReactDOM.render(<App />, document.getElementById('app'));
};
diff --git a/web/js/map/ui.js b/web/js/map/ui.js
index 919b273cc..d76b5edca 100644
--- a/web/js/map/ui.js
+++ b/web/js/map/ui.js
@@ -22,7 +22,6 @@ import OlInteractionDragPan from 'ol/interaction/DragPan';
import OlInteractionMouseWheelZoom from 'ol/interaction/MouseWheelZoom';
import OlInteractionDragZoom from 'ol/interaction/DragZoom';
import OlLayerGroup from 'ol/layer/Group';
-import * as olExtent from 'ol/extent';
import * as olProj from 'ol/proj';
import { MapRotate } from './rotation';
import { mapDateLineBuilder } from './datelinebuilder';
@@ -937,100 +936,11 @@ export function mapui(models, config) {
* @todo move this component to another Location
*/
var createMousePosSel = function(map, proj) {
- var $map;
- var mapId;
- var $mousePosition;
- var $latlonDD;
- var $latlonDMS;
- var $coordBtn;
- var $coordWrapper;
- var coordinateFormat;
var hoverThrottle;
- var extent;
-
- // var timer = null;
- // var isIntervalSet = false;
-
- $map = $('#' + map.getTarget());
- map = map || self.selected;
- mapId = 'coords-' + proj.id;
- extent = proj.maxExtent;
-
- $mousePosition = $('<div></div>')
- .attr('id', mapId)
- .addClass('wv-coords-map wv-coords-map-btn');
-
- /*
- * Creates map events based on mouse position
- *
- * @function coordinateFormat
- * @static
- *
- * @param {Array} source - Coordinates
- * @param {String} format - units of coordinates
- *
- * @returns {void}
- */
- coordinateFormat = function(source, format, outsideExtent) {
- var target, crs;
- crs = models.proj.selected.crs;
- if (outsideExtent) {
- return crs;
- }
- target = olProj.transform(source, proj.crs, 'EPSG:4326');
- return util.formatCoordinate(target, format) + ' ' + crs;
- };
-
- $map.append($mousePosition);
-
- $latlonDD = $('<span></span>')
- .attr('id', mapId + '-latlon-dd')
- .attr('data-format', 'latlon-dd')
- .addClass('map-coord');
- $latlonDMS = $('<span></span>')
- .attr('id', mapId + '-latlon-dms')
- .attr('data-format', 'latlon-dms')
- .addClass('map-coord');
-
- if (util.getCoordinateFormat() === 'latlon-dd') {
- $('div.map-coord').removeClass('latlon-selected');
- $latlonDD.addClass('latlon-selected');
- } else {
- $('div.map-coord').removeClass('latlon-selected');
- $latlonDMS.addClass('latlon-selected');
- }
- $coordBtn = $('<i></i>').addClass('coord-switch');
-
- $coordWrapper = $('<div></div>').addClass('coord-btn');
-
- $coordWrapper.append($coordBtn);
-
- $mousePosition
- .append($latlonDD)
- .append($latlonDMS)
- .append($coordWrapper)
- .click(function() {
- var $format = $(this).find('.latlon-selected');
-
- if ($format.attr('data-format') === 'latlon-dd') {
- $('span.map-coord').removeClass('latlon-selected');
- $('span.map-coord[data-format="latlon-dms"]').addClass(
- 'latlon-selected'
- );
- util.setCoordinateFormat('latlon-dms');
- } else {
- $('span.map-coord').removeClass('latlon-selected');
- $('span.map-coord[data-format="latlon-dd"]').addClass(
- 'latlon-selected'
- );
- util.setCoordinateFormat('latlon-dd');
- }
- });
function onMouseMove(e) {
var coords;
var pixels;
- var outside;
if (compare && compare.dragging) return;
// if mobile return
if (util.browser.small) {
@@ -1046,9 +956,6 @@ export function mapui(models, config) {
pixels = map.getEventPixel(e.originalEvent);
coords = map.getCoordinateFromPixel(pixels);
if (!coords) return;
- if (!olExtent.containsCoordinate(extent, coords)) {
- outside = true;
- }
if (Math.abs(coords[0]) > 180) {
if (coords[0] > 0) {
@@ -1058,12 +965,6 @@ export function mapui(models, config) {
}
}
- $('#' + mapId).show();
- $('#' + mapId + ' span.map-coord').each(function() {
- var format = $(this).attr('data-format');
- $(this).html(coordinateFormat(coords, format, outside));
- });
-
// setting a limit on running-data retrievel
if (self.mapIsbeingDragged || util.browser.small) {
return;
@@ -1081,15 +982,6 @@ export function mapui(models, config) {
dataRunner.newPoint(pixels, map);
}
$(map.getViewport())
- .mouseover(function(e) {
- if (
- $(e.relatedTarget).hasClass('map-coord') ||
- $(e.relatedTarget).hasClass('coord-btn')
- ) {
- return;
- }
- $('#' + mapId).show();
- })
.mouseout(function(e) {
if (
$(e.relatedTarget).hasClass('map-coord') ||
@@ -1097,7 +989,7 @@ export function mapui(models, config) {
) {
return;
}
- $('#' + mapId).hide();
+ // $('#' + mapId).hide();
hoverThrottle.cancel();
dataRunner.clearAll();
})
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 9cd780b26..c7d9128ad 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -951,14 +951,14 @@ export default (function (self) {
let sdegrees = self.pad(degrees, width, ' ');
let sminutes = self.pad(minutes, 2, '0');
let sseconds = self.pad(seconds, 2, '0');
- return sdegrees + '&deg;' + sminutes + '\'' + sseconds + '"' + sign;
+ return sdegrees + '°' + sminutes + '\'' + sseconds + '"' + sign;
} else {
let sdegrees = self.pad(degrees, width, ' ');
// toFixed rounds and to prevent seeing 60.000, get it out to
// four digits and then chop off the last one
let sminutes = self.pad(fminutes.toFixed(4), 7, '0');
sminutes = sminutes.substring(0, sminutes.length - 1);
- return sdegrees + '&deg;' + sminutes + '\'' + sign;
+ return sdegrees + '°' + sminutes + '\'' + sign;
}
};
@@ -984,11 +984,11 @@ export default (function (self) {
return self.formatDMS(coord[1], 'latitude') + ', ' +
self.formatDMS(coord[0], 'longitude');
} else if (type === 'latlon-dm') {
- return self.formatDMS(coord[0], 'latitude') + ', ' +
- self.formatDMS(coord[0], 'longitude');
+ return self.formatDM(coord[1], 'latitude') + ', ' +
+ self.formatDM(coord[0], 'longitude');
} else {
- return coord[1].toFixed(4) + '&deg;, ' +
- coord[0].toFixed(4) + '&deg;';
+ return coord[1].toFixed(4) + '°, ' +
+ coord[0].toFixed(4) + '°';
}
};
diff --git a/web/js/util/util.test.js b/web/js/util/util.test.js
index 770ad274d..9f7575847 100644
--- a/web/js/util/util.test.js
+++ b/web/js/util/util.test.js
@@ -320,19 +320,19 @@ describe('formatDMS', () => {
let tests = [{
name: 'zero',
dd: [0, 0],
- str: [' 0&deg;00\'00"N', ' 0&deg;00\'00"E']
+ str: [' 0°00\'00"N', ' 0°00\'00"E']
}, {
name: 'positive',
dd: [12.582222, 12.582222],
- str: ['12&deg;34\'55"N', ' 12&deg;34\'55"E']
+ str: ['12°34\'55"N', ' 12°34\'55"E']
}, {
name: 'negative',
dd: [-12.582222, -12.582222],
- str: ['12&deg;34\'55"S', ' 12&deg;34\'55"W']
+ str: ['12°34\'55"S', ' 12°34\'55"W']
}, {
name: 'max',
dd: [89.999997, 179.999997],
- str: ['89&deg;59\'59"N', '179&deg;59\'59"E']
+ str: ['89°59\'59"N', '179°59\'59"E']
}];
tests.forEach((t) => {
@@ -349,19 +349,19 @@ describe('formatDM', () => {
let tests = [{
name: 'zero',
dd: [0, 0],
- str: [' 0&deg;00.000\'N', ' 0&deg;00.000\'E']
+ str: [' 0°00.000\'N', ' 0°00.000\'E']
}, {
name: 'positive',
dd: [12.582222, 12.582222],
- str: ['12&deg;34.933\'N', ' 12&deg;34.933\'E']
+ str: ['12°34.933\'N', ' 12°34.933\'E']
}, {
name: 'negative',
dd: [-12.582222, -12.582222],
- str: ['12&deg;34.933\'S', ' 12&deg;34.933\'W']
+ str: ['12°34.933\'S', ' 12°34.933\'W']
}, {
name: 'max',
dd: [89.999997, 179.999997],
- str: ['89&deg;59.999\'N', '179&deg;59.999\'E']
+ str: ['89°59.999\'N', '179°59.999\'E']
}];
tests.forEach((t) => {
diff --git a/webpack.config.js b/webpack.config.js
index 6a9c88143..3122afaf6 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -4,13 +4,16 @@ const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
+const CopyWebpackPlugin = require('copy-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const cssnano = require('cssnano');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
-const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
+const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
+ .BundleAnalyzerPlugin;
-const devMode = process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'testing';
+const devMode =
+ process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'testing';
const pluginSystem = [
new CleanWebpackPlugin(['web/build']),
@@ -21,15 +24,16 @@ const pluginSystem = [
inject: false
}),
new webpack.ProvidePlugin({
- '$': 'jquery',
- 'jQuery': 'jquery',
+ $: 'jquery',
+ jQuery: 'jquery',
'window.jQuery': 'jquery',
'window.$': 'jquery'
}),
new MiniCssExtractPlugin({
filename: 'wv.css'
}),
- new WriteFilePlugin()
+ new WriteFilePlugin(),
+ new CopyWebpackPlugin([{ from: 'web/images', to: 'images' }])
];
/* Conditional Plugin Management */
@@ -39,12 +43,12 @@ if (process.env.NODE_ENV === 'development') {
new webpack.HotModuleReplacementPlugin(), // use path to module for development performance
new webpack.NamedModulesPlugin()
);
-};
+}
// add bundle analzyer
if (process.env.NODE_ENV === 'analyze') {
pluginSystem.push(new BundleAnalyzerPlugin());
-};
+}
// handle testing entry point and output file name
let entryPoint = './web/js/main.js';
@@ -58,7 +62,8 @@ if (process.env.NODE_ENV === 'testing') {
module.exports = {
mode: devMode ? 'development' : 'production',
- stats: { // reduce output text on build - remove for more verbose
+ stats: {
+ // reduce output text on build - remove for more verbose
chunks: false,
modules: false,
children: false
@@ -119,20 +124,20 @@ module.exports = {
compact: false // fixes https://stackoverflow.com/questions/29576341/what-does-the-code-generator-has-deoptimised-the-styling-of-some-file-as-it-e
}
},
- exclude: [
- /\.test\.js$/,
- /fixtures\.js$/
- ]
+ exclude: [/\.test\.js$/, /fixtures\.js$/]
},
{
test: require.resolve('jquery'), // expose globally for jQuery plugins
- use: [{
- loader: 'expose-loader',
- options: 'jQuery'
- }, {
- loader: 'expose-loader',
- options: '$'
- }]
+ use: [
+ {
+ loader: 'expose-loader',
+ options: 'jQuery'
+ },
+ {
+ loader: 'expose-loader',
+ options: '$'
+ }
+ ]
},
{
test: /\.(sa|sc|c)ss$/,
@@ -161,7 +166,12 @@ module.exports = {
plugins: [
require('autoprefixer')({
// handle browserlist restrictions
- 'browsers': ['last 5 versions', 'not ie < 11', 'not edge < 15', '> 2%']
+ browsers: [
+ 'last 5 versions',
+ 'not ie < 11',
+ 'not edge < 15',
+ '> 2%'
+ ]
})
]
}
@@ -208,15 +218,17 @@ module.exports = {
},
{
test: /\.html$/,
- use: [ {
- loader: 'html-loader',
- options: {
- minimize: !devMode,
- removeEmptyAttributes: !devMode,
- sortAttributes: !devMode,
- sortClassName: !devMode
+ use: [
+ {
+ loader: 'html-loader',
+ options: {
+ minimize: !devMode,
+ removeEmptyAttributes: !devMode,
+ sortAttributes: !devMode,
+ sortClassName: !devMode
+ }
}
- }]
+ ]
}
]
}