(file) Return to provider.js CVS log (file) (dir) Up to [Pegasus] / pegasus / www / js

  1 lawrence.luo 1.2 /*!LICENSE
  2                   *
  3                   * Licensed to The Open Group (TOG) under one or more contributor license
  4                   * agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5                   * this work for additional information regarding copyright ownership.
  6                   * Each contributor licenses this file to you under the OpenPegasus Open
  7                   * Source License; you may not use this file except in compliance with the
  8                   * License.
  9                   *
 10                   * Permission is hereby granted, free of charge, to any person obtaining a
 11                   * copy of this software and associated documentation files (the "Software"),
 12                   * to deal in the Software without restriction, including without limitation
 13                   * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14                   * and/or sell copies of the Software, and to permit persons to whom the
 15                   * Software is furnished to do so, subject to the following conditions:
 16                   *
 17                   * The above copyright notice and this permission notice shall be included
 18                   * in all copies or substantial portions of the Software.
 19                   *
 20                   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21                   * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 lawrence.luo 1.2  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23                   * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24                   * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25                   * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26                   * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27                   *
 28                   */
 29                  
 30                  configURL = "root%2FPG_InterOp/enum?class=PG_ProviderModule";
 31                  currentElement = null;
 32                  
 33                  function insertProviderRow(name, location, vendor, version, interfacetype, state, ref) {
 34                      var t_rows = document.getElementById('providerTable').rows;
 35                  	
 36                  
 37                      var x=1;
 38                  
 39                      for (x=1; x < t_rows.length; x++) {
 40                          var celValue = t_rows[x].cells[0].textContent;
 41                          if (name < celValue) {
 42                              break;
 43 lawrence.luo 1.2         }
 44                      }
 45                  
 46                  	
 47                      var t_row = document.getElementById('providerTable').insertRow(x);
 48                      t_row.id = "row_" + ref;
 49                      var t_name =t_row.insertCell(0);
 50                      var t_location = t_row.insertCell(1);
 51                      var t_vendor =t_row.insertCell(2);
 52                      var t_version =t_row.insertCell(3);
 53                      var t_interfacetype =t_row.insertCell(4);
 54                      var t_state = t_row.insertCell(5);
 55                  	
 56                  	
 57                  	
 58                      refArray[name] = ref;
 59                  
 60                      t_name.innerHTML=name;
 61                      t_location.innerHTML=location;
 62                      t_vendor.innerHTML=vendor;
 63                      t_version.innerHTML = version;
 64 lawrence.luo 1.2     t_interfacetype.innerHTML = interfacetype; 
 65                      t_state.innerHTML = state;
 66                  }
 67                  
 68                  
 69                  /**
 70                   * Writes received content on page.
 71                   */
 72                  function writeContent(data) {
 73                      //define a global variable to store property names and corresponding $ref values 
 74                      refArray = new Array();
 75                  	
 76                      var responseArray = JSON.parse(data);
 77                      var providerList=responseArray.instances;
 78                      var i=0;
 79                      for (i=0; i < providerList.length; i++) {
 80                          insertProviderRow(decodeURIComponent(providerList[i].properties.Name),
 81                          		          decodeURIComponent(providerList[i].properties.Location),
 82                          		          decodeURIComponent(providerList[i].properties.Vendor),
 83                          		          decodeURIComponent(providerList[i].properties.Version),
 84                          		          decodeURIComponent(providerList[i].properties.InterfaceType),
 85 lawrence.luo 1.2         		          decodeURIComponent(providerList[i].properties.OperationalStatus));
 86                      }
 87                      //change background color for every second row to improve readability
 88                      var t_rows = document.getElementById('providerTable').rows;
 89                      var x;
 90                      for (x=0; x < t_rows.length; x+=2) {
 91                          document.getElementById('providerTable').rows[x].style.background = "#EEEEEE";
 92                          //document.getElementById('providerTable').rows[x+1].style.background = "#E0E0E0";		
 93                      }
 94                  	
 95                  	
 96                  }
 97                  
 98                  /**function to delete all rows of a table except the head row
 99                   * afterwards a new request is send to get the lastet data and the table can be rebuilt
100                   */
101                  function reloadTable(table)
102                  {
103                      var rows = table.rows;
104                      var rowCount = rows.length;
105                      for (var i = rowCount-1; i > 0; i--)
106 lawrence.luo 1.2         {
107                              table.deleteRow(i);
108                          }
109                     //default case, change it to redraw another table
110                     genericRequest('root%2FPG_InterOp/enum?class=PG_ProviderModule', writeContent, true);         
111                      
112                  }
113                  
114                  

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2