Mercurial > repos > pieterlukasse > nist_wrapper
diff templates/spectrum_gen.js @ 17:82368bd06e1d
small improvements
author | pieter.lukasse@wur.nl |
---|---|
date | Fri, 23 Jan 2015 17:13:06 +0100 |
parents | cce6989ed423 |
children |
line wrap: on
line diff
--- a/templates/spectrum_gen.js Fri Jan 23 14:57:55 2015 +0100 +++ b/templates/spectrum_gen.js Fri Jan 23 17:13:06 2015 +0100 @@ -90,20 +90,28 @@ } catch(e) { - //assume running locally: - alert("Error while trying to get data from NIST. Rendering library spectrum with dummy data."); - peakTable = "55,290 56,240 57,100 58,80"+ - " 63,30 65,150 66,50 67,1271"+ - " 68,370 69,100 70,210 71,10"+ - " 74,50 75,60 76,120 77,2312"+ - " 78,220 79,120 80,190 81,630"+ - " 82,4884 83,2702 84,240 85,20"+ - " 91,180 92,50 93,210 94,3353"+ - " 95,1371 96,1261 97,370 98,120"+ - " 105,1621 106,160 107,70 108,220"+ - " 109,80 110,60 111,30 112,40"+ - " 121,30 122,460 123,940 124,9999"; - //note that the intensities in jcamp response are 10x when compared to MSP format + try + { + //workaround for galaxy.wur.nl/galaxy_production/ scenario TODO: make more robust code: + peakTable = httpGet2("/galaxy_production/nist_controller/get_nistdata?casnr="+casNr); + } + catch(e2) + { + //assume running locally: + alert("Error while trying to get data from NIST. Rendering library spectrum with dummy data."); + peakTable = "55,290 56,240 57,100 58,80"+ + " 63,30 65,150 66,50 67,1271"+ + " 68,370 69,100 70,210 71,10"+ + " 74,50 75,60 76,120 77,2312"+ + " 78,220 79,120 80,190 81,630"+ + " 82,4884 83,2702 84,240 85,20"+ + " 91,180 92,50 93,210 94,3353"+ + " 95,1371 96,1261 97,370 98,120"+ + " 105,1621 106,160 107,70 108,220"+ + " 109,80 110,60 111,30 112,40"+ + " 121,30 122,460 123,940 124,9999"; + //note that the intensities in jcamp response are 10x when compared to MSP format + } } var spectrum1 = getSpectrumObjectFromMSPString(spectrumMSPString); var spectrum2 = getSpectrumObjectFromJCAMPString(peakTable); @@ -124,6 +132,8 @@ xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", theUrl, false ); xmlHttp.send( null ); + if (xmlHttp.status == 404) + throw new Exception("Error while trying to access the data: " + xmlHttp.statusText) return xmlHttp.responseText; }