A new version of the column configuration interface including
[plewww.git] / plekit / table / columns.js
1
2 /* $Id: column.js Panos $ */
3
4 var filtered_color = "grey";
5 var normal_color = "black";
6
7 //Descriptions overriding the default ones set in Accessors_site.py and configuration 
8
9 var sourceComon = '<a target="source_window" href="http://comon.cs.princeton.edu/">CoMon</a>';
10 var sourceTophat = '<b><a target="source_window" href="http://www.top-hat.info/">TopHat</a></b>';
11 var sourceTophatAPI = '<b><a target="source_window" href="http://www.top-hat.info/API/">TopHat API</a></b>';
12 var sourceMySlice = '<b><a target="source_window" href="http://myslice.info/">MySlice</a></b>';
13 var sourceCymru = '<b><a target="source_window" href="http://www.team-cymru.org/">Team Cymru</a></b>';
14 var sourceMyPLC = '<b><a target="source_window" href="https://www.planet-lab.eu/db/doc/PLCAPI.php">MyPLC API</a></b>';
15 var sourceManiacs = '<b><a target="source_window" href="http://www.ece.gatech.edu/research/labs/MANIACS/as_taxonomy/">MANIACS</a></b>';
16 var sourceMaxmind = '<b><a target="source_window" href="http://www.maxmind.com/app/geolitecity">MaxMind</a></b>';
17 var sourceMonitor = '<b><a target="source_window" href="http://monitor.planet-lab.org/">Monitor</a></b>';
18 var hardwareReqs = 'current <b><a target="source_window" href="http://www.planet-lab.org/hardware">PlanetLab hardware requirement</a></b>';
19 var selectReferenceNode ='Select reference node: <select id="reference_node" onChange="updateReferenceNode(this.value)"><option value=planetlab-europe-07.ipv6.lip6.fr>planetlab-europe-07.ipv6.lip6.fr</option><option value=planetlab2.ipv6.lip6.fr>planetlab2.ipv6.lip6.fr</option></select>';
20 //var addButton = '<input id="addButton" type="button" value="Add" onclick=addColumnAjax(document.getElementById("list1").value)></input>';
21 //var deleteButton = '<input id="deleteButton" type="button" value="Delete" onclick=deleteColumn(window.document.getElementById("list1").value)></input>';
22
23 var descHOSTNAME = "test";
24
25
26 var titleAU = 'Authority';
27 var detailAU = '<i>The authority of the global PlanetLab federation that the site of the node belongs to.</i>';
28 var valuesAU = 'Values: <b>PLC</b> (PlanetLab Central), <b>PLE</b> (PlanetLab Europe)';
29 var sourceAU = 'Source: '+sourceMyPLC;
30 var descAU = '<span class="myslice title">'+titleAU+'</span><p>'+detailAU+'<p>'+valuesAU+'<p>'+sourceAU;
31
32 var titleST = 'Status';
33 var sourceST = 'Source: '+sourceMonitor;
34 var valuesST = 'Values: <b>online</b> (up and running), <b>good</b> (up and running recently), <b>offline</b> (unreachable today), <b>down</b> (node unreachable for more than one day), <b>failboot</b> (reachable, but only by administrators for debugging purposes).';
35 var descST = '<span class="myslice title">'+titleST+'</span><p>'+valuesST+'<p>'+sourceST;
36
37 var titleA = 'Architecture name';
38 var detailA = '<i>The node architecture.</i>';
39 var sourceA = 'Source: '+sourceMyPLC;
40 var valuesA = 'Values: <b>x86_64</b>, <b>i386</b>, <b>n/a</b>';
41 var descA = '<span class="myslice title">'+titleA+'</span><p>'+detailA+'<p>'+valuesA+'<p>'+sourceA;
42
43 var titleAS = 'Autonomous system ID';
44 var sourceAS = 'Source: '+sourceCymru+' (via '+sourceTophat+')';
45 var valuesAS = 'Values: <b>Integer between 0 and 65535</b>, <b>n/a</b>';
46 var descAS = '<span class="myslice title">'+titleAS+'</span><p>'+valuesAS+'<p>' + sourceAS;
47
48 var titleAST = 'Autonomous system type';
49 var sourceAST = 'Source: '+sourceManiacs;
50 var valuesAST = 'Values: <b>t1</b> (tier-1), <b>t2</b> (tier-2), <b>edu</b> (university), <b>comp</b> (company), <b>nic</b> (network information centre -- old name for a domain name registry operator), <b>ix</b> (IXP), <b>n/a</b>';
51 var descAST = '<span class="myslice title">'+titleAST+'</span><p>'+valuesAST+'<p>'+sourceAST;
52
53 var titleASN = 'Autonomous system name';
54 var sourceASN = 'Source: '+sourceTophat;
55 var descASN = '<span class="myslice title">'+titleASN+'</span><p>'+sourceASN;
56
57 var selectPeriodBU = 'Select period: <select id="selectperiodBU" onChange=updatePeriod("BU",this.value)><option value="">Latest</option><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
58 var titleBU = 'Bandwidth utilization ';
59 var sourceBU = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
60 var valuesBU ='Unit: <b>Kbps</b>';
61 var detailBU = '<i>The average transmited bandwidh over the selected period. The period is the most recent for which data is available, with CoMon data being collected by MySlice daily.</i>'
62 var descBU = '<span class="myslice title">'+titleBU+'</span><p>'+detailBU+'<p>'+selectPeriodBU+'<p>'+valuesBU+'<p>'+sourceBU; 
63
64 var titleBW= 'Bandwidth limit';
65 var sourceBW = 'Source: '+sourceComon;
66 var valuesBW = 'Unit: <b>Kbps</b>';
67 var detailBW = '<i>The bandwidth limit is a cap on the total outbound bandwidth usage of a node. It is set by the site administrator (PI). For more details see <a targe="source_window" href="http://www.planet-lab.org/doc/BandwidthLimits">Bandwidth Limits (planet-lab.org)</a></i>.';
68 var descBW = '<span class="myslice title">'+titleBW+'</span><p>'+detailBW+'<p>'+valuesBW+'<p>'+sourceBW;
69
70 var titleCC = 'Number of CPU cores';
71 var sourceCC = 'Source: '+sourceComon;
72 var valuesCC = '<i>The number of CPU cores on the node. For reference, the '+hardwareReqs+' is <b>4 cores min.</b> <br> (Older nodes may have fewer cores)</i>.';
73 var descCC = '<span class="myslice title">'+titleCC+'</span><p>'+valuesCC+'<p>'+sourceCC;
74
75 var titleCN = 'Number of CPUs';
76 var sourceCN = 'Source: '+sourceComon;
77 var valuesCN = '<i>The number of CPUs on the node. For reference, the '+hardwareReqs+' is <b>1 (if quad core) or 2 (if dual core)</b>.</i>';
78 var descCN = '<span class="myslice title">'+titleCN+'</span><p>'+valuesCN+'<p>'+sourceCN;
79
80 var titleCR = 'CPU clock rate';
81 var detailCR = '<i>The clock rate for the CPUs on the node. For reference, the '+hardwareReqs+' is <b>2.4 GHz</b></i>.';
82 var sourceCR = 'Source: '+sourceComon;
83 var valuesCR = 'Unit: <b>GHz</b>';
84 var descCR = '<span class="myslice title">'+titleCR+'</span><p>'+detailCR+'<p>'+valuesCR+'<p>'+sourceCR;
85
86 var selectPeriodCF = 'Select period: <select id="selectperiodCF" onChange=updatePeriod("CF",this.value)><option value="">Latest</option><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
87 var titleCF = 'Free CPU';
88 var sourceCF = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
89 var valuesCF = 'Unit: <b>%</b>';
90 var detailCF = '<i> The average CPU percentage that gets allocated to a test slice named burb that is periodically run by CoMon.</i>';
91 var descCF = '<span class="myslice title">'+titleCF+'</span><p>'+detailCF+'<p>'+selectPeriodCF+'<p>'+valuesCF+'<p>'+sourceCF; 
92
93 var titleDN = 'Toplevel domain name';
94 var sourceDN = 'Source: '+sourceMyPLC;
95 var descDN = '<span class="myslice title">'+titleDN+'</span><p>'+sourceDN;
96
97 var titleDA = 'Date added';
98 var sourceDA = 'Source: '+sourceMyPLC;
99 var detailDA = '<i> The date that the noded was added to PlanetLab.</i>';
100 var descDA = '<span class="myslice title">'+titleDA+'</span><p>'+detailDA+'<p>'+sourceDA;
101
102 var titleDS = 'Disk size';
103 var detailDS = '<i>The size of the hard disk available on the node. For reference, the '+hardwareReqs+' is <b>500 GB</b></i>.';
104 var sourceDS = 'Source: '+sourceComon;
105 var valuesDS = 'Unit: <b>GB</b>';
106 var descDS = '<span class="myslice title">'+titleDS+'</span><p>'+detailDS+'<p>'+valuesDS+'<p>'+sourceDS;
107
108 var titleDU = 'Current disk utilization';
109 var sourceDU = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
110 var valuesDU = 'Unit: <b>GB</b>';
111 var detailDU = '<i> The amount of disk space currently consumed (checked daily).</i>';
112 var descDU = '<span class="myslice title">'+titleDU+'</span><p>'+detailDU+'<p>'+valuesDU+'<p>'+sourceDU;
113
114 var titleDF = 'Disk space free';
115 var sourceDF = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
116 var valuesDF = 'Unit: <b>GB</b>';
117 var detailDF = '<i> The amount of disk space currently available (checked daily).</i>';
118 var descDF = '<span class="myslice title">'+titleDF+'</span><p>'+detailDF+'<p>'+valuesDF+'<p>'+sourceDF;
119
120 var titleHC = 'Hop count (pairwise)';
121 var sourceHC = 'Source: '+sourceTophat;
122 var detailHC = '<i>TopHat conducts traceroutes every five minutes in a full mesh between all PlanetLab nodes. The hop count is the length of the traceroute from the node to the reference node, based upon the most recently reported traceroute</i>.';
123 var descHC = '<span class="myslice title">'+titleHC+'</span><p>'+detailHC+'<p>'+selectReferenceNode+'<p>'+sourceHC;
124
125 var titleIP = 'IP address';
126 var sourceIP = 'Source: '+sourceMyPLC;
127 var descIP = '<span class="myslice title">'+titleIP+'</span><p>'+sourceIP;
128
129 var selectPeriodL = 'Select period: <select id="selectperiodL" onChange=updatePeriod("L",this.value)><option value="">Latest</option><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
130 var titleL= 'Load ';
131 var sourceL = 'Source: '+sourceComon;
132 var valuesL = 'Unit: <b>5-minute load</b>';
133 var detailL = '<i>The average 5-minute load (as reported by the Unix uptime command) over the selected period.</i>';
134 var descL = '<span class="myslice title">'+titleL+'</span><p>'+detailL+'<p>'+selectPeriodL+'<p>'+valuesL+'<p>'+sourceL; 
135
136 var titleLON= 'Longitude';
137 var sourceLON = 'Source: '+sourceTophat;
138 var descLON = '<span class="myslice title">'+titleLON+'</span><p>'+sourceLON;
139
140 var titleLAT= 'Latitude';
141 var sourceLAT = 'Source: '+sourceTophat;
142 var descLAT = '<span class="myslice title">'+titleLAT+'</span><p>'+sourceLAT;
143
144 var titleLCN= 'Location (Country)';
145 var sourceLCN = 'Source: '+sourceMaxmind+' (via '+sourceTophat+')';
146 var detailLCN = '<i>Based on the latitude and longitude information.</i>';
147 var descLCN = '<span class="myslice title">'+titleLCN+'</span><p>'+detailLCN+'<p>'+sourceLCN;
148
149 var titleLCT= 'Location (Continent)';
150 var sourceLCT = 'Source: '+sourceMaxmind+' (via '+sourceTophat+')';
151 var detailLCT = '<i>Based on the latitude and longitude information.</i>';
152 var descLCT = '<span class="myslice title">'+titleLCT+'</span><p>'+detailLCT+'<p>'+sourceLCT;
153
154 var titleLCY= 'Location (City)';
155 var sourceLCY = 'Source: '+sourceMaxmind+' (via '+sourceTophat+')';
156 var detailLCY = '<i>Based on the latitude and longitude information.</i>';
157 var descLCY = '<span class="myslice title">'+titleLCY+'</span><p>'+detailLCY+'<p>'+sourceLCY;
158
159 var titleLPR= 'Location precision radius';
160 var sourceLPR = 'Source: '+sourceTophat;
161 var valuesLPR = 'Unit: <b>float</b>.';
162 var detailLPR = '<i>The radius of the circle corresponding to the error in precision of the geolocalization estimate.</i>';
163 var descLPR = '<span class="myslice title">'+titleLPR+'</span><p>'+detailLPR+'<p>'+valuesLPR+'<p>'+sourceLPR;
164
165 var titleLRN= 'Location (Region)';
166 var sourceLRN = 'Source: '+sourceMaxmind+' (via '+sourceTophat+')';
167 var detailLRN = '<i>Based on the latitude and longitude information.</i>';
168 var descLRN = '<span class="myslice title">'+titleLRN+'</span><p>'+detailLRN+'<p>'+sourceLRN;
169
170 var titleMS= 'Memory size';
171 var detailMS = '<i>The memory size (RAM) available on the node. For reference, the '+hardwareReqs+' is <b>4 GB</b></i>.';
172 var sourceMS = 'Source: '+sourceComon;
173 var valuesMS = 'Unit: <b>GB</b>.';
174 var descMS = '<span class="myslice title">'+titleMS+'</span><p>'+valuesMS+'<p>'+sourceMS;
175
176 var selectPeriodMU = 'Select period: <select id="selectperiodMU" onChange=updatePeriod("MU",this.value)><option value="">Latest</option><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
177 var titleMU = 'Memory utilization';
178 var sourceMU = 'Source: '+sourceComon;
179 var valuesMU = '<p>Unit: <b>%</b>';
180 var detailMU = '<i>The average active memory utilization as reported by CoMon.</i>';
181 var descMU = '<span class="myslice title">'+titleMU+'</span><p>'+detailMU+'<p>'+selectPeriodMU+'<p>'+valuesMU+'<p>'+sourceMU; 
182
183 var titleNEC= 'Network information (ETOMIC)';
184 var sourceNEC = 'Source: '+sourceTophat;
185 var valuesNEC = 'Values: <b>yes/no</b>';
186 var detailNEC = '<i>The existence of a colocated ETOMIC box. When an ETOMIC box is present, you have the possibility to conduct high-precision measurements through the '+sourceTophatAPI+'.</i>';
187 var descNEC = '<span class="myslice title">'+titleNEC+'</span><p>'+detailNEC+'<p>'+valuesNEC+'<p>'+sourceNEC;
188
189 var titleNSN= 'Network information (SONoMA)';
190 var sourceNSN = 'Source: '+sourceTophat;
191 var valuesNSN = 'Values: <b>yes/no</b>';
192 var detailNSN = '<i>The existence of a SONoMA agent. When an SONoMA is present, you have the possibility to have access to high-precision measurements through the '+sourceTophatAPI+'.</i>';
193 var descNSN = '<span class="myslice title">'+titleNSN+'</span><p>'+detailNSN+'<p>'+valuesNSN+'<p>'+sourceNSN;
194
195 var titleNTH= 'Network information (TopHat)';
196 var sourceNTH = 'Source: '+sourceTophat;
197 var valuesNTH = 'Values: <b>yes/no</b>';
198 var detailNTH = '<i>The existence of a colocated TDMI (TopHat Dedicated Measurement Infrastructure) agent. When a TDMI agent is present, you have access to a wide variety of network topology measurements through the '+sourceTophatAPI+'.</i>';
199 var descNTH = '<span class="myslice title">'+titleNTH+'</span><p>'+detailNTH+'<p>'+valuesNTH+'<p>'+sourceNTH;
200
201 var titleNDS= 'Network information (DIMES)';
202 var sourceNDS = 'Source: '+sourceTophat;
203 var valuesNDS = 'Values: <b>yes/no</b>';
204 var detailNDS = '<i>The existence of a colocated DIMES agent. When a DIMES agent is present, you have access to DIMES measurements through the '+sourceTophatAPI+'.</i>';
205 var descNDS = '<span class="myslice title">'+titleNDS+'</span><p>'+detailNDS+'<p>'+valuesNDS+'<p>'+sourceNDS;
206
207 var titleNSF= 'Network information (spoof)';
208 var sourceNSF = 'Source: '+sourceTophat;
209 var valuesNSF = '<p>Values: <b>yes/no</b>';
210 var detailNSF = '<i> Whether the node can send packets successfully (or not) with a spoofed IP source address.</i>';
211 var descNSF = '<span class="myslice title">'+titleNSF+'</span><p>'+detailNSF+'<p>'+valuesNSF+'<p>'+sourceNSF;
212
213 var titleNSR= 'Network information (source route)';
214 var sourceNSR = 'Source: '+sourceTophat;
215 var valuesNSR = '<p>Values: <b>yes/no</b>';
216 var detailNSR = '<i> Whether the node can send packets packets using the IP source route option. See <a target="info_window" href="http://www.networksorcery.com/enp/protocol/ip/option003.htm">here</a>for more info.</i>';
217 var descNSR = '<span class="myslice title">'+titleNSR+'</span><p>'+detailNSR+'<p>'+valuesNSR+'<p>'+sourceNSR;
218
219 var titleNTP= 'Network information (timestamp)';
220 var sourceNTP = 'Source: '+sourceTophat;
221 var valuesNTP = '<p>Values: <b>yes/no</b>';
222 var detailNTP = '<i> Whether the node can send packets packets using the IP timestamp option. See <a target="info_window" href="http://www.networksorcery.com/enp/protocol/ip/option004.htm">here</a>for more info.</i>';
223 var descNTP = '<span class="myslice title">'+titleNTP+'</span><p>'+detailNTP+'<p>'+valuesNTP+'<p>'+sourceNTP;
224
225 var titleNRR= 'Network information (record route)';
226 var sourceNRR = 'Source: '+sourceTophat;
227 var valuesNRR = '<p>Values: <b>yes/no</b>';
228 var detailNRR = '<i> Whether the node can send packets packets using the IP record route option. See <a target="info_window" href="http://www.networksorcery.com/enp/protocol/ip/option007.htm">here</a>for more info.</i>';
229 var descNRR = '<span class="myslice title">'+titleNRR+'</span><p>'+detailNRR+'<p>'+valuesNRR+'<p>'+sourceNRR;
230
231 var titleOS = 'Operating system';
232 var detailOS = '<i>Fedora or CentOS distribution to use for node or slivers.</i>';
233 var sourceOS = 'Source: '+sourceMyPLC;
234 var valuesOS = 'Values: <b>f8, f12, Cent/OS, other, n/a</b>';
235 var descOS = '<span class="myslice title">'+titleOS+'</span><p>'+valuesOS+'<p>'+sourceOS;
236
237 var selectPeriodR = 'Select period: <select id="selectperiodR" onChange=updatePeriod("R",this.value)><option value="">Latest</option><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
238 var titleR = 'Reliability';
239 var sourceR = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
240 var detailR = '<i>CoMon queries nodes every 5 minutes, for 255 queries per day. The average reliability is the percentage of queries over the selected period for which CoMon reports a value. The period is the most recent for which data is available, with CoMon data being collected by MySlice daily.</i>';
241 var valuesR = 'Unit: <b>%</b>';
242 var descR = '<span class="myslice title">'+titleR+'</span><p>'+detailR+'<p>'+selectPeriodR+'<p>'+valuesR+'<p>'+sourceR; 
243
244 var titleRES = 'Reservation capabilities';
245 var sourceRES = 'Source: '+sourceMyPLC;
246 //var valuesRES = 'Values: <b>yes/no</b>';
247 var valuesRES = 'Values: <b>-R-</b> (if yes)';
248 var detailRES = '<i> Whether the node can be reserved for a certain duration.<br>Your slivers will be available <span class=bold>only during timeslots where you have obtained leases (see tab above)</span></i>.  <p>Please note that as of August 2010 this feature is experimental.  Feedback is appreciated at <a href="mailto:devel@planet-lab.org">devel@planet-lab.org</a>';
249 var descRES = '<span class="myslice title">'+titleRES+'</span><p>'+detailRES+'<p>'+valuesRES+'<p>'+sourceRES;
250
251 var selectPeriodS = 'Select period: <select id="selectperiodS" onChange=updatePeriod("S",this.value)><option value="">Latest</option><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
252 var titleS = 'Active slices';
253 var sourceS = 'Source: '+sourceComon+' (via '+sourceMySlice+')';
254 var valuesS = 'Unit: <b>%</b>';
255 var detailS = '<i>Average number of active slices over the selected period for which CoMon reports a value. The period is the most recent for which data is available, with CoMon data being collected by MySlice daily.</i>';
256 var descS = '<span class="myslice title">'+titleS+'</span><p>'+detailS+'<p>'+selectPeriodS+'<p>'+valuesS+'<p>'+sourceS; 
257
258 var titleSN = 'Site name';
259 var sourceSN = 'Source: '+sourceMyPLC;
260 var descSN = '<span class="myslice title">'+titleSN+'</span><p>'+sourceSN;
261
262 var selectPeriodSSH = 'Select period: <select id="selectperiodSSH" onChange=updatePeriod("SSH",this.value)><option value="">Latest</option><option value=w>Week</option><option value=m>Month</option><option value=y>Year</option></select>';
263 var titleSSH = 'Average SSH response delay';
264 var valuesSSH = 'Unit: <b>%</b>';
265 var detailSSH = '<i>The average response delay of the node to SSH logins over the selected period for which CoMon reports a value. The period is the most recent for which data is available, with CoMon data being collected by MySlice daily.</i>';
266 var sourceSSH ='Source: '+sourceComon+' (via '+sourceMySlice+')';
267 var descSSH = '<span class="myslice title">'+titleSSH+'</span><p>'+detailSSH+'<p>'+selectPeriodSSH+'<p>'+valuesSSH+'<p>'+sourceSSH; 
268
269
270 var titleUT = 'Uptime';
271 var sourceUT = 'Source: '+sourceComon;
272 var valuesUT = 'Unit: <b>days</b>';
273 var detailUT = 'The continuous uptime until the moment that the page is loaded, as reported by the CoMon html query API.';
274 var descUT = '<span class="myslice title">'+titleUT+'</span><p>'+detailUT+'<p>'+valuesUT+'<p>'+sourceUT;
275
276
277 //Categorization of columns in different types, useful for filtering 
278
279 function inTypeA(header_name) {
280         var typeA = ['ST','SN','RES','OS','NRR','NTP','NSR','NSF','NDS','NTH','NEC','LRN','LCY','LPR','LCN','LAT','LON','IP','ASN','AST'];
281         return typeA.indexOf(header_name);
282 }
283
284 function inTypeB(header_name) {
285         var typeB = ['BW','DS','MS','CC','CR','AS','MU','DU','CN'];
286         return typeB.indexOf(header_name);
287 }
288
289 function inTypeC(header_name) {
290         var typeC = ['Rw','Rm','Ry','BWw','BWm','BWy','Lw','Lm','Ly','Sw','Sm','Sy','CFw','CFm','CFy','BUw','BUm','BUy','MUw','MUm','MUy','SSHw','SSHm','SSHy'];
291         return typeC.indexOf(header_name);
292 }
293
294 function inTypeD(header_name) {
295         var typeD = ['HC'];
296         return typeD.indexOf(header_name);
297 }
298
299
300 //Debugging
301 function debugfilter(s) {
302         document.getElementById('debug').innerHTML+=s;
303 }
304
305
306 //Called when a column is selected. It displays the detailed description
307 //on the right panel
308
309 function highlightOption(divid) {
310
311         //debugfilter("highlighting option "+divid);
312
313         var columns = document.getElementsByName('columnlist');
314         for(var j = 0; j < columns.length; j++)
315                 columns[j].className = 'out'; 
316
317         document.getElementById(divid).className = 'selected';
318
319         showDescription(divid);
320
321 //panos: to IMPROVE 
322         if (document.getElementById('selectperiod'+divid))
323                 document.getElementById('selectperiod'+divid).value = document.getElementById('period'+divid).value;
324
325 }
326
327
328 //Displays the detailed column description 
329
330 function showDescription(h) {
331
332         //debugfilter("showing description "+h);
333
334 //Checks if the detailed description div exists 
335         if (document.getElementById('selectdescr'))
336         {
337                 //Checks if there is a detailed description defined
338                 if (window['desc'+h])
339                         document.getElementById('selectdescr').innerHTML = ""+window['desc'+h];
340                 //else if (document.getElementById('fdesc'+h))
341                         //document.getElementById('selectdescr').innerHTML = document.getElementById('fdesc'+h).value;
342                 else 
343                         document.getElementById('selectdescr').innerHTML = "No detailed description provided";
344         }
345 }
346
347
348 //Overrides the titles of the columns as they are shown in the column selection panel.
349 //If no overriding variable exists the tag's description is used
350 function overrideTitles() {
351
352         var columns = document.getElementsByName('columnlist');
353
354         for(var j = 0; j < columns.length; j++)
355         {
356                 var kk = columns[j].id;
357                 if (window['title'+kk])
358                         document.getElementById('htitle'+kk).innerHTML = window['title'+kk];
359         }
360 }
361
362 //When the checkbox is clicked. Adds/removes column respectively
363 function changeCheckStatus(column) {
364
365         var h = document.getElementById(column).value;
366
367         if (document.getElementById('selectdescr'))
368                 showDescription(h);
369
370         //debugfilter("HERE: "+column+" - "+document.getElementById('type '+column).value);
371         //debugfilter("HERE: "+column);
372
373
374         if (document.getElementById(column).checked)
375                 addColumn(h, true, document.getElementById('type'+h).value);
376         else
377                 deleteColumn(h);
378 }
379
380
381
382 //This function is used when the alternative "quick" selection list is used
383 function changeSelectStatus(column) {
384
385         var optionClass = "";
386         var selected_index = document.getElementById('quicklist').selectedIndex;
387
388         if (document.getElementById('quicklist') && selected_index != 0)
389         {
390
391                 optionClass = document.getElementById('quicklist').options[selected_index].className;
392
393                 if (optionClass == "in")
394                 {
395                         deleteColumn(document.getElementById('quicklist').value);
396                         document.getElementById('quicklist').options[selected_index].className = "out";
397                         document.getElementById('quicklist').value="0";
398                 }
399                 else
400                 {
401                         addColumn(document.getElementById('quicklist').value, true);
402                         document.getElementById('quicklist').options[selected_index].className = "in";
403                         document.getElementById('quicklist').value="0";
404                 }
405         }
406 }
407
408 function updateReferenceNode(new_ref_node) {
409
410         var old_ref_node = document.getElementById('selected_reference_node').value;
411         document.getElementById('selected_reference_node').value=new_ref_node;
412
413         //debugfilter("changed "+old_ref_node+" with "+new_ref_node);
414
415         if (document.getElementById('checkHC').checked)
416         {
417                 addColumnAjax('HC', 'HC');
418                 //debugfilter("replacing "+old_ref_node+" with "+new_ref_node);
419                 replaceColumnConfiguration('HC:'+old_ref_node,'HC:'+new_ref_node);
420         }
421
422 }
423
424
425 //When the period of an already selected column is changed
426 function updatePeriod(h, new_period) {
427
428         var old_period = document.getElementById('period'+h).value;
429         document.getElementById('period'+h).value=new_period;
430
431         //debugfilter(h+''+old_period+'-'+h+''+new_period);
432         if (document.getElementById('check'+h).checked)
433         {
434                 deleteColumnCells(h+''+old_period);
435                 addColumnCells(h+''+new_period);
436                 addColumnAjax(h, h+''+new_period);
437
438                 replaceColumnConfiguration(h+''+old_period,h+''+new_period);
439         }
440 }
441
442 /*
443  
444 RESET/SAVE CONFIGURATION
445 */
446
447 function getHTTPObject()
448 {
449         if (typeof XMLHttpRequest != 'undefined')
450         { return new XMLHttpRequest(); }
451
452         try
453         { return new ActiveXObject("Msxml2.XMLHTTP"); }
454         catch (e)
455         {
456                 try { return new ActiveXObject("Microsoft.XMLHTTP"); }
457                 catch (e) {}
458         }
459         return false;
460 }
461
462 function closeMessage(tab)
463 {
464         var current_conf = document.getElementById('show_configuration').value;
465         var value = '';
466
467         if (current_conf != "")
468                 current_conf += ";";
469
470         if (tab == 'reservable') {      
471         document.getElementById('note_reservable_div').style.display = "none";
472         if (current_conf.indexOf('reservable') != -1)
473                 return;
474         value = current_conf+'reservable';
475         }
476
477         if (tab == 'columns') { 
478         document.getElementById('note_columns_div').style.display = "none";
479         if (current_conf.indexOf('columns') != -1)
480                 return;
481         value = current_conf+'columns';
482         }
483
484         var slice_id = document.getElementById('slice_id').value;
485         var person_id = document.getElementById('person_id').value;
486         var tag_id = document.getElementById('show_tag_id').value;
487         
488         var url = "/plekit/php/updateConfiguration.php?value="+value+"&slice_id="+slice_id+"&person_id="+person_id+"&tag_name=showconf&tag_id="+tag_id;
489         //debugfilter("updating conf with "+url);
490         document.getElementById('show_configuration').value = value;
491
492         var req = getHTTPObject();
493         req.open('GET', url, true);
494         req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
495         req.onreadystatechange =
496         function() {
497                 if (req.readyState == 4)
498                 { debugfilter(req.responseText); }
499         }
500         req.send(null);
501
502 }
503
504
505 function updateColumnConfiguration(value, reload)
506 {
507         var person_id = document.getElementById('person_id').value;
508         var slice_id = document.getElementById('slice_id').value;
509         var tag_id = document.getElementById('conf_tag_id').value;
510         var full_column_configuration = document.getElementById('full_column_configuration').value;
511
512         //debugfilter("<br>OLD = "+full_column_configuration);
513         //debugfilter("<br>value = "+value);
514         //
515         
516         var old_columns = full_column_configuration.split(";");
517         var new_columns = new Array();
518
519         for (var column_index = 0; column_index < old_columns.length ; column_index++) {
520                 new_columns.push(old_columns[column_index]);
521                 if (old_columns[column_index] != slice_id)
522                         new_columns.push(old_columns[++column_index]);
523                 else
524                 {
525                         if (value != "")
526                                 new_columns.push(value);
527                         else
528                                 new_columns.push("default");
529                                 
530                         column_index++;
531                 }
532         }
533
534         var new_configuration = new_columns.join(";");
535         //debugfilter("<br>NEW = "+new_configuration);
536
537         if (window.XMLHttpRequest)
538           {// code for IE7+, Firefox, Chrome, Opera, Safari
539           xmlhttp=new XMLHttpRequest();
540           }
541         else
542           {// code for IE6, IE5
543           xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
544           }
545         xmlhttp.onreadystatechange=function()
546           {
547           if (xmlhttp.readyState==4) // && xmlhttp.status==200)
548             {
549                 //value=xmlhttp.responseText;
550                 //debugfilter(value+"-----"+new_configuration);
551                 document.getElementById('column_configuration').value=value;
552                 document.getElementById('full_column_configuration').value=new_configuration;
553
554                 if (reload)
555                         window.location.reload(true);
556             }
557           }
558
559         xmlhttp.open("GET","/plekit/php/updateConfiguration.php?value="+new_configuration+"&slice_id="+slice_id+"&person_id="+person_id+"&tag_name=columnconf&tag_id="+tag_id,true);
560         //xmlhttp.open("GET","/plekit/php/updateConf.php?value="+value+"&slice_id="+slice_id+"&person_id="+person_id+"&tagName=Columnconf",true);
561
562         xmlhttp.send();
563 }
564
565 function logSortingAction(person_id, slice_id, value)
566 {
567
568
569         var req = getHTTPObject();
570         var url = "/plekit/php/logSorting.php?value="+value+"&slice_id="+slice_id+"&person_id="+person_id;
571
572         req.open('GET', url, true);
573         req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
574         req.onreadystatechange =
575         function() {
576                 if (req.readyState == 4)
577                 { debugfilter(req.responseText); }
578         }
579         req.send(null);
580 }
581
582 function sortCompleteCallback(tableid) {
583
584         var slice_id = document.getElementById('slice_id').value;
585         var person_id = document.getElementById('person_id').value;
586
587         var ths = document.getElementById(tableid).getElementsByTagName("th");
588         for(var i = 0, th; th = ths[i]; i++) {
589         if (th.className.indexOf("Sort") != -1)
590         {
591                 //debugfilter("sorted"+th.getAttribute("name"));
592
593                 var column_name = th.getAttribute("name");
594                 var hclass = th.className;
595                 var column = hclass.substr(hclass.indexOf("column"),hclass.indexOf("column")+1);
596                 var sortdirection = "forward";
597                 if (hclass.indexOf("reverse")!=-1)
598                         sortdirection = "reverse";
599
600                 if (column.indexOf("column-1")==-1 && column.indexOf("column-0")==-1)
601                         logSortingAction(person_id, slice_id, tableid+"|"+column_name+"|"+sortdirection);
602         }
603         }
604 }
605
606
607 function addColumnToConfiguration(column) {
608
609         var old_configuration = document.getElementById('column_configuration').value;
610
611         var new_configuration = "";
612
613         if (old_configuration != "")
614                 new_configuration = old_configuration += "|"+column;
615         else
616                 new_configuration = column;
617
618         //debugfilter("new configuration = "+new_configuration);
619
620         updateColumnConfiguration(new_configuration, false);
621 }
622
623
624 function deleteColumnFromConfiguration(column) {
625
626         var old_configuration = document.getElementById('column_configuration').value;
627
628         var old_columns = old_configuration.split("|");
629         var new_columns = new Array();
630
631         for (var column_index = 0; column_index < old_columns.length ; column_index++) {
632                 var conf = old_columns[column_index].split(':');
633                 if (conf[0] != column)
634                         new_columns.push(old_columns[column_index]);
635         }
636
637         var new_configuration = new_columns.join("|");
638         updateColumnConfiguration(new_configuration, false);
639
640 }
641
642 function replaceColumnConfiguration(column_old, column_new) {
643
644         var old_configuration = document.getElementById('column_configuration').value;
645
646         var old_columns = old_configuration.split("|");
647         var new_columns = new Array();
648
649         var olds = column_old.split(':');
650
651         for (var column_index = 0; column_index < old_columns.length ; column_index++) {
652                 var conf = old_columns[column_index].split(':');
653                 if (conf[0] != olds[0])
654                         new_columns.push(old_columns[column_index]);
655                 else
656                         new_columns.push(column_new);
657         }
658
659         var new_configuration = new_columns.join("|");
660         
661         updateColumnConfiguration(new_configuration);
662 }
663
664 /*
665  
666 ADD/REMOVE COLUMNS
667
668 */
669
670
671 function convert_data(value, data_source, data_type, tagname) {
672
673         //debugfilter("v["+tagname+"]="+value+"-");
674
675         if (value == "" || value == "n/a" || value == null || value == "NaN" || value == "None")
676                 return "n/a";
677
678         if (tagname == "uptime") {
679                 return parseInt((parseFloat(value) / 86400));
680         }
681         
682         if (data_type == "date") {
683
684                 var date = new Date(value*1000);
685
686                 var year = date.getFullYear();
687                 var month = date.getMonth()+1;
688                 if (month < 10)
689                         month = "0"+month;
690                 var day = date.getDate();
691                 if (day < 10)
692                         day = "0"+day;
693         
694                 return year + '-' + month + '-' + day;
695         }
696
697         return value;
698 }
699
700
701 function load_data(column, header, url, data_source, data_type, tagname) {
702
703         //debugfilter("<br>loading "+url);
704         var req = getHTTPObject();
705         var res;
706         req.open('GET', url, true);
707         req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
708         req.onreadystatechange =
709         function() {
710                 if (req.readyState == 4)
711                 { updateColumnData(column, header, req.responseText, data_source, data_type, tagname); }
712         }
713         req.send(null);
714 }
715
716
717 function updateColumnData(column, header, data, data_source, data_type, tagname) {
718
719 var headers = header.split("|");
720 var data_table = data.split("|"); 
721
722 //debugfilter("<p>headers[0] = "+headers[0]);
723 //debugfilter("<p>data[2] = "+data_table[2]);
724
725 //debugfilter("data = "+data + " with type "+data_type + " and source "+data_source);
726
727 if (data != "")
728 {
729   
730 //debugfilter("GOT SOME DATA");
731
732   var node_data;
733
734   var table_id1 = 'nodes';
735   var table=$(table_id1);
736   var css='#'+table_id1+'>tbody';
737   var rows = $$(css)[0].rows;
738
739   var data_array1 = new Array();
740
741   //debugfilter("COLUMN "+column+"<p>");
742
743   for (var node_index = 1; node_index < data_table.length; node_index++) {
744         if (data_table[node_index] == '---potential---')        
745                 break;
746         node_data = data_table[node_index].split(':');
747
748         data_array1[node_data[0]] = new Array();
749
750         for (var h_index=0; h_index < headers.length; h_index++) {
751                 
752                 if (node_data[h_index+1] == "" || node_data[h_index+1] == "None")
753                         data_array1[node_data[0]][h_index] = "n/a";
754                 else
755                         data_array1[node_data[0]][h_index] = convert_data(node_data[h_index+1], data_source, data_type, tagname);
756         }
757
758   }
759         
760
761   if (rows)
762   for (var row_index = 0; row_index < rows.length ; row_index++) {
763     var tr=rows[row_index];
764
765     for (var column_index=0; column_index < tr.cells.length; column_index++) {
766                 //debugfilter("<p>node id = "+tr.cells[0].innerHTML+" - "+tr.cells[column_index].getAttribute('name'));
767                 if (tr.cells[column_index].getAttribute('name'))
768                 {
769                 var found_index = headers.indexOf(tr.cells[column_index].getAttribute('name'));
770                 if (found_index != -1)
771                         //debugfilter(tr.cells[0].innerHTML+"-"+found_index);
772                         tr.cells[column_index].innerHTML = data_array1[tr.cells[0].innerHTML][found_index];
773                 }
774     }
775   }
776
777   //tablePaginater.init(table_id1);
778   fdTableSort.init(table_id1);
779
780 //potential nodes
781 if (data_table[node_index] == '---potential---')        
782 {
783
784   var table_id2 = 'add_nodes';
785   var table2=$(table_id2);
786   var css2='#'+table_id2+'>tbody';
787   var rows2 = $$(css2)[0].rows;
788
789   var data_array2 = new Array();
790
791   //debugfilter("COLUMN "+column+"<p>");
792
793   for (; node_index < data_table.length; node_index++) {
794         if (data_table[node_index] == '')       
795                 continue;
796         node_data = data_table[node_index].split(':');
797
798         data_array2[node_data[0]] = new Array();
799
800         for (var h_index=0; h_index < headers.length; h_index++) {
801                 
802                 if (node_data[h_index+1] == "")
803                         data_array2[node_data[0]][h_index] = "n/a";
804                 else
805                         data_array2[node_data[0]][h_index] = convert_data(node_data[h_index+1], data_source, data_type, tagname);
806         }
807   }
808         
809   if (rows)
810   for (var row_index = 0; row_index < rows2.length ; row_index++) {
811     var tr=rows2[row_index];
812
813     for (var column_index=0; column_index < tr.cells.length; column_index++) {
814                 if (tr.cells[column_index].getAttribute('name'))
815                 {
816                 var found_index = headers.indexOf(tr.cells[column_index].getAttribute('name'));
817                 if (found_index != -1)
818                         tr.cells[column_index].innerHTML = data_array2[tr.cells[0].innerHTML][found_index];
819                 }
820     }
821   }
822   fdTableSort.init(table_id2);
823   //tablePaginater.init(table_id2);
824
825 }
826
827   //fdTableSort.removeTableCache(table_id2);
828   //document.getElementById('loading'+column).innerHTML = "";
829   //debugfilter("Reset sorting .....");
830   
831 }
832
833 document.getElementById('loading'+column).innerHTML = "";
834
835 }
836
837
838 function addColumnCells(header) {
839
840         var cells = document.getElementsByName(header);
841
842         //debugfilter("got cells -"+cells+"- for "+header);
843         for(var j = 0; j < cells.length; j++) 
844                 cells[j].style.display = "table-cell";
845 }
846
847 function addSampleCells(column) {
848
849         var cellsheader = document.getElementsByName("confheader"+column);
850         for(var j = 0; j < cellsheader.length; j++) 
851                 cellsheader[j].style.display = "table-cell";
852
853 }
854
855 function addColumnAjax(column, header) {
856
857         //var t = document.getElementById('check'+column).name;
858         var t = document.getElementById('tagname'+header).value;
859         var slice_id = document.getElementById('slice_id').value;
860
861         var selectedperiod = document.getElementById('period'+column).value;
862
863         var fetched = document.getElementById('fetched'+column).value;
864         var data_source = document.getElementById('source'+column).value;
865         var data_type = document.getElementById('type'+column).value;
866         var to_load = false;
867
868         //debugfilter("<br>adding "+column+","+header+','+fetched+','+t);
869
870         if (fetched.indexOf("false")!=-1)
871         {
872                 to_load = true;
873                 document.getElementById('fetched'+column).value = ','+selectedperiod+',true';
874         }
875         else if (fetched.indexOf(','+selectedperiod+',')==-1)
876         {
877                         to_load = true;
878                         document.getElementById('fetched'+column).value = ','+selectedperiod+''+fetched;
879         }
880
881         if (to_load)
882         {
883                 document.getElementById('loading'+column).innerHTML = "<img width=10 src=/plekit/icons/ajax-loader.gif>";
884                 var url = "/plekit/php/updateColumn.php?slice_id="+slice_id+"&tagName="+t+"&data_type="+data_type+"&data_source="+data_source;
885                 load_data(column, header, url, data_source, data_type, t);
886         }
887 }
888
889
890
891 function addColumn(column, fetch) {
892
893         var selectedperiod="";
894         var header=column;
895         var conf="";
896
897
898         if (inTypeC(column)!=-1)
899         {
900                 column = column.substring(0,column.length-1);
901         }
902
903         selectedperiod = document.getElementById('period'+column).value;
904         header = column+""+selectedperiod;
905
906         if (inTypeD(column)!=-1)
907         {
908                 conf = header+":"+document.getElementById('reference_node').value;
909                 document.getElementById('selected_reference_node').value=document.getElementById('reference_node').value;
910         }
911         else
912                 conf = header;
913
914         //debugfilter("adding column "+column+" and header "+header+" and conf = "+conf);
915
916         addColumnCells(header);
917
918         if (fetch)
919                 addColumnAjax(column, header);
920
921         addColumnToConfiguration(conf);
922 }
923
924
925 function deleteColumnCells(header) {
926
927         var cells = document.getElementsByName(header);
928         for(var j = 0; j < cells.length; j++) 
929                 cells[j].style.display = "none";
930
931 }
932
933
934 function deleteColumn(column) {
935
936         var selectedperiod="";
937         var header=column;
938
939         selectedperiod = document.getElementById('period'+column).value;
940         header = column+""+selectedperiod;
941
942         //debugfilter("deleting "+column+","+header);
943
944         deleteColumnCells(header);
945
946         deleteColumnFromConfiguration(header);
947 }
948
949
950 /* 
951  
952 EXTRA
953
954
955 function removeSelectHandler(object)
956 {
957         debugfilter(object);
958         object.onclick = null;
959 }
960
961 //to be used for scrolling the column list with down/up arrows 
962
963 function scrollList() {
964 debugfilter("here "+document.getElementById('scrolldiv').focused);
965 if (event.keyCode == 40)
966         debugfilter("down");
967 else if (event.keyCode == 38)
968         debugfilter("up");
969 }
970
971 function resetColumns() {
972
973         for (var kk in column_table) {
974
975         if (column_table[kk]['visible'] == true && column_table[kk]['fetch'] == false)
976                 deleteColumn(kk);
977         else if (column_table[kk]['visible'] == false && column_table[kk]['fetch'] == true)
978                 addColumn(kk, true);
979         }
980
981 }
982
983 function resetCols(which_conf) {
984
985         var target_configuration = "|"+document.getElementById(which_conf).value+"|";
986         
987         //debugfilter("<p>Target configuration =  "+target_configuration);
988
989         for (var kk in column_table) {
990                 //debugfilter("in "+kk+" ");
991
992                 if (target_configuration.indexOf("|"+kk+"|")>=0)
993                 {
994                         if (document.getElementById('check'+kk))
995                         if (document.getElementById('check'+kk).checked == false)
996                         {
997                                 debugfilter("<p>Adding "+kk);
998                                 addColumn(kk, true);
999                         }
1000                 }
1001                 else
1002                 {
1003                         if (document.getElementById('check'+kk))
1004                         if (document.getElementById('check'+kk).checked == true)
1005                         {
1006                                 debugfilter("<p>Deleting "+kk);
1007                                 deleteColumn(kk);
1008                         }
1009                 }
1010         }
1011 }
1012
1013 function filterByType(selectedtype) {
1014
1015 var notselectedyet = true;
1016
1017 for (var kk in column_headers) {
1018
1019         if (document.getElementById(kk))
1020         {
1021                 if (window['type'+kk] == selectedtype)
1022                 {
1023                         document.getElementById(kk).className = 'in';
1024                         if (notselectedyet)
1025                                 highlightOption(kk);
1026                         notselectedyet = false;
1027                 }
1028                 else
1029                         document.getElementById(kk).className = 'out';
1030         }
1031 }
1032 }
1033
1034
1035 function deleteColumnSample() {
1036         var cellsheader = document.getElementsByName("confheader"+column);
1037         for(var j = 0; j < cellsheader.length; j++) 
1038                 cellsheader[j].style.display = "none";
1039
1040 }
1041
1042 function checkDataToFetch() {
1043
1044 var dataExist = false;
1045
1046 for (var kk in column_table) {
1047
1048         if (document.getElementById(kk))
1049         {
1050                 if (column_table[kk]['visible'] == true && column_table[kk]['fetch'] == false)
1051                 {
1052                         document.getElementById('fetchbutton').disabled = false;
1053                         document.getElementById('fetchbutton').style.color = 'red';
1054                         dataExist = true;
1055                 }
1056         }
1057 }
1058
1059 if (!dataExist)
1060 {
1061         document.getElementById('fetchbutton').disabled = true;
1062         document.getElementById('fetchbutton').style.color = 'grey';
1063 }
1064
1065 }
1066
1067
1068 function fetchData() {
1069
1070 var tagnames = "";
1071 var headers = "";
1072
1073 for (var kk in column_table) {
1074
1075 if (column_table[kk]['visible'] == true && column_table[kk]['fetch'] == false)
1076         if (tagnames == "")
1077         {       
1078                 tagnames = column_table[kk]['tagname'];
1079                 headers = kk;
1080         }
1081         else
1082         {
1083                 tagnames += "|"+column_table[kk]['tagname'];
1084                 headers += "|"+kk;
1085         }
1086 }
1087
1088 //debugfilter("fetching these columns: "+tagnames+ "("+headers+")");
1089
1090         var slice_id = document.getElementById('slice_id').value;
1091         document.getElementById('loadingDiv').innerHTML = "&nbsp;&nbsp;&nbsp;<img src=/plekit/icons/ajax-loader.gif>&nbsp;Loading data. Please wait ...";
1092         var url = "/plekit/php/updateColumn.php?slice_id="+slice_id+"&tagName="+tagnames;
1093         load_data(headers, url);
1094 }
1095
1096
1097 /*
1098  
1099
1100 HIGHLIGHTING
1101
1102
1103
1104 function updateColumnThreshold(column, minT, maxT) {
1105
1106 debugfilter("updating threshold for "+column+" with "+minT+" and "+maxT);
1107
1108 var cells = document.getElementsByName(column);
1109
1110 for(var j = 0; j < cells.length; j++) 
1111 {
1112 var val = parseFloat(cells[j].innerHTML);
1113
1114 if (val >= minT && val <= maxT)
1115         cells[j].style.color = filtered_color;
1116 else
1117         cells[j].style.color = normal_color;
1118 }
1119
1120 var old_configuration = document.getElementById('column_configuration').value;
1121 var slice_id = document.getElementById('slice_id').value;
1122
1123 var old_columns = old_configuration.split("|");
1124 var new_columns = new Array();
1125
1126 for (var column_index = 0; column_index < old_columns.length ; column_index++) {
1127         var conf = old_columns[column_index].split(':');
1128         if (conf[0] != column)
1129                 new_columns.push(old_columns[column_index]);
1130         else
1131                 new_columns.push(column+":"+minT+","+maxT);
1132 }
1133
1134 var new_configuration = new_columns.join("|");
1135
1136 updateColumnConfiguration(slice_id, new_configuration);
1137
1138 }
1139
1140 function updateExcludeList(column, excludeList) {
1141
1142 //debugfilter("updating list");
1143 debugfilter("updating list for "+column+" with "+excludeList);
1144
1145 var cells = document.getElementsByName(column);
1146
1147 for(var j = 1; j < cells.length; j++) 
1148 {
1149 var val = cells[j].innerHTML;
1150
1151 if (excludeList == val)
1152         cells[j].style.color = filtered_color;
1153 else
1154         cells[j].style.color = normal_color;
1155 }
1156
1157 var old_configuration = document.getElementById('column_configuration').value;
1158 var slice_id = document.getElementById('slice_id').value;
1159
1160 var old_columns = old_configuration.split("|");
1161 var new_columns = new Array();
1162
1163 for (var column_index = 0; column_index < old_columns.length ; column_index++) {
1164         var conf = old_columns[column_index].split(':');
1165         if (conf[0] != column)
1166                 new_columns.push(old_columns[column_index]);
1167         else
1168                 new_columns.push(column+":"+excludeList);
1169 }
1170
1171 var new_configuration = new_columns.join("|");
1172
1173 updateColumnConfiguration(slice_id, new_configuration);
1174
1175 }
1176
1177
1178
1179 /*
1180  
1181 ROW FILTERING
1182
1183
1184 function plekit_table_showAll (slicetable_id) {
1185
1186   var table=$(slicetable_id);
1187   var css='#'+slicetable_id+'>tbody';
1188   var rows = $$(css)[0].rows;
1189
1190   // scan rows, elaborate 'visible'
1191   for (var row_index = 0; row_index < rows.length ; row_index++) {
1192     var tr=rows[row_index];
1193     var visible=true;
1194     plekit_table_row_visible(tr,visible);
1195   }
1196
1197     plekit_table_count_filtered(slicetable_id);
1198
1199   tablePaginater.init(slicetable_id);
1200   
1201 }
1202
1203 function plekit_table_count_filtered (slicetable_id) {
1204   var table=$(slicetable_id);
1205   var css='#'+slicetable_id+'>tbody';
1206   var rows = $$(css)[0].rows;
1207
1208   var no_filtered=0;
1209
1210   // scan rows, elaborate 'visible'
1211   for (var row_index = 0; row_index < rows.length ; row_index++) {
1212     var tr=rows[row_index];
1213     var filtered = false;
1214
1215     for (var column_index=0; column_index < tr.cells.length; column_index++) 
1216                 if (tr.cells[column_index].style.color == "red")
1217                         filtered = true;
1218
1219         if (filtered)
1220         no_filtered++;
1221
1222   }
1223
1224   debugfilter(no_filtered+' nodes do not satisfy the requested threshold');
1225 }
1226
1227
1228 function plekit_table_hide_filtered (slicetable_id) {
1229   var table=$(slicetable_id);
1230   var css='#'+slicetable_id+'>tbody';
1231   var rows = $$(css)[0].rows;
1232
1233   var reg = /(^|\s)invisibleRow(\s|$)/;
1234
1235
1236   if (!document.getElementById('filtercheck').checked)
1237   {
1238         plekit_table_showAll(slicetable_id);
1239         return;
1240   }
1241
1242   var hidden=0;
1243
1244   // scan rows, elaborate 'visible'
1245   for (var row_index = 0; row_index < rows.length ; row_index++) {
1246     var tr=rows[row_index];
1247     var visible=true;
1248
1249     for (var column_index=0; column_index < tr.cells.length; column_index++) {
1250                 if (tr.cells[column_index].style.color == filtered_color)
1251                         visible = false;
1252     }
1253     if (!visible)
1254         hidden++;
1255
1256     plekit_table_row_visible(tr,visible);
1257   }
1258
1259   //debugfilter('hidden '+hidden+' nodes');
1260   debugfilter(hidden+' nodes do not satisfy the requested threshold (hidden)');
1261   
1262   tablePaginater.init(slicetable_id);
1263 }
1264
1265
1266
1267
1268 function plekit_table_apply_config(slicetable_id, configuration) {
1269
1270 var new_configuration = document.getElementById('new_conf').value;
1271 var all_columns = new_configuration.split("|");
1272
1273 var min_values = new Array();
1274 var max_values = new Array();
1275
1276
1277 for (var column_index = 0; column_index < all_columns.length ; column_index++) {
1278
1279         var conf = all_columns[column_index].split(':');
1280         
1281         if (inTypeB(conf[0]) != -1)
1282         {
1283                 var threshold = conf[1].split(',');
1284                 if (threshold.length == 2)
1285                 {
1286                 min_values.push(parseFloat(threshold[0]));
1287                 max_values.push(parseFloat(threshold[1]));
1288                 }
1289         }
1290         else if (inTypeC(conf[0]) == -1)
1291         {
1292                 var threshold = conf[2].split(',');
1293                 if (threshold.length == 2)
1294                 {
1295                 min_values.push(parseInt(threshold[0]));
1296                 max_values.push(parseInt(threshold[1]));
1297                 }
1298         }
1299         else
1300         {
1301                 min_values.push(-1);
1302                 max_values.push(-1);
1303         }
1304         
1305 }
1306
1307   var table=$(slicetable_id);
1308   var css='#'+slicetable_id+'>tbody';
1309   var rows = $$(css)[0].rows;
1310
1311
1312   var no_filtered=0;
1313
1314   for (var row_index = 0; row_index < rows.length ; row_index++) {
1315
1316         var tr=rows[row_index];
1317
1318         var filtered = false;
1319
1320         for (var column_index = 0; column_index < all_columns.length ; column_index++) 
1321         if (min_values[column_index]!=-1)
1322         {
1323                 var val = parseFloat(tr.cells[3+column_index].innerHTML);
1324                 
1325                 if (val >= min_values[column_index] && val <= max_values[column_index])
1326                 {
1327                         tr.cells[3+column_index].style.color = filtered_color;
1328                         filtered = true;
1329                 }
1330                 else
1331                         tr.cells[3+column_index].style.color = normal_color;
1332         }
1333         else
1334                 if (tr.cells[3+column_index].style.color == filtered_color)
1335                         filtered = true;
1336                 
1337
1338         if (filtered)
1339         no_filtered++;
1340   }
1341
1342   debugfilter(no_filtered+' nodes do not satisfy the requested threshold');
1343
1344   //tablePaginater.init(slicetable_id);
1345
1346 }
1347
1348
1349 function reset_select () {
1350   var table=$(slicetable_id);
1351   var css='#'+slicetable_id+'>tbody';
1352   var rows = $$(css)[0].rows;
1353
1354 var action = document.getElementById('onlyselected');
1355 action.checked=false;
1356
1357   // scan rows, elaborate 'visible'
1358   for (var row_index = 0; row_index < rows.length ; row_index++) {
1359     var tr=rows[row_index];
1360
1361     document.getElementById("check"+tr.id).checked=false;
1362
1363   }
1364
1365   plekit_table_count_nodes();
1366 }
1367
1368 }
1369
1370
1371 function plekit_table_select_filter () {
1372   var table=$(slicetable_id);
1373   var css='#'+slicetable_id+'>tbody';
1374   var rows = $$(css)[0].rows;
1375
1376   var reg = /(^|\s)invisibleRow(\s|$)/;
1377
1378   var action = document.getElementById('onlyselected');
1379   if (!action.checked)
1380         plekit_table_reset_filter();
1381
1382   // scan rows, elaborate 'visible'
1383   for (var row_index = 0; row_index < rows.length ; row_index++) {
1384     var tr=rows[row_index];
1385     var visible=true;
1386
1387     if (action.checked)
1388     {
1389          if(tr.className.search(reg) == -1) 
1390               if(!document.getElementById("check"+tr.id).checked)
1391                   visible=false;
1392     }
1393
1394     if(tr.className.search(reg) != -1) 
1395         visible=false;
1396
1397     plekit_table_row_visible(tr,visible);
1398   }
1399   
1400   tablePaginater.init(slicetable_id);
1401   plekit_table_count_nodes();
1402 }
1403
1404 function plekit_table_select_filter2 () {
1405   var table=$(slicetable_id);
1406   var css='#'+slicetable_id+'>tbody';
1407   var rows = $$(css)[0].rows;
1408
1409   var reg = /(^|\s)invisibleRow(\s|$)/;
1410
1411   var action = document.getElementById('onlyselected');
1412
1413   // scan rows, elaborate 'visible'
1414   for (var row_index = 0; row_index < rows.length ; row_index++) {
1415     var tr=rows[row_index];
1416     var visible=true;
1417
1418     if (action.checked)
1419     {
1420          if(tr.className.search(reg) == -1) 
1421               if(!document.getElementById("check"+tr.id).checked)
1422                   visible=false;
1423     }
1424
1425     if(tr.className.search(reg) != -1) 
1426         visible=false;
1427
1428     plekit_table_row_visible(tr,visible);
1429   }
1430   
1431   tablePaginater.init(slicetable_id);
1432   plekit_table_count_nodes();
1433 }
1434
1435 function CheckTopNodes(n) {
1436   var table=$(slicetable_id);
1437   var css='#'+slicetable_id+'>tbody';
1438   var rows = $$(css)[0].rows;
1439   var reg = /(^|\s)invisibleRow(\s|$)/;
1440
1441   var checked=0;
1442
1443   for (var row_index = 0; row_index < rows.length ; row_index++) {
1444     var tr=rows[row_index];
1445
1446     if(tr.className.search(reg) == -1) {
1447         if (checked<n)
1448         {
1449                 document.getElementById("check"+tr.id).checked=true;
1450                 checked++;
1451         }
1452         else
1453         {
1454                 document.getElementById("check"+tr.id).checked=false;
1455         };
1456     };
1457    };
1458 };
1459
1460
1461 function CheckRandomNodes(n) {
1462   var table=$(slicetable_id);
1463   var css='#'+slicetable_id+'>tbody';
1464   var rows = $$(css)[0].rows;
1465   var reg = /(^|\s)invisibleRow(\s|$)/;
1466
1467   var r = n/plekit_table_visible_count();
1468   var checked=0;
1469
1470   for (var row_index = 0; row_index < rows.length ; row_index++) {
1471     var tr=rows[row_index];
1472
1473     if(tr.className.search(reg) == -1) {
1474         if(Math.random() < r) {
1475                 document.getElementById("check"+tr.id).checked=true;
1476                 checked++;
1477         };
1478         if (checked>=n)
1479                 break;
1480      };
1481   };
1482 };
1483
1484
1485 function plekit_table_visible_count() {
1486   var table=$(slicetable_id);
1487   var css='#'+slicetable_id+'>tbody';
1488   var rows = $$(css)[0].rows;
1489   var reg = /(^|\s)invisibleRow(\s|$)/;
1490   var v=0;
1491
1492   for (var row_index = 0; row_index < rows.length ; row_index++) {
1493     var tr=rows[row_index];
1494
1495         if(tr.className.search(reg) == -1) 
1496         {
1497                 v++;
1498         }
1499   }
1500
1501   return v;
1502 }
1503
1504
1505 function plekit_table_count_nodes() {
1506   var table=$(slicetable_id);
1507   var css='#'+slicetable_id+'>tbody';
1508   var rows = $$(css)[0].rows;
1509   var reg = /(^|\s)invisibleRow(\s|$)/;
1510   var n=0;
1511   var v=0;
1512   var s=0;
1513
1514   for (var row_index = 0; row_index < rows.length ; row_index++) {
1515     var tr=rows[row_index];
1516
1517         n++;
1518         var ch = document.getElementById("check"+tr.id);
1519
1520         if(tr.className.search(reg) == -1) 
1521                 v++;
1522         else
1523         {
1524                 if (ch.checked)
1525                         ch.checked=false;
1526         };
1527
1528         if (ch.checked)
1529                 s++;
1530         
1531    };
1532
1533    var dd = document.getElementById('node_statistics');
1534    dd.innerHTML = "Total: "+n+" - Shown: "+v+" - Selected: "+s;
1535 };
1536
1537 function AutoSelect()
1538 {
1539   var a = document.getElementById('automatic').value;
1540   var n = parseInt(document.getElementById('no_nodes').value);
1541
1542   if (isNaN(n))
1543         return;
1544
1545   if (a == "random")
1546          CheckRandomNodes(n);
1547   else if (a == "top")
1548          CheckTopNodes(n);
1549
1550   plekit_table_select_filter2();
1551   plekit_table_count_nodes();
1552 }
1553
1554 */