Style improvements, moved connection-related JavaScript code to own file.

This commit is contained in:
Michael Jumper
2011-11-08 12:28:46 -08:00
parent 67412b8666
commit 57a95042e2
3 changed files with 58 additions and 38 deletions

View File

@@ -0,0 +1,32 @@
function Config(protocol, id) {
this.protocol = protocol;
this.id = id;
}
function getConfigList() {
// Get config list
var xhr = new XMLHttpRequest();
xhr.open("GET", "configs", false);
xhr.send(null);
// If fail, throw error
if (xhr.status != 200)
throw new Error(xhr.statusText);
// Otherwise, get list
var configs = new Array();
var configElements = xhr.responseXML.getElementsByTagName("config");
for (var i=0; i<configElements.length; i++) {
configs.push(new Config(
configElements[i].getAttribute("protocol"),
configElements[i].getAttribute("id")
));
}
return configs;
}