/[BackupPC]/trunk/lib/BackupPC/SearchLib.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/BackupPC/SearchLib.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 137 by iklaric, Thu Sep 29 08:46:13 2005 UTC revision 143 by iklaric, Fri Oct 7 09:36:10 2005 UTC
# Line 293  sub getGzipName($$$) Line 293  sub getGzipName($$$)
293                    
294  }  }
295    
296    sub getGzipSize($$)
297    {
298            my ($hostID, $backupNum) = @_;
299            my $ret;
300            my $sql;
301            my $dbh = get_dbh();
302            
303            $sql = q{
304                                    SELECT hosts.name  as host,
305                                               shares.name as share,
306                                               backups.num as backupnum
307                                    FROM hosts, backups, shares
308                                    WHERE shares.id=backups.shareid AND
309                                              hosts.id =backups.hostid AND
310                                              hosts.id=? AND
311                                              backups.num=?;
312                            };
313            my $sth = $dbh->prepare($sql);
314            $sth->execute($hostID, $backupNUM);
315            my $row = $res->fetchrow_hashref();
316            
317            my (undef,undef,undef,undef,undef,undef,undef,$ret,undef,undef,undef,undef,undef) =
318                            stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.
319                                    getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'}));
320            
321            return $ret;    
322    }
323    
324  sub getBackupsNotBurned() {  sub getBackupsNotBurned() {
325    
326          my $dbh = get_dbh();          my $dbh = get_dbh();
# Line 343  sub getBackupsNotBurned() { Line 371  sub getBackupsNotBurned() {
371  sub displayBackupsGrid() {  sub displayBackupsGrid() {
372    
373          my $retHTML .= q{          my $retHTML .= q{
374                  <form id="forma" method="POST" action=};                  <form id="forma" method="POST" action="}.$MyURL.q{?action=burn">
                 $retHTML .= "\"".$MyURL."\"";  
                 $retHTML .= q{?action=burn>  
375          };          };
376    
377          $retHTML .= <<'EOF3';          $retHTML .= <<'EOF3';
378  <style>  <style type="text/css">
379  <!--  <!--
380    DIV#fixedBox {
 div#fixedBox {  
381          position: absolute;          position: absolute;
382          bottom: 1em;          top: 50em;
383          left: 0.5em;          left: -24%;
384          padding: 0.5em;          padding: 0.5em;
385          width: 10em;          width: 20%;
386          background: #e0f0e0;          background-color: #E0F0E0;
387          border: 1px solid #00ff00;          border: 1px solid #00C000;
 }  
 @media screen {  
         div#fixedBox {  
                 position: fixed;  
         }  
         /* Don't do this at home */  
         * html {  
                 overflow-y: hidden;  
         }  
         * html body {  
                 overflow-y: auto;  
                 height: 100%;  
                 padding: 0 1em 0 12em;  
                 font-size: 100%;  
         }  
         * html div#fixedBox {  
                 position: absolute;      
         }  
         /* All done. */  
388  }  }
389    
390  #mContainer {  DIV#fixedBox, DIV#fixedBox INPUT, DIV#fixedBox TEXTAREA {
391          position: relative;          font-size: 10pt;
         width: 100%;  
         height: 1.1em;  
         padding: 0px;  
         border: 1px solid #000000;  
392  }  }
393    
394  #gradient {  FORM>DIV#fixedBox {
395          position: absolute;          position: fixed !important;
396          top: 0px;          left: 0.5em !important;
397          left: 0px;          top: auto !important;
398          width: 100%;          bottom: 1em !important;
399          height: 100%;          width: 15% !important;
400    }
401    
402    DIV#fixedBox INPUT[type=text], DIV#fixedBox TEXTAREA {
403            border: 1px solid #00C000;
404    }
405    
406    DIV#fixedBox #note {
407          display: block;          display: block;
408          background-color: #ffff00;          width: 100%;
409  }  }
410    
411  #mask {  DIV#fixedBox #submitBurner {
412          position: absolute;          display: block;
         top: 0px;  
         left: 0px;  
413          width: 100%;          width: 100%;
414            margin-top: 0.5em;
415            cursor: pointer;
416    }
417    
418    * HTML {
419            overflow-y: hidden;
420    }
421    
422    * HTML BODY {
423            overflow-y: auto;
424          height: 100%;          height: 100%;
425          display: block;          font-size: 100%;
         font-size: 1px;  
         background-color: #FFFFFF;  
         overflow: hidden;  
426  }  }
427    
428  #progressIndicator {  * HTML DIV#fixedBox {
429          position: absolute;          position: absolute;
430          top: 0px;  }
431          left: 0px;  
432          width: 100%;  #mContainer, #gradient, #mask, #progressIndicator {
         height: 100%;  
433          display: block;          display: block;
434          font-weight: bold;          width: 100%;
         color: #404040;  
435          font-size: 10pt;          font-size: 10pt;
436            font-weight: bold;
437          text-align: center;          text-align: center;
438            vertical-align: middle;
439            padding: 1px;
440  }  }
441    
442    #gradient, #mask, #progressIndicator {
443            left: 0;
444            border-width: 1px;
445            border-style: solid;
446            border-color: #000000;
447            color: #404040;
448            margin: 0.4em;
449            position: absolute;
450            margin-left: -1px;
451            margin-top: -1px;
452            margin-bottom: -1px;
453            overflow: hidden;
454    }
455    
456    #mContainer {
457            display: block;
458            position: relative;
459            padding: 0px;
460            margin-top: 0.4em;
461            margin-bottom: 0.5em;
462    }
463    
464    #gradient {
465            z-index: 1;
466            background-color: #FFFF00;
467    }
468    
469    #mask {
470            z-index: 2;
471            background-color: #FFFFFF;
472    }
473    
474    #progressIndicator {
475            z-index: 3;
476            background-color: transparent;
477    }
478  -->  -->
479  </style>  </style>
480  <script language="javascript" type="text/javascript">  <script type="text/javascript">
481  <!--  <!--
482    
483  var debug_div = null;  var debug_div = null;
# Line 460  function element_id(name,element) { Line 511  function element_id(name,element) {
511  }  }
512    
513  function checkAll(location) {  function checkAll(location) {
514          var len = element_id('forma').elements.length;          var f = element_id('forma') || null;
515            if (!f) return false;
516    
517            var len = f.elements.length;
518          var check_all = element_id('allFiles');          var check_all = element_id('allFiles');
519          var suma = 0;          var suma = check_all.checked ? (parseInt(f.elements['totalsize'].value) || 0) : 0;
520    
521          for (var i = 0; i < len; i++) {          for (var i = 0; i < len; i++) {
522                    var e = f.elements[i];
523                  var e = element_id('forma').elements[i];                  if (e.name != 'all' && e.name.substr(0, 3) == 'fcb') {
                 if (e.name != 'all' && e.name.substr(0,3) == 'fcb') {  
524                          if (check_all.checked) {                          if (check_all.checked) {
525                                    if (e.checked) continue;
526                                  var el = element_id("fss" + e.name.substr(3));                                  var el = element_id("fss" + e.name.substr(3));
527                                  var size = parseInt(el.value) || 0;                                  var size = parseInt(el.value) || 0;
528                                  debug('suma: '+suma+' size: '+size);                                  debug('suma: '+suma+' size: '+size);
# Line 487  function checkAll(location) { Line 541  function checkAll(location) {
541  }  }
542    
543  function update_sum(suma) {  function update_sum(suma) {
544          element_id('forma').totalsize.value = suma;          element_id('forma').elements['totalsize'].value = suma;
545          pbar_set(suma, media_size);          pbar_set(suma, media_size);
546          debug('total size: '+suma);          debug('total size: ' + suma);
547  }  }
548    
549  function sumiraj(e) {  function sumiraj(e) {
550          var suma = parseInt(element_id('forma').totalsize.value) || 0;          var suma = parseInt(element_id('forma').elements['totalsize'].value) || 0;
551          var len = element_id('forma').elements.length;          var len = element_id('forma').elements.length;
552          if (e) {          if (e) {
553                  var size = parseInt( element_id("fss" + e.name.substr(3)).value );                  var size = parseInt( element_id("fss" + e.name.substr(3)).value);
554                  if (e.checked) {                  if (e.checked) {
555                          suma += size;                          suma += size;
556                  } else {                  } else {
# Line 518  function sumiraj(e) { Line 572  function sumiraj(e) {
572    
573  /* progress bar */  /* progress bar */
574    
575  var _pbar_width = 0;  var _pbar_width = null;
576  var _pbar_warn = 10;    // change color in last 10%  var _pbar_warn = 10;    // change color in last 10%
577    
578  function pbar_reset() {  function pbar_reset() {
579          element_id("mask").style.left = "0px";          element_id("mask").style.left = "0px";
580          _pbar_width = element_id("mContainer").offsetWidth - 2;          _pbar_width = element_id("mContainer").offsetWidth - 2;
581          element_id("mask").style.width = _pbar_width + "px";          element_id("mask").style.width = _pbar_width + "px";
         element_id("progressIndicator").style.zIndex  = 10;  
582          element_id("mask").style.display = "block";          element_id("mask").style.display = "block";
583            element_id("progressIndicator").style.zIndex  = 10;
584          element_id("progressIndicator").innerHTML = "0";          element_id("progressIndicator").innerHTML = "0";
585  }  }
586    
587  function dec2hex(d) {  function dec2hex(d) {
588          var hch="0123456789ABCDEF";          var hch = '0123456789ABCDEF';
589          var a=d%16;          var a = d % 16;
590          var q=(d-a)/16;          var q = (d - a) / 16;
591          return hch.charAt(q)+hch.charAt(a);          return hch.charAt(q) + hch.charAt(a);
592  }  }
593    
   
594  function pbar_set(amount, max) {  function pbar_set(amount, max) {
595            debug('pbar_set('+amount+', '+max+')');
596    
597          debug('pbar_set( '+amount+' , '+max+' )');          if (_pbar_width == null) {
598                    var _mc = element_id("mContainer");
599          curWidth = parseInt(element_id("mask").offsetWidth);                  if (_pbar_width == null) _pbar_width = parseInt(_mc.offsetWidth ? (_mc.offsetWidth - 2) : 0) || null;
600          curLeft = parseInt(element_id("mask").offsetLeft);                  if (_pbar_width == null) _pbar_width = parseInt(_mc.clientWidth ? (_mc.clientWidth + 2) : 0) || null;
601                    if (_pbar_width == null) _pbar_width = 0;
602            }
603    
604          var pcnt = Math.floor( amount * 100 / max );          var pcnt = Math.floor(amount * 100 / max);
605          var p90 = 100 - _pbar_warn;          var p90 = 100 - _pbar_warn;
606          var pcol = pcnt - p90;          var pcol = pcnt - p90;
607          if (pcol < _pbar_warn) {          if (Math.round(pcnt) <= 100) {
608                  if (pcol < 0) pcol = 0;                  if (pcol < 0) pcol = 0;
609                  var e = element_id("submitBurner");                  var e = element_id("submitBurner");
610                  if (e && e.disabled) {                  debug('enable_button');
611                          debug('enable_button');                  e.disabled = false;
612                          var a = e.getAttributeNode('disabled') || null;                  var a = e.getAttributeNode('disabled') || null;
613                          if (a) e.removeAttributeNode(a);                  if (a) e.removeAttributeNode(a);
614                  }          } else {
         } else if (pcol > _pbar_warn) {  
615                  debug('disable button');                  debug('disable button');
616                  pcol = _pbar_warn;                  pcol = _pbar_warn;
617                  var e = element_id("submitBurner");                  var e = element_id("submitBurner");
618                  if (! e.disabled) e.disabled = true;                  if (!e.disabled) e.disabled = true;
619          }          }
620          var col_g = Math.floor( ( _pbar_warn - pcol ) * 255 / _pbar_warn );          var col_g = Math.floor((_pbar_warn - pcol) * 255 / _pbar_warn);
621          var col = '#ff' + dec2hex( col_g ) + '00';          var col = '#FF' + dec2hex(col_g) + '00';
622    
623          //debug('pcol: '+pcol+' g:'+col_g+' _pbar_warn:'+ _pbar_warn + ' color: '+col);          //debug('pcol: '+pcol+' g:'+col_g+' _pbar_warn:'+ _pbar_warn + ' color: '+col);
624          element_id("gradient").style.backgroundColor = col;          element_id("gradient").style.backgroundColor = col;
625    
         var size = parseInt( _pbar_width * amount / max );  
   
         curWidth = _pbar_width - size;  
         curLeft = size ;  
   
         //debug('size: '+size+' curWidth '+curWidth+' curLeft: '+curLeft);  
   
626          element_id("progressIndicator").innerHTML = pcnt + '%';          element_id("progressIndicator").innerHTML = pcnt + '%';
627          //element_id("progressIndicator").innerHTML = amount;          //element_id("progressIndicator").innerHTML = amount;
628    
629          if (curLeft > _pbar_width) {          element_id("mask").style.clip = 'rect(' + Array(
630                  element_id("mask").style.display = "none";                  '0px',
631                  return;                  element_id("mask").offsetWidth + 'px',
632          } else {                  element_id("mask").offsetHeight + 'px',
633                  element_id("mask").style.display = "";                  Math.round(_pbar_width * amount / max) + 'px'
634          }          ).join(' ') + ')';
   
         //if(parseInt(element_id("mask").offsetWidth)>10)  
         element_id("mask").style.width = curWidth + "px";  
         element_id("mask").style.left = curLeft + "px";  
   
635  }  }
636    
637  if (!self.body) self.body = new Object();  if (!self.body) self.body = new Object();
638  self.onload = self.document.onload = self.body.onload = function() {  self.onload = self.document.onload = self.body.onload = function() {
639          pbar_reset();          //pbar_reset();
640          sumiraj();          sumiraj();
641  }  };
642    
643  //-->  // -->
644  </script>  </script>
645  <div id="fixedBox">  <div id="fixedBox">
646    
647  Size:  Size: <input type="text" name="totalsize" size="7" readonly="readonly" style="text-align:right;" value="0" /> kB
 <input type="text" name="totalsize" size="7" readonly>  
648    
649  <div id="mContainer">  <div id="mContainer">
650          <div id="gradient"></div>          <div id="gradient">&nbsp;</div>
651          <div id="mask"></div>          <div id="mask">&nbsp;</div>
652          <div id="progressIndicator">&nbsp;</div>          <div id="progressIndicator">0%</div>
653  </div>  </div>
   
654  <br/>  <br/>
655    
656  Note:  Note:
657  <br/>  <textarea name="note" cols="10" rows="5" id="note"></textarea>
658  <textarea name="note" cols="10" rows="5">  
659  </textarea>  <input type="submit" id="submitBurner" value="Burn selected" name="submitBurner" />
 <br/>  
 <input type="submit" id="submitBurner" value="Burn selected" name="submitBurner">  
660    
661  </div>  </div>
662    <!--
663  <div id="debug" style="float: right; width: 10em; border: 1px #ff0000 solid; background-color: #ffe0e0; -moz-opacity: 0.7;">  <div id="debug" style="float: right; width: 10em; border: 1px #ff0000 solid; background-color: #ffe0e0; -moz-opacity: 0.7;">
664  no debug output yet  no debug output yet
665  </div>  </div>
666    -->
667  EOF3  EOF3
668          $retHTML .= q{          $retHTML .= q{
669                          <input type="hidden" value="burn" name="action">                          <input type="hidden" value="burn" name="action">

Legend:
Removed from v.137  
changed lines
  Added in v.143

  ViewVC Help
Powered by ViewVC 1.1.26