diff --git a/tomcat/webapps/Trawl/index.jsp b/tomcat/webapps/Trawl/index.jsp index d4f6ab8678636a9ddd32ab6783514820bae41746..535087a7ca62bbf68ff959090f6fc24476a94d09 100644 --- a/tomcat/webapps/Trawl/index.jsp +++ b/tomcat/webapps/Trawl/index.jsp @@ -42,22 +42,23 @@ Double Handle Slider Modified from: http://jqueryui.com/slider/#range <section id="formWrapper"> <section id="pickSciRanks"> Phylum: - <select name="pickSciR" id="pickPhylum" size="1" onChange="changedSciR('phylum')"><!--Dynamically Filled--></select> + <%--<select name="pickSciR" id="pickPhylum" size="1" onChange="updateSci(this)"><!--Dynamically Filled--></select>--%> + <select name="pickSciR" id="pickPhylum" size="1" onChange="updateSciR('pickClass', this)"><!--Dynamically Filled--></select> Class: - <select name="pickSciR" id="pickClass" size="1" onChange="changedSciR('class')"> - <option value="00">Arthropoda</option> - <option value="01">Chordata</option> - <option value="03">Mollusca</option> + <select name="pickSciR" id="pickClass" size="1" onChange="updateSciR('pickOrder', this)"> + <%--<option value="00">Arthropoda</option>--%> + <%--<option value="01">Chordata</option>--%> + <%--<option value="03">Mollusca</option>--%> </select> Order: - <select name="pickSciR" size="1" onChange="alert()"><!--Dynamically Filled--></select> + <select name="pickSciR" id="pickOrder" size="1" onChange="updateSciR('pickFamily', this)""><!--Dynamically Filled--></select> Family: - <select name="pickSciR" size="1"><!--Dynamically Filled--></select> + <select name="pickSciR" id="pickFamily" size="1" onChange="updateSciR('pickGenus', this)"><!--Dynamically Filled--></select> Genus: - <select name="pickSciR" size="1"><!--Dynamically Filled--></select> + <select name="pickSciR" id="pickGenus" size="1" onChange="updateSciR('pickSpecies', this)"><!--Dynamically Filled--></select> Species: - <select name="pickSciR" size="1"><!--Dynamically Filled--></select> + <select name="pickSciR" id="pickSpecies" size="1" onChange="alert("No function atm")"><!--Dynamically Filled--></select> </section> <section id="yearIn"> diff --git a/tomcat/webapps/Trawl/script.js b/tomcat/webapps/Trawl/script.js index c4709569a4107b34d79b3fafbfd434e71f43baaf..95d072e12ca22c266901579b7bc71ef9963ea869 100644 --- a/tomcat/webapps/Trawl/script.js +++ b/tomcat/webapps/Trawl/script.js @@ -1,48 +1,48 @@ // Initialization function init() { - updateSciR(2); // Init Phylum. [Animalia == 2] + initPickPhylum(); } -// Post Function -// Used by getChildren(id) -function getChildren(id) { - document.getElementById("console").innerHTML += "In | getChildren()<br>"; //TODO: Console REMOVEME +// nodeList = { +// "taxonId":[1821,51,1065], +// "taxonName":["Chordata","Mollusca","Arthropoda"] +// }; + +function initPickPhylum(){ + updateSciR("pickPhylum", {value:2}); +} + +// Updates a dropdown List +// tagID = tag of dropdown that changes +// taxID = id of parent of the thing that changes +function updateSciR(tagID, object) { var path = 'doBioLookup.do'; - var params = { taxid: id}; + var taxID = object.value; + alert("Updating: " + tagID + "with children of: " + taxID); //TODO Remove me + var params = { taxId: taxID}; var xhr = new XMLHttpRequest(); xhr.open("POST", path); //Send the proper header information along with the request xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - // xhr.setRequestHeader("Content-type", "application/json"); xhr.onreadystatechange = function() {//Call a function when the state changes (i.e. response comes back) - document.getElementById("console").innerHTML += "In | onreadystatechange ... "; //TODO: Console REMOVEME - //this is where we can update the various dropdowns + // Update the dropdown if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { - document.getElementById("console").innerHTML += "Retrieved:<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 += "Retrieved: "; //TODO: Console REMOVEME + document.getElementById("console").innerHTML += this.responseText + "<br>"; //TODO: Console REMOVEME + console.log("RETRIEVED:" + this.responseText); + var nodeList = JSON.parse(this.responseText); document.getElementById("console").innerHTML += nodeList + "<br>"; //TODO: Console REMOVEME var content = "", x, y; - for (i in nodeList.taxonId){ + for (var 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; + document.getElementById(tagID).innerHTML = content; } else{ document.getElementById("console").innerHTML += "Error<br>"; //TODO: Console REMOVEME @@ -56,20 +56,6 @@ function getChildren(id) { document.getElementById("console").innerHTML += "Sent request to " + path + ": " + jsonString + "<br>"; //TODO: Console REMOVEME } -nodeList = { - "taxonId":[1821,51,1065], - "taxonName":["Chordata","Mollusca","Arthropoda"] -}; - -function updateSciR(rank){ - document.getElementById("console").innerHTML += "In | init phylum<br>"; //TODO: Console REMOVEME - getChildren(rank); -} - -function changedSciR(rank){ - // var changedRank = document.getElementsByName() -} - // JQuery for Range Slider $( function() { $( "#slider-range" ).slider({