Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Clean up main file

Jo Sprague032f0e1cd771
diff --git a/web/js/wv.main.js b/web/js/wv.main.js
index 30ab94693..13c1db94a 100644
--- a/web/js/wv.main.js
+++ b/web/js/wv.main.js
@@ -6,15 +6,14 @@ import {dateParse} from './date/wv.date'; // export default function parse!!!
import dateModel from './date/wv.date.model';
import DateLabel from './date/wv.date.label';
import DateWheels from './date/wv.date.wheels';
-//Timeline
-import Timeline from './date/wv.date.timeline';
+// Timeline
+import Timeline from './date/wv.date.timeline';
import TimelineData from './date/wv.date.timeline.data';
import TimelineConfig from './date/wv.date.timeline.config';
import TimelineZoom from './date/wv.date.timeline.zoom';
import TimelineTicks from './date/wv.date.timeline.ticks';
import TimelinePick from './date/wv.date.timeline.pick';
import TimelinePan from './date/wv.date.timeline.pan';
-import TimelineConfig from './date/wv.date.timeline.config';
import TimelineInput from './date/wv.date.timeline.input';
// Layers
import {layerParse, layerValidate} from './layers/wv.layers';// export parse as layerParse. etc...
@@ -87,7 +86,6 @@ window.onload = () => {
var state = util.fromQueryString(location.search);
var parameters = util.fromQueryString(location.search);
-
var main = function() {
if (parameters.elapsed) {
startTime = new Date()
@@ -95,20 +93,13 @@ window.onload = () => {
} else {
elapsed = function() {};
}
- elapsed("start");
- /* May be included in next version
- yepnope({
- test: parameters.debug,
- yep: ['js/wv.debug.js'],
- complete: loadConfig
- });
- */
+ elapsed('start');
loadConfig();
};
var loadConfig = function() {
- elapsed("loading config");
- var configURI = Brand.url("config/wv.json");
+ elapsed('loading config');
+ var configURI = Brand.url('config/wv.json');
var promise = $.getJSON(configURI);
promise
.done(util.wrap(onConfigLoaded))
@@ -117,7 +108,7 @@ window.onload = () => {
};
var onConfigLoaded = function(data) {
- elapsed("config loaded");
+ elapsed('config loaded');
config = data;
config.parameters = parameters;
@@ -161,7 +152,7 @@ window.onload = () => {
};
var init = function() {
- elapsed("init");
+ elapsed('init');
// If at the beginning of the day, wait on the previous day until GIBS
// catches up (about three hours)
var initialDate;
@@ -234,14 +225,13 @@ window.onload = () => {
models.proj.change = ProjChange(models, config);
}
- elapsed("ui");
+ elapsed('ui');
// Create widgets
ui.proj = ProjUI(models, config);
ui.sidebar = LayersSidebar(models, config);
ui.activeLayers = LayersActive(models, ui, config);
ui.addModal = LayersModal(models, ui, config);
-
function timelineInit() {
ui.timeline = Timeline(models, config, ui);
ui.timeline.data = TimelineData(models, config, ui);
@@ -285,7 +275,7 @@ window.onload = () => {
ui.alert = NotificationsUI(ui, config);
}
- //FIXME: Old hack
+ // FIXME: Old hack
$(window)
.resize(function() {
if (browser.small) {
@@ -298,84 +288,71 @@ window.onload = () => {
});
document.activeElement.blur();
- $("input")
+ $('input')
.blur();
- $("#eventsHolder")
+ $('#eventsHolder')
.hide();
if (config.features.dataDownload) {
models.data.events
- .on("activate", function() {
- ui.sidebar.selectTab("download");
+ .on('activate', function() {
+ ui.sidebar.selectTab('download');
})
- .on("queryResults", function() {
+ .on('queryResults', function() {
ui.data.onViewChange();
});
- ui.map.events.on("extent", function() {
+ ui.map.events.on('extent', function() {
ui.data.onViewChange();
});
// FIXME: This is a hack
- models.map.events.on("projection", models.data.updateProjection);
+ 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")
+ 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");
+ console.warn('Development version');
}
debug.layers(ui, models, config);
errorReport();
- //wv.debug.error(parameters);
- models.wv.events.trigger("startup");
- elapsed("done");
+ 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);
+ if (e.target.id === 'wv-logo') resetWorldview(e);
});
};
- var resetWorldview = function(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 = "/";
+ 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;
_.each(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;
}
});
-
- if (layersRemoved > 0) {
- // Remove for now until new GIBS has settled down.
- /*
- wv.ui.notify(
- "Incomplete configuration<br><br>" +
- layersRemoved + " layer(s) were removed<br><br>" +
- "Contact us at " +
- "<a href='mailto:@MAIL@'>" +
- "@MAIL@</a>");
- */
- }
};
var elapsed = function(message) {
@@ -385,27 +362,5 @@ window.onload = () => {
console.log(t, message);
};
- /*
- var debuggingFeatures = function(config) {
- // Install a black palette which can be used to find "holes" in
- // LUT mappings.
- if ( config.parameters.debugPalette ) {
- var debugPalette = Worldview.Palette.Palette({
- id: "__DEBUG",
- name: "Debug",
- stops: [{at: 0, r: 0, g: 0, b: 0, a: 0}]
- });
- config.palettes["__DEBUG"] = debugPalette;
- config.paletteOrder.unshift("__DEBUG");
- }
-
- // Test error dialog
- if ( config.parameters.showError ) {
- *** SHOW ERROR
- }
- };
- */
-
util.wrap(main)();
-
-};
\ No newline at end of file
+};