source: schedule/js/xmlrequest.js@ 16661

Last change on this file since 16661 was 16576, checked in by tanio, 12 years ago
File size: 1.3 KB
Line 
1
2 function testData()
3 {
4 //calls the xml request in a loop based on the current sources
5 var source = ['Mrk 421','Mrk 501'];
6 for (i = 0; i<source.length; i++) {
7 testXMLData(i, source);
8 }
9 }
10
11 function testXMLData(index, source)
12 {
13 var testXML;
14 testXML = new XMLHttpRequest();
15 //NOTE: previous errors on the request was caused by appending "http://www.fact-project.org"
16 testXML.open("GET","/smartfact/index.php?source="+escape(source[index])+"&time="+year+"-"+month+"-"+day,true);
17 dataSource = new Array();
18 testXML.onload=function() {
19 if (testXML.status==200)
20 {
21 line=testXML.responseText.split('\n');
22 dataSource.push(line);
23 if (dataSource.length == source.length)
24 displayXMLData(dataSource, source); //this will be called when the last data from the list is read
25 }
26 testXML.send();
27 }
28
29 function displayXMLData(dataSource, source)
30 {
31 //This function splits the lines of data per data source
32 var dataGraph = new Array(source.length);
33 for (i=0; i<source.length; i++) {
34 dataGraph[i] = new Array(); //dataGraph contains the individual points for each source i
35 for(row=0;row<dataSource[i].length;row++)
36 {
37 rows=line[row].split(',');
38 dataGraph[i].push(rows[4]);
39 $('#data').append(i + ' GRAPH DATA ' + dataGraph[i]);
40 }
41 }
42 }
Note: See TracBrowser for help on using the repository browser.