diff --git a/tomcat/webapps/Trawl/script.js b/tomcat/webapps/Trawl/script.js index ba7a75eb7a024b9dce4538f8930b9c42ed2df791..c4709569a4107b34d79b3fafbfd434e71f43baaf 100644 --- a/tomcat/webapps/Trawl/script.js +++ b/tomcat/webapps/Trawl/script.js @@ -1,12 +1,14 @@ // Initialization function init() { - initPhylum() + updateSciR(2); // Init Phylum. [Animalia == 2] } // Post Function // Used by getChildren(id) -function post(path, params) { - document.getElementById("console").innerHTML += "In | post()<br>"; //TODO: Console REMOVEME +function getChildren(id) { + document.getElementById("console").innerHTML += "In | getChildren()<br>"; //TODO: Console REMOVEME + var path = 'doBioLookup.do'; + var params = { taxid: id}; var xhr = new XMLHttpRequest(); xhr.open("POST", path); @@ -19,9 +21,27 @@ function post(path, params) { //this is where we can update the various dropdowns if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { document.getElementById("console").innerHTML += "Retrieved:<br>"; //TODO: Console REMOVEME - document.getElementById("console").innerHTML += xhr.responseText + "<br>"; //TODO: Console REMOVEME + console.log("RETRIEVED:") console.log(this.responseText); // Have to go to dev console to print this. Won't show up on pseudo-console. + var nodeList; + + nodeList = JSON.parse(this.responseText); + + // nodeList = { + // "taxonId":[1821,51,1065], + // "taxonName":["Chordata","Mollusca","Arthropoda"] + // }; + document.getElementById("console").innerHTML += nodeList + "<br>"; //TODO: Console REMOVEME + + var content = "", x, y; + for (i in nodeList.taxonId){ + x = nodeList.taxonId[i]; + y = nodeList.taxonName[i]; + content += '"<option value="' + x + '">' + y + '</option>'; + } + + document.getElementById("pickPhylum").innerHTML = content; // return this.responseText; } else{ @@ -30,40 +50,20 @@ function post(path, params) { }; //generate JSON string var jsonString= JSON.stringify(params); - console.log(jsonString); + //send request to server - xhr.send(jsonString); - // xhr.send('{taxid":"2"}'); + xhr.send(jsonString); // xhr.send('{taxid":"2"}'); document.getElementById("console").innerHTML += "Sent request to " + path + ": " + jsonString + "<br>"; //TODO: Console REMOVEME } -// Get Children ranks of Parent ranks from Java -function getChildren(id) { - document.getElementById("console").innerHTML += "In | getChildren()<br>"; //TODO: Console REMOVEME - var nodeList; - //nodeList = { - // "taxonId":[1821,51,1065], - // "taxonName":["Chordata","Mollusca","Arthropoda"] - //}; - nodeList = post('doBioLookup.do', { taxid: id}); // {taxid: intID} - return nodeList; -} - -// Creates Phylum dropdown choices on page load -function initPhylum(){ - // alert("initPhylum function"); - document.getElementById("console").innerHTML += "init phylum<br>"; //TODO: Console REMOVEME - var parentId = 2; //Animalia AphiaID = 2 - var nodeList = getChildren(parentId); - var content = "", x, y; - - for (i in nodeList.taxonId){ - x = nodeList.taxonId[i]; - y = nodeList.taxonName[i]; - content += '"<option value="' + x + '">' + y + '</option>'; - } +nodeList = { + "taxonId":[1821,51,1065], + "taxonName":["Chordata","Mollusca","Arthropoda"] +}; - document.getElementById("pickPhylum").innerHTML = content; +function updateSciR(rank){ + document.getElementById("console").innerHTML += "In | init phylum<br>"; //TODO: Console REMOVEME + getChildren(rank); } function changedSciR(rank){ diff --git a/tomcat/webapps/Trawl/style.css b/tomcat/webapps/Trawl/style.css index ad4e85ee907240486dcec74adf0e482cf4d01668..c45ad01b7cc0bc93ee48fc283482f91bc1969441 100644 --- a/tomcat/webapps/Trawl/style.css +++ b/tomcat/webapps/Trawl/style.css @@ -35,7 +35,7 @@ header{ } .nav-bar{ - border: 1px solid white; + /*border: 1px solid white;*/ font-size: 18px; position: absolute; bottom: 0; @@ -43,7 +43,7 @@ header{ } .nav-bar>*{ - border: 1px solid orange; + /*border: 1px solid orange;*/ } body{