Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

remove unneeded imports #1118

Benjamin King2c453a006182
diff --git a/web/js/main.js b/web/js/main.js
index e68f43313..c762bc792 100644
--- a/web/js/main.js
+++ b/web/js/main.js
@@ -21,14 +21,20 @@ 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 {
+ parse as layerParser,
+ validate as layerValidate
+} from './layers/layers';
import { layersModel } from './layers/model';
import { layersModal } from './layers/modal';
-import { layersSidebar } from './layers/sidebar';
+
import { layersActive } from './layers/active';
+import { sidebarUi } from './sidebar/ui';
+
// Map
import { mapParser } from './map/map';
import { mapModel } from './map/model';
@@ -81,6 +87,8 @@ 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';
@@ -103,8 +111,7 @@ window.onload = () => {
var main = function() {
if (parameters.elapsed) {
- startTime = new Date()
- .getTime();
+ startTime = new Date().getTime();
} else {
elapsed = function() {};
}
@@ -116,9 +123,7 @@ window.onload = () => {
elapsed('loading config');
var configURI = Brand.url('config/wv.json');
var promise = $.getJSON(configURI);
- promise
- .done(util.wrap(onConfigLoaded))
- .fail(util.error);
+ promise.done(util.wrap(onConfigLoaded)).fail(util.error);
loadingIndicator.delayed(promise, 1000);
};
@@ -129,7 +134,7 @@ window.onload = () => {
// Attach to wvx object for debugging
wvx.config = config;
-
+ config.features.compare = true;
debugConfig(config);
// Load any additional scripts as needed
@@ -157,11 +162,10 @@ window.onload = () => {
lodashEach(parsers, function(parser) {
parser(state, errors, config);
});
- requirements = [
- palettes.requirements(state, config)
- ];
+ requirements = [palettes.requirements(state, config)];
- $.when.apply(null, requirements)
+ $.when
+ .apply(null, requirements)
.then(util.wrap(init))
.fail(util.error);
};
@@ -199,7 +203,10 @@ window.onload = () => {
});
models.map = mapModel(models, config);
models.link = linkModel(config);
-
+ if (config.features.compare) {
+ models.compare = compareModel(models, config, ui);
+ models.link.register(models.compare);
+ }
models.link
.register(models.proj)
.register(models.layers)
@@ -210,6 +217,7 @@ window.onload = () => {
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,
@@ -239,7 +247,7 @@ window.onload = () => {
elapsed('ui');
// Create widgets
ui.proj = projectionUi(models, config);
- ui.sidebar = layersSidebar(models, config);
+ ui.sidebar = sidebarUi(models, config, ui);
ui.activeLayers = layersActive(models, ui, config);
ui.addModal = layersModal(models, ui, config);
@@ -271,11 +279,15 @@ window.onload = () => {
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
+ if (!util.browser.small) {
+ // If mobile device, do not build timeline
timelineInit();
}
ui.dateWheels = dateWheels(models, config);
@@ -285,8 +297,6 @@ window.onload = () => {
ui.image = imagePanel(models, ui, config);
if (config.features.dataDownload) {
ui.data = dataUi(models, ui, config);
- // FIXME: Why is this here?
- ui.data.render();
}
if (config.features.naturalEvents) {
var request = naturalEventsRequest(models, ui, config);
@@ -300,31 +310,23 @@ window.onload = () => {
}
// FIXME: Old hack
- $(window)
- .resize(function() {
- if (util.browser.small) {
- $('#productsHoldertabs li.first a')
- .trigger('click');
- }
- if (!ui.timeline) {
- timelineInit();
- }
- });
+ $(window).resize(function() {
+ if (util.browser.small) {
+ $('#productsHoldertabs li.first a').trigger('click');
+ }
+ if (!ui.timeline) {
+ timelineInit();
+ }
+ });
document.activeElement.blur();
- $('input')
- .blur();
- $('#eventsHolder')
- .hide();
+ $('input').blur();
+ $('#eventsHolder').hide();
if (config.features.dataDownload) {
- models.data.events
- .on('activate', function() {
- ui.sidebar.selectTab('download');
- })
- .on('queryResults', function() {
- ui.data.onViewChange();
- });
+ models.data.events.on('queryResults', function() {
+ ui.data.onViewChange();
+ });
ui.map.events.on('extent', function() {
ui.data.onViewChange();
});
@@ -332,18 +334,21 @@ window.onload = () => {
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();
- }
- });
+ $(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);
+ console.info(
+ Brand.NAME +
+ ' - Version ' +
+ Brand.VERSION +
+ ' - ' +
+ Brand.BUILD_TIMESTAMP
+ );
} else {
console.warn('Development version');
}
@@ -363,7 +368,8 @@ window.onload = () => {
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.';
+ var msg =
+ 'Do you want to reset Worldview to its defaults? You will lose your current state.';
if (confirm(msg)) document.location.href = '/';
};
@@ -371,7 +377,7 @@ window.onload = () => {
var layersRemoved = 0;
lodashEach(errors, function(error) {
- var cause = (error.cause) ? ': ' + error.cause : '';
+ var cause = error.cause ? ': ' + error.cause : '';
util.warn(error.message + cause);
if (error.layerRemoved) {
layersRemoved = layersRemoved + 1;
@@ -381,8 +387,7 @@ window.onload = () => {
var elapsed = function(message) {
if (!parameters.elapsed) return;
- var t = new Date()
- .getTime() - startTime;
+ var t = new Date().getTime() - startTime;
console.log(t, message);
};
util.wrap(main)();