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 bweb_root = "/bweb/";
23 var up_icon = "/bweb/up.gif";
24 var down_icon = "/bweb/down.gif";
25 var prev_icon = "/bweb/left.gif";
26 var next_icon = "/bweb/right.gif";
27 var rew_icon = "/bweb/first.gif";
28 var fwd_icon = "/bweb/last.gif";
31 'C': 'created but not yet running',
34 'T': 'terminated normally',
35 'E': 'Job terminated in error',
36 'e': 'Non-fatal error',
38 'D': 'Verify differences',
39 'A': 'canceled by user',
40 'F': 'waiting on File daemon',
41 'S': 'waiting on the Storage daemon',
42 'm': 'waiting for new media',
43 'M': 'waiting for Mount',
44 's': 'Waiting for storage resource',
45 'j': 'Waiting for job resource',
46 'c': 'Waiting for Client resource',
47 'd': 'Waiting for maximum jobs',
48 't': 'Waiting for start time',
49 'p': 'Waiting for higher priority jobs to finish'
54 'I': 'Incr (since last backup)',
55 'D': 'Diff (since last full backup)',
56 'C': 'verify from catalog',
57 'V': 'verify save (init DB)',
58 'O': 'verify Volume to catalog entries',
59 'd': 'verify Disk attributes to catalog',
60 'A': 'verify data on volume',
65 var refresh_time = 60000;
67 function bweb_refresh() {
70 function bweb_add_refresh(){
71 window.setInterval("bweb_refresh()",refresh_time);
74 function human_size(val)
79 var unit = ['b', 'Kb', 'Mb', 'Gb', 'Tb'];
82 while (val /1024 > 1) {
87 var format = (i>0)?1:0;
88 return val.toFixed(format) + ' ' + unit[i];
91 function human_sec(val)
96 val /= 60; // sec -> min
98 if ((val / 60) <= 1) {
99 return val.toFixed(0) + ' mins';
102 val /= 60; // min -> hour
104 if ((val / 24) <= 1) {
105 return val.toFixed(0) + ' hours';
108 val /= 24; // hour -> day
110 if ((val / 365) < 2) {
111 return val.toFixed(0) + ' days';
116 return val.toFixed(0) + ' years';
121 // percent_display("row2", [ { nb: 1, name: "Full" },
122 // { nb: 2, name: "Error" },
123 // { nb: 5, name: "Append" },
124 // { nb: 2, name: "Purged" },
125 // {} # last element must be {}
128 function percent_get_img(type)
130 var img=document.createElement('img');
132 img.className="pSlice" + type ;
134 img.className="pSlice";
136 img.src="/bweb/pix.png";
141 var percent_display_nb_slice = 20;
142 var percent_usage_nb_slice = 5;
144 function percent_display(hash_values, parent)
146 var nb_elt=percent_display_nb_slice;
150 parent = document.createElement('DIV');
153 if (typeof parent != "object") {
154 parent = document.getElementById(parent);
158 alert("E : display_percent(): Can't find parent " + parent);
162 hash_values.pop(); // drop last element {}
164 var nb_displayed = 0;
167 for(var i=0;i<hash_values.length;i++) {
168 nb_max += hash_values[i]['nb'];
171 for(var i=0;i<hash_values.length;i++) {
172 var elt = hash_values[i];
173 var cur_nb = (elt['nb'] * nb_elt)/nb_max;
174 var cur_name = elt['name'];
175 cur_name.replace(/-/,"_");
177 tips = tips + " " + elt['nb'] + " " + cur_name;
179 while ((nb_displayed < nb_elt) && (cur_nb >=1)) {
183 var img= percent_get_img(cur_name);
184 parent.appendChild(img);
188 while (nb_displayed < nb_elt) {
190 var img= percent_get_img();
191 parent.appendChild(img);
199 function percent_usage(value, parent)
201 var nb_elt=percent_usage_nb_slice;
205 parent = document.createElement('DIV');
208 if (typeof parent != "object") {
209 parent = document.getElementById(parent);
213 alert("E : display_percent(): Can't find parent " + parent);
217 if (value <= 0.001) {
220 } else if (value <= 40) {
222 } else if (value <= 75) {
224 } else if (value <= 85) {
230 var nb = parseInt(value*nb_elt/100, 10);
231 parent.title = parseInt(value*100,10)/100 + "% used (approximate)";
233 for(var i=0; i<nb; i++) {
234 var img= percent_get_img(type);
235 parent.appendChild(img);
238 for(nb;nb < nb_elt;nb++) {
239 var img= percent_get_img("Empty");
240 parent.appendChild(img);
246 function bweb_get_job_img(status, errors)
259 ret = status + ".png";
262 return bweb_root + ret;
265 function search_media()
267 var what = document.getElementById('searchbox').value;
269 document.search.action.value='media';
270 document.search.re_media.value=what;
271 document.search.submit();
275 function search_client()
277 var what = document.getElementById('searchbox').value;
279 document.search.action.value='client';
280 document.search.re_client.value=what;
281 document.search.submit();
285 sfHover = function() {
286 var sfEls = document.getElementById("menu").getElementsByTagName("LI");
287 for (var i=0; i<sfEls.length; i++) {
288 sfEls[i].onmouseover=function() {
289 this.className+=" sfhover";
291 sfEls[i].onmouseout=function() {
292 this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
297 if (window.attachEvent) window.attachEvent("onload", sfHover);