1 lawrence.luo 1.1.2.1
2 //base url which is identical for all requests
3 baseURL = "http://"+window.location.hostname+":"+window.location.port+"/cimrs/";
4 host = "http://"+window.location.hostname+":"+window.location.port+"/";
5 configURL = "root%2FPG_InterOp/enum?class=PG_ProviderModule";
6 currentElement = null;
7
8 function insertProviderRow(name, location, vendor, version, interfacetype, state, ref) {
9 var t_rows = document.getElementById('providerTable').rows;
10
11
12 var x=1;
13
14 for (x=1; x < t_rows.length; x++) {
15 var celValue = t_rows[x].cells[0].textContent;
16 if (name < celValue) {
17 break;
18 }
19 }
20
21
22 lawrence.luo 1.1.2.1 var t_row = document.getElementById('providerTable').insertRow(x);
23 t_row.id = "row_" + ref;
24 var t_name =t_row.insertCell(0);
25 var t_location = t_row.insertCell(1);
26 var t_vendor =t_row.insertCell(2);
27 var t_version =t_row.insertCell(3);
28 var t_interfacetype =t_row.insertCell(4);
29 var t_state = t_row.insertCell(5);
30
31
32
33 refArray[name] = ref;
34
35 t_name.innerHTML=name;
36 t_location.innerHTML=location;
37 t_vendor.innerHTML=vendor;
38 t_version.innerHTML = version;
39 t_interfacetype.innerHTML = interfacetype;
40 t_state.innerHTML = state;
41 }
42
43 lawrence.luo 1.1.2.1
44 /**
45 * Writes received content on page.
46 */
47 function writeContent(data) {
48 //define a global variable to store property names and corresponding $ref values
49 refArray = new Array();
50
51 var responseArray = JSON.parse(data);
52 var providerList=responseArray.instances;
53 var i=0;
54 for (i=0; i < providerList.length; i++) {
|
55 lawrence.luo 1.1.2.2 insertProviderRow(decodeURIComponent(providerList[i].properties.Name),
56 decodeURIComponent(providerList[i].properties.Location),
57 decodeURIComponent(providerList[i].properties.Vendor),
58 decodeURIComponent(providerList[i].properties.Version),
59 decodeURIComponent(providerList[i].properties.InterfaceType),
60 decodeURIComponent(providerList[i].properties.OperationalStatus));
|
61 lawrence.luo 1.1.2.1 }
62 //change background color for every second row to improve readability
63 var t_rows = document.getElementById('providerTable').rows;
64 var x;
65 for (x=0; x < t_rows.length; x+=2) {
66 document.getElementById('providerTable').rows[x].style.background = "#EEEEEE";
|
67 lawrence.luo 1.1.2.2 //document.getElementById('providerTable').rows[x+1].style.background = "#E0E0E0";
|
68 lawrence.luo 1.1.2.1 }
69
70
71 }
72
73 /**function to delete all rows of a table except the head row
74 * afterwards a new request is send to get the lastet data and the table can be rebuilt
75 */
76 function reloadTable(table)
77 {
78 var rows = table.rows;
79 var rowCount = rows.length;
80 for (var i = rowCount-1; i > 0; i--)
81 {
82 table.deleteRow(i);
83 }
84 //default case, change it to redraw another table
85 genericRequest('root%2FPG_InterOp/enum?class=PG_ProviderModule', writeContent, true);
86
87 }
88
89 lawrence.luo 1.1.2.1
|