98f2a37c4b1cb34b7d101c44929c3db187954a3f
[guacamole.git] / src / main / webapp / scripts / connections.js
1
2
3 function Config(protocol, id) {
4     this.protocol = protocol;
5     this.id = id;
6 }
7
8 function getConfigList() {
9
10     // Get config list
11     var xhr = new XMLHttpRequest();
12     xhr.open("GET", "configs", false);
13     xhr.send(null);
14
15     // If fail, throw error
16     if (xhr.status != 200)
17         throw new Error(xhr.statusText);
18
19     // Otherwise, get list
20     var configs = new Array();
21
22     var configElements = xhr.responseXML.getElementsByTagName("config");
23     for (var i=0; i<configElements.length; i++) {
24         configs.push(new Config(
25             configElements[i].getAttribute("protocol"),
26             configElements[i].getAttribute("id")
27         ));
28     }
29
30     return configs;
31     
32 }