Code

Updated image reload in gotomasses
[gosa.git] / gosa-plugins / goto / addons / goto / gotomasses.tpl
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");
80                 
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(/^.*\|/,"");
86         
87                         /* Walk through progress images and check if the 
88                                 progress status has changed 
89              */
90                         for (var e = 0; e < fai_status.length; e++) {
92                                 /* */
93                                 if(fai_status[e]["MAC"] == mac){
95                                         /* Check if progress has changed 
96                                          */     
97                                         if(fai_status[e]["PROGRESS"] != progress){
98                                                 var id          = mac.replace(/:/g,"_"); 
99                                                 id = "progress_" + id;
100                                                 if(document.getElementById(id)){
101                                                         document.getElementById(id).src = "progress.php?x=80&y=13&p=" + progress; 
102                                                         fai_status[e]["PROGRESS"] = progress;
103                                                 }
104                                         }
105                                 }
106                         }
107                 }
108                 timer=setTimeout('loadContent()',5000);
109     }
112 timer=setTimeout('loadContent()',5000);
113 </script>
114 {/literal}