From 78e553f2d66888dc49ed1600b9013cb56d305d23 Mon Sep 17 00:00:00 2001
From: o9h <hoppdj@ornl.gov>
Date: Thu, 20 Apr 2023 17:24:58 -0400
Subject: [PATCH] Update jarvisCommands to use new DB functions

---
 code/html/jarvisWorld.html            |   4 +-
 code/javascript/jarvisCommands.js     | 797 +++++---------------------
 code/javascript/jarvisCommands_New.js |  22 -
 code/javascript/jarvisCommands_Old.js | 680 ++++++++++++++++++++++
 code/javascript/jarvisFunctions.js    | 110 ++--
 code/php/getFlyToCoords.php           |  10 +-
 code/php/getFlyToCoords_old.php       |  44 ++
 code/php/importBordersById.php        |   2 +-
 8 files changed, 958 insertions(+), 711 deletions(-)
 delete mode 100644 code/javascript/jarvisCommands_New.js
 create mode 100644 code/javascript/jarvisCommands_Old.js
 create mode 100644 code/php/getFlyToCoords_old.php

diff --git a/code/html/jarvisWorld.html b/code/html/jarvisWorld.html
index 6efdc101..1ad37b4f 100755
--- a/code/html/jarvisWorld.html
+++ b/code/html/jarvisWorld.html
@@ -94,7 +94,7 @@
     </style>
 
 <script src="../javascript/jarvisFunctions.js"></script>
-<script src="../javascript/jarvisCommands_New.js"></script>
+<script src="../javascript/jarvisCommands.js"></script>
 <script src="../javascript/jarvisWorld.js"></script>
 <script src="../javascript/jarvisMenus.js"></script>
 <script src="../javascript/exportFunctions.js"></script>
@@ -110,7 +110,7 @@
     <input id="ShowWorld" type="text" size = "50" value="Typed or spoken commands for Jarvis are shown here"></input>
 <button id="inputmode" onClick="switchinputmodes()">Use Menus </button> 
 <h1><p style="color:white">Choose the data that you wish to explore.</p></h1>
-<button id="dataset" onClick="jarvisCommand('Jarvis show me poplar')">Poplar Genets </button>
+<button id="dataset" onClick="jarvisCommand('Jarvis show me Poplar Genets points')">Poplar Genets </button>
 <button id="dataset" onClick="jarvisCommand('Jarvis show me points Stress Gradients');jarvisCommand('Jarvis show me Stress Gradients');">Stress Gradients</button> 
 <button id="dataset" onClick="jarvisCommand('Jarvis show me switchgrass')">Switchgrass Genets </button>
 <button id="dataset" onClick="jarvisCommand('Jarvis show me the common gardens')">Common Gardens </button>
diff --git a/code/javascript/jarvisCommands.js b/code/javascript/jarvisCommands.js
index 0facaab7..e54f205f 100755
--- a/code/javascript/jarvisCommands.js
+++ b/code/javascript/jarvisCommands.js
@@ -1,680 +1,199 @@
 //Jarvis voice functions. Is the entities variable being used anywhere?
 function jarvisCommand(command){
-    command = command.toUpperCase();
-
-    if (command.includes('jarvis'.toUpperCase())){
-        console.log(command);
-        switch (true) {
-
-            case command =='hello Jarvis':
-
-                speechSynthesis.speak(new SpeechSynthesisUtterance("Hello there. What can I do for you today?"));
-                break;
-
-            case command.includes('world'.toUpperCase()):
-                // start viewer
-                initializeViewer();
-
-                // initialize entity selection listeners
-                entitySelection();
-
-                // initialize listener for rightclick export menu
-                //exportMenuListeners();
-
-                console.log('Viewer initialized');
-                break;
-
-
-            /* NON FLY-TO POINTS --------------------------------------------------------------------------------------------------*/    
-            // fly-to for a non-bsd_site table needs to be revisited (really the whole system for various DB data sources)
-            case (command.includes('show me popular'.toUpperCase())|| command.includes('show me poplar'.toUpperCase())):
-                qryParams = '{"queryName" : "poplar_genets"}';
-                fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
-                break;
-
-            case (command.includes('show me Metabolomics'.toUpperCase())):
-                qryParams = '{"queryName" : "metabolomics"}';
-                fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
-                break;
-
-            case command.includes('show me switchgrass'.toUpperCase()):
-                qryParams = '{"queryName" : "switchgrass_genets"}';
-                fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
-                 break;
-
-            case (command.includes('show me points No Name organisms'.toUpperCase()) ||
-                command.includes('show me points organisms with no name'.toUpperCase()) ||
-                command.includes('show me points organisms with no names'.toUpperCase()) ||
-                command.includes('show me points organisms with null names'.toUpperCase()) ||
-                command.includes('show me points organisms that have no name'.toUpperCase())):
-                qryParams = '{"queryName" : "no_name_organisms"}';
-                fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
-                break;
-            
-            /* ROUTES ---------------------------------------------------------------------------------------------------------------*/
-            case (command.includes('show me Pando D routes'.toUpperCase())|| command.includes('show me panda D routes'.toUpperCase())):
-                startingPoint = (command.substring(command.indexOf('SHOW ME PANDO D ROUTES') + 'SHOW ME PANDO D ROUTES'.length)).trim();
-                routeTable = 'routes_pando_d';
-                tsParams = '{"routeTable" : "' + routeTable + '", "startingPoint" : "' + startingPoint + '"}';
-                fetchWithTextBodyAndJsonResponse("../php/importTsRoutes.php", tsParams);
-                break;
-
-
-            /* POINTS ---------------------------------------------------------------------------------------------------------------*/
-            case (command.includes('show me points Pando E'.toUpperCase())|| command.includes('show me points panda E'.toUpperCase())):
-                fetchAndFlyTo("7", 'lookup_borders_plot');
-                break;      
-            case (command.includes('show me points Pando A'.toUpperCase())|| command.includes('show me points panda A'.toUpperCase())):
-                fetchAndFlyTo("8", 'lookup_borders_plot');
-                break;
-            case (command.includes('show me points Pando H'.toUpperCase())|| command.includes('show me points panda H'.toUpperCase())):
-                fetchAndFlyTo("9", 'lookup_borders_plot');
-                break;
-            case (command.includes('show me points Pando D'.toUpperCase())|| command.includes('show me points panda D'.toUpperCase())):
-                fetchAndFlyTo("6", 'lookup_borders_plot');
-                break;   
-
-            // Show the points of all of davis' subplots and fly to the center of the main border
-            case (command.includes('show me points davis'.toUpperCase())):
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 10); // Drought Block 1
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 19); // Drought Block 2
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 20); // Drought Block 3
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 21); // Control Block 3
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 22); // Control Block 2
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 23); // Control Block 1
-                fetchWithTextBodyAndJsonResponseFlyTo("../php/getFlyToCoords.php", 3, 'lookup_borders');
-                break;
-
-            case (command.includes('show me points Drought Block 1'.toUpperCase())):
-                fetchAndFlyTo(10, 'lookup_borders_plot');
-                break;
-
-            case (command.includes('show me points Drought Block 2'.toUpperCase())):
-                fetchAndFlyTo(19, 'lookup_borders_plot');
-                break;
-
-            case (command.includes('show me points Drought Block 3'.toUpperCase())):
-                fetchAndFlyTo(20, 'lookup_borders_plot');
-                break;
-
-            case (command.includes('show me points Control Block 1'.toUpperCase())):
-                fetchAndFlyTo(23, 'lookup_borders_plot');
-                break;
-
-            case (command.includes('show me points Control Block 2'.toUpperCase())):
-                fetchAndFlyTo(22, 'lookup_borders_plot');
-                break;
-
-            case (command.includes('show me points Control Block 3'.toUpperCase())):
-                fetchAndFlyTo(21, 'lookup_borders_plot');
-                break;
-
-
-            // PMI Stress Gradients
-            case (command.includes('show me points Stress Gradients'.toUpperCase())):
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 25); // Leach Lake Pacific Crest Trailhead
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 26); // Convey Rainer vista 11
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 27); // Miriam creek bridge
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 28); // Rim Rock
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 29); // Forest road 504
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 30); // Titan near Sentinel creek
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 31); // Windy Point boat launch
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 32); // Titan naches confluence
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 33); // Rowe public access Naches River
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 34); // Minto creek rd quarry
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 35); // Marion creek fish hatchery
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 36); // Quartzville Byway
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 37); // Parish Lake road
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 38); // Lost Lake
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 39); // Creek bed forest road 1514
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 40); // Forest road 1514 big ass poplar
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 41); // Three creeks road sisters
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 42); // Camp Polk Preserve
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 43); // Alder Spring crossing
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 44); // Cove palisades
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 45); // Indian museum
-                break;
-
-
-            case (command.includes('show me points caney'.toUpperCase())|| command.includes('show me points fork'.toUpperCase())):
-                fetchAndFlyTo("14", 'lookup_borders_plot');
-                break;
-
-            case (command.includes('show me points seeds'.toUpperCase())):
-                fetchAndFlyTo("11", 'lookup_borders_plot');
-                break;
-
-            case (command.includes('show me points south carolina'.toUpperCase())):
-                fetchAndFlyTo("12", 'lookup_borders_plot');
-                break;  
-
-            case (command.includes('show me points corvallis common gardens'.toUpperCase())):
-                fetchAndFlyTo("3", 'lookup_borders_plot');
-                break;
-
-            case (command.includes('show me points stoolbed'.toUpperCase())):
-                fetchAndFlyTo("15", 'lookup_borders_plot');
-                break;   
-
-            case (command.includes('show me points clatskanie'.toUpperCase())):
-                fetchAndFlyTo("2", 'lookup_borders_plot');
-                break;
-
-            // Show the points of all of westport's subplots and fly to the center of the main border
-            case (command.includes('show me points westport'.toUpperCase())):
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 16);
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 17);
-                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 18);
-                fetchWithTextBodyAndJsonResponseFlyTo("../php/getFlyToCoords.php", 1, 'lookup_borders');
-                break;
-
-            case (command.includes('show me points 2020 QTL Trial Rep 1 and 2'.toUpperCase())):
-                fetchAndFlyTo("18", 'lookup_borders_plot');
-            break;  
-
-            case (command.includes('show me points 2020 QTL Trial Rep 3'.toUpperCase())):
-                fetchAndFlyTo("17", 'lookup_borders_plot');
-            break;   
-
-            case (command.includes('show me points 7 by 7'.toUpperCase()) || 
-            command.includes('show me points seven by seven'.toUpperCase()) ||
-            command.includes('show me points 7x7'.toUpperCase()) ||
-            command.includes('show me points 7 x 7'.toUpperCase())):
-                fetchAndFlyTo("16", 'lookup_borders_plot');
-            break;   
-
-            case (command.includes('show me points Tennessee'.toUpperCase()) || 
-                    command.includes('SHOW ME points utk SWITCHGRASS'.toUpperCase())):
-                fetchAndFlyTo("13", 'lookup_borders_plot');
-                break;
-
-
-
-            /* GENOTYPE ---------------------------------------------------------------------------------------------------------------*/
-            // --04-NOV-2022 query_site_genotype() needs to be updated
-            case (command.includes('SHOW ME GENOTYPE') || command.includes('SHOW ME GENO TYPE')):
-                genotype = '';
-                // get genotype string
-                if (command.includes('SHOW ME GENOTYPE')){
-                    genotype = command.substring(command.indexOf('JARVIS SHOW ME GENOTYPE') + 'JARVIS SHOW ME GENOTYPE'.length);
-                }
-                else if (command.includes('SHOW ME GENO TYPE')){
-                    genotype = command.substring(command.indexOf('JARVIS SHOW ME GENO TYPE') + 'JARVIS SHOW ME GENO TYPE'.length);
-                }
-                // pass genotype to DB for query
-                genotype = genotype.trim();
-                if (genotype.length > 0) {
-                    fetchWithTextBodyAndJsonResponse("../php/importGenotype.php", genotype)
-                }
-                break;
-
-
-            /* OUTLIERS ---------------------------------------------------------------------------------------------------------------*/
-            case (command.includes('show me outliers exif'.toUpperCase())):
-
-                break;
-
-
-            /* DEAD TREES -------------------------------------------------------------------------------------------------------------*/
-
-
-
-
-            /* BORDERS ---------------------------------------------------------------------------------------------------------------*/
-            
-            // Show ALL parent and child borders with a point marker in the center of each. Do not fly to
-            case (command.includes('show me borders'.toUpperCase())):
-                // children are red
-                drawPolygon("lookup_borders_plot", "#FD1134", Cesium.Color.RED);
-                // parents are orange
-                drawPolygon("lookup_borders", "#FF6600", Cesium.Color.DARKORANGE);
-                break;
-
-            // Common gardens    
-            case (command.includes('SHOW ME GARDENS'.toUpperCase()) || 
-            command.includes('SHOW ME THE COMMON GARDENS'.toUpperCase()) ||
-            command.includes('SHOW ME COMMON GARDENS'.toUpperCase())):
-                drawPolygonById(3,'lookup_borders', Cesium.Color.DARKORANGE); // Davis
-                drawPolygonById(2,'lookup_borders', Cesium.Color.DARKORANGE); // Corvallis
-                drawPolygonById(1,'lookup_borders', Cesium.Color.DARKORANGE); // Westport
-                drawPolygonById(3,'lookup_borders_plot', Cesium.Color.RED); // Corvallis Common Garden
-                drawPolygonById(10,'lookup_borders_plot', Cesium.Color.RED); // Drought Block 1
-                drawPolygonById(19,'lookup_borders_plot', Cesium.Color.RED); // Drought Block 2
-                drawPolygonById(20,'lookup_borders_plot', Cesium.Color.RED); // Drought Block 3
-                drawPolygonById(23,'lookup_borders_plot', Cesium.Color.RED); // Control Block 1
-                drawPolygonById(22,'lookup_borders_plot', Cesium.Color.RED); // Control Block 2
-                drawPolygonById(21,'lookup_borders_plot', Cesium.Color.RED); // Control Block 3
-                drawPolygonById(13,'lookup_borders_plot', Cesium.Color.DARKORANGE);// UTK Switchgrass
-                fetchWithTextBodyAndJsonResponseFlyTo("../php/getFlyToCoords.php", 4, 'lookup_borders');
-                break;
-            
-            // PMI Stress Gradients
-            case (command.includes('show me Stress Gradients'.toUpperCase())):
-                drawPolygonById(25,'lookup_borders_plot', Cesium.Color.RED); // Leach Lake Pacific Crest Trailhead
-                drawPolygonById(26,'lookup_borders_plot', Cesium.Color.RED); // Convey Rainer vista 11
-                drawPolygonById(27,'lookup_borders_plot', Cesium.Color.RED); // Miriam creek bridge
-                drawPolygonById(28,'lookup_borders_plot', Cesium.Color.RED); // Rim Rock
-                drawPolygonById(29,'lookup_borders_plot', Cesium.Color.RED); // Forest road 504
-                drawPolygonById(30,'lookup_borders_plot', Cesium.Color.RED); // Titan near Sentinel creek
-                drawPolygonById(31,'lookup_borders_plot', Cesium.Color.RED); // Windy Point boat launch
-                drawPolygonById(32,'lookup_borders_plot', Cesium.Color.RED); // Titan naches confluence
-                drawPolygonById(33,'lookup_borders_plot', Cesium.Color.RED); // Rowe public access Naches River
-                drawPolygonById(34,'lookup_borders_plot', Cesium.Color.RED); // Minto creek rd quarry
-                drawPolygonById(35,'lookup_borders_plot', Cesium.Color.RED); // Marion creek fish hatchery
-                drawPolygonById(36,'lookup_borders_plot', Cesium.Color.RED); // Quartzville Byway
-                drawPolygonById(37,'lookup_borders_plot', Cesium.Color.RED); // Parish Lake road
-                drawPolygonById(38,'lookup_borders_plot', Cesium.Color.RED); // Lost Lake
-                drawPolygonById(39,'lookup_borders_plot', Cesium.Color.RED); // Creek bed forest road 1514
-                drawPolygonById(40,'lookup_borders_plot', Cesium.Color.RED); // Forest road 1514 big ass poplar
-                drawPolygonById(41,'lookup_borders_plot', Cesium.Color.RED); // Three creeks road sisters
-                drawPolygonById(42,'lookup_borders_plot', Cesium.Color.RED); // Camp Polk Preserve
-                drawPolygonById(43,'lookup_borders_plot', Cesium.Color.RED); // Alder Spring crossing
-                drawPolygonById(44,'lookup_borders_plot', Cesium.Color.RED); // Cove palisades
-                drawPolygonById(45,'lookup_borders_plot', Cesium.Color.RED); // Indian museum                
-                break;
-
-
-            case (command.includes('show me Tennessee border'.toUpperCase()) || command.includes('SHOW ME utk SWITCHGRASS border'.toUpperCase())):
-                fetchAndFlyToPolygon("13", 'lookup_borders_plot', Cesium.Color.BLUE);
-                break;
-            case (command.includes('show me Pando D'.toUpperCase())|| command.includes('show me panda D'.toUpperCase())):
-
-                fetchAndFlyToPolygon("6", 'lookup_borders_plot', Cesium.Color.BLUE);
-                break;                
-            case (command.includes('show me Pando E border'.toUpperCase())|| command.includes('show me panda E border'.toUpperCase())):
-                fetchAndFlyToPolygon("7", 'lookup_borders_plot', Cesium.Color.BLUE);
-                break;  
-            case (command.includes('show me Pando A border'.toUpperCase())|| command.includes('show me panda A border'.toUpperCase())):
-                fetchAndFlyToPolygon("8", 'lookup_borders_plot', Cesium.Color.BLUE);
-                break;
-            case (command.includes('show me Pando H border'.toUpperCase())|| command.includes('show me panda H border'.toUpperCase())):
-                fetchAndFlyToPolygon("9", 'lookup_borders_plot', Cesium.Color.BLUE);
-                break;  
-
-            case (command.includes('show me caney border'.toUpperCase())|| command.includes('show me caney forks border'.toUpperCase())):
-
-
-                fetchAndFlyToPolygon("14", 'lookup_borders_plot', Cesium.Color.BLUE);
-                break;
-
-            case (command.includes('show me davis border'.toUpperCase())):
-                fetchAndFlyToPolygon("3", 'lookup_borders', Cesium.Color.DARKORANGE);
-
-                break;
-
-            case (command.includes('show me seeds border'.toUpperCase())):
-                fetchAndFlyToPolygon("11", 'lookup_borders_plot', Cesium.Color.BLUE);
-                break;
-
-            case (command.includes('show me south carolina border'.toUpperCase())):
-                fetchAndFlyToPolygon("12", 'lookup_borders_plot', Cesium.Color.BLUE);
-                break;
-
-            case (command.includes('show me corvallis border'.toUpperCase())):
-                fetchAndFlyToPolygon("2", 'lookup_borders', Cesium.Color.DARKORANGE);
-                break;
-
-            // All corvallis-related command's text ordering needs to be looked at (More importantly the entire 
-            // command system needs to be revamped):
-            case (command.includes('show me border corvallis common gardens'.toUpperCase())):
-                fetchAndFlyToPolygon("3", 'lookup_borders_plot', Cesium.Color.RED);
-                break;
-
-            case (command.includes('show me stoolbed border'.toUpperCase())):
-                fetchAndFlyToPolygon("15", 'lookup_borders_plot', Cesium.Color.RED);
-                break;
-
-            case (command.includes('show me clatskanie border'.toUpperCase())):
-                fetchAndFlyToPolygon("2", 'lookup_borders_plot', Cesium.Color.BLUE);
-                break;
-
-            case (command.includes('show me westport border'.toUpperCase())):
-                fetchAndFlyToPolygon("1", 'lookup_borders', Cesium.Color.BLUE);
-                break;    
-
-            case (command.includes('show me 7 by 7 border'.toUpperCase()) || 
-            command.includes('show me seven by seven border'.toUpperCase()) ||
-            command.includes('show me 7x7 border'.toUpperCase()) ||
-            command.includes('show me 7 x 7 border'.toUpperCase())):
-                fetchAndFlyToPolygon("16", 'lookup_borders_plot', Cesium.Color.RED);
-            break;     
-
-
-            /* DOWNLOAD POINTS ---------------------------------------------------------------------------------------------------------*/
-            case (command.includes('download westport points'.toUpperCase())):
-                downloadPoints("1","border_id", "WestportPlots");
-                break;
-
-            case (command.includes('download 7 by 7 points'.toUpperCase()) || 
-            command.includes('download seven by seven points'.toUpperCase()) ||
-            command.includes('download 7x7 points'.toUpperCase()) ||
-            command.includes('download 7 x 7 points'.toUpperCase())):   
-                downloadPoints("16","solo.id", "7x7_Matrix");
-                break;
-
-            case (command.includes('download corvallis points'.toUpperCase())):
-                downloadPoints("3","solo.id", "CorvallisCommonGarden");
-                break;
-
-            case (command.includes('download stoolbed points'.toUpperCase())):
-                downloadPoints("15","solo.id", "StoolbedCloneBank");
-                break;
-
-            case (command.includes('download davis points'.toUpperCase())):
-                downloadPoints("3","border_id", "DavisCommonGardenTreeLocations");
-                break;
-
-            case (command.includes('download seeds points'.toUpperCase())):
-                downloadPoints("11","solo.id", "SeedsCommonGarden");
-                break;
-
-            case (command.includes('download Pando E points'.toUpperCase())|| command.includes('download panda E points'.toUpperCase())):
-                downloadPoints("7","solo.id", "Pando_E_Forest");
-                break;      
-            case (command.includes('download Pando A points'.toUpperCase())|| command.includes('download panda A points'.toUpperCase())):
-                downloadPoints("8","solo.id", "Pando_A_Forest");
-                break;
-            case (command.includes('download Pando H points'.toUpperCase())|| command.includes('download panda H points'.toUpperCase())):
-                downloadPoints("9","solo.id", "Pando_H_Forest");
-                break;
-            case (command.includes('download Pando D points'.toUpperCase())|| command.includes('download panda D points'.toUpperCase())):
-                downloadPoints("6","solo.id", "Pando_D_Forest");
-                break;
-
-            case (command.includes('download Clatskanie points'.toUpperCase())):
-                downloadPoints("2","solo.id", "ClatskanieCommonGarden");
-            break;
 
-            case (command.includes('download Boardman points'.toUpperCase())):
-                downloadPoints("1","solo.id", "BoardmanCommonGarden");
-            break;
+    // remove whitespaces
+    command = command.trim()
+    command = command.toUpperCase(); // Will be removed once all commands are processed by the database
+    switch (true) {
 
-            case (command.includes('download Placerville points'.toUpperCase())):
-                downloadPoints("4","solo.id", "PlacervilleCommonGarden");
+        // Old Command functions to be improved/replaced
+        /* NON FLY-TO POINTS --------------------------------------------------------------------------------------------------*/    
+        case (command.includes('Jarvis show me Metabolomics'.toUpperCase())):
+            qryParams = '{"queryName" : "metabolomics"}';
+            fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
             break;
 
-            case (command.includes('download Sedona points'.toUpperCase())):
-                downloadPoints("5","solo.id", "SedonaCommonGarden");
+        case command.includes('Jarvis show me switchgrass'.toUpperCase()):
+            qryParams = '{"queryName" : "switchgrass_genets"}';
+            fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
+             break;
+        case (command.includes('Jarvis show me points No Name organisms'.toUpperCase()) ||
+        command.includes('Jarvis show me points organisms with no name'.toUpperCase()) ||
+        command.includes('Jarvis show me points organisms with no names'.toUpperCase()) ||
+        command.includes('Jarvis show me points organisms with null names'.toUpperCase()) ||
+        command.includes('Jarvis show me points organisms that have no name'.toUpperCase())):
+        qryParams = '{"queryName" : "no_name_organisms"}';
+        fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
+        break;
+
+        /* ROUTES ---------------------------------------------------------------------------------------------------------------*/
+        case (command.includes('Jarvis show me Pando D routes'.toUpperCase())|| command.includes('Jarvis show me panda D routes'.toUpperCase())):
+            startingPoint = (command.substring(command.indexOf('SHOW ME PANDO D ROUTES') + 'SHOW ME PANDO D ROUTES'.length)).trim();
+            routeTable = 'routes_pando_d';
+            tsParams = '{"routeTable" : "' + routeTable + '", "startingPoint" : "' + startingPoint + '"}';
+            fetchWithTextBodyAndJsonResponse("../php/importTsRoutes.php", tsParams);
             break;
-
-            case (command.includes('download Tennessee points'.toUpperCase()) || 
-            command.includes('download utk SWITCHGRASS points'.toUpperCase())):
-                downloadPoints("13","solo.id", "TennesseeCommonGarden");
+        
+        /* GENOTYPE ---------------------------------------------------------------------------------------------------------------*/
+        // --04-NOV-2022 query_site_genotype() needs to be updated
+        case (command.includes('Jarvis SHOW ME GENOTYPE'.toUpperCase()) || command.includes('Jarvis SHOW ME GENO TYPE'.toUpperCase())):
+            genotype = '';
+            // get genotype string
+            if (command.includes('Jarvis SHOW ME GENOTYPE'.toUpperCase())){
+                genotype = command.substring(command.indexOf('JARVIS SHOW ME GENOTYPE') + 'JARVIS SHOW ME GENOTYPE'.length);
+            }
+            else if (command.includes('Jarvis SHOW ME GENO TYPE').toUpperCase()){
+                genotype = command.substring(command.indexOf('JARVIS SHOW ME GENO TYPE') + 'JARVIS SHOW ME GENO TYPE'.length);
+            }
+            // pass genotype to DB for query
+            genotype = genotype.trim();
+            if (genotype.length > 0) {
+                fetchWithTextBodyAndJsonResponse("../php/importGenotype.php", genotype)
+            }
             break;
+        /* OUTLIERS ---------------------------------------------------------------------------------------------------------------*/
+        case (command.includes('Jarvis show me outliers exif'.toUpperCase())):
 
-            case (command.includes('download South Carolina points'.toUpperCase())):
-                downloadPoints("12","solo.id", "SouthCarolinaCommonGarden");
-            break;
+        break;
+
+
+        /* DEAD TREES -------------------------------------------------------------------------------------------------------------*/
 
-            case (command.includes('download Caney Forks points'.toUpperCase())):
-                downloadPoints("14","solo.id", "Caney_Forks_Microbes");
-                // exportCSVFile('a',caneyforks,'Caney_Forks_Microbes.csv');
-                // console.log(caneyforks);
-                break;
 
-            case (command.includes('download metabolomics identifications'.toUpperCase()) ||
-                command.includes('download metabo identifications'.toUpperCase())):
+
+
+        /* BORDERS ---------------------------------------------------------------------------------------------------------------*/
+
+        // Show ALL parent and child borders with a point marker in the center of each. Do not fly to
+        case (command.includes('Jarvis show me borders'.toUpperCase())):
+            // children are red
+            drawPolygon("lookup_borders_plot", "#FD1134", Cesium.Color.RED);
+            // parents are orange
+            drawPolygon("lookup_borders", "#FF6600", Cesium.Color.DARKORANGE);
+        break;
+
+        // Common gardens    
+        case (command.includes('Jarvis SHOW ME GARDENS'.toUpperCase()) || 
+        command.includes('Jarvis SHOW ME THE COMMON GARDENS'.toUpperCase()) ||
+        command.includes('Jarvis SHOW ME COMMON GARDENS'.toUpperCase())):
+            drawPolygonById_Old(3,'lookup_borders', Cesium.Color.DARKORANGE); // Davis
+            drawPolygonById_Old(2,'lookup_borders', Cesium.Color.DARKORANGE); // Corvallis
+            drawPolygonById_Old(1,'lookup_borders', Cesium.Color.DARKORANGE); // Westport
+            drawPolygonById_Old(3,'lookup_borders_plot', Cesium.Color.RED); // Corvallis Common Garden
+            drawPolygonById_Old(10,'lookup_borders_plot', Cesium.Color.RED); // Drought Block 1
+            drawPolygonById_Old(19,'lookup_borders_plot', Cesium.Color.RED); // Drought Block 2
+            drawPolygonById_Old(20,'lookup_borders_plot', Cesium.Color.RED); // Drought Block 3
+            drawPolygonById_Old(23,'lookup_borders_plot', Cesium.Color.RED); // Control Block 1
+            drawPolygonById_Old(22,'lookup_borders_plot', Cesium.Color.RED); // Control Block 2
+            drawPolygonById_Old(21,'lookup_borders_plot', Cesium.Color.RED); // Control Block 3
+            drawPolygonById_Old(13,'lookup_borders_plot', Cesium.Color.DARKORANGE);// UTK Switchgrass
+            fetchWithTextBodyAndJsonResponseFlyTo_Old("../php/getFlyToCoords_old.php", 4, 'lookup_borders');
+        break;
+
+        /* DOWNLOAD ----------------------------------------------------------------------------------------------------------------*/
+        case (command.includes('Jarvis download metabolomics identifications'.toUpperCase()) ||
+                command.includes('Jarvis download metabo identifications'.toUpperCase())):
                 downloadQuery('MetabolomicsIdentifications', 'metabolomics IDs');
                 downloadQuery('MetabolomicsIdentifications_ColumnDesc', 'column descriptions');
             break;
 
-            case (command.includes('download No Name organisms'.toUpperCase()) ||
-            command.includes('download organisms with no name'.toUpperCase()) ||
+        case (command.includes('Jarvis download No Name organisms'.toUpperCase()) ||
+            command.includes('Jarvis download organisms with no name'.toUpperCase()) ||
                 command.includes('download organisms with no names'.toUpperCase()) ||
                 command.includes('download organisms with null names'.toUpperCase()) ||
                 command.includes('download organisms that have no name'.toUpperCase())):
                 downloadQuery('NoNameOrganisms', 'No Name Organisms');
             break;
 
+        // Show ALL parent and child borders - will need a query to create a multi-polygon for all
+        case (command.includes('download borders'.toUpperCase())||
+            command.includes('download all borders'.toUpperCase())):
+            downloadMultipolygon("all_borders", "AllBorders");
+            break;             
+        
+        // Common gardens - will need a query to create a multi-polygon for only common gardens
+        case (command.includes('download GARDENS borders') || 
+        command.includes('download THE COMMON GARDENS borders') ||
+        command.includes('download COMMON GARDENS borders')):
+            downloadMultipolygon("common_gardens_borders", "CommonGardens_Borders");
+            break;
+
+        /* DELETIONS ---------------------------------------------------------------------------------------------------------------*/
 
-            /* DOWNLOAD BORDERS -------------------------------------------------------------------------------------------------------*/
-
-
-            // Show ALL parent and child borders - will need a query to create a multi-polygon for all
-            case (command.includes('download borders'.toUpperCase())||
-                command.includes('download all borders'.toUpperCase())):
-                downloadMultipolygon("all_borders", "AllBorders");
-                break;             
-            
-            // Common gardens - will need a query to create a multi-polygon for only common gardens
-            case (command.includes('download GARDENS borders') || 
-            command.includes('download THE COMMON GARDENS borders') ||
-            command.includes('download COMMON GARDENS borders')):
-                downloadMultipolygon("common_gardens_borders", "CommonGardens_Borders");
-                break;
-            
-            case (command.includes('download westport border'.toUpperCase())):
-                downloadBorder("1","lookup_borders", "WestportPlots_Border");
-                break;
-
-            case (command.includes('download 7 by 7 border'.toUpperCase()) || 
-            command.includes('download seven by seven border'.toUpperCase()) ||
-            command.includes('download 7x7 border'.toUpperCase()) ||
-            command.includes('download 7 x 7 border'.toUpperCase())):   
-                downloadBorder("16","lookup_borders_plot", "7x7_Matrix_Border");
-                break;
-
-            case (command.includes('download corvallis border'.toUpperCase())):
-                downloadBorder("2","lookup_borders", "CorvallisCommonGarden_Border");
-                break;
-
-            case (command.includes('download stoolbed border'.toUpperCase())):
-                downloadBorder("15","lookup_borders_plot", "StoolbedCloneBank_Border");
-                break;
-
-            case (command.includes('download davis border'.toUpperCase())):
-                downloadBorder("3","lookup_borders", "DavisCommonGardenTreeLocations_Border");
-                break;
-
-            case (command.includes('download seeds border'.toUpperCase())):
-                downloadBorder("11","lookup_borders_plot", "SeedsCommonGarden_Border");
-                break;
-
-            case (command.includes('download Pando E border'.toUpperCase())|| command.includes('download panda E border'.toUpperCase())):
-                downloadBorder("7","lookup_borders_plot", "Pando_E_Forest_Border");
-                break;      
-            case (command.includes('download Pando A border'.toUpperCase())|| command.includes('download panda A border'.toUpperCase())):
-                downloadBorder("8","lookup_borders_plot", "Pando_A_Forest_Border");
-                break;
-            case (command.includes('download Pando H border'.toUpperCase())|| command.includes('download panda H border'.toUpperCase())):
-                downloadBorder("9","lookup_borders_plot", "Pando_H_Forest_Border");
-                break;
-            case (command.includes('download Pando D border'.toUpperCase())|| command.includes('download panda D border'.toUpperCase())):
-                downloadBorder("6","lookup_borders_plot", "Pando_D_Forest_Border");
-                break;
-
-            case (command.includes('download Clatskanie border'.toUpperCase())):
-                downloadBorder("2","lookup_borders_plot", "ClatskanieCommonGarden_Border");
+        case (command.includes('Jarvis delete davis'.toUpperCase())):
+            // deleteDataSource(datasourceName); // ? How to remove points from Cesium?
             break;
 
-            case (command.includes('download Boardman border'.toUpperCase())):
-                downloadBorder("1","lookup_borders_plot", "BoardmanCommonGarden_Border");
+        /* MISC -----------------------------------------------------------------------------------------------------*/       
+        case command.includes('Jarvis CREATE SAMPLING TRIP'.toUpperCase()):
+            if (dbUserID){
+                showMenu(window.innerWidth / 2, window.innerHeight / 2, "uploadRouteMenu");
+            }
+            else {
+                alert("You must be logged in to use this feature.");
+            }
             break;
 
-            case (command.includes('download Placerville border'.toUpperCase())):
-                downloadBorder("4","lookup_borders_plot", "PlacervilleCommonGarden_Border");
+        case command.includes('menu'.toUpperCase()):
+            var j= document.createElement("div");
+            j.id ="jarvisSpeechBox";
+            var jtb = document.createTextNode("Hello there");
+            j.appendChild(jtb);
+            document.getElementById("NormalInterface").appendChild(j);
+            console.log("here");
             break;
 
-            case (command.includes('download Sedona border'.toUpperCase())):
-                downloadBorder("5","lookup_borders_plot", "SedonaCommonGarden_Border");
+        case command.includes('Jarvis show me United States'.toUpperCase()):
+            datasourceUSmap = new Cesium.GeoJsonDataSource.load('../cesium/Apps/SampleData/ne_10m_us_states.topojson');
+            addAndFlyToDataSource(datasourceUSmap);
+            break;
+        case (command.includes('Jarvis delete United States'.toUpperCase())):
+            deleteDataSource(datasourceUSmap);
+            break;
+        case command.includes('hide'):
+            speechSynthesis.speak(new SpeechSynthesisUtterance("Sorry, that hasn't been coded  yet?"));
             break;
 
-            case (command.includes('download Tennessee border'.toUpperCase()) || 
-            command.includes('download utk SWITCHGRASS border'.toUpperCase())):
-                downloadBorder("13","lookup_borders_plot", "TennesseeCommonGarden_Border");
+        case command.includes('zoom out'):
+            viewer.camera.zoomOut();
             break;
 
-            case (command.includes('download South Carolina border'.toUpperCase())):
-                downloadBorder("12","lookup_borders_plot", "SouthCarolinaCommonGarden_Border");
+        case (command.includes('grin'.toUpperCase()) || command.includes('green'.toUpperCase()) ||
+            command.includes('Grant')):
+
+            speechSynthesis.speak(new SpeechSynthesisUtterance('Grin is not a person. Grin is an acronym ' +
+                                'that stands for Germplasm Resources Information Network.'));
+            var grin= new SpeechSynthesisUtterance(" I see you are looking at that clone from Argentina. " + 
+                                "That is an old one. We got it in 1968.  Here is some more info about it.");
+            speechSynthesis.getVoices().forEach(function(voice) {
+                console.log(voice.name, voice.default ? voice.default :'');
+            });
+            grin.voice = speechSynthesis.getVoices().filter(function(voice) {return voice.name == 'Google UK English Female'})[0]
+
+            setTimeout(() => {speechSynthesis.speak(grin)},10000)
+
+            setTimeout(()=> {window.open('https://npgsweb.ars-grin.gov/gringlobal/accessiondetail.aspx?id=1251519')},10000)
             break;
 
-            case (command.includes('download Caney Forks border'.toUpperCase())):
-                downloadBorder("14","lookup_borders_plot", "Caney_Forks_Microbes_Border");
+        case (command.includes('structure'.toUpperCase())):
+
+            setTimeout(()=> {window.open('https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?&mmdbid=146850&bu=1&showanno=1')},10000)
             break;
 
+        case command.includes('How many'.toUpperCase()):
+           //speechSynthesis.speak(new SpeechSynthesisUtterance("There were 567 clones planted at the University of Tennessee Common Garden"));
+            break;
+
+        /* END-OF-CASE -----------------------------------------------------------------------------------------------------------*/    
 
-            /* DELETIONS ---------------------------------------------------------------------------------------------------------------*/
-            case (command.includes('delete Pando'.toUpperCase()) || command.includes('delete panda'.toUpperCase())):
-                // datasourcePandoPics.then(function (dataSource){
-                //     viewer.dataSources.remove(dataSource);
-                //     viewer.resize();
-                // });
-                break;
-            case (command.includes('delete popular'.toUpperCase()) || command.includes('delete poplar'.toUpperCase())):
-                // deleteDataSource();
-                // deleteDataSource(datasourcePoplarGenets);
-                break;
-            case (command.includes('delete davis'.toUpperCase())):
-                // deleteDataSource(datasourceDavis);
-                break;
-            case (command.includes('delete seeds'.toUpperCase())):
-                // deleteDataSource();
-                break;
-            case (command.includes('delete south carolina'.toUpperCase())):
-                // deleteDataSource();
-                break;
-            case (command.includes('delete corvallis'.toUpperCase())):
-                // deleteDataSource(datasourceCorvallis);
-                break;
-             case (command.includes('delete Tennessee'.toUpperCase())):
-                // deleteDataSource(datasourceUTKSwitchGrass);
-                break;   
-            case (command.includes('delete borders'.toUpperCase())):
-                deleteDataSource(datasourcePublicData);
-                break;
-            case (command.includes('delete Gardens'.toUpperCase())):
-                deleteDataSource(datasourcePoplarCommonGardens);
-                break;
-
-            // case (command.includes('delete switchgrass'.toUpperCase())):
-            //     deleteDataSource(datasourceSwitchGrassGenets);
-
-
-            /* DISCONTINUED DATA SOURCES ----------------------------------------------------------------------------------------*/
-
-            case (command.includes('show me test data'.toUpperCase())):
-                datasourceTestUpload = new Cesium.GeoJsonDataSource.load('./DATA/TestData/Oregon_Fall_35-36_TestData.geojson');
-                addAndFlyToDataSourceWithMinMaxCreationDates(datasourceTestUpload);
-                break;
-            case (command.includes('delete test data'.toUpperCase())):
-                deleteDataSource(datasourceTestUpload);
-                break;            
-
-            // case (command.includes('show me Midland'.toUpperCase())):
-            //     datasourceMidland = new Cesium.GeoJsonDataSource.load('./DATA/BioScales/Midland.geojson');
-            //     addAndFlyToDataSourceWithMinMaxCreationDates(datasourceMidland);
-            //     break;
-            // case (command.includes('delete Midland'.toUpperCase())):
-            //     deleteDataSource(datasourceMidland);
-            //     break;
-
-            // case (command.includes('show me clean esri'.toUpperCase())):
-            //     datasourceCleanEsri = new Cesium.GeoJsonDataSource.load('./DATA/CBI/clean_esri.geojson');
-            //     addAndFlyToDataSourceWithMinMaxCreationDates(datasourceCleanEsri);
-            //     break;
-            // case (command.includes('delete clean esri'.toUpperCase())):
-            //     deleteDataSource(datasourceCleanEsri);
-            //     break;
-
-            // previous pando datafile
-                // datasourcePandoPics = new Cesium.GeoJsonDataSource.load('./DATA/PMI/Pando/Pando_Pics.geojson');
-                // datasourcePandoPics.then(function (dataSource) {
-                //     flyToPandoPics = viewer.dataSources.add(dataSource);
-                //     entities = dataSource.entities.values;
-                //     viewer.flyTo(flyToPandoPics);
-                // });
-                // fetchAndFlyTo("6");
-
-            // datasourceCorvallis = new Cesium.GeoJsonDataSource.load('./DATA/BioScales/Corvallis_Fall_2020_BioScales.geojson');
-            // addAndFlyToDataSource(datasourceCorvallis);
-
-            // datasourceSwitchGrassGenets = new Cesium.GeoJsonDataSource.load('./DATA/genets/SWG_genets.geojson');
-            // addAndFlyToDataSource(datasourceSwitchGrassGenets);
-
-            // fetchWithNoReturnValue("../php/importSiteByCBIgenets.php", "CBI genets");
-            // datasourcePoplarGenets = new Cesium.GeoJsonDataSource.load('./DATA/genets/Poplar_genets.geojson');
-            // addAndFlyToDataSource(datasourcePoplarGenets);
-
-            // datasourceUTKSwitchGrass = new Cesium.GeoJsonDataSource.load('./DATA/CBI/UTK_switchgrass.geojson');
-            // addAndFlyToDataSource(datasourceUTKSwitchGrass);
-        
-            // datasourceCaneyForks = new Cesium.GeoJsonDataSource.load('./DATA/PMI/Caney_Forks_Microbes.geojson');
-            // addAndFlyToDataSource(datasourceCaneyForks);
-            
-            // datasourceDavis = new Cesium.GeoJsonDataSource.load('./DATA/CBI/davis.geojson');
-            // addAndFlyToDataSource(datasourceDavis);         
-
-            // datasourceUTKSwitchGrass = new Cesium.GeoJsonDataSource.load('./DATA/CBI/UTK_switchgrass.geojson');
-            // addAndFlyToDataSource(datasourceUTKSwitchGrass);
-        
 
-            /* MISC -----------------------------------------------------------------------------------------------------*/       
-            case command.includes('CREATE SAMPLING TRIP'):
-                if (dbUserID){
-                    showMenu(window.innerWidth / 2, window.innerHeight / 2, "uploadRouteMenu");
-                }
-                else {
-                    alert("You must be logged in to use this feature.");
-                }
-                break;
-
-            case command.includes('menu'.toUpperCase()):
-                var j= document.createElement("div");
-                j.id ="jarvisSpeechBox";
-                var jtb = document.createTextNode("Hello there");
-                j.appendChild(jtb);
-                document.getElementById("NormalInterface").appendChild(j);
-                console.log("here");
-                break;
-
-            case command.includes('show me United States'.toUpperCase()):
-                datasourceUSmap = new Cesium.GeoJsonDataSource.load('../cesium/Apps/SampleData/ne_10m_us_states.topojson');
-                addAndFlyToDataSource(datasourceUSmap);
-                break;
-            case (command.includes('delete United States'.toUpperCase())):
-                deleteDataSource(datasourceUSmap);
-                break;
-            case command.includes('hide'):
-                speechSynthesis.speak(new SpeechSynthesisUtterance("Sorry, that hasn't been coded  yet?"));
-                break;
-
-            case command.includes('zoom out'):
-                viewer.camera.zoomOut();
-                break;
-
-            case (command.includes('grin'.toUpperCase()) || command.includes('green'.toUpperCase()) ||
-                command.includes('Grant')):
-
-                speechSynthesis.speak(new SpeechSynthesisUtterance('Grin is not a person. Grin is an acronym ' +
-                                    'that stands for Germplasm Resources Information Network.'));
-                var grin= new SpeechSynthesisUtterance(" I see you are looking at that clone from Argentina. " + 
-                                    "That is an old one. We got it in 1968.  Here is some more info about it.");
-                speechSynthesis.getVoices().forEach(function(voice) {
-                    console.log(voice.name, voice.default ? voice.default :'');
-                });
-                grin.voice = speechSynthesis.getVoices().filter(function(voice) {return voice.name == 'Google UK English Female'})[0]
-
-                setTimeout(() => {speechSynthesis.speak(grin)},10000)
-
-                setTimeout(()=> {window.open('https://npgsweb.ars-grin.gov/gringlobal/accessiondetail.aspx?id=1251519')},10000)
-                break;
-
-            case (command.includes('structure'.toUpperCase())):
-
-                setTimeout(()=> {window.open('https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?&mmdbid=146850&bu=1&showanno=1')},10000)
-                break;
-
-            case command.includes('How many'.toUpperCase()):
-               //speechSynthesis.speak(new SpeechSynthesisUtterance("There were 567 clones planted at the University of Tennessee Common Garden"));
-                break;
-
-
-            /* END-OF-CASE -----------------------------------------------------------------------------------------------------------*/    
-            default:
-                //    speechSynthesis.speak(new SpeechSynthesisUtterance('I heard' +
-                //      command + ' and I am not sure I understand that.  Did I hear you correctly?'));)
-                break;
-        }
+        default:
+           // New function to process commands. 
+            if (command.length > 0){
+                processJarvisCommand(command);
+            }
+        break;
     }
+
 }
 
diff --git a/code/javascript/jarvisCommands_New.js b/code/javascript/jarvisCommands_New.js
deleted file mode 100644
index f2f39643..00000000
--- a/code/javascript/jarvisCommands_New.js
+++ /dev/null
@@ -1,22 +0,0 @@
-//Jarvis voice functions. Is the entities variable being used anywhere?
-function jarvisCommand(command){
-
-    // remove whitespaces
-    command = command.trim()
-
-    // // start viewer
-    // initializeViewer();
-
-    // // initialize entity selection listeners
-    // entitySelection();
-
-    // initialize listener for rightclick export menu
-    //exportMenuListeners();
-
-    // Function to process command.
-    if (command.length > 0){
-        processJarvisCommand(command);
-    }
-
-}
-
diff --git a/code/javascript/jarvisCommands_Old.js b/code/javascript/jarvisCommands_Old.js
new file mode 100644
index 00000000..fb59817a
--- /dev/null
+++ b/code/javascript/jarvisCommands_Old.js
@@ -0,0 +1,680 @@
+//Jarvis voice functions. Is the entities variable being used anywhere?
+function jarvisCommand(command){
+    command = command.toUpperCase();
+
+    if (command.includes('jarvis'.toUpperCase())){
+        console.log(command);
+        switch (true) {
+
+            case command =='hello Jarvis':
+
+                speechSynthesis.speak(new SpeechSynthesisUtterance("Hello there. What can I do for you today?"));
+                break;
+
+            case command.includes('world'.toUpperCase()):
+                // start viewer
+                initializeViewer();
+
+                // initialize entity selection listeners
+                entitySelection();
+
+                // initialize listener for rightclick export menu
+                //exportMenuListeners();
+
+                console.log('Viewer initialized');
+                break;
+
+
+            /* NON FLY-TO POINTS --------------------------------------------------------------------------------------------------*/    
+            // fly-to for a non-bsd_site table needs to be revisited (really the whole system for various DB data sources)
+            case (command.includes('show me popular'.toUpperCase())|| command.includes('show me poplar'.toUpperCase())):
+                qryParams = '{"queryName" : "poplar_genets"}';
+                fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
+                break;
+
+            case (command.includes('show me Metabolomics'.toUpperCase())):
+                qryParams = '{"queryName" : "metabolomics"}';
+                fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
+                break;
+
+            case command.includes('show me switchgrass'.toUpperCase()):
+                qryParams = '{"queryName" : "switchgrass_genets"}';
+                fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
+                 break;
+
+            case (command.includes('show me points No Name organisms'.toUpperCase()) ||
+                command.includes('show me points organisms with no name'.toUpperCase()) ||
+                command.includes('show me points organisms with no names'.toUpperCase()) ||
+                command.includes('show me points organisms with null names'.toUpperCase()) ||
+                command.includes('show me points organisms that have no name'.toUpperCase())):
+                qryParams = '{"queryName" : "no_name_organisms"}';
+                fetchWithTextBodyAndJsonResponse('../php/importSitePassColorOnly.php', qryParams)
+                break;
+            
+            /* ROUTES ---------------------------------------------------------------------------------------------------------------*/
+            case (command.includes('show me Pando D routes'.toUpperCase())|| command.includes('show me panda D routes'.toUpperCase())):
+                startingPoint = (command.substring(command.indexOf('SHOW ME PANDO D ROUTES') + 'SHOW ME PANDO D ROUTES'.length)).trim();
+                routeTable = 'routes_pando_d';
+                tsParams = '{"routeTable" : "' + routeTable + '", "startingPoint" : "' + startingPoint + '"}';
+                fetchWithTextBodyAndJsonResponse("../php/importTsRoutes.php", tsParams);
+                break;
+
+
+            /* POINTS ---------------------------------------------------------------------------------------------------------------*/
+            case (command.includes('show me points Pando E'.toUpperCase())|| command.includes('show me points panda E'.toUpperCase())):
+                fetchAndFlyTo("7", 'lookup_borders_plot');
+                break;      
+            case (command.includes('show me points Pando A'.toUpperCase())|| command.includes('show me points panda A'.toUpperCase())):
+                fetchAndFlyTo("8", 'lookup_borders_plot');
+                break;
+            case (command.includes('show me points Pando H'.toUpperCase())|| command.includes('show me points panda H'.toUpperCase())):
+                fetchAndFlyTo("9", 'lookup_borders_plot');
+                break;
+            case (command.includes('show me points Pando D'.toUpperCase())|| command.includes('show me points panda D'.toUpperCase())):
+                fetchAndFlyTo("6", 'lookup_borders_plot');
+                break;   
+
+            // Show the points of all of davis' subplots and fly to the center of the main border
+            case (command.includes('show me points davis'.toUpperCase())):
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 10); // Drought Block 1
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 19); // Drought Block 2
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 20); // Drought Block 3
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 21); // Control Block 3
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 22); // Control Block 2
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 23); // Control Block 1
+                fetchWithTextBodyAndJsonResponseFlyTo("../php/getFlyToCoords.php", 3, 'lookup_borders');
+                break;
+
+            case (command.includes('show me points Drought Block 1'.toUpperCase())):
+                fetchAndFlyTo(10, 'lookup_borders_plot');
+                break;
+
+            case (command.includes('show me points Drought Block 2'.toUpperCase())):
+                fetchAndFlyTo(19, 'lookup_borders_plot');
+                break;
+
+            case (command.includes('show me points Drought Block 3'.toUpperCase())):
+                fetchAndFlyTo(20, 'lookup_borders_plot');
+                break;
+
+            case (command.includes('show me points Control Block 1'.toUpperCase())):
+                fetchAndFlyTo(23, 'lookup_borders_plot');
+                break;
+
+            case (command.includes('show me points Control Block 2'.toUpperCase())):
+                fetchAndFlyTo(22, 'lookup_borders_plot');
+                break;
+
+            case (command.includes('show me points Control Block 3'.toUpperCase())):
+                fetchAndFlyTo(21, 'lookup_borders_plot');
+                break;
+
+
+            // PMI Stress Gradients
+            case (command.includes('show me points Stress Gradients'.toUpperCase())):
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 25); // Leach Lake Pacific Crest Trailhead
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 26); // Convey Rainer vista 11
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 27); // Miriam creek bridge
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 28); // Rim Rock
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 29); // Forest road 504
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 30); // Titan near Sentinel creek
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 31); // Windy Point boat launch
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 32); // Titan naches confluence
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 33); // Rowe public access Naches River
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 34); // Minto creek rd quarry
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 35); // Marion creek fish hatchery
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 36); // Quartzville Byway
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 37); // Parish Lake road
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 38); // Lost Lake
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 39); // Creek bed forest road 1514
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 40); // Forest road 1514 big ass poplar
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 41); // Three creeks road sisters
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 42); // Camp Polk Preserve
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 43); // Alder Spring crossing
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 44); // Cove palisades
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 45); // Indian museum
+                break;
+
+
+            case (command.includes('show me points caney'.toUpperCase())|| command.includes('show me points fork'.toUpperCase())):
+                fetchAndFlyTo("14", 'lookup_borders_plot');
+                break;
+
+            case (command.includes('show me points seeds'.toUpperCase())):
+                fetchAndFlyTo("11", 'lookup_borders_plot');
+                break;
+
+            case (command.includes('show me points south carolina'.toUpperCase())):
+                fetchAndFlyTo("12", 'lookup_borders_plot');
+                break;  
+
+            case (command.includes('show me points corvallis common gardens'.toUpperCase())):
+                fetchAndFlyTo("3", 'lookup_borders_plot');
+                break;
+
+            case (command.includes('show me points stoolbed'.toUpperCase())):
+                fetchAndFlyTo("15", 'lookup_borders_plot');
+                break;   
+
+            case (command.includes('show me points clatskanie'.toUpperCase())):
+                fetchAndFlyTo("2", 'lookup_borders_plot');
+                break;
+
+            // Show the points of all of westport's subplots and fly to the center of the main border
+            case (command.includes('show me points westport'.toUpperCase())):
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 16);
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 17);
+                fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", 18);
+                fetchWithTextBodyAndJsonResponseFlyTo("../php/getFlyToCoords.php", 1, 'lookup_borders');
+                break;
+
+            case (command.includes('show me points 2020 QTL Trial Rep 1 and 2'.toUpperCase())):
+                fetchAndFlyTo("18", 'lookup_borders_plot');
+            break;  
+
+            case (command.includes('show me points 2020 QTL Trial Rep 3'.toUpperCase())):
+                fetchAndFlyTo("17", 'lookup_borders_plot');
+            break;   
+
+            case (command.includes('show me points 7 by 7'.toUpperCase()) || 
+            command.includes('show me points seven by seven'.toUpperCase()) ||
+            command.includes('show me points 7x7'.toUpperCase()) ||
+            command.includes('show me points 7 x 7'.toUpperCase())):
+                fetchAndFlyTo("16", 'lookup_borders_plot');
+            break;   
+
+            case (command.includes('show me points Tennessee'.toUpperCase()) || 
+                    command.includes('SHOW ME points utk SWITCHGRASS'.toUpperCase())):
+                fetchAndFlyTo("13", 'lookup_borders_plot');
+                break;
+
+
+
+            /* GENOTYPE ---------------------------------------------------------------------------------------------------------------*/
+            // --04-NOV-2022 query_site_genotype() needs to be updated
+            case (command.includes('SHOW ME GENOTYPE') || command.includes('SHOW ME GENO TYPE')):
+                genotype = '';
+                // get genotype string
+                if (command.includes('SHOW ME GENOTYPE')){
+                    genotype = command.substring(command.indexOf('JARVIS SHOW ME GENOTYPE') + 'JARVIS SHOW ME GENOTYPE'.length);
+                }
+                else if (command.includes('SHOW ME GENO TYPE')){
+                    genotype = command.substring(command.indexOf('JARVIS SHOW ME GENO TYPE') + 'JARVIS SHOW ME GENO TYPE'.length);
+                }
+                // pass genotype to DB for query
+                genotype = genotype.trim();
+                if (genotype.length > 0) {
+                    fetchWithTextBodyAndJsonResponse("../php/importGenotype.php", genotype)
+                }
+                break;
+
+
+            /* OUTLIERS ---------------------------------------------------------------------------------------------------------------*/
+            case (command.includes('show me outliers exif'.toUpperCase())):
+
+                break;
+
+
+            /* DEAD TREES -------------------------------------------------------------------------------------------------------------*/
+
+
+
+
+            /* BORDERS ---------------------------------------------------------------------------------------------------------------*/
+            
+            // Show ALL parent and child borders with a point marker in the center of each. Do not fly to
+            case (command.includes('show me borders'.toUpperCase())):
+                // children are red
+                drawPolygon("lookup_borders_plot", "#FD1134", Cesium.Color.RED);
+                // parents are orange
+                drawPolygon("lookup_borders", "#FF6600", Cesium.Color.DARKORANGE);
+                break;
+
+            // Common gardens    
+            case (command.includes('SHOW ME GARDENS'.toUpperCase()) || 
+            command.includes('SHOW ME THE COMMON GARDENS'.toUpperCase()) ||
+            command.includes('SHOW ME COMMON GARDENS'.toUpperCase())):
+                drawPolygonById(3,'lookup_borders', Cesium.Color.DARKORANGE); // Davis
+                drawPolygonById(2,'lookup_borders', Cesium.Color.DARKORANGE); // Corvallis
+                drawPolygonById(1,'lookup_borders', Cesium.Color.DARKORANGE); // Westport
+                drawPolygonById(3,'lookup_borders_plot', Cesium.Color.RED); // Corvallis Common Garden
+                drawPolygonById(10,'lookup_borders_plot', Cesium.Color.RED); // Drought Block 1
+                drawPolygonById(19,'lookup_borders_plot', Cesium.Color.RED); // Drought Block 2
+                drawPolygonById(20,'lookup_borders_plot', Cesium.Color.RED); // Drought Block 3
+                drawPolygonById(23,'lookup_borders_plot', Cesium.Color.RED); // Control Block 1
+                drawPolygonById(22,'lookup_borders_plot', Cesium.Color.RED); // Control Block 2
+                drawPolygonById(21,'lookup_borders_plot', Cesium.Color.RED); // Control Block 3
+                drawPolygonById(13,'lookup_borders_plot', Cesium.Color.DARKORANGE);// UTK Switchgrass
+                fetchWithTextBodyAndJsonResponseFlyTo("../php/getFlyToCoords.php", 4, 'lookup_borders');
+                break;
+            
+            // PMI Stress Gradients
+            case (command.includes('show me Stress Gradients'.toUpperCase())):
+                drawPolygonById(25,'lookup_borders_plot', Cesium.Color.RED); // Leach Lake Pacific Crest Trailhead
+                drawPolygonById(26,'lookup_borders_plot', Cesium.Color.RED); // Convey Rainer vista 11
+                drawPolygonById(27,'lookup_borders_plot', Cesium.Color.RED); // Miriam creek bridge
+                drawPolygonById(28,'lookup_borders_plot', Cesium.Color.RED); // Rim Rock
+                drawPolygonById(29,'lookup_borders_plot', Cesium.Color.RED); // Forest road 504
+                drawPolygonById(30,'lookup_borders_plot', Cesium.Color.RED); // Titan near Sentinel creek
+                drawPolygonById(31,'lookup_borders_plot', Cesium.Color.RED); // Windy Point boat launch
+                drawPolygonById(32,'lookup_borders_plot', Cesium.Color.RED); // Titan naches confluence
+                drawPolygonById(33,'lookup_borders_plot', Cesium.Color.RED); // Rowe public access Naches River
+                drawPolygonById(34,'lookup_borders_plot', Cesium.Color.RED); // Minto creek rd quarry
+                drawPolygonById(35,'lookup_borders_plot', Cesium.Color.RED); // Marion creek fish hatchery
+                drawPolygonById(36,'lookup_borders_plot', Cesium.Color.RED); // Quartzville Byway
+                drawPolygonById(37,'lookup_borders_plot', Cesium.Color.RED); // Parish Lake road
+                drawPolygonById(38,'lookup_borders_plot', Cesium.Color.RED); // Lost Lake
+                drawPolygonById(39,'lookup_borders_plot', Cesium.Color.RED); // Creek bed forest road 1514
+                drawPolygonById(40,'lookup_borders_plot', Cesium.Color.RED); // Forest road 1514 big ass poplar
+                drawPolygonById(41,'lookup_borders_plot', Cesium.Color.RED); // Three creeks road sisters
+                drawPolygonById(42,'lookup_borders_plot', Cesium.Color.RED); // Camp Polk Preserve
+                drawPolygonById(43,'lookup_borders_plot', Cesium.Color.RED); // Alder Spring crossing
+                drawPolygonById(44,'lookup_borders_plot', Cesium.Color.RED); // Cove palisades
+                drawPolygonById(45,'lookup_borders_plot', Cesium.Color.RED); // Indian museum                
+                break;
+
+
+            case (command.includes('show me Tennessee border'.toUpperCase()) || command.includes('SHOW ME utk SWITCHGRASS border'.toUpperCase())):
+                fetchAndFlyToPolygon("13", 'lookup_borders_plot', Cesium.Color.BLUE);
+                break;
+            case (command.includes('show me Pando D'.toUpperCase())|| command.includes('show me panda D'.toUpperCase())):
+
+                fetchAndFlyToPolygon("6", 'lookup_borders_plot', Cesium.Color.BLUE);
+                break;                
+            case (command.includes('show me Pando E border'.toUpperCase())|| command.includes('show me panda E border'.toUpperCase())):
+                fetchAndFlyToPolygon("7", 'lookup_borders_plot', Cesium.Color.BLUE);
+                break;  
+            case (command.includes('show me Pando A border'.toUpperCase())|| command.includes('show me panda A border'.toUpperCase())):
+                fetchAndFlyToPolygon("8", 'lookup_borders_plot', Cesium.Color.BLUE);
+                break;
+            case (command.includes('show me Pando H border'.toUpperCase())|| command.includes('show me panda H border'.toUpperCase())):
+                fetchAndFlyToPolygon("9", 'lookup_borders_plot', Cesium.Color.BLUE);
+                break;  
+
+            case (command.includes('show me caney border'.toUpperCase())|| command.includes('show me caney forks border'.toUpperCase())):
+
+
+                fetchAndFlyToPolygon("14", 'lookup_borders_plot', Cesium.Color.BLUE);
+                break;
+
+            case (command.includes('show me davis border'.toUpperCase())):
+                fetchAndFlyToPolygon("3", 'lookup_borders', Cesium.Color.DARKORANGE);
+
+                break;
+
+            case (command.includes('show me seeds border'.toUpperCase())):
+                fetchAndFlyToPolygon("11", 'lookup_borders_plot', Cesium.Color.BLUE);
+                break;
+
+            case (command.includes('show me south carolina border'.toUpperCase())):
+                fetchAndFlyToPolygon("12", 'lookup_borders_plot', Cesium.Color.BLUE);
+                break;
+
+            case (command.includes('show me corvallis border'.toUpperCase())):
+                fetchAndFlyToPolygon("2", 'lookup_borders', Cesium.Color.DARKORANGE);
+                break;
+
+            // All corvallis-related command's text ordering needs to be looked at (More importantly the entire 
+            // command system needs to be revamped):
+            case (command.includes('show me border corvallis common gardens'.toUpperCase())):
+                fetchAndFlyToPolygon("3", 'lookup_borders_plot', Cesium.Color.RED);
+                break;
+
+            case (command.includes('show me stoolbed border'.toUpperCase())):
+                fetchAndFlyToPolygon("15", 'lookup_borders_plot', Cesium.Color.RED);
+                break;
+
+            case (command.includes('show me clatskanie border'.toUpperCase())):
+                fetchAndFlyToPolygon("2", 'lookup_borders_plot', Cesium.Color.BLUE);
+                break;
+
+            case (command.includes('show me westport border'.toUpperCase())):
+                fetchAndFlyToPolygon("1", 'lookup_borders', Cesium.Color.BLUE);
+                break;    
+
+            case (command.includes('show me 7 by 7 border'.toUpperCase()) || 
+            command.includes('show me seven by seven border'.toUpperCase()) ||
+            command.includes('show me 7x7 border'.toUpperCase()) ||
+            command.includes('show me 7 x 7 border'.toUpperCase())):
+                fetchAndFlyToPolygon("16", 'lookup_borders_plot', Cesium.Color.RED);
+            break;     
+
+
+            /* DOWNLOAD POINTS ---------------------------------------------------------------------------------------------------------*/
+            case (command.includes('download westport points'.toUpperCase())):
+                downloadPoints("1","border_id", "WestportPlots");
+                break;
+
+            case (command.includes('download 7 by 7 points'.toUpperCase()) || 
+            command.includes('download seven by seven points'.toUpperCase()) ||
+            command.includes('download 7x7 points'.toUpperCase()) ||
+            command.includes('download 7 x 7 points'.toUpperCase())):   
+                downloadPoints("16","solo.id", "7x7_Matrix");
+                break;
+
+            case (command.includes('download corvallis points'.toUpperCase())):
+                downloadPoints("3","solo.id", "CorvallisCommonGarden");
+                break;
+
+            case (command.includes('download stoolbed points'.toUpperCase())):
+                downloadPoints("15","solo.id", "StoolbedCloneBank");
+                break;
+
+            case (command.includes('download davis points'.toUpperCase())):
+                downloadPoints("3","border_id", "DavisCommonGardenTreeLocations");
+                break;
+
+            case (command.includes('download seeds points'.toUpperCase())):
+                downloadPoints("11","solo.id", "SeedsCommonGarden");
+                break;
+
+            case (command.includes('download Pando E points'.toUpperCase())|| command.includes('download panda E points'.toUpperCase())):
+                downloadPoints("7","solo.id", "Pando_E_Forest");
+                break;      
+            case (command.includes('download Pando A points'.toUpperCase())|| command.includes('download panda A points'.toUpperCase())):
+                downloadPoints("8","solo.id", "Pando_A_Forest");
+                break;
+            case (command.includes('download Pando H points'.toUpperCase())|| command.includes('download panda H points'.toUpperCase())):
+                downloadPoints("9","solo.id", "Pando_H_Forest");
+                break;
+            case (command.includes('download Pando D points'.toUpperCase())|| command.includes('download panda D points'.toUpperCase())):
+                downloadPoints("6","solo.id", "Pando_D_Forest");
+                break;
+
+            case (command.includes('download Clatskanie points'.toUpperCase())):
+                downloadPoints("2","solo.id", "ClatskanieCommonGarden");
+            break;
+
+            case (command.includes('download Boardman points'.toUpperCase())):
+                downloadPoints("1","solo.id", "BoardmanCommonGarden");
+            break;
+
+            case (command.includes('download Placerville points'.toUpperCase())):
+                downloadPoints("4","solo.id", "PlacervilleCommonGarden");
+            break;
+
+            case (command.includes('download Sedona points'.toUpperCase())):
+                downloadPoints("5","solo.id", "SedonaCommonGarden");
+            break;
+
+            case (command.includes('download Tennessee points'.toUpperCase()) || 
+            command.includes('download utk SWITCHGRASS points'.toUpperCase())):
+                downloadPoints("13","solo.id", "TennesseeCommonGarden");
+            break;
+
+            case (command.includes('download South Carolina points'.toUpperCase())):
+                downloadPoints("12","solo.id", "SouthCarolinaCommonGarden");
+            break;
+
+            case (command.includes('download Caney Forks points'.toUpperCase())):
+                downloadPoints("14","solo.id", "Caney_Forks_Microbes");
+                // exportCSVFile('a',caneyforks,'Caney_Forks_Microbes.csv');
+                // console.log(caneyforks);
+                break;
+
+            case (command.includes('download metabolomics identifications'.toUpperCase()) ||
+                command.includes('download metabo identifications'.toUpperCase())):
+                downloadQuery('MetabolomicsIdentifications', 'metabolomics IDs');
+                downloadQuery('MetabolomicsIdentifications_ColumnDesc', 'column descriptions');
+            break;
+
+            case (command.includes('download No Name organisms'.toUpperCase()) ||
+            command.includes('download organisms with no name'.toUpperCase()) ||
+                command.includes('download organisms with no names'.toUpperCase()) ||
+                command.includes('download organisms with null names'.toUpperCase()) ||
+                command.includes('download organisms that have no name'.toUpperCase())):
+                downloadQuery('NoNameOrganisms', 'No Name Organisms');
+            break;
+
+
+            /* DOWNLOAD BORDERS -------------------------------------------------------------------------------------------------------*/
+
+
+            // Show ALL parent and child borders - will need a query to create a multi-polygon for all
+            case (command.includes('download borders'.toUpperCase())||
+                command.includes('download all borders'.toUpperCase())):
+                downloadMultipolygon("all_borders", "AllBorders");
+                break;             
+            
+            // Common gardens - will need a query to create a multi-polygon for only common gardens
+            case (command.includes('download GARDENS borders') || 
+            command.includes('download THE COMMON GARDENS borders') ||
+            command.includes('download COMMON GARDENS borders')):
+                downloadMultipolygon("common_gardens_borders", "CommonGardens_Borders");
+                break;
+            
+            case (command.includes('download westport border'.toUpperCase())):
+                downloadBorder("1","lookup_borders", "WestportPlots_Border");
+                break;
+
+            case (command.includes('download 7 by 7 border'.toUpperCase()) || 
+            command.includes('download seven by seven border'.toUpperCase()) ||
+            command.includes('download 7x7 border'.toUpperCase()) ||
+            command.includes('download 7 x 7 border'.toUpperCase())):   
+                downloadBorder("16","lookup_borders_plot", "7x7_Matrix_Border");
+                break;
+
+            case (command.includes('download corvallis border'.toUpperCase())):
+                downloadBorder("2","lookup_borders", "CorvallisCommonGarden_Border");
+                break;
+
+            case (command.includes('download stoolbed border'.toUpperCase())):
+                downloadBorder("15","lookup_borders_plot", "StoolbedCloneBank_Border");
+                break;
+
+            case (command.includes('download davis border'.toUpperCase())):
+                downloadBorder("3","lookup_borders", "DavisCommonGardenTreeLocations_Border");
+                break;
+
+            case (command.includes('download seeds border'.toUpperCase())):
+                downloadBorder("11","lookup_borders_plot", "SeedsCommonGarden_Border");
+                break;
+
+            case (command.includes('download Pando E border'.toUpperCase())|| command.includes('download panda E border'.toUpperCase())):
+                downloadBorder("7","lookup_borders_plot", "Pando_E_Forest_Border");
+                break;      
+            case (command.includes('download Pando A border'.toUpperCase())|| command.includes('download panda A border'.toUpperCase())):
+                downloadBorder("8","lookup_borders_plot", "Pando_A_Forest_Border");
+                break;
+            case (command.includes('download Pando H border'.toUpperCase())|| command.includes('download panda H border'.toUpperCase())):
+                downloadBorder("9","lookup_borders_plot", "Pando_H_Forest_Border");
+                break;
+            case (command.includes('download Pando D border'.toUpperCase())|| command.includes('download panda D border'.toUpperCase())):
+                downloadBorder("6","lookup_borders_plot", "Pando_D_Forest_Border");
+                break;
+
+            case (command.includes('download Clatskanie border'.toUpperCase())):
+                downloadBorder("2","lookup_borders_plot", "ClatskanieCommonGarden_Border");
+            break;
+
+            case (command.includes('download Boardman border'.toUpperCase())):
+                downloadBorder("1","lookup_borders_plot", "BoardmanCommonGarden_Border");
+            break;
+
+            case (command.includes('download Placerville border'.toUpperCase())):
+                downloadBorder("4","lookup_borders_plot", "PlacervilleCommonGarden_Border");
+            break;
+
+            case (command.includes('download Sedona border'.toUpperCase())):
+                downloadBorder("5","lookup_borders_plot", "SedonaCommonGarden_Border");
+            break;
+
+            case (command.includes('download Tennessee border'.toUpperCase()) || 
+            command.includes('download utk SWITCHGRASS border'.toUpperCase())):
+                downloadBorder("13","lookup_borders_plot", "TennesseeCommonGarden_Border");
+            break;
+
+            case (command.includes('download South Carolina border'.toUpperCase())):
+                downloadBorder("12","lookup_borders_plot", "SouthCarolinaCommonGarden_Border");
+            break;
+
+            case (command.includes('download Caney Forks border'.toUpperCase())):
+                downloadBorder("14","lookup_borders_plot", "Caney_Forks_Microbes_Border");
+            break;
+
+
+            /* DELETIONS ---------------------------------------------------------------------------------------------------------------*/
+            case (command.includes('delete Pando'.toUpperCase()) || command.includes('delete panda'.toUpperCase())):
+                // datasourcePandoPics.then(function (dataSource){
+                //     viewer.dataSources.remove(dataSource);
+                //     viewer.resize();
+                // });
+                break;
+            case (command.includes('delete popular'.toUpperCase()) || command.includes('delete poplar'.toUpperCase())):
+                // deleteDataSource();
+                // deleteDataSource(datasourcePoplarGenets);
+                break;
+            case (command.includes('delete davis'.toUpperCase())):
+                // deleteDataSource(datasourceDavis);
+                break;
+            case (command.includes('delete seeds'.toUpperCase())):
+                // deleteDataSource();
+                break;
+            case (command.includes('delete south carolina'.toUpperCase())):
+                // deleteDataSource();
+                break;
+            case (command.includes('delete corvallis'.toUpperCase())):
+                // deleteDataSource(datasourceCorvallis);
+                break;
+             case (command.includes('delete Tennessee'.toUpperCase())):
+                // deleteDataSource(datasourceUTKSwitchGrass);
+                break;   
+            case (command.includes('delete borders'.toUpperCase())):
+                deleteDataSource(datasourcePublicData);
+                break;
+            case (command.includes('delete Gardens'.toUpperCase())):
+                deleteDataSource(datasourcePoplarCommonGardens);
+                break;
+
+            // case (command.includes('delete switchgrass'.toUpperCase())):
+            //     deleteDataSource(datasourceSwitchGrassGenets);
+
+
+            /* DISCONTINUED DATA SOURCES ----------------------------------------------------------------------------------------*/
+
+            case (command.includes('show me test data'.toUpperCase())):
+                datasourceTestUpload = new Cesium.GeoJsonDataSource.load('./DATA/TestData/Oregon_Fall_35-36_TestData.geojson');
+                addAndFlyToDataSourceWithMinMaxCreationDates(datasourceTestUpload);
+                break;
+            case (command.includes('delete test data'.toUpperCase())):
+                deleteDataSource(datasourceTestUpload);
+                break;            
+
+            // case (command.includes('show me Midland'.toUpperCase())):
+            //     datasourceMidland = new Cesium.GeoJsonDataSource.load('./DATA/BioScales/Midland.geojson');
+            //     addAndFlyToDataSourceWithMinMaxCreationDates(datasourceMidland);
+            //     break;
+            // case (command.includes('delete Midland'.toUpperCase())):
+            //     deleteDataSource(datasourceMidland);
+            //     break;
+
+            // case (command.includes('show me clean esri'.toUpperCase())):
+            //     datasourceCleanEsri = new Cesium.GeoJsonDataSource.load('./DATA/CBI/clean_esri.geojson');
+            //     addAndFlyToDataSourceWithMinMaxCreationDates(datasourceCleanEsri);
+            //     break;
+            // case (command.includes('delete clean esri'.toUpperCase())):
+            //     deleteDataSource(datasourceCleanEsri);
+            //     break;
+
+            // previous pando datafile
+                // datasourcePandoPics = new Cesium.GeoJsonDataSource.load('./DATA/PMI/Pando/Pando_Pics.geojson');
+                // datasourcePandoPics.then(function (dataSource) {
+                //     flyToPandoPics = viewer.dataSources.add(dataSource);
+                //     entities = dataSource.entities.values;
+                //     viewer.flyTo(flyToPandoPics);
+                // });
+                // fetchAndFlyTo("6");
+
+            // datasourceCorvallis = new Cesium.GeoJsonDataSource.load('./DATA/BioScales/Corvallis_Fall_2020_BioScales.geojson');
+            // addAndFlyToDataSource(datasourceCorvallis);
+
+            // datasourceSwitchGrassGenets = new Cesium.GeoJsonDataSource.load('./DATA/genets/SWG_genets.geojson');
+            // addAndFlyToDataSource(datasourceSwitchGrassGenets);
+
+            // fetchWithNoReturnValue("../php/importSiteByCBIgenets.php", "CBI genets");
+            // datasourcePoplarGenets = new Cesium.GeoJsonDataSource.load('./DATA/genets/Poplar_genets.geojson');
+            // addAndFlyToDataSource(datasourcePoplarGenets);
+
+            // datasourceUTKSwitchGrass = new Cesium.GeoJsonDataSource.load('./DATA/CBI/UTK_switchgrass.geojson');
+            // addAndFlyToDataSource(datasourceUTKSwitchGrass);
+        
+            // datasourceCaneyForks = new Cesium.GeoJsonDataSource.load('./DATA/PMI/Caney_Forks_Microbes.geojson');
+            // addAndFlyToDataSource(datasourceCaneyForks);
+            
+            // datasourceDavis = new Cesium.GeoJsonDataSource.load('./DATA/CBI/davis.geojson');
+            // addAndFlyToDataSource(datasourceDavis);         
+
+            // datasourceUTKSwitchGrass = new Cesium.GeoJsonDataSource.load('./DATA/CBI/UTK_switchgrass.geojson');
+            // addAndFlyToDataSource(datasourceUTKSwitchGrass);
+        
+
+            /* MISC -----------------------------------------------------------------------------------------------------*/       
+            case command.includes('CREATE SAMPLING TRIP'):
+                if (dbUserID){
+                    showMenu(window.innerWidth / 2, window.innerHeight / 2, "uploadRouteMenu");
+                }
+                else {
+                    alert("You must be logged in to use this feature.");
+                }
+                break;
+
+            case command.includes('menu'.toUpperCase()):
+                var j= document.createElement("div");
+                j.id ="jarvisSpeechBox";
+                var jtb = document.createTextNode("Hello there");
+                j.appendChild(jtb);
+                document.getElementById("NormalInterface").appendChild(j);
+                console.log("here");
+                break;
+
+            case command.includes('show me United States'.toUpperCase()):
+                datasourceUSmap = new Cesium.GeoJsonDataSource.load('../cesium/Apps/SampleData/ne_10m_us_states.topojson');
+                addAndFlyToDataSource(datasourceUSmap);
+                break;
+            case (command.includes('delete United States'.toUpperCase())):
+                deleteDataSource(datasourceUSmap);
+                break;
+            case command.includes('hide'):
+                speechSynthesis.speak(new SpeechSynthesisUtterance("Sorry, that hasn't been coded  yet?"));
+                break;
+
+            case command.includes('zoom out'):
+                viewer.camera.zoomOut();
+                break;
+
+            case (command.includes('grin'.toUpperCase()) || command.includes('green'.toUpperCase()) ||
+                command.includes('Grant')):
+
+                speechSynthesis.speak(new SpeechSynthesisUtterance('Grin is not a person. Grin is an acronym ' +
+                                    'that stands for Germplasm Resources Information Network.'));
+                var grin= new SpeechSynthesisUtterance(" I see you are looking at that clone from Argentina. " + 
+                                    "That is an old one. We got it in 1968.  Here is some more info about it.");
+                speechSynthesis.getVoices().forEach(function(voice) {
+                    console.log(voice.name, voice.default ? voice.default :'');
+                });
+                grin.voice = speechSynthesis.getVoices().filter(function(voice) {return voice.name == 'Google UK English Female'})[0]
+
+                setTimeout(() => {speechSynthesis.speak(grin)},10000)
+
+                setTimeout(()=> {window.open('https://npgsweb.ars-grin.gov/gringlobal/accessiondetail.aspx?id=1251519')},10000)
+                break;
+
+            case (command.includes('structure'.toUpperCase())):
+
+                setTimeout(()=> {window.open('https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?&mmdbid=146850&bu=1&showanno=1')},10000)
+                break;
+
+            case command.includes('How many'.toUpperCase()):
+               //speechSynthesis.speak(new SpeechSynthesisUtterance("There were 567 clones planted at the University of Tennessee Common Garden"));
+                break;
+
+
+            /* END-OF-CASE -----------------------------------------------------------------------------------------------------------*/    
+            default:
+                //    speechSynthesis.speak(new SpeechSynthesisUtterance('I heard' +
+                //      command + ' and I am not sure I understand that.  Did I hear you correctly?'));)
+                break;
+        }
+    }
+}
+
diff --git a/code/javascript/jarvisFunctions.js b/code/javascript/jarvisFunctions.js
index 6390a543..40f2f6c9 100755
--- a/code/javascript/jarvisFunctions.js
+++ b/code/javascript/jarvisFunctions.js
@@ -22,6 +22,10 @@ function startJarvis(){
 
     // initialize entity selection listeners
     entitySelection();
+
+    // initialize listener for rightclick export menu
+    //exportMenuListeners();
+
 }
 
 // Function to setup the viewer
@@ -264,19 +268,34 @@ function processJarvisCommand(command){
     }).then(function (response) {
         //console.log(response.headers);
         response.json().then(function (myJson) {
-            console.log(myJson);
+            console.log(myJson[0]);
             console.log(myJson[1]);
+            result = myJson[0];
+            action = myJson[1];
             // Determine action
             // show points
-            //addGeojsonToCesium(myJson);
-            // Fly to center and adjust camera height
-
+            if (action === "show points"){
+                addGeojsonToCesium(result);
+                // Fly to center and adjust camera height                
+                fetchWithTextBodyAndJsonResponseFlyTo(command);
+            }            
             // show border
-
-
+            else if (action === "show border"){
+                // 3rd column in the query return for Cesium.Color?
+                drawPolygonBySiteName(result, Cesium.Color.DARKORANGE)
+                // Fly to center and adjust camera height 
+                fetchWithTextBodyAndJsonResponseFlyTo(command);
+            }
             // download points
-
+            else if (action === "download points"){
+                // 3rd column in the query return for fileName?
+                exportCSVFile(myJson, "TempName");
+            }
             // download border
+            else if (action === "download border"){
+                // 3rd column in the query return for fileName?
+                exportJSONFile("TempName_Borders", myJson)
+            }
         });
     });
 }
@@ -285,51 +304,34 @@ function processJarvisCommand(command){
 // put points in cesium and fly to their center
 function fetchAndFlyTo(sitename_id, tableName){
     fetchWithTextBodyAndJsonResponse("../php/importSiteBySitenameID.php", sitename_id);
-    fetchWithTextBodyAndJsonResponseFlyTo("../php/getFlyToCoords.php", sitename_id, tableName);
+    fetchWithTextBodyAndJsonResponseFlyTo_Old("../php/getFlyToCoords.php", sitename_id, tableName);
 }
 
 // draw a polygon in cesium with a point at the center of it, and fly to its center
 function fetchAndFlyToPolygon(sitename_id, tableName, strokeColor){
-    drawPolygonById(sitename_id, tableName, strokeColor)
-    fetchWithTextBodyAndJsonResponseFlyTo("../php/getFlyToCoords.php", sitename_id, tableName);
+    drawPolygonById_Old(sitename_id, tableName, strokeColor)
+    fetchWithTextBodyAndJsonResponseFlyTo_Old("../php/getFlyToCoords.php", sitename_id, tableName);
 }
 
 
 function addGeojsonToCesium(myJson) {
     if (myJson.length > 0) {
-        strTemp = '{"type": "FeatureCollection", "features": ['; // added
+        // Create the rest of the JSON to keep the result to 1 Feature Collection
+        strTemp = '{"type": "FeatureCollection", "features": [';
         myJson.forEach(function (geojson) {
-            strTemp = strTemp + geojson + ',';  // added
+            strTemp = strTemp + geojson + ',';
         });
-        strTemp = strTemp.slice(0, -1);  // added
-        strTemp = strTemp + ']}';  // added
+        strTemp = strTemp.slice(0, -1);
+        strTemp = strTemp + ']}';
         datasourcePublicData = Cesium.GeoJsonDataSource.load(JSON.parse(strTemp), 
-            {}); // moved from forEach
-        viewer.dataSources.add(datasourcePublicData);  // moved from forEach
-        strTemp = "";       // added
+            {});
+        viewer.dataSources.add(datasourcePublicData);
+        strTemp = "";
     };
 }
 
 // get geopoints from the DB and download as CSV. pass the location ID and the column name used for the ID
-function downloadPoints(siteName, fileName) {
-    qryParams = '{"sitename" : "' + siteName + '"}';
-    fetch('../php/getPointsCSVDownload.php', {
-        method: "POST",
-        headers: {
-            "Content-Type": "text/plain"
-        },
-        body: qryParams
-        }
-    ).then(function (response) {
-    //console.log(response.headers);
-    response.json().then(function (myJson) {
-        //console.log(myJson);
-        exportCSVFile(myJson, fileName);
-        });
-    });
-}
-
-function downloadPoints_old(id, columnName, fileName) {
+function downloadPoints_Old(id, columnName, fileName) {
     qryParams = '{"id" : "' + id + '", "columname" : "' + columnName + '"}';
     fetch('../php/getPointsCSVDownload.php', {
         method: "POST",
@@ -349,7 +351,7 @@ function downloadPoints_old(id, columnName, fileName) {
 
 // get a polygon in geojson format from the DB and download as JSON. pass the column (sitename ID) and 
 // the table name to be used for the query
-function downloadBorder(sitenameId, tableName, fileName){
+function downloadBorder_Old(sitenameId, tableName, fileName){
     qryParams = '{"tableName" : "' + tableName + '", "sitenameId" : "' + sitenameId + '"}';
     fetch('../php/importBordersById.php', {
         method: "POST",
@@ -451,7 +453,23 @@ function fetchWithTextBodyAndJsonResponse(fetchURL, bdy) {
     });
 }
 
-function fetchWithTextBodyAndJsonResponseFlyTo(fetchURL, sitenameId, tableName) {
+function fetchWithTextBodyAndJsonResponseFlyTo(sitenName) {
+    fetch("../php/getFlyToCoords.php", {
+        method: "POST",
+        headers: {
+            "Content-Type": "text/plain"
+        },
+        body: sitenName
+    }).then(function (response) {
+        response.json().then(function (myJson) {
+            viewer.camera.flyTo({
+                destination: Cesium.Cartesian3.fromDegrees(myJson[0], myJson[1], myJson[2])
+            });
+        });
+    });
+}
+
+function fetchWithTextBodyAndJsonResponseFlyTo_Old(fetchURL, sitenameId, tableName) {
     qryParams = '{"tableName" : "' + tableName + '", "sitenameId" : "' + sitenameId + '"}';
     fetch(fetchURL, {
         method: "POST",
@@ -500,8 +518,20 @@ function drawPolygon(tableName, pointColor, strokeColor){
     });
 }
 
-// draw a polygon in cesium with a point at the center of it by ID. the borders are random shades of orange
-function drawPolygonById(sitenameId, tableName, strokeColor){
+// draw a polygon in cesium with a point at the center of it by the site's name. Pass the border color
+function drawPolygonBySiteName(result, strokeColor){
+
+    result.forEach(function (geojson) {
+        datasourcePublicData = Cesium.GeoJsonDataSource.load(JSON.parse(geojson), {
+            stroke: strokeColor,
+            fill: Cesium.Color.PINK.withAlpha(0.0),
+            strokeWidth: 15
+        });
+        viewer.dataSources.add(datasourcePublicData);
+    });
+}
+
+function drawPolygonById_Old(sitenameId, tableName, strokeColor){
     qryParams = '{"tableName" : "' + tableName + '", "sitenameId" : "' + sitenameId + '"}';
     fetch("../php/importBordersById.php", {
         method: "POST",
diff --git a/code/php/getFlyToCoords.php b/code/php/getFlyToCoords.php
index 4d88197e..f24c8a46 100755
--- a/code/php/getFlyToCoords.php
+++ b/code/php/getFlyToCoords.php
@@ -9,6 +9,7 @@ header("Content-Type: application/json");
 //$body = http_get_request_body('php://input');  //another method to get header body contents
 $body = file_get_contents('php://input');
 
+$body = htmlentities($body);
 // error_log($body);
 
 $dbConn = logIntoPostgreSQL();
@@ -18,13 +19,8 @@ echo json_encode($LongLatArray);
 function getLongLatPoint($dbConn, $body){
     $LongLatArray = array();
 
-    $obj_array = json_decode($body);
-    $tableName = htmlentities($obj_array->{'tableName'});
-    $sitenameId = htmlentities($obj_array->{'sitenameId'});
-
-//    $result = pg_query($dbConn, "select * from query_site_sitename_id_center_point('$body');");
-    $result = pg_query_params($dbConn, "select * from query_site_sitename_id_center_point($1, $2)", // 18-APR-2023 replacement QRY will be query_site_sitename_center_point($1)
-        array($sitenameId, $tableName));
+    $result = pg_query_params($dbConn, "select * from query_site_sitename_center_point($1)",
+        array($body));
 
     // error_log('Query result:');
     // error_log(print_r($result, true));
diff --git a/code/php/getFlyToCoords_old.php b/code/php/getFlyToCoords_old.php
new file mode 100644
index 00000000..34f08a77
--- /dev/null
+++ b/code/php/getFlyToCoords_old.php
@@ -0,0 +1,44 @@
+<?php
+
+// DON’T DELETE UNTIL THE REMAINING COMMANDS ARE UPDATED
+
+require_once "login.php";
+
+ini_set("session.cookie_httponly", True); // The following line sets the HttpOnly flag for session cookies - make sure to call it before you call session_start()
+session_start();
+header("Content-Type: application/json");
+
+//$body = http_get_request_body('php://input');  //another method to get header body contents
+$body = file_get_contents('php://input');
+
+// error_log($body);
+
+$dbConn = logIntoPostgreSQL();
+$LongLatArray = getLongLatPoint($dbConn, $body);
+echo json_encode($LongLatArray);
+
+function getLongLatPoint($dbConn, $body){
+    $LongLatArray = array();
+
+    $obj_array = json_decode($body);
+    $tableName = htmlentities($obj_array->{'tableName'});
+    $sitenameId = htmlentities($obj_array->{'sitenameId'});
+
+    $result = pg_query_params($dbConn, "select * from query_site_sitename_id_center_point_old($1, $2)",
+        array($sitenameId, $tableName));
+
+    // error_log('Query result:');
+    // error_log(print_r($result, true));
+
+    while ($row = pg_fetch_row($result)) {
+        array_push($LongLatArray, $row[0]); // long
+        array_push($LongLatArray, $row[1]); // lat
+        array_push($LongLatArray, $row[2]); // height
+    }
+
+    pg_close($dbConn);
+    return $LongLatArray;
+}
+
+?>
+
diff --git a/code/php/importBordersById.php b/code/php/importBordersById.php
index 8abfd1a8..14544164 100644
--- a/code/php/importBordersById.php
+++ b/code/php/importBordersById.php
@@ -24,7 +24,7 @@ function getPolygonCenter($dbConn, $body){
     $randomColor = rand_color_only_orange();
 
     $geojsonArray = array();
-    $result = pg_query_params($dbConn, "select query_borders_by_id($1, $2, $3)",
+    $result = pg_query_params($dbConn, "select query_borders_by_id_old($1, $2, $3)",
         array($sitenameId, $tableName, $randomColor));
     // error_log(print_r($result, true));
         while ($row = pg_fetch_row($result)) {
-- 
GitLab