Line Code
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
var gif_url; 

// strings containing the names of all active GifDisplays                            
var active_displays_l = new Array();

// the current displayFrame                                                          
var current_display;                                                                 
                                                                                     
// the list of displayFrame objects                                                  
var displays_l = new Array();                                                        
                                                                                     
function displayFrame(name)                                                          
{                                                                                    
  this.name = name;                                                                  
  this.is_viewed = false;                                                            
  this.viewed_l = new Array();                                                       
}                                                                                    
                                                                                     
/*                                                                                   
  This function is called onload. It creates the list of                             
  displayFrame objects.                                                              
*/                                                                                   
                                                                                     
function fillDisplayList()                                                           
{                                                                                    
  var iframes_l = document.getElementsByTagName("iframe");                           
  for (i = 0; i < iframes_l.length; i++)                                             
  {                                                                                  
    displays_l[i] = new displayFrame(iframes_l[i].id);                               
  }                                                                                  
                                                                                     
  // the default current is the first:                                               
  current_display = displays_l[0];                                                   
}                                                                                    
                                                                                     
function makeCurrent(display_frame_name)                                             
{                                                                                    
  for (i = 0; i < displays_l.length; i++)                                            
  {                                                                                  
    if (displays_l[i].name == display_frame_name)                                    
    {                                                                                
      break;                                                                         
    }                                                                                
  }                                                                                  
  current_display = displays_l[i];                                                   
}

/*                                                                                   
  Returns true if the display frame provided as an argument                          
  is currently being viewed.                                                         
*/                                                                                   
                                                                                     
function isViewed(display_frame_name)                                                
{                                                                                    
  for (i = 0; i < active_displays_l.length; i++)                                     
  {                                                                                  
    if (active_displays_l[i] == display_frame_name)                                  
    {                                                                                
      return true;                                                                   
    }                                                                                
  }                                                                                  
  return false;                                                                      
}                                                                                    
                                                                                     
//*************************************************************/                     
                                                                                     
/*                                                                                   
  These functions get called if the user clicks on the "start viewing"               
  or "stop viewing" buttons of a display frame. They set the is_viewed               
  field of the displayFrame object.                                                  
*/                                                                                   
                                                                                     
function getDisplayFrame(display_frame_name)                                         
{                                                                                    
  for (i = 0; i < displays_l.length; i++)                                            
  {                                                                                  
    if (displays_l[i].name == display_frame_name)                                    
    return displays_l[i];                                                            
  }                                                                                  
}                                                                                    
                                                                                     
function startViewing(display_frame_name)                                            
{                                                                                    
  var display = getDisplayFrame(display_frame_name);                                 
                                                                                     
  if (display.is_viewed)                                                             
  {                                                                                  
    alert('This GifViewer is already active');                                       
    return;                                                                          
  }                                                                                  
                                                                                     
  display.is_viewed = true;                                                          
  updateDisplay(display_frame_name);                                                 
}                                                                                    
 
function stopViewing(display_frame_name)                                             
{                                                                                    
  var display = getDisplayFrame(display_frame_name);                                 
  display.is_viewed = false;                                                         
}  

/*                                                                                   
  This function is initially called when the "start viewing" button                  
  of a display frame is pressed and keeps calling itself every                       
  [interval] msec, refreshing the frame until it becomes inactive.                   
*/                                                                                   
                                                                                     
function updateDisplay(display_frame_name)                                           
{                                                                                    
  var interval = 5000;                                                               
  var display_frame = getDisplayFrame(display_frame_name);                           
                                                                                     
  if (display_frame.is_viewed == true)                                               
  {                                                                                  
    makeDisplayRequest(display_frame_name);                                          
    if (display_frame.viewed_l.length != 0)                                          
    {                                                                                
      window.frames[display_frame_name].location.href = getGifURL(display_frame_name); 
    }                                                                                
  }                                                                                  
  var this_function_call = "updateDisplay('" + display_frame_name + "')";            
  setTimeout(this_function_call, interval);                                          
}                                                                                    
                                                                                     
//*************************************************************/                     
                                                                                     
function getGifURL(display_frame_name)                                               
{                                                                                    
  var url = getContextURL();                                                         
  url = url + "/temporary/" + display_frame_name + ".gif";                           
  return url;                                                                        
}                                                                                    
                                                                                     
//*************************************************************/                     
                                                                                     
function getDisplayRequestURL(display_frame_name)                                    
{                                                                                    
  url = getApplicationURL();                                                         
  url = url + "/Request"                                                             
  url = url + "?" + "RequestID=Draw"                                                 
  url = url + "&" + "Current=" + contentViewer_current;                              
  url = url + "&" + "DisplayFrameName=" + display_frame_name;                        
                                                                                     
  var display_frame = getDisplayFrame(display_frame_name);                           
  for (i = 0; i < display_frame.viewed_l.length; i++)                                
  {                                                                                  
    url = url + "&" + "View=" + display_frame.viewed_l[i];                           
  }                                                                                  
  return url;                                                                        
}

//*************************************************************/                     
                                                                                     
function makeDisplayRequest(display_frame_name)                                      
{                                                                                    
  url = getDisplayRequestURL(display_frame_name);                                    
  // pass a reference to the updateGifURL function:                                  
  makeRequest(url, updateGifURL);                                                    
}                                                                                    
                                                                                     
//*************************************************************/                     
                                                                                     
function updateGifURL()                                                              
{                                                                                    
  if (http_request.readyState == 4)                                                  
  {                                                                                  
    if (http_request.status == 200)                                                  
    {                                                                                
      var xmldoc;                                                                    
                                                                                     
       // Load the xml elements on javascript lists:                                 
      if (http_request != false)                                                     
      {                                                                              
        xmldoc  = http_request.responseXML;                                          
        gif_url = xmldoc.getElementsByTagName('fileURL').item(0).firstChild.data;    
      }                                                                              
    }                                                                                
  }                                                                                  
}