1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
var Timers = {
haveRapi : false,
timerList : {}
};
Timers.init = function() {
var url = "http://192.168.1.122:8002/info.xml";
$.ajax({
url: url,
type : "GET",
success : function(data, status, XHR ) {
Timers.haveRapi = true;
Main.log ("Timers: Got response");
Timers.readTimers();
},
error : function (jqXHR, status, error) {
Timers.haveRapi = false;
Main.log ("Timers: Not found!!!");
}
});
};
Timers.readTimers = function () {
if (Timers.haveRapi == false) {
Main.log ("Timers.readTimers: no restful API!!!");
return;
}
var url = "http://192.168.1.122:8002/timers.xml";
$.ajax({
url: url,
type : "GET",
success : function(data, status, XHR ) {
Main.log ("Timers.readTimer: Success");
Main.log(" Count= " + $(data).find("count").text());
$(data).find("timer").each(function () {
Main.log("timer: ");
Timers.curItem = {};
$(this).find("param").each(function () {
Main.log(" + " + $(this).attr("name") + " val= " +$(this).text());
Timers.curItem[$(this).attr("name")] = $(this).text();
});
/* for (var prop in Timers.curItem) {
Main.log (" -" + prop + " : " + Timers.curItem[prop]);
}
*/
Main.log("Adding id " +Timers.curItem["id"]);
Timers.timerList[Timers.curItem["id"]] = Timers.curItem;
Timers.curItem = {};
});
Main.log("Summary");
for (var id in Timers.timerList) {
Main.log (id + " : ");
for (var prop in Timers.timerList[id]) {
Main.log (" - " + prop + " : " + Timers.timerList[id][prop]);
}
}
},
error : function (jqXHR, status, error) {
Main.log ("Timers.readTimer: Failure");
}
});
};
|