Mercurial > repos > pieterlukasse > nist_wrapper
comparison 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 |
comparison
equal
deleted
inserted
replaced
16:c21e96bb68c8 | 17:82368bd06e1d |
---|---|
88 peakTable = httpGet2("/nist_controller/get_nistdata?casnr="+casNr); | 88 peakTable = httpGet2("/nist_controller/get_nistdata?casnr="+casNr); |
89 | 89 |
90 } | 90 } |
91 catch(e) | 91 catch(e) |
92 { | 92 { |
93 //assume running locally: | 93 try |
94 alert("Error while trying to get data from NIST. Rendering library spectrum with dummy data."); | 94 { |
95 peakTable = "55,290 56,240 57,100 58,80"+ | 95 //workaround for galaxy.wur.nl/galaxy_production/ scenario TODO: make more robust code: |
96 " 63,30 65,150 66,50 67,1271"+ | 96 peakTable = httpGet2("/galaxy_production/nist_controller/get_nistdata?casnr="+casNr); |
97 " 68,370 69,100 70,210 71,10"+ | 97 } |
98 " 74,50 75,60 76,120 77,2312"+ | 98 catch(e2) |
99 " 78,220 79,120 80,190 81,630"+ | 99 { |
100 " 82,4884 83,2702 84,240 85,20"+ | 100 //assume running locally: |
101 " 91,180 92,50 93,210 94,3353"+ | 101 alert("Error while trying to get data from NIST. Rendering library spectrum with dummy data."); |
102 " 95,1371 96,1261 97,370 98,120"+ | 102 peakTable = "55,290 56,240 57,100 58,80"+ |
103 " 105,1621 106,160 107,70 108,220"+ | 103 " 63,30 65,150 66,50 67,1271"+ |
104 " 109,80 110,60 111,30 112,40"+ | 104 " 68,370 69,100 70,210 71,10"+ |
105 " 121,30 122,460 123,940 124,9999"; | 105 " 74,50 75,60 76,120 77,2312"+ |
106 //note that the intensities in jcamp response are 10x when compared to MSP format | 106 " 78,220 79,120 80,190 81,630"+ |
107 " 82,4884 83,2702 84,240 85,20"+ | |
108 " 91,180 92,50 93,210 94,3353"+ | |
109 " 95,1371 96,1261 97,370 98,120"+ | |
110 " 105,1621 106,160 107,70 108,220"+ | |
111 " 109,80 110,60 111,30 112,40"+ | |
112 " 121,30 122,460 123,940 124,9999"; | |
113 //note that the intensities in jcamp response are 10x when compared to MSP format | |
114 } | |
107 } | 115 } |
108 var spectrum1 = getSpectrumObjectFromMSPString(spectrumMSPString); | 116 var spectrum1 = getSpectrumObjectFromMSPString(spectrumMSPString); |
109 var spectrum2 = getSpectrumObjectFromJCAMPString(peakTable); | 117 var spectrum2 = getSpectrumObjectFromJCAMPString(peakTable); |
110 renderSpectrum(spectrum1, spectrum2,targetElement); | 118 renderSpectrum(spectrum1, spectrum2,targetElement); |
111 } | 119 } |
122 var xmlHttp = null; | 130 var xmlHttp = null; |
123 | 131 |
124 xmlHttp = new XMLHttpRequest(); | 132 xmlHttp = new XMLHttpRequest(); |
125 xmlHttp.open( "GET", theUrl, false ); | 133 xmlHttp.open( "GET", theUrl, false ); |
126 xmlHttp.send( null ); | 134 xmlHttp.send( null ); |
135 if (xmlHttp.status == 404) | |
136 throw new Exception("Error while trying to access the data: " + xmlHttp.statusText) | |
127 return xmlHttp.responseText; | 137 return xmlHttp.responseText; |
128 } | 138 } |
129 | 139 |
130 | 140 |
131 | 141 |