From 54932fed5db91a46fb9bef134fed99ca33fdb9aa Mon Sep 17 00:00:00 2001 From: Winnie <liang15@mcmaster.ca> Date: Mon, 2 Apr 2018 19:07:51 -0400 Subject: [PATCH] Updates --- tomcat/webapps/Trawl/index.jsp | 3 ++- tomcat/webapps/Trawl/script.js | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tomcat/webapps/Trawl/index.jsp b/tomcat/webapps/Trawl/index.jsp index 78d1f65..963baec 100644 --- a/tomcat/webapps/Trawl/index.jsp +++ b/tomcat/webapps/Trawl/index.jsp @@ -82,7 +82,8 @@ Double Handle Slider Modified from: http://jqueryui.com/slider/#range </section> <section id="outputBox"><!-- Map, Histogram Box. Histogram selected by default but we might want to have a loading screen instead.--> - <div id="histogram"></div> + <div display="none" id="histogram"></div> + <div display="none" id="map"></div> <%--<div id="console">~~~ PSEUDO-CONSOLE ~~~<br></div>--%> </section> </section> diff --git a/tomcat/webapps/Trawl/script.js b/tomcat/webapps/Trawl/script.js index 06b7c59..793d193 100644 --- a/tomcat/webapps/Trawl/script.js +++ b/tomcat/webapps/Trawl/script.js @@ -183,6 +183,28 @@ function getTaxGroup() { } } + +function reqMap(params){ + var path = 'doMap.do'; + var xhr = new XMLHttpRequest(); + xhr.open("POST", path); + xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //Send the proper header info + + xhr.onreadystatechange = function() {//Call a function when the state changes (i.e. response comes back) + // Update the dropdown when response is ready + if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { + var nodeList = JSON.parse(this.responseText); + initMap(nodeList["x"], nodeList["y"]); + document.getElementById("outputDetails").innerHTML = "Found " + nodeList["n"] + " results " + "(" + nodeList["time"] + " seconds)<br> Total Population: " + nodeList["individualCount"]; + } + else { + console.log("Server Response: Error"); //RME + } + }; + xhr.send(params); //send request to server + // document.getElementById("console").innerHTML += "Sent request to " + path + ": " + jsonString + "<br>"; //RME +} + function callOutput(){ var pickOutputType = document.getElementsByName('pickOutput'); var outType, taxGroup, yearFrom, yearTo; @@ -200,11 +222,19 @@ function callOutput(){ var params= JSON.stringify({taxId: Number(taxGroup), yearF: Number(yearFrom), yearT: Number(yearTo)}); //Switch Output Display + document.getElementById("histogram").style.display = "none"; + document.getElementById("map").style.display = "none"; + if(outType === "histogram"){ reqHistogram(params); + document.getElementById("histogram").style.display = "block"; + } + else if(outType === "map"){ + reqMap(params); + document.getElementById("map").style.display = "block"; } else{ - console.log("Map or Heatmap"); + console.log("Heatmap/Cluster") } } -- GitLab