/*
* hacktest02.js, coded by Ian Ruotsala beginning
* Apr. 12, 2010
* This is a test program to hack/sketch out how a
* more final version would work.
* Specifically it represents the module that holds
* and interacts with the various event arrays.
*/
/*
program outputs the following in Firefox:
stringobjectobjectundefined
undefined
undefined
0,result [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
0,result,0,kb_archivid
ivo://helio-informatics.org/AR_NOAASECObserver_20090904_153554_859 has event_id 187590
There are 25 active region events
stringobject
There are 0 coronal ejection events59
*/
function get_events(event_type){
//send present url to query, update the stored JSON
var httpQuery = new XMLHttpRequest();
httpQuery.open("GET",event_type,false);
httpQuery.send(null);
//this.jsonDoc = eval('(' + httpQuery.responceText + ')');
//eval is generall considered bad practice, security risk
//use parseJSON instead
var returnString = httpQuery.responseText;
document.write(typeof(returnString));
var returnObj = YAHOO.lang.JSON.parse(returnString);
document.write(typeof(returnObj));
//this.jsonDoc = returnObj;
//var jsonCode = (document.childNodes[0]);
//document.write(jsonCode);
//document.write(typeof((document.childNodes[1])));
//this.jsonDoc = returnString.parseJSON();
//document.write(typeof(returnString));
//this.jsonDoc = this.parse(returnString);
//return true if >= 200 events returned
if (returnObj.result.length >= 200){
return true;
}
return returnObj;
}
function test(){
var events = new Array();
events[0] = get_events("ar");
//^^^ note it will query once per event type
document.write(typeof(events[0]));
document.write(typeof(events[0][0]))
document.write("
");
document.write(events[0][0]);
document.write("
");
document.write(typeof(events[0][2]));
document.write("
0,result ");
document.write(events[0].result);
document.write("
");
document.write("
0,result,0,kb_archivid
");
document.write(events[0].result[0].kb_archivid);
document.write(" has event_id " + events[0].result[0].event_id);
document.write("
");
document.write("There are " + events[0].result.length + " active region events");
document.write("
");
events[1] = get_events("ce");
document.write("
");
document.write("There are " + events[1].result.length + " coronal ejection events");
}