Cleaning up sources

Change-Id: I8d6799333da60355861119b23cc91cd045e8016d
diff --git a/client/query/query.html b/client/query/query.html
index a9ae690..828b37e 100644
--- a/client/query/query.html
+++ b/client/query/query.html
@@ -46,11 +46,17 @@
             <div class="currentSelections"></div>
             <div class="autocomplete">
               <div class="ui-widget">
-                <label for="tags"> Search: </label> <input id="autocompleteText"
-                  placeholder="/cmip" class="textbox"
-                  onkeydown="if (event.keyCode == 13) submitAutoComplete(); ">
-                <button id="autoButton" value="Search"
-                  onclick="submitAutoComplete()" id="autocompleteButton">Search</button>
+                <form class="form-inline" id="searchBar">
+                  <div class="form-group">
+                    <label for="searchBar">Search:&nbsp;</label>
+                    <div class="input-group">
+                      <input id="search" placeholder="/cmip" type="text" class="form-control">
+                      <div class="input-group-btn">
+                        <button id="searchButton" type="submit" class="btn btn-primary">Search</button>
+                      </div>
+                    </div>
+                  </div>
+                </form>
               </div>
             </div>
           </div>
diff --git a/client/query/query.js b/client/query/query.js
index 42f074c..5241edf 100644
--- a/client/query/query.js
+++ b/client/query/query.js
@@ -7,136 +7,182 @@
 
 // @}
 
-var Atmos = {}; //Placeholder for the class.
-
-(function(){
-  "use strict"; //Magic (If you really wanna know, look it up.)
-
-  function Atmos(catalog, config){
-    //Internal variables.
-    this.searchMenuOptions = {}
-    this.results = []
-    this.resultCount = 0;
-    this.page = 1;
-    this.totalPages = 1;
-    this.selectedSearch = {};
-    this.dropdown = [];
-    this.state = {};
-    this.currentViewIndex = 0;
-
-    this.face = new Face(config);
-    this.categories = $('#side-menu');
-    this.resultTable = $('#resultTable');
-
-    var scope = this;
-
-    this.resultTable.on('click', '.interest-button', function(){
-      var button = $(this);
-
-      var name = button.parent().prev().text();
-      var interest = new Interest(new Name('/retrieve' + name));
-      scope.face.expressInterest(interest, function(){
-        var message = $('<div class="success"><span class="glyphicon glyphicon-ok"></span> Success!</div>');
-        message.insertAfter(button);
-        message.fadeOut(5000);
-      }, function(){
-        var message = $('<div class="fail"><span class="glyphicon glyphicon-remove"></span> Failed!</div>');
-        message.insertAfter(button);
-        message.fadeOut(5000);
-      });
-
-    });
-
-    $.getJSON("search_catagories.json").done(function (data) {
-      $.each(data, function (pageSection, contents) {
-        if (pageSection == "SearchCatagories") {
-          $.each(contents, function (search, searchOptions) {
-            search = search.replace(/\_/g, " ");
-
-            searchMenu.append('<li id="' + search + '" onclick="getDropDown(this.id)"><a href="#">' + search + '</a></li>');
-            scope.searchMenuOptions[String(search)] = searchOptions;
-          });
-        }
-      });
-    });
-
-  }
-
-  Atmos.prototype.onData = function(data) {
-    var payloadStr = data.content.toString().split("\n")[0];
-
-    var queryResults = JSON.parse(payloadStr);
-
-    var scope = this;
-
-    $.each(this.queryResults, function (queryResult, field) {
-
-      if (queryResult == "next") {
-        scope.populateAutocomplete(field);
-      }
-
-      $.each(field, function (entryCount, name) {
-        scope.results.push(name);
-      });
-    });
-
-    // Calculating the current page and the view
-    this.totalPages = Math.ceil(this.resultCount / 20);
-    this.populateResults(0);
-  }
-
-  Atmos.prototype.query = function(prefix, parameters, callback, pipeline) {
-    this.results = [];
-    this.dropdown = [];
-    this.resultTable.empty();
-    this.resultTable.append('<tr><th colspan="2">Results</th></tr>');
-
-    var queryPrefix = new Name(prefix);
-    queryPrefix.append("query");
-
-    var jsonString = JSON.stringify(parameters);
-    queryPrefix.append(jsonString);
-
-    this.state = {
-        prefix: new Name(prefix),
-        userOnData: callback,
-        outstanding: {},
-        nextSegment: 0,
-    };
-
-    /*if (state.hasOwnProperty("version")) {
-                  console.log("state already has version");
-              }*/
-
-    var queryInterest = new Interest(queryPrefix);
-    queryInterest.setInterestLifetimeMilliseconds(10000);
-
-    var scope = this;
-
-    this.face.expressInterest(queryInterest,
-      function(){
-        onQueryData()
-      }, function(){
-        onQueryTimeout()
-      }
-    );
-
-    this.state["outstanding"][queryInterest.getName().toUri()] = 0;
-  }
-
-})(); //Run as soon as the script loads but keep the "use strict"" from escaping to the global space.
-
-
 var atmos = {}; //Comment this out if you don't want debug access.
 
 //Run when the document loads.
 $(function () {
-
+  
+  //remove "atmos =" if you don't want debug access
   atmos = new Atmos(catalog, config);
   
 });
 
-function expressNextInterest() {
+/*
+  Atmos
+  Version 2
+*/
+
+function Atmos(catalog, config){
+  "use strict";
+  //Internal variables.
+  this.results = []
+  this.resultCount = 0;
+  this.page = 1;
+  this.totalPages = 1;
+  this.selectedSearch = {};
+  this.dropdown = [];
+  this.state = {};
+  this.currentViewIndex = 0;
+
+  this.face = new Face(config);
+  this.categories = $('#side-menu');
+  this.resultTable = $('#resultTable');
+
+  var scope = this;
+
+  this.resultTable.on('click', '.interest-button', function(){
+    var button = $(this);
+
+    var name = button.parent().prev().text();
+    var interest = new Interest(new Name('/retrieve' + name));
+    scope.face.expressInterest(interest, function(){
+      var message = $('<div class="success"><span class="glyphicon glyphicon-ok"></span> Success!</div>');
+      message.insertAfter(button);
+      message.fadeOut(5000);
+    }, function(){
+      var message = $('<div class="fail"><span class="glyphicon glyphicon-remove"></span> Failed!</div>');
+      message.insertAfter(button);
+      message.fadeOut(5000);
+    });
+
+  });
+
+  $.getJSON("search_catagories.json").done(function (data) {
+    $.each(data, function (pageSection, contents) {
+      if (pageSection == "SearchCatagories") {
+        $.each(contents, function (search, searchOptions) {
+          var e = $('<li><a href="#">' + search.replace(/\_/g, " ") + '</a><ul class="subnav nav nav-pills nav-stacked"></ul></li>');
+
+          var sub = e.find('ul.subnav');
+          $.each(searchOptions, function(index, name){
+            var item = $('<li><a href="#">' + name + '</a></li>');
+            sub.append(item);
+            item.click(function(){
+              scope.submitCatalogSearch(name);
+            });
+          });
+
+          //Toggle the menus.
+          e.click(function(){
+            scope.categories.find('.subnav').slideUp();
+            var t = $(this).find('.subnav');
+            if ( !t.is(':visible')){
+              t.slideDown().triggerHandler('focus'); //Cancel other animations and slide down.
+            }
+          });
+
+          scope.categories.append(e);
+        });
+      }
+    });
+  });
+
+  $('#searchBar').submit(function(e){
+    e.preventDefault();
+  })
+
+}
+
+Atmos.prototype.onData = function(data) {
+  var payloadStr = data.content.toString().split("\n")[0];
+
+  var queryResults = JSON.parse(payloadStr);
+
+  var scope = this;
+
+  $.each(this.queryResults, function (queryResult, field) {
+
+    if (queryResult == "next") {
+      scope.populateAutocomplete(field);
+    }
+
+    $.each(field, function (entryCount, name) {
+      scope.results.push(name);
+    });
+  });
+
+  // Calculating the current page and the view
+  this.totalPages = Math.ceil(this.resultCount / 20);
+  this.populateResults(0);
+}
+
+Atmos.prototype.query = function(prefix, parameters, callback, pipeline) {
+  this.results = [];
+  this.dropdown = [];
+  this.resultTable.empty();
+  this.resultTable.append('<tr><th colspan="2">Results</th></tr>');
+
+  var queryPrefix = new Name(prefix);
+  queryPrefix.append("query");
+
+  var jsonString = JSON.stringify(parameters);
+  queryPrefix.append(jsonString);
+
+  this.state = {
+      prefix: new Name(prefix),
+      userOnData: callback,
+      outstanding: {},
+      nextSegment: 0,
+  };
+
+  /*if (state.hasOwnProperty("version")) {
+                console.log("state already has version");
+            }*/
+
+  var queryInterest = new Interest(queryPrefix);
+  queryInterest.setInterestLifetimeMilliseconds(10000);
+
+  var scope = this;
+
+  this.face.expressInterest(queryInterest,
+    function(){ //FIXME
+      scope.onQueryData.apply(scope, arguments); //TODO
+    }, function(){
+      scope.onQueryTimeout.apply(scope, arguments);
+    }
+  );
+
+  this.state["outstanding"][queryInterest.getName().toUri()] = 0;
+}
+
+Atmos.prototype.submitCatalogSearch = function(field) {
+  console.log("Sumbit Catalog Search: " + field);
+  // @todo: this logic isn't quite right
+  var remove = false;
+  var scope = this;
+  $.each(scope.selectedSearch, function (search, f) {
+    if (field == f) {
+      delete scope.selectedSearch[field];
+      remove = true;
+    }
+  });
+  if (!remove) {
+    $.each(scope.searchMenuOptions, function (search, fields) {
+      $.each(fields, function (index, f) {
+        if (f == field) {
+          scope.selectedSearch[search] = field;
+        }
+      });
+    });
+  }
+  this.query(scope.catalog, scope.selectedSearch, function(){
+    scope.onData.apply(scope, arguments); //Unknown arguments. FIXME (Works but could be improved for readability)
+  }, 1);
+  scope.populateCurrentSelections();
+  return false;//?? Is this used?
+}
+
+Atmos.prototype.expressNextInterest = function() {
   // @todo pipelines
   var nextName = new Name(state["results"]);
   nextName.appendSegment(state["nextSegment"]);
@@ -144,116 +190,133 @@
   var nextInterest = new Interest(nextName);
   nextInterest.setInterestLifetimeMilliseconds(10000);
 
-  face.expressInterest(nextInterest,
-      onQueryResultsData,
-      onQueryResultsTimeout);
+  var scope = this;
 
-  state["nextSegment"] ++;
-  state["outstanding"][nextName.toUri()] = 0;
+  this.face.expressInterest(nextInterest,
+      function(){
+        scope.onQueryResultsData.apply(scope, arguments); //FIXME
+      },
+      function(){
+        scope.onQueryResultsTimeout.apply(scope, arguments); //FIXME
+      });
+
+  this.state["nextSegment"] ++;
+  this.state["outstanding"][nextName.toUri()] = 0;
 }
 
-function onQueryData(interest, data) {
+Atmos.prototype.onQueryData = function(interest, data) {
   var name = data.getName();
 
-  delete state["outstanding"][interest.getName().toUri()];
+  delete this.state["outstanding"][interest.getName().toUri()];
 
-  state["version"] = name.get(state["prefix"].size() + 2).toVersion();
+  this.state["version"] = name.get(this.state["prefix"].size() + 2).toVersion();
 
-  state["results"] = new Name(state["prefix"]).append("query-results").appendVersion(state["version"]);
+  this.state["results"] = new Name(this.state["prefix"]).append("query-results").appendVersion(this.state["version"]);
 
-  expressNextInterest();
+  this.expressNextInterest();
 }
 
-function onQueryResultsData(interest, data) {
+Atmos.prototype.onQueryResultsData = function(interest, data) {
   var name = data.getName();
-  delete state["outstanding"][interest.getName().toUri()];
+  delete this.state["outstanding"][interest.getName().toUri()];
   if (!name.get(-1).equals(data.getMetaInfo().getFinalBlockId())) {
-    expressNextInterest();
+    this.expressNextInterest();
   } //else {
     //alert("found final block");
   //}
 
-  state["userOnData"](data);
+  this.state["userOnData"](data);
 }
 
-function onQueryTimeout(interest) {
+Atmos.prototype.onQueryTimeout = function(interest) {
   var uri = interest.getName().toUri();
-  if (state["outstanding"][uri] < 1) {
-    state["outstanding"][uri] ++;
-    face.expressInterest(interest,
-        onQueryData,
-        onQueryTimeout);
+  if (this.state["outstanding"][uri] < 1) {
+    this.state["outstanding"][uri] ++;
+    var scope = this;
+    this.face.expressInterest(interest,
+        function(){
+          scope.onQueryData.apply(scope, arguments);
+        },
+        function(){
+          scope.onQueryTimeout.apply(scope, arguments);
+        });
   } else {
-    delete state["outstanding"][uri];
+    delete this.state["outstanding"][uri];
 
     // We modify the autocomplete box here because we need to know
     // we have all of the entries first. Fairly hacky.
+    /* TODO FIXME
+    var autocompleteFullName = this.autocompleteText.value;
+    for (var i = 0; i < dropdown.length; ++i) {
+      if (this.dropdown[i].substr(0, dropdown[i].length - 1).toUpperCase === this.autocompleteText.value.toUpperCase || dropdown.length == 1) {
+        autocompleteText.value = dropdown[i];
+      }
+    }
+    */
+  }
+}
+
+Atmos.prototype.onQueryResultsTimeout = function(interest) {
+  var uri = interest.getName().toUri();
+  if (this.state["outstanding"][uri] < 1) {
+    this.state["outstanding"][uri] ++;
+    var scope = this;
+    this.face.expressInterest(interest,
+        function(){
+          scope.onQueryResultsData.apply(scope, arguments);
+        },
+        function(){
+          scope.onQueryResultsTimeout.apply(scope, arguments);
+        });
+  } else {
+    delete this.state["outstanding"][uri];
+    // We modify the autocomplete box here because we need to know
+    // we have all of the entries first. Fairly hacky.
+    /* TODO FIXME
     var autocompleteFullName = autocompleteText.value;
     for (var i = 0; i < dropdown.length; ++i) {
       if (dropdown[i].substr(0, dropdown[i].length - 1).toUpperCase === autocompleteText.value.toUpperCase || dropdown.length == 1) {
         autocompleteText.value = dropdown[i];
       }
     }
+    */
   }
 }
 
-function onQueryResultsTimeout(interest) {
-  var uri = interest.getName().toUri();
-  if (state["outstanding"][uri] < 1) {
-    state["outstanding"][uri] ++;
-    face.expressInterest(interest,
-        onQueryResultsData,
-        onQueryResultsTimeout);
+Atmos.prototype.populateResults = function(startIndex) {
+  this.resultTable.empty();
+  this.resultTable.append('<tr><th colspan="2">Results</th></tr>');
+
+
+  for (var i = startIndex; i < startIndex + 20 && i < this.results.length; ++i) {
+    resultTable.append('<tr><td>' + this.results[i]
+    + '</td><td><button class="interest-button btn btn-default btn-xs">Retrieve</button></td></tr>');
+  }
+
+  if (this.results.length <= 20) {
+    this.page = 1;
   } else {
-    delete state["outstanding"][uri];
-    // We modify the autocomplete box here because we need to know
-    // we have all of the entries first. Fairly hacky.
-    var autocompleteFullName = autocompleteText.value;
-    for (var i = 0; i < dropdown.length; ++i) {
-      if (dropdown[i].substr(0, dropdown[i].length - 1).toUpperCase === autocompleteText.value.toUpperCase || dropdown.length == 1) {
-        autocompleteText.value = dropdown[i];
-      }
-    }
-  }
-}
-
-
-
-
-function populateResults(startIndex) {
-  var resultTable = $(".resultTable");
-  resultTable.empty();
-  resultTable.append('<tr><th colspan="2">Results</th></tr>');
-
-
-  for (var i = startIndex; i < startIndex + 20 && i < results.length; ++i) {
-    resultTable.append('<tr><td>' + results[i]
-    + '</td><td><button class="interest-button btn btn-default btn-xs">Express Interest</button></td></tr>');
+    this.page = startIndex / 20 + 1;
   }
 
-  if (results.length <= 20) {
-    page = 1;
-  } else {
-    page = startIndex / 20 + 1;
-  }
+  this.totalPages = Math.ceil(this.results.length / 20);
 
-  totalPages = Math.ceil(results.length / 20);
-
+  //TODO Fix the page to fit the theme.
   var currentPage = $(".page");
   currentPage.empty();
-  if (page != 1) {
+  if (this.page != 1) {
     currentPage.append('<a href="#" onclick="getPage(this.id);" id="<"><</a>');
   }
   // This section of code creates the paging for the results.
   // To prevent it from having a 1000+ pages, it will only show the 5 pages before/after
   // the current page and the total pages (expect users not to really jump around a lot).
-  for (var i = 1; i <= totalPages; ++i) {
-    if (i == 1 || i == totalPages     // Min or max
-        || (i <= page && i + 5 >= page)    // in our current page range
-        || (i >= page && i - 5 <= page)) { // in our current page range
-      if (i != page) {
+  for (var i = 1; i <= this.totalPages; ++i) {
+    if (i == 1 || i == this.totalPages      // Min or max
+        || (i <= this.page && i + 5 >= this.page)    // in our current page range
+        || (i >= this.page && i - 5 <= this.page)) { // in our current page range
+      if (i != this.page) {
         currentPage.append(' <a href="#" onclick="getPage(' + i + ');">' + i + '</a>')
-        if (i == 1 && page > i + 5) {
+        if (i == 1 && this.page > i + 5) {
           currentPage.append(' ... ');
         }
       } else {
@@ -264,49 +327,23 @@
         currentPage.append(' ... ');
 
         currentPage.append(' <a href="#" onclick="getPage(this.id);" id=">">></a>')
-        i = totalPages - 1;
+        i = this.totalPages - 1;
       }
     }
   }
-  currentPage.append('  ' + results.length + ' results');
+  currentPage.append('  ' + this.results.length + ' results');
 }
 
-var dropState = "";
-
-function getDropDown(str) {
-  var searchMenu = $("#side-menu");
-  if (str == dropState) {
-    dropState = "";
-    searchMenu.find("#" + str).find("#options_" + str).empty();
-  } else {
-    dropState = str;
-
-    $.each(searchMenuOptions, function (search, fields) {
-      if (search === str) {
-        searchMenu.find("#" + search).append('<ul id="options_' + search + '" class="sub-menu">');
-        for (var i = 0; i < fields.length; ++i) {
-          searchMenu.find("#options_" + search).append('<li id="' + fields[i] + '" onclick="submitCatalogSearch(this.id)"><a href="#">' + fields[i] + '</a></li>');
-        }
-        searchMenu.append('</ul>');
-      } else {
-        var ul = $("options_" + search);
-        ul.empty();
-        searchMenu.find("#" + search).find("#options_" + search).empty();
-      }
-    });
-  }
-}
-
-function getPage(clickedPage) {
+Atmos.prototype.getPage = function(clickedPage) {
   console.log(clickedPage);
 
   var nextPage = clickedPage;
   if (clickedPage === "<") {
-    nextPage = page - 5;
+    nextPage = this.page - 5;
   } else if (clickedPage === ">") {
     console.log("> enabled");
 
-    nextPage = page + 5;
+    nextPage = this.page + 5;
   }
 
   nextPage--; // Need to adjust for starting at 0
@@ -314,16 +351,18 @@
   if (nextPage < 0 ) {
     nextPage = 0;
     console.log("0 enabled");
-  } else if (nextPage > totalPages - 1) {
-    nextPage = totalPages - 1;
+  } else if (nextPage > this.totalPages - 1) {
+    nextPage = this.totalPages - 1;
     console.log("total enabled");
   }
 
-  populateResults(nextPage * 20);
+  this.populateResults(nextPage * 20);
   return false;
 }
 
-function submitAutoComplete() {
+
+Atmos.prototype.submitAutoComplete = function() {
+  /* FIXME TODO
   if (autocompleteText.value.length > 0) {
     var selection = autocompleteText.value;
     $.each(dropdown, function (i, dropdownEntry) {
@@ -336,33 +375,11 @@
     query(catalog, selectedSearch, onData, 1);
     delete selectedSearch["?"];
   }
+  */
 }
 
-function submitCatalogSearch(field) {
-  console.log("Sumbit Catalog Search: " + field);
-  // @todo: this logic isn't quite right
-  var remove = false;
-  $.each(selectedSearch, function (search, f) {
-    if (field == f) {
-      delete selectedSearch[field];
-      remove = true;
-    }
-  });
-  if (!remove) {
-    $.each(searchMenuOptions, function (search, fields) {
-      $.each(fields, function (index, f) {
-        if (f == field) {
-          selectedSearch[search] = field;
-        }
-      });
-    });
-  }
-  query(catalog, selectedSearch, onData, 1);
-  populateCurrentSelections();
-  return false;
-}
-
-function populateAutocomplete(fields) {
+Atmos.prototype.populateAutocomplete = function(fields) {
+  /* FIXME TODO
   var isAutocompleteFullName = (autocompleteText.value.charAt(autocompleteText.value.length - 1) === "/");
   var autocompleteFullName = autocompleteText.value;
   for (var i = 0; i < fields.length; ++i) {
@@ -403,35 +420,34 @@
   $("#autocompleteText").autocomplete({
     source: dropdown
   });
+  */
 }
 
-function populateCurrentSelections() {
+Atmos.prototype.populateCurrentSelections = function() { //TODO
   var currentSelection = $(".currentSelections");
   currentSelection.empty();
 
   currentSelection.append("<p>Filtering on:");
 
-  $.each(selectedSearch, function (searchMenuCatagory, selection) {
-    currentSelection.append('  <a href="#" onclick="removeFilter(this.id);" id="' + searchMenuCatagory + ':' + selection + '">[X] ' + searchMenuCatagory + ":" + selection + '</a>');
+  var scope = this;
+
+  $.each(this.selectedSearch, function (searchMenuCatagory, selection) {
+    var e = $('<a href="#">[X] ' + searchMenuCatagory + ":" + selection + '</a>');
+    e.onclick(function(){
+      var searchFilter = $(this).text();
+
+      var search = "";
+      for (var j = 0; j < searchFilter.length; ++j) {
+        search += searchFilter[j] + " ";
+      }
+      console.log("Split values: '" + search + "'");
+
+      delete this.selectedSearch[searchFilter[0]];
+      this.query(catalog, selectedSearch, onData, 1);
+      populateCurrentSelections();
+    });
+    currentSelection.append(e);
   });
 
   currentSelection.append("</p>");
 }
-
-
-function removeFilter(filter) {
-  console.log("Remove filter" + filter);
-  var searchFilter = filter.split(":");
-
-  var search = "";
-  for (var j = 0; j < searchFilter.length; ++j) {
-    search += searchFilter[j] + " ";
-  }
-  console.log("Split values: '" + search + "'");
-
-  delete selectedSearch[searchFilter[0]];
-  query(catalog, selectedSearch, onData, 1);
-  populateCurrentSelections();
-
-  return false;
-}
\ No newline at end of file
diff --git a/client/query/query2.css b/client/query/query2.css
index d5e28d3..a39b328 100644
--- a/client/query/query2.css
+++ b/client/query/query2.css
@@ -17,3 +17,11 @@
 .sucess {
   color: green;
 }
+
+.subnav {
+  display: none;
+  max-height: 500px;
+  overflow: auto;
+  margin-left: 15px;
+  border-left: gray 3px solid;
+}
diff --git a/client/query/search_catagories.json b/client/query/search_catagories.json
index f506486..8d902ad 100644
--- a/client/query/search_catagories.json
+++ b/client/query/search_catagories.json
@@ -1,27 +1,539 @@
 {
     "SearchCatagories": {
-        "activity": ["CMIP5"],
-        "product": ["output1", "output2", "restricted", "unsolicited"],
-        "organization": ["BCC", "BNU", "CCCMA", "CMCC", "CNRM-CERFACS", "COLA-CFS", "CSIRO-BOM", "CSIRO-QCCCE", "FIO", "ICHEC", "INM", "INPE", "IPSL", "LASG-CESS", "LASG-IAP", "MIROC", "MOHC", "MPI-M", "MRI", "NASA-GISS", "NASA-GMAO", "NCAR", "NCC", "NCEP", "NICAM", "NIMR-KMA", "NOAA-GFDL", "NSF-DOE-NCAR", "SMHI", "UNSW"],
-        "model": ["ACCESS1.0", "ACCESS1.3", "BCC - CSM1.1", "BCC - CSM1.1(m)", "BNU - ESM", "CCSM4", "CESM1(BGC)", "CESM1(CAM5)", "CESM1(CAM5.1, FV2)", "CESM1(FASTCHEM)", "CESM1(WACCM)", "CFSv2 - 2011", "CMCC - CESM", "CMCC - CM", "CMCC - CMS", " CNRM - CM5", "CNRM - CM5 - 2", "CSIRO - Mk3.6.0", "CSIRO - Mk3L - 1 - 2", "CanAM4", "CanCM4", "CanESM2", "EC - EARTH", "FGOALS - g2", "FGOALS - gl", "FGOALS - s2", "FIO - ESM", "GEOS - 5", "GFDL - CM2.1", "GFDL - CM3", "GFDL - ESM2G", "GFDL - ESM2M", "GFDL - HIRAM - C180", "GFDL - HIRAM - C360", "GISS - E2 - H", "GISS - E2 - H - CC", "GISS - E2 - R", "GISS - E2 - R - CC", "HadCM3", "HadGEM2 - A", "HadGEM2 - AO", "HadGEM2 - CC ", "HadGEM2 - ES", "INM - CM4", "IPSL - CM5A - LR", "IPSL - CM5A - MR", "IPSL - CM5B - LR", "MIROC - ESM", "MIROC - ESM - CHEM", "MIROC4h", "MIROC5", "MPI - ESM - LR", "MPI - ESM - MR", "MPI - ESM - P", "MRI - AGCM3.2H", "MRI - AGCM3.2S", "MRI - CGCM3", "MRI - ESM1", "NICAM - 09", "NorESM1 - M", "NorESM1 - ME"],
-        "experiment": ["abrupt4xCO2", "amip", "amip4K", "amip4xCO2", "amipFuture", "aqua4K", "aqua4xCO2", "aquaControl", "decadal1959", "decadal1960", "decadal1961", "decadal1962", "decadal1963", "decadal1964", "decadal1965", "decadal1966", "decadal1967", "decadal1968", "decadal1969", "decadal1970", "decadal1971", "decadal1972", "decadal1973", "decadal1974", "decadal1975", "decadal1976", "decadal1977", "decadal1978", "decadal1979", "decadal1980", "decadal1981", "decadal1982", "decadal1983", "decadal1984", "decadal1985", "decadal1986", "decadal1987", "decadal1988", "decadal1989", "decadal1990", "decadal1991", "decadal1992", "decadal1993", "decadal1994", "decadal1995", "decadal1996", "decadal1997", "decadal1998", "decadal1999", "decadal2000", "decadal2001", "decadal2002", "decadal2003", "decadal2004", "decadal2005", "decadal2006", "decadal2007", "decadal2008", "decadal2009", "decadal2010", " decadal2011", "decadal2012", "esmControl", "esmFdbk1", "esmFdbk2", "esmFixClim1", "esmFixClim2", "esmHistorical", "esmrcp85", "historical", "historicalExt", "historicalGHG", "historicalMisc", "historicalNat", "lgm", "midHolocene", "noVolc1960", "noVolc1965", "noVolc1970", "noVolc1975", "noVolc1985", "noVolc1990", "noVolc1995", "noVolc2000", "noVolc2005", "past1000", "piControl", "rcp26", "rcp45", "rcp60", "rcp85", "sst2030", "sst2090", "sst2090rcp45", "sstClim", "sstClim4xCO2", "sstClimAerosol", "sstClimSulfate", "volcIn2010"],
-        "frequency": ["3hr", "6hr", "day", "fx", "mon", "monClim", "subhr", "yr"],
-        "modeling_realm": ["aerosol", "atmos", "land", "landIce", "ocean", "seaIce"],
-        "variable_name": ["agessc",
-                          "albisccp",
-                          "areacella",
-                          "areacello",
-                          "bmelt",
-                          "burntArea",
-                          "cCwd",
-                          "cLeaf",
-                          "cLitter",
-                          "cMisc",
-                          "cProduct",
-                          "cRoot",
-                          "cSoil",
-                          "cSoilFast",
-                          "cSoilMedium", "cSoilSlow", "cVeg", "cWood", "ccb", "cct", "cfc11", "ch4", "chl", "chlcalc", "chldiat", "chldiaz", "chlpico", "ci", "cl", "clcalipso", "clhcalipso", "cli", "clic", "clis", "clisccp", "clivi", "cllcalipso", "clmcalipso", "clt", "cltcalipso", "cltisccp", "clw", "clwc", "clws", "clwvi", "co2", "co3", "co3satarag", "co3satcalc", "deptho", "dfe", "dissic", "dissoc", "divice", "dpco2", "epc100", "epcalc100", "epfe100", "epsi100", "evap", "evspsbl", "expc", "expcalc", "expcfe", "expsi", "fFire", "fLitterSoil", "fLuc", "fVegLitter", "fbddtalk", "fbddtdic", "fbddtdife", "fbddtdin", "fbddtdip", "fbddtdisi", "fddtalk", "fddtdic", "fddtdife", "fddtdin", "fddtdip", "fddtdisi", "fgco2", "fgo2", "frn", "gpp", "grCongel", "grFrazil", "h2o", "hflssi", "hfss", "hfssi", "hur", "hurs", "hus", "huss", "intdic", "intpbsi", "intpcalc", "intpcalcite", "intpdiat", "intpdiaz", "intpn2", "intpnitrate", "intpp", "intppico", "lai", "lwsnl", "masso", "mc", "mrfso", "mrlsl", "mrro", "mrros", "mrso", "mrsofc", "mrsos", "msftbarot", "msftmyz", "msftmyzba", "n2o", "nbp", "nh4", "no3", "npp", "nppLeaf", "nppRoot", "nppWood", "o2", "o2min", "od550aer", "omlmax", "orog", "ph", "phyc", "phyfe", "phyn", "phyp", "phypico", "physi", "po4", "pr", "prc", "prsn", "prveg", "prw", "ps", "psl", "rGrowth", "rMaint", "ra", "reffclic", "reffclis", "reffclwc", "reffclws", "reffrains", "rlds", "rldscs", "rldssi", "rlus", "rlussi", "rlut", "rlutcs", "rsds", "rsdscs", "rsdssi", "rsdt", "rsntds", "rsus", "rsuscs", "rsut", "rsutcs", "rtmt", "sci", "sfcWind", "sftgif", "sftlf", "sftof", "si", "sic", "sit", "snc", "snoToIce", "snomelt", "snw", "so", "soga", "sootsn", "sos", "spco2", "strairx", "strairy", "streng", "strocnx", "strocny", "ta", "ta700", "talk", "tas", "tasmax", "tasmin", "tauu", "tauuo", "tauv", "tauvo", "thetao", "thetaoga", "thkcello", "tmelt", "tnhus", "tnhusa", "tnhusc", "tnhusd", "tnhusmp", "tnhusscpbl", "tnt", "tntc", "tntmp", "tntr", "tntscpbl", "tos", "tossq", "tran", "tro3", "ts", "tsice", "tsl", "ua", "umo", "uo", "usi", "va", "vmo", "vo", "volcello", "vsi", "wap", "wmo", "wmosq", "zg", "zo2min", "zooc", "zos", "zosga", "zossga", "zossq", "zostoga", "zsatarag", "zsatcalc"],
-        "ensemble": ["r0i0p0", "r10i1p1", "r10i2p1", "r1i1p1", "r1i1p10", "r1i1p11", "r1i1p12", "r1i1p13", "r1i1p14", "r1i1p15", "r1i1p16", "r1i1p17", "r1i1p2", "r1i1p3", "r1i2p1", "r1i2p2", "r2i1p1", "r2i1p10", "r2i1p11", "r2i1p12", "r2i1p13", "r2i1p14", "r2i1p16", "r2i1p17", "r2i2p1", "r3i1p1", "r3i1p10", "r3i1p11", "r3i1p13", "r3i1p14", "r3i1p16", "r3i1p17", "r3i2p1", "r4i1p1", "r4i1p10", "r4i1p11", "r4i1p12", "r4i1p14", "r4i1p15", "r4i1p16", "r4i1p17", "r4i2p1", "r5i1p1", "r5i2p1", "r6i1p1", "r6i1p10", "r6i1p11", "r6i1p12", "r6i1p13", "r6i1p14", "r6i1p15", "r6i1p16", "r6i1p17", "r6i2p1", "r7i1p1", "r7i2p1", "r8i1p1", "r8i2p1", "r9i1p1", "r9i2p1"]
+        "activity": [
+            "CMIP5"
+        ],
+        "product": [
+            "output1",
+            "output2",
+            "restricted",
+            "unsolicited"
+        ],
+        "organization": [
+            "BCC",
+            "BNU",
+            "CCCMA",
+            "CMCC",
+            "CNRM-CERFACS",
+            "COLA-CFS",
+            "CSIRO-BOM",
+            "CSIRO-QCCCE",
+            "FIO",
+            "ICHEC",
+            "INM",
+            "INPE",
+            "IPSL",
+            "LASG-CESS",
+            "LASG-IAP",
+            "MIROC",
+            "MOHC",
+            "MPI-M",
+            "MRI",
+            "NASA-GISS",
+            "NASA-GMAO",
+            "NCAR",
+            "NCC",
+            "NCEP",
+            "NICAM",
+            "NIMR-KMA",
+            "NOAA-GFDL",
+            "NSF-DOE-NCAR",
+            "SMHI",
+            "UNSW"
+        ],
+        "model": [
+            "ACCESS1.0",
+            "ACCESS1.3",
+            "BCC - CSM1.1",
+            "BCC - CSM1.1(m)",
+            "BNU - ESM",
+            "CCSM4",
+            "CESM1(BGC)",
+            "CESM1(CAM5)",
+            "CESM1(CAM5.1, FV2)",
+            "CESM1(FASTCHEM)",
+            "CESM1(WACCM)",
+            "CFSv2 - 2011",
+            "CMCC - CESM",
+            "CMCC - CM",
+            "CMCC - CMS",
+            " CNRM - CM5",
+            "CNRM - CM5 - 2",
+            "CSIRO - Mk3.6.0",
+            "CSIRO - Mk3L - 1 - 2",
+            "CanAM4",
+            "CanCM4",
+            "CanESM2",
+            "EC - EARTH",
+            "FGOALS - g2",
+            "FGOALS - gl",
+            "FGOALS - s2",
+            "FIO - ESM",
+            "GEOS - 5",
+            "GFDL - CM2.1",
+            "GFDL - CM3",
+            "GFDL - ESM2G",
+            "GFDL - ESM2M",
+            "GFDL - HIRAM - C180",
+            "GFDL - HIRAM - C360",
+            "GISS - E2 - H",
+            "GISS - E2 - H - CC",
+            "GISS - E2 - R",
+            "GISS - E2 - R - CC",
+            "HadCM3",
+            "HadGEM2 - A",
+            "HadGEM2 - AO",
+            "HadGEM2 - CC ",
+            "HadGEM2 - ES",
+            "INM - CM4",
+            "IPSL - CM5A - LR",
+            "IPSL - CM5A - MR",
+            "IPSL - CM5B - LR",
+            "MIROC - ESM",
+            "MIROC - ESM - CHEM",
+            "MIROC4h",
+            "MIROC5",
+            "MPI - ESM - LR",
+            "MPI - ESM - MR",
+            "MPI - ESM - P",
+            "MRI - AGCM3.2H",
+            "MRI - AGCM3.2S",
+            "MRI - CGCM3",
+            "MRI - ESM1",
+            "NICAM - 09",
+            "NorESM1 - M",
+            "NorESM1 - ME"
+        ],
+        "experiment": [
+            "abrupt4xCO2",
+            "amip",
+            "amip4K",
+            "amip4xCO2",
+            "amipFuture",
+            "aqua4K",
+            "aqua4xCO2",
+            "aquaControl",
+            "decadal1959",
+            "decadal1960",
+            "decadal1961",
+            "decadal1962",
+            "decadal1963",
+            "decadal1964",
+            "decadal1965",
+            "decadal1966",
+            "decadal1967",
+            "decadal1968",
+            "decadal1969",
+            "decadal1970",
+            "decadal1971",
+            "decadal1972",
+            "decadal1973",
+            "decadal1974",
+            "decadal1975",
+            "decadal1976",
+            "decadal1977",
+            "decadal1978",
+            "decadal1979",
+            "decadal1980",
+            "decadal1981",
+            "decadal1982",
+            "decadal1983",
+            "decadal1984",
+            "decadal1985",
+            "decadal1986",
+            "decadal1987",
+            "decadal1988",
+            "decadal1989",
+            "decadal1990",
+            "decadal1991",
+            "decadal1992",
+            "decadal1993",
+            "decadal1994",
+            "decadal1995",
+            "decadal1996",
+            "decadal1997",
+            "decadal1998",
+            "decadal1999",
+            "decadal2000",
+            "decadal2001",
+            "decadal2002",
+            "decadal2003",
+            "decadal2004",
+            "decadal2005",
+            "decadal2006",
+            "decadal2007",
+            "decadal2008",
+            "decadal2009",
+            "decadal2010",
+            " decadal2011",
+            "decadal2012",
+            "esmControl",
+            "esmFdbk1",
+            "esmFdbk2",
+            "esmFixClim1",
+            "esmFixClim2",
+            "esmHistorical",
+            "esmrcp85",
+            "historical",
+            "historicalExt",
+            "historicalGHG",
+            "historicalMisc",
+            "historicalNat",
+            "lgm",
+            "midHolocene",
+            "noVolc1960",
+            "noVolc1965",
+            "noVolc1970",
+            "noVolc1975",
+            "noVolc1985",
+            "noVolc1990",
+            "noVolc1995",
+            "noVolc2000",
+            "noVolc2005",
+            "past1000",
+            "piControl",
+            "rcp26",
+            "rcp45",
+            "rcp60",
+            "rcp85",
+            "sst2030",
+            "sst2090",
+            "sst2090rcp45",
+            "sstClim",
+            "sstClim4xCO2",
+            "sstClimAerosol",
+            "sstClimSulfate",
+            "volcIn2010"
+        ],
+        "frequency": [
+            "3hr",
+            "6hr",
+            "day",
+            "fx",
+            "mon",
+            "monClim",
+            "subhr",
+            "yr"
+        ],
+        "modeling_realm": [
+            "aerosol",
+            "atmos",
+            "land",
+            "landIce",
+            "ocean",
+            "seaIce"
+        ],
+        "variable_name": [
+            "agessc",
+            "albisccp",
+            "areacella",
+            "areacello",
+            "bmelt",
+            "burntArea",
+            "cCwd",
+            "cLeaf",
+            "cLitter",
+            "cMisc",
+            "cProduct",
+            "cRoot",
+            "cSoil",
+            "cSoilFast",
+            "cSoilMedium",
+            "cSoilSlow",
+            "cVeg",
+            "cWood",
+            "ccb",
+            "cct",
+            "cfc11",
+            "ch4",
+            "chl",
+            "chlcalc",
+            "chldiat",
+            "chldiaz",
+            "chlpico",
+            "ci",
+            "cl",
+            "clcalipso",
+            "clhcalipso",
+            "cli",
+            "clic",
+            "clis",
+            "clisccp",
+            "clivi",
+            "cllcalipso",
+            "clmcalipso",
+            "clt",
+            "cltcalipso",
+            "cltisccp",
+            "clw",
+            "clwc",
+            "clws",
+            "clwvi",
+            "co2",
+            "co3",
+            "co3satarag",
+            "co3satcalc",
+            "deptho",
+            "dfe",
+            "dissic",
+            "dissoc",
+            "divice",
+            "dpco2",
+            "epc100",
+            "epcalc100",
+            "epfe100",
+            "epsi100",
+            "evap",
+            "evspsbl",
+            "expc",
+            "expcalc",
+            "expcfe",
+            "expsi",
+            "fFire",
+            "fLitterSoil",
+            "fLuc",
+            "fVegLitter",
+            "fbddtalk",
+            "fbddtdic",
+            "fbddtdife",
+            "fbddtdin",
+            "fbddtdip",
+            "fbddtdisi",
+            "fddtalk",
+            "fddtdic",
+            "fddtdife",
+            "fddtdin",
+            "fddtdip",
+            "fddtdisi",
+            "fgco2",
+            "fgo2",
+            "frn",
+            "gpp",
+            "grCongel",
+            "grFrazil",
+            "h2o",
+            "hflssi",
+            "hfss",
+            "hfssi",
+            "hur",
+            "hurs",
+            "hus",
+            "huss",
+            "intdic",
+            "intpbsi",
+            "intpcalc",
+            "intpcalcite",
+            "intpdiat",
+            "intpdiaz",
+            "intpn2",
+            "intpnitrate",
+            "intpp",
+            "intppico",
+            "lai",
+            "lwsnl",
+            "masso",
+            "mc",
+            "mrfso",
+            "mrlsl",
+            "mrro",
+            "mrros",
+            "mrso",
+            "mrsofc",
+            "mrsos",
+            "msftbarot",
+            "msftmyz",
+            "msftmyzba",
+            "n2o",
+            "nbp",
+            "nh4",
+            "no3",
+            "npp",
+            "nppLeaf",
+            "nppRoot",
+            "nppWood",
+            "o2",
+            "o2min",
+            "od550aer",
+            "omlmax",
+            "orog",
+            "ph",
+            "phyc",
+            "phyfe",
+            "phyn",
+            "phyp",
+            "phypico",
+            "physi",
+            "po4",
+            "pr",
+            "prc",
+            "prsn",
+            "prveg",
+            "prw",
+            "ps",
+            "psl",
+            "rGrowth",
+            "rMaint",
+            "ra",
+            "reffclic",
+            "reffclis",
+            "reffclwc",
+            "reffclws",
+            "reffrains",
+            "rlds",
+            "rldscs",
+            "rldssi",
+            "rlus",
+            "rlussi",
+            "rlut",
+            "rlutcs",
+            "rsds",
+            "rsdscs",
+            "rsdssi",
+            "rsdt",
+            "rsntds",
+            "rsus",
+            "rsuscs",
+            "rsut",
+            "rsutcs",
+            "rtmt",
+            "sci",
+            "sfcWind",
+            "sftgif",
+            "sftlf",
+            "sftof",
+            "si",
+            "sic",
+            "sit",
+            "snc",
+            "snoToIce",
+            "snomelt",
+            "snw",
+            "so",
+            "soga",
+            "sootsn",
+            "sos",
+            "spco2",
+            "strairx",
+            "strairy",
+            "streng",
+            "strocnx",
+            "strocny",
+            "ta",
+            "ta700",
+            "talk",
+            "tas",
+            "tasmax",
+            "tasmin",
+            "tauu",
+            "tauuo",
+            "tauv",
+            "tauvo",
+            "thetao",
+            "thetaoga",
+            "thkcello",
+            "tmelt",
+            "tnhus",
+            "tnhusa",
+            "tnhusc",
+            "tnhusd",
+            "tnhusmp",
+            "tnhusscpbl",
+            "tnt",
+            "tntc",
+            "tntmp",
+            "tntr",
+            "tntscpbl",
+            "tos",
+            "tossq",
+            "tran",
+            "tro3",
+            "ts",
+            "tsice",
+            "tsl",
+            "ua",
+            "umo",
+            "uo",
+            "usi",
+            "va",
+            "vmo",
+            "vo",
+            "volcello",
+            "vsi",
+            "wap",
+            "wmo",
+            "wmosq",
+            "zg",
+            "zo2min",
+            "zooc",
+            "zos",
+            "zosga",
+            "zossga",
+            "zossq",
+            "zostoga",
+            "zsatarag",
+            "zsatcalc"
+        ],
+        "ensemble": [
+            "r0i0p0",
+            "r10i1p1",
+            "r10i2p1",
+            "r1i1p1",
+            "r1i1p10",
+            "r1i1p11",
+            "r1i1p12",
+            "r1i1p13",
+            "r1i1p14",
+            "r1i1p15",
+            "r1i1p16",
+            "r1i1p17",
+            "r1i1p2",
+            "r1i1p3",
+            "r1i2p1",
+            "r1i2p2",
+            "r2i1p1",
+            "r2i1p10",
+            "r2i1p11",
+            "r2i1p12",
+            "r2i1p13",
+            "r2i1p14",
+            "r2i1p16",
+            "r2i1p17",
+            "r2i2p1",
+            "r3i1p1",
+            "r3i1p10",
+            "r3i1p11",
+            "r3i1p13",
+            "r3i1p14",
+            "r3i1p16",
+            "r3i1p17",
+            "r3i2p1",
+            "r4i1p1",
+            "r4i1p10",
+            "r4i1p11",
+            "r4i1p12",
+            "r4i1p14",
+            "r4i1p15",
+            "r4i1p16",
+            "r4i1p17",
+            "r4i2p1",
+            "r5i1p1",
+            "r5i2p1",
+            "r6i1p1",
+            "r6i1p10",
+            "r6i1p11",
+            "r6i1p12",
+            "r6i1p13",
+            "r6i1p14",
+            "r6i1p15",
+            "r6i1p16",
+            "r6i1p17",
+            "r6i2p1",
+            "r7i1p1",
+            "r7i2p1",
+            "r8i1p1",
+            "r8i2p1",
+            "r9i1p1",
+            "r9i2p1"
+        ]
     }
-}
+}
\ No newline at end of file