Code

Updated progress bar handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 20 May 2008 07:08:14 +0000 (07:08 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 20 May 2008 07:08:14 +0000 (07:08 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10962 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/addons/goto/gotomasses.tpl

index 42cfd429a23cb72a5bcf64e4c526f66b704f0b7a..85a29495db0e294591c933fb2c8c441a77f518ae 100644 (file)
@@ -2,10 +2,15 @@
 
 {$div}
 
+<!--
+JS to reload the progress bars.
 
+-->
 {literal}
 <script type="text/javascript">
 
+/* Get request object handler for this type of browser 
+ */
 if (typeof XMLHttpRequest != 'undefined')
 {
     xmlHttpObject = new XMLHttpRequest();
@@ -77,42 +82,60 @@ function handleContent()
          */
         var text = xmlHttpObject.responseText;
                var data = text.split("\n");
+
+               /* Walk through progress images and check if the 
+                  progress status has changed 
+                */
+               for (var e = 0; e < fai_status.length; e++) {
                
-               /* Walk through returned values and parse out 
-            mac and progress value */
-               for (var i = 0; i < data.length; i++) {
-                       var mac         = data[i].replace(/\|.*$/,"");
-                       var progress= data[i].replace(/^.*\|/,"");
-
-                       // DEBUG 
-                       //progress = parseInt(Math.random() * 100);
-       
-                       /* Walk through progress images and check if the 
-                               progress status has changed 
+                       /* Walk through returned values and parse out 
+                          mac and progress value */
+                       var found       = false;
+
+                       /* Create object id out of mac address 
+               12:34:56:12:34:56 => progress_12_34_56_12_34_56
              */
-                       for (var e = 0; e < fai_status.length; e++) {
+                       var id          = fai_status[e]["MAC"].replace(/:/g,"_"); 
+                       id = "progress_" + id;
+                       var img = document.getElementById(id);  
+
+                       /* Continue if there is no image object iwth this id 
+                    */
+                       if(!img){
+                               continue;
+                       }
+
+                       for (var i = 0; i < data.length; i++) {
+                               var mac         = data[i].replace(/\|.*$/,"");
+                               var progress= data[i].replace(/^.*\|/,"");
 
-                               /* */
+                               /* Match mac returned by the support daemon and 
+                                       the one out of our list */
                                if(fai_status[e]["MAC"] == mac){
+                                       found = true;   
 
                                        /* Check if progress has changed 
                                         */     
                                        if(fai_status[e]["PROGRESS"] != progress){
-                                               var id          = mac.replace(/:/g,"_"); 
-                                               id = "progress_" + id;
-                                               if(document.getElementById(id)){
-                                                       document.getElementById(id).src = "progress.php?x=80&y=13&p=" + progress; 
-                                                       fai_status[e]["PROGRESS"] = progress;
-                                               }
+                                               img.src = "progress.php?x=80&y=13&p=" + progress; 
+                                               fai_status[e]["PROGRESS"] = progress;
                                        }
+                                       break;
                                }
                        }
+                       //document.getElementById("text1").value += "\n ";
+
+                       /* There was no status send for the current mac. 
+                          This means it was removed from the queue.
+                        */
+                       if(!found){
+                               document.location.reload();                             
+                       }
                }
-               timer=setTimeout('loadContent()',5000);
+               timer=setTimeout('loadContent()',3000);
     }
 }
 
-timer=setTimeout('loadContent()',5000);
+timer=setTimeout('loadContent()',3000);
 </script>
 {/literal}
-