There have been some minor updates:
The request can come in any order now, as long as you specify an What and an Event and the When where applicable it will do its best to figure out what you meant.
Human format has been tweaked to be tabular.
XML option should be a little more standard. I am now using an XML generator instead of just string concatenation.
Got rid of all evals in the python code. I also cleaned up the code to use one function in the place of 4.
Also, as a small project I decided to put together some a Javascript object for getting data. I forgot how ugly Javascript's object stuff is. I have included it below.
Code:
function Event(eventCode,year){
this.eventCode = eventCode;
this.year = year;
}
Event.prototype.getRankings = function(){
myEvent = this
url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/rankings/json"
new AJAX_Request(url,function(){myEvent.Rankings = eval("("+xmlhttp.responseText+")")},myEvent)
return myEvent
}
Event.prototype.getAwards = function(){
myEvent = this
url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/awards/json"
new AJAX_Request(url,function(){myEvent.Awards = eval("("+xmlhttp.responseText+")")},myEvent)
return myEvent
}
Event.prototype.getQualificationSchedule = function(){
myEvent = this
url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/qualification/schedule/json"
new AJAX_Request(url,function(){myEvent.Qualification_Schedule = eval("("+xmlhttp.responseText+")")},myEvent)
return myEvent
}
Event.prototype.getEliminationSchedule = function(){
myEvent = this
url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/elimination/schedule/json"
new AJAX_Request(url,function(){myEvent.Elimination_Schedule = eval("("+xmlhttp.responseText+")")},myEvent)
return myEvent
}
Event.prototype.getQualificationResults = function(){
myEvent = this
url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/qualification/results/json"
new AJAX_Request(url,function(){myEvent.Qualification_Results = eval("("+xmlhttp.responseText+")")},myEvent)
return myEvent
}
Event.prototype.getEliminationResults = function(){
myEvent = this
url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/elimination/results/json"
new AJAX_Request(url,function(){myEvent.Elimination_Results = eval("("+xmlhttp.responseText+")")},myEvent)
return myEvent
}
// Utility Functions
function AJAX_Request(url,handlerFunction,newEvent){
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
url = url
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
handlerFunction(newEvent)
}
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
Usage is incredibly simple, create an Event and then get whatever data you want. The data will be placed inside the Event object. Below is an example of getting the first team on the winning alliance.
Code:
kettering = new Event("Kettering",2009);
kettering.getAwards();
kettering.Awards["Regional Winner #1"]["Team"]