diff options
author | Adhitya Kamakshidasan | 2016-11-04 12:58:57 +0530 |
---|---|---|
committer | GitHub | 2016-11-04 12:58:57 +0530 |
commit | 25afcccb46a603cc9d2485e25216acfffa2e3e02 (patch) | |
tree | 388d9d499a6fbf4496e4e906c1f028557e20a289 /src/main/webapp/index.html | |
parent | e56ebbef304e4837359065efe197e823404a33c9 (diff) | |
parent | 45e0da62e955b2350da8f2ccc1923475c06e1e2f (diff) | |
download | xcos-on-web-25afcccb46a603cc9d2485e25216acfffa2e3e02.tar.gz xcos-on-web-25afcccb46a603cc9d2485e25216acfffa2e3e02.tar.bz2 xcos-on-web-25afcccb46a603cc9d2485e25216acfffa2e3e02.zip |
Merge pull request #186 from Hrily/master
Graph Plotting
Diffstat (limited to 'src/main/webapp/index.html')
-rw-r--r-- | src/main/webapp/index.html | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index 299a30c..f61f726 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -17,6 +17,9 @@ <script type="text/javascript" src="setup.js"></script> <script type="text/javascript" src="combined.js"></script> <script type="text/javascript" src="orientation.js"></script> + <script type="text/javascript" src="highcharts/highcharts.js"></script> + <script type="text/javascript" src="Queue.js"></script> + <script type="text/javascript" src="chart.js"></script> <script type="text/javascript"> // Stores edgeState for every recently created edge in updateFixedTerminalPoint() function @@ -1550,28 +1553,43 @@ editor.addAction('simulate', function(editor, cell) { var diagram = getXcosDiagram(editor, cell); - var blob = new Blob([diagram], { type: 'text/plain' }); - var xhr = new XMLHttpRequest(); - xhr.open('POST', 'SciExec', true); - xhr.onload = function() { - // Create basic structure for the form - var content = document.createElement('div'); - content.setAttribute("id", "contentProperties"); - - // Heading of content - var heading = document.createElement('h2'); - heading.innerHTML = "Set Scope Parameters"; - heading.id = "headingProperties"; - content.appendChild(heading); - var paragraph = document.createElement("p"); - paragraph.innerHTML = xhr.responseText; - content.appendChild(paragraph); + // Create mxWindow for charts + var win = '<div id="charts" style="text-align: center;"><img id="loader" style="position: absolute; top:50%; transform: translate(-50%, -50%);" src="images/loading.gif"/></div>'; + var content = document.createElement('div'); + content.style.padding="1%"; + content.innerHTML = win; + // Center the mxWindow + var w = document.body.clientWidth; + var h = (document.body.clientHeight || document.documentElement.clientHeight); + wnd = new mxWindow('Simulation', content, (w-600)/2, (h-400)/2, 600, 400, true, true); + wnd.setMaximizable(false); + wnd.setMinimizable(false); + wnd.setScrollable(false); + wnd.setResizable(false); + wnd.setClosable(true); + wnd.setVisible(true); + wnd.addListener(mxEvent.CLOSE, function(e){ + chart_reset(); + }); - var wind = showModalWindow(graph, 'Properties', content, 1000, 1000); + // Send xcos file to server + var form = new FormData() + form.append("file",blob); + var xhr = new XMLHttpRequest(); + xhr.open("POST", "/upload", true); + xhr.onload = function() { + console.log(this.responseText); + if(this.responseText!='error'){ + // If no error in uploading, initialize chart + clientID = this.responseText; + chart_init(wnd); + }else{ + alert("Error"); + } }; xhr.onreadystatechange = function() { console.log("state: " + xhr.readyState); @@ -1579,8 +1597,7 @@ xhr.upload.onprogress = function() { console.log("uploading..."); }; - xhr.setRequestHeader("Content-Type", "text/plain"); - xhr.send(blob); + xhr.send(form); }); // Adds toolbar buttons into the status bar at the bottom |