1 // Copyright (C) 2006 Eric Bollengier
2 // All rights reserved.
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 var even_cell_color = "#FFFFFF";
19 var odd_cell_color = "#EEEEEE";
20 var header_color = "#E1E0DA";
21 var rows_per_page = 20;
22 var up_icon = "/bweb/up.gif";
23 var down_icon = "/bweb/down.gif";
24 var prev_icon = "/bweb/left.gif";
25 var next_icon = "/bweb/right.gif";
26 var rew_icon = "/bweb/first.gif";
27 var fwd_icon = "/bweb/last.gif";
30 'C': 'created but not yet running',
33 'T': 'terminated normally',
34 'E': 'Job terminated in error',
35 'e': 'Non-fatal error',
37 'D': 'Verify differences',
38 'A': 'canceled by user',
39 'F': 'waiting on File daemon',
40 'S': 'waiting on the Storage daemon',
41 'm': 'waiting for new media',
42 'M': 'waiting for Mount',
43 's': 'Waiting for storage resource',
44 'j': 'Waiting for job resource',
45 'c': 'Waiting for Client resource',
46 'd': 'Waiting for maximum jobs',
47 't': 'Waiting for start time',
48 'p': 'Waiting for higher priority jobs to finish'
53 'I': 'Incr (since last backup)',
54 'D': 'Diff (since last full backup)',
55 'C': 'verify from catalog',
56 'V': 'verify save (init DB)',
57 'O': 'verify Volume to catalog entries',
58 'd': 'verify Disk attributes to catalog',
59 'A': 'verify data on volume',
64 var refresh_time = 60000;
66 function bweb_refresh() {
69 function bweb_add_refresh(){
70 window.setInterval("bweb_refresh()",refresh_time);
73 function human_size(val)
78 var unit = ['b', 'Kb', 'Mb', 'Gb', 'Tb'];
81 while (val /1024 > 1) {
86 var format = (i>0)?1:0;
87 return val.toFixed(format) + ' ' + unit[i];
90 function human_sec(val)
95 val /= 60; // sec -> min
97 if ((val / 60) <= 1) {
98 return val.toFixed(0) + ' mins';
101 val /= 60; // min -> hour
103 if ((val / 24) <= 1) {
104 return val.toFixed(0) + ' hours';
107 val /= 24; // hour -> day
109 if ((val / 365) < 2) {
110 return val.toFixed(0) + ' days';
115 return val.toFixed(0) + ' years';
120 // percent_display("row2", [ { nb: 1, name: "Full" },
121 // { nb: 2, name: "Error" },
122 // { nb: 5, name: "Append" },
123 // { nb: 2, name: "Purged" },
124 // {} # last element must be {}
127 function percent_get_img(type)
129 var img=document.createElement('img');
131 img.className="pSlice" + type ;
133 img.className="pSlice";
135 img.src="/bweb/pix.png";
140 var percent_display_nb_slice = 20;
141 var percent_usage_nb_slice = 5;
143 function percent_display(hash_values, parent)
145 var nb_elt=percent_display_nb_slice;
149 parent = document.createElement('DIV');
152 if (typeof parent != "object") {
153 parent = document.getElementById(parent);
157 alert("E : display_percent(): Can't find parent " + parent);
161 hash_values.pop(); // drop last element {}
163 var nb_displayed = 0;
166 for(var i=0;i<hash_values.length;i++) {
167 nb_max += hash_values[i]['nb'];
170 for(var i=0;i<hash_values.length;i++) {
171 var elt = hash_values[i];
172 var cur_nb = (elt['nb'] * nb_elt)/nb_max;
173 var cur_name = elt['name'];
174 cur_name.replace(/-/,"_");
176 tips = tips + " " + elt['nb'] + " " + cur_name;
178 while ((nb_displayed < nb_elt) && (cur_nb >=1)) {
182 var img= percent_get_img(cur_name);
183 parent.appendChild(img);
187 while (nb_displayed < nb_elt) {
189 var img= percent_get_img();
190 parent.appendChild(img);
198 function percent_usage(value, parent)
200 var nb_elt=percent_usage_nb_slice;
204 parent = document.createElement('DIV');
207 if (typeof parent != "object") {
208 parent = document.getElementById(parent);
212 alert("E : display_percent(): Can't find parent " + parent);
219 } else if (value <= 40) {
221 } else if (value <= 75) {
223 } else if (value <= 85) {
229 var nb = parseInt(value*nb_elt/100, 10);
230 parent.title = parseInt(value*100,10)/100 + "% used (approximate)";
232 for(var i=0; i<nb; i++) {
233 var img= percent_get_img(type);
234 parent.appendChild(img);
237 for(nb;nb < nb_elt;nb++) {
238 var img= percent_get_img("Empty");
239 parent.appendChild(img);
245 function search_media()
247 var what = document.getElementById('searchbox').value;
249 document.search.action.value='media';
250 document.search.re_media.value=what;
251 document.search.submit();
255 function search_client()
257 var what = document.getElementById('searchbox').value;
259 document.search.action.value='client';
260 document.search.re_client.value=what;
261 document.search.submit();
265 sfHover = function() {
266 var sfEls = document.getElementById("menu").getElementsByTagName("LI");
267 for (var i=0; i<sfEls.length; i++) {
268 sfEls[i].onmouseover=function() {
269 this.className+=" sfhover";
271 sfEls[i].onmouseout=function() {
272 this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
277 if (window.attachEvent) window.attachEvent("onload", sfHover);