Interactive interface for browsing global, full-resolution satellite imagery
Moved State.js into the registry
Mike McGannec375b6ef5b5
diff --git a/ant/js.build.xml b/ant/js.build.xmlindex f23bf6645..5016f60b3 100644--- a/ant/js.build.xml+++ b/ant/js.build.xml@@ -47,7 +47,6 @@<file name="Worldview/Support.js"/><file name="Worldview/Permalink.js"/><file name="Worldview/Scheduler.js"/>- <file name="Worldview/State.js"/><file name="Worldview/Palette.js"/><file name="Worldview/Palette/ColorBar.js"/>diff --git a/index.html b/index.htmlindex 73ce1e461..a65ce6950 100644--- a/index.html+++ b/index.html@@ -99,7 +99,6 @@<!-- js.dev --> <script type="text/javascript" src="js/Worldview/Support.js"></script><!-- js.dev --> <script type="text/javascript" src="js/Worldview/Scheduler.js"></script><!-- js.dev --> <script type="text/javascript" src="js/Worldview/Permalink.js"></script>- <!-- js.dev --> <script type="text/javascript" src="js/Worldview/State.js"></script><!-- js.dev --> <script type="text/javascript" src="js/Worldview/Palette.js"></script><!-- js.dev --> <script type="text/javascript" src="js/Worldview/Palette/ColorBar.js"></script>diff --git a/js/Worldview/State.js b/js/Worldview/State.jsdeleted file mode 100644index 0c9083727..000000000--- a/js/Worldview/State.js+++ /dev/null@@ -1,49 +0,0 @@-/*- * NASA Worldview- *- * This code was originally developed at NASA/Goddard Space Flight Center for- * the Earth Science Data and Information System (ESDIS) project.- *- * Copyright (C) 2013 United States Government as represented by the- * Administrator of the National Aeronautics and Space Administration.- * All Rights Reserved.- */--/**- * Namespace: Worldview.Permalink- * Handles permalinks- */-Worldview.namespace("State");--$(function() {-- // This namespace- var ns = Worldview.State;-- var components = {};-- ns.register = function(name, component) {- components[name] = component;- };-- ns.parse = function(queryString) {- if ( !queryString ) {- queryString = Worldview.Permalink.fromRegistry();- }- var results = {- components: {}- };- $.each(components, function(name, component) {- results.components[name] = component;- component.parse(queryString, results);- });- return results;- };-- ns.get = function() {- return ns.parse(Worldview.Permalink.fromRegistry());- };--});--\ No newline at end of filediff --git a/js/Worldview/Widget/Map.js b/js/Worldview/Widget/Map.jsindex 4166f948a..1f042c5b3 100644--- a/js/Worldview/Widget/Map.js+++ b/js/Worldview/Widget/Map.js@@ -47,12 +47,6 @@ Worldview.Widget.Map = function(containerId, config) {self.config = config;var init = function() {- if ( REGISTRY ) {- REGISTRY.register(containerId, self);- } else {- throw new Error("Cannot register Map, REGISTRY not found");- }-self.config = validateConfig(self.config);self.productMap = Worldview.Map.ProductMap(containerId,self.config, self);@@ -62,10 +56,6 @@ Worldview.Widget.Map = function(containerId, config) {self.productMap.append(name);}});-- REGISTRY.markComponentReady(containerId);- Worldview.State.register("view", self);- log.debug("Map is ready");};/**diff --git a/js/Worldview/Widget/Opacity.js b/js/Worldview/Widget/Opacity.jsindex d8256484c..f211ba8e7 100644--- a/js/Worldview/Widget/Opacity.js+++ b/js/Worldview/Widget/Opacity.js@@ -20,7 +20,6 @@ Worldview.Widget.Opacity = function(config) {self.containerId = "opacity";var init = function() {- Worldview.State.register("opacity", self);REGISTRY.register(self.containerId, self);REGISTRY.markComponentReady(self.containerId);};diff --git a/js/Worldview/Widget/Palette.js b/js/Worldview/Widget/Palette.jsindex de8e807bc..0f4a4ebd4 100644--- a/js/Worldview/Widget/Palette.js+++ b/js/Worldview/Widget/Palette.js@@ -33,7 +33,6 @@ Worldview.Widget.Palette = function(containerId, config, spec) {throw new Error("Cannot register paletteWidget, REGISTRY " +"not found");}- Worldview.State.register("palette", self);REGISTRY.markComponentReady(containerId);};@@ -88,7 +87,7 @@ Worldview.Widget.Palette = function(containerId, config, spec) {queryString = queryString || "";var changed = false;try {- var state = Worldview.State.parse(queryString);+ var state = REGISTRY.getState(queryString);log.debug("Palette: updateComponent", state);$.each(self.active, function(product, palette) {if ( $.inArray(product, state.products) < 0 ) {diff --git a/js/Worldview/Widget/WorldviewMap.js b/js/Worldview/Widget/WorldviewMap.jsindex 7b3f930e1..afeb3b370 100644--- a/js/Worldview/Widget/WorldviewMap.js+++ b/js/Worldview/Widget/WorldviewMap.js@@ -40,6 +40,15 @@ Worldview.Widget.WorldviewMap = function(containerId, config) {var init = function() {//Logging.debug("Worldview.Map");+ if ( REGISTRY ) {+ REGISTRY.register(containerId, self);+ } else {+ throw new Error("Cannot register Map, REGISTRY not found");+ }++ REGISTRY.markComponentReady(containerId);+ log.debug("Map is ready");+setExtentToLeading();};@@ -63,7 +72,7 @@ Worldview.Widget.WorldviewMap = function(containerId, config) {return;}log.debug("WorldviewMap: updateComponent", queryString);- var state = Worldview.State.parse(queryString);+ var state = REGISTRY.getState(queryString);log.debug(state);if ( state.projection !== undefined &&diff --git a/js/dateSpan.js b/js/dateSpan.jsindex 1fc19aeec..1f3c7012b 100644--- a/js/dateSpan.js+++ b/js/dateSpan.js@@ -120,7 +120,6 @@ SOTE.widget.DateSpan = function(containerId, config){this.statusStr = "";this.init();- Worldview.State.register("time", this);$(window).bind("resize",{self:this},SOTE.widget.DateSpan.refreshSliders);};diff --git a/js/registry.js b/js/registry.jsindex 54c0d0f7a..2c88d929e 100644--- a/js/registry.js+++ b/js/registry.js@@ -15,10 +15,16 @@ SOTE.util.Registry = function () {// HACK: Components can check this value to ignore bogus state on startupthis.isLoadingQuery = false;+ // Components that have a function to parse query string state.+ this.parsableComponents = {};+// register a componentthis.register = function register(id,component){var compObj = new ComponentObj(id,component);this.storeComponent( id, compObj );+ if ( typeof component.parse === "function" ) {+ this.parsableComponents[id] = component;+ }}// registry component object - this is what is actually held in compRegistry@@ -339,6 +345,27 @@ SOTE.util.Registry = function () {return consumers;}+ this.getState = function(queryString) {+ if ( !queryString ) {+ var queryParts = [];+ $.each(this.getComponents(), function(index, component) {+ var part = component.obj.getValue();+ if ( part ) {+ queryParts.push(part);+ }+ });+ queryString = queryParts.join("&");+ }++ var state = {+ components: {}+ };+ $.each(this.parsableComponents, function(name, component) {+ state.components[name] = component;+ component.parse(queryString, state);+ });+ return state;+ };};diff --git a/js/switch.js b/js/switch.jsindex 5dd32f0b6..1be3b8108 100644--- a/js/switch.js+++ b/js/switch.js@@ -44,8 +44,6 @@ SOTE.widget.Switch = function(containerId, config){this.dataSourceUrl = config.dataSourceUrl;this.statusStr = "";this.init();-- Worldview.State.register("projection", this);//this.updateComponent(this.id+"=baselayers.MODIS_Terra_CorrectedReflectance_TrueColor-overlays.fires48.AIRS_Dust_Score.OMI_Aerosol_Index")};