3 {$div}
6 {literal}
7 <script type="text/javascript">
9 if (typeof XMLHttpRequest != 'undefined')
10 {
11 xmlHttpObject = new XMLHttpRequest();
12 }
13 if (!xmlHttpObject)
14 {
15 try
16 {
17 xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
18 }
19 catch(e)
20 {
21 try
22 {
23 xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
24 }
25 catch(e)
26 {
27 xmlHttpObject = null;
28 }
29 }
30 }
32 var fai_status = new Array();
34 function loadContent()
35 {
36 var c = 0;
38 /* Create array of available progress images once
39 */
40 if(!fai_status.length){
41 for (var i = 0; i < document.images.length; i++) {
42 var img = document.images[i];
43 var id = img.id;
44 if(id.match(/^progress_/)){
45 var mac = id.replace(/^progress_/,'');
46 mac = mac.replace(/_/g,':');
47 fai_status[c] = new Object();
48 fai_status[c]['MAC'] = mac;
49 fai_status[c]['PROGRESS'] = -1;
50 c ++;
51 }
52 }
53 }
55 /* Create string of macs used as parameter for getFAIstatus.php
56 to retrieve all progress values.
57 */
58 var macs = "";
59 for (var i = 0; i < fai_status.length; i++) {
60 macs += fai_status[i]['MAC'] + ","
61 }
63 /* Send request
64 */
65 xmlHttpObject.open('get','getFAIstatus.php?mac=' + macs);
66 xmlHttpObject.onreadystatechange = handleContent;
67 xmlHttpObject.send(null);
68 return false;
69 }
72 function handleContent()
73 {
74 if (xmlHttpObject.readyState == 4)
75 {
76 /* Get text and split by newline
77 */
78 var text = xmlHttpObject.responseText;
79 var data = text.split("\n");
81 /* Walk through returned values and parse out
82 mac and progress value */
83 for (var i = 0; i < data.length; i++) {
84 var mac = data[i].replace(/\|.*$/,"");
85 var progress= data[i].replace(/^.*\|/,"");
87 // DEBUG
88 //progress = parseInt(Math.random() * 100);
90 /* Walk through progress images and check if the
91 progress status has changed
92 */
93 for (var e = 0; e < fai_status.length; e++) {
95 /* */
96 if(fai_status[e]["MAC"] == mac){
98 /* Check if progress has changed
99 */
100 if(fai_status[e]["PROGRESS"] != progress){
101 var id = mac.replace(/:/g,"_");
102 id = "progress_" + id;
103 if(document.getElementById(id)){
104 document.getElementById(id).src = "progress.php?x=80&y=13&p=" + progress;
105 fai_status[e]["PROGRESS"] = progress;
106 }
107 }
108 }
109 }
110 }
111 timer=setTimeout('loadContent()',5000);
112 }
113 }
115 timer=setTimeout('loadContent()',5000);
116 </script>
117 {/literal}