/[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 128 by dpavlin, Thu Sep 22 13:31:04 2005 UTC revision 142 by ravilov, Fri Oct 7 08:58:45 2005 UTC
# Line 309  sub getBackupsNotBurned() { Line 309  sub getBackupsNotBurned() {
309                  FROM backups                  FROM backups
310                  INNER JOIN shares       ON backups.shareID=shares.ID                  INNER JOIN shares       ON backups.shareID=shares.ID
311                  INNER JOIN hosts        ON backups.hostID = hosts.ID                  INNER JOIN hosts        ON backups.hostID = hosts.ID
312                  LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id AND archive_backup.backup_id IS NULL                  LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id
313                  WHERE backups.size > 0                  WHERE backups.size > 0 AND archive_backup.backup_id IS NULL
314                  GROUP BY                  GROUP BY
315                          backups.hostID,                          backups.hostID,
316                          hosts.name,                          hosts.name,
# Line 343  sub getBackupsNotBurned() { Line 343  sub getBackupsNotBurned() {
343  sub displayBackupsGrid() {  sub displayBackupsGrid() {
344    
345          my $retHTML .= q{          my $retHTML .= q{
346                  <form id="forma" method="POST" action=};                  <form id="forma" method="POST" action="}.$MyURL.q{?action=burn">
                 $retHTML .= "\"".$MyURL."\"";  
                 $retHTML .= q{?action=burn>  
347          };          };
348    
349          $retHTML .= <<'EOF3';          $retHTML .= <<'EOF3';
350  <style>  <style type="text/css">
351  <!--  <!--
352    DIV#fixedBox {
 div#fixedBox {  
353          position: absolute;          position: absolute;
354          bottom: 1em;          top: 50em;
355          left: 0.5em;          left: -24%;
356          padding: 0.5em;          padding: 0.5em;
357          width: 10em;          width: 20%;
358          background: #e0f0e0;          background-color: #E0F0E0;
359          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. */  
360  }  }
361    
362  #mContainer {  DIV#fixedBox, DIV#fixedBox INPUT, DIV#fixedBox TEXTAREA {
363          position: relative;          font-size: 10pt;
         width: 100%;  
         height: 1.1em;  
         padding: 0px;  
         border: 1px solid #000000;  
364  }  }
365    
366  #gradient {  FORM>DIV#fixedBox {
367          position: absolute;          position: fixed !important;
368          top: 0px;          left: 0.5em !important;
369          left: 0px;          top: auto !important;
370          width: 100%;          bottom: 1em !important;
371          height: 100%;          width: 15% !important;
372    }
373    
374    DIV#fixedBox INPUT[type=text], DIV#fixedBox TEXTAREA {
375            border: 1px solid #00C000;
376    }
377    
378    DIV#fixedBox #note {
379          display: block;          display: block;
380          background-color: #ffff00;          width: 100%;
381  }  }
382    
383  #mask {  DIV#fixedBox #submitBurner {
384          position: absolute;          display: block;
         top: 0px;  
         left: 0px;  
385          width: 100%;          width: 100%;
386            margin-top: 0.5em;
387            cursor: pointer;
388    }
389    
390    * HTML {
391            overflow-y: hidden;
392    }
393    
394    * HTML BODY {
395            overflow-y: auto;
396          height: 100%;          height: 100%;
397          display: block;          font-size: 100%;
         font-size: 1px;  
         background-color: #FFFFFF;  
         overflow: hidden;  
398  }  }
399    
400  #progressIndicator {  * HTML DIV#fixedBox {
401          position: absolute;          position: absolute;
402          top: 0px;  }
403          left: 0px;  
404          width: 100%;  #mContainer, #gradient, #mask, #progressIndicator {
         height: 100%;  
405          display: block;          display: block;
406          font-weight: bold;          width: 100%;
         color: #404040;  
407          font-size: 10pt;          font-size: 10pt;
408            font-weight: bold;
409          text-align: center;          text-align: center;
410            vertical-align: middle;
411            padding: 1px;
412    }
413    
414    #gradient, #mask, #progressIndicator {
415            left: 0;
416            border-width: 1px;
417            border-style: solid;
418            border-color: #000000;
419            color: #404040;
420            margin: 0.4em;
421            position: absolute;
422            margin-left: -1px;
423            margin-top: -1px;
424            margin-bottom: -1px;
425            overflow: hidden;
426    }
427    
428    #mContainer {
429            display: block;
430            position: relative;
431            padding: 0px;
432            margin-top: 0.4em;
433            margin-bottom: 0.5em;
434    }
435    
436    #gradient {
437            z-index: 1;
438            background-color: #FFFF00;
439    }
440    
441    #mask {
442            z-index: 2;
443            background-color: #FFFFFF;
444  }  }
445    
446    #progressIndicator {
447            z-index: 3;
448            background-color: transparent;
449    }
450  -->  -->
451  </style>  </style>
452  <script language="javascript" type="text/javascript">  <script type="text/javascript">
453  <!--  <!--
454    
455  var debug_div = null;  var debug_div = null;
# Line 460  function element_id(name,element) { Line 483  function element_id(name,element) {
483  }  }
484    
485  function checkAll(location) {  function checkAll(location) {
486          var len = element_id('forma').elements.length;          var f = element_id('forma') || null;
487            if (!f) return false;
488    
489            var len = f.elements.length;
490          var check_all = element_id('allFiles');          var check_all = element_id('allFiles');
491            var suma = check_all.checked ? (parseInt(f.elements['totalsize'].value) || 0) : 0;
492    
493          for (var i = 0; i < len; i++) {          for (var i = 0; i < len; i++) {
494                    var e = f.elements[i];
495                  var e = element_id('forma').elements[i];                  if (e.name != 'all' && e.name.substr(0, 3) == 'fcb') {
                 if ((e.checked || !e.checked) && e.name != 'all') {  
496                          if (check_all.checked) {                          if (check_all.checked) {
497                                  e.checked = true;                                  if (e.checked) continue;
498                                    var el = element_id("fss" + e.name.substr(3));
499                                    var size = parseInt(el.value) || 0;
500                                    debug('suma: '+suma+' size: '+size);
501                                    if ((suma + size) < media_size) {
502                                            suma += size;
503                                            e.checked = true;
504                                    } else {
505                                            break;
506                                    }
507                          } else {                          } else {
508                                  e.checked = false;                                  e.checked = false;
509                          }                          }
510                  }                  }
511          }          }
512            update_sum(suma);
513    }
514    
515          sumiraj();  function update_sum(suma) {
516            element_id('forma').elements['totalsize'].value = suma;
517            pbar_set(suma, media_size);
518            debug('total size: ' + suma);
519  }  }
520        
521  function sumiraj(e) {  function sumiraj(e) {
522          var suma = parseInt(element_id('forma').totalsize.value) || 0;          var suma = parseInt(element_id('forma').elements['totalsize'].value) || 0;
523          var len = element_id('forma').elements.length;          var len = element_id('forma').elements.length;
524          if (e) {          if (e) {
525                  var size = parseInt( element_id("fss" + e.name.substr(3)).value );                  var size = parseInt( element_id("fss" + e.name.substr(3)).value);
526                  if (e.checked) {                  if (e.checked) {
527                          suma += size;                          suma += size;
528                  } else {                  } else {
# Line 498  function sumiraj(e) { Line 538  function sumiraj(e) {
538                          }                          }
539                  }                  }
540          }          }
541          element_id('forma').totalsize.value = suma;          update_sum(suma);
         pbar_set(suma, media_size);  
         debug('total size: '+suma);  
542          return suma;          return suma;
543  }  }
544    
545  /* progress bar */  /* progress bar */
546    
547  var _pbar_width = 0;  var _pbar_width = null;
548  var _pbar_warn = 10;    // change color in last 10%  var _pbar_warn = 10;    // change color in last 10%
549    
550  function pbar_reset() {  function pbar_reset() {
551          element_id("mask").style.left = "0px";          element_id("mask").style.left = "0px";
552          _pbar_width = element_id("mContainer").offsetWidth - 2;          _pbar_width = element_id("mContainer").offsetWidth - 2;
553          element_id("mask").style.width = _pbar_width + "px";          element_id("mask").style.width = _pbar_width + "px";
         element_id("progressIndicator").style.zIndex  = 10;  
554          element_id("mask").style.display = "block";          element_id("mask").style.display = "block";
555            element_id("progressIndicator").style.zIndex  = 10;
556          element_id("progressIndicator").innerHTML = "0";          element_id("progressIndicator").innerHTML = "0";
557  }  }
558    
559  function dec2hex(d) {  function dec2hex(d) {
560          var hch="0123456789ABCDEF";          var hch = '0123456789ABCDEF';
561          var a=d%16;          var a = d % 16;
562          var q=(d-a)/16;          var q = (d - a) / 16;
563          return hch.charAt(q)+hch.charAt(a);          return hch.charAt(q) + hch.charAt(a);
564  }  }
565    
   
566  function pbar_set(amount, max) {  function pbar_set(amount, max) {
567            debug('pbar_set('+amount+', '+max+')');
568    
569          debug('pbar_set( '+amount+' , '+max+' )');          if (_pbar_width == null) {
570                    var _mc = element_id("mContainer");
571          curWidth = parseInt(element_id("mask").offsetWidth);                  if (_pbar_width == null) _pbar_width = parseInt(_mc.offsetWidth ? (_mc.offsetWidth - 2) : 0) || null;
572          curLeft = parseInt(element_id("mask").offsetLeft);                  if (_pbar_width == null) _pbar_width = parseInt(_mc.clientWidth ? (_mc.clientWidth + 2) : 0) || null;
573                    if (_pbar_width == null) _pbar_width = 0;
574            }
575    
576          var pcnt = Math.floor( amount * 100 / max );          var pcnt = Math.floor(amount * 100 / max);
577          var p90 = 100 - _pbar_warn;          var p90 = 100 - _pbar_warn;
578          var pcol = pcnt - p90;          var pcol = pcnt - p90;
579          if (pcol < _pbar_warn) {          if (Math.round(pcnt) <= 100) {
580                  if (pcol < 0) pcol = 0;                  if (pcol < 0) pcol = 0;
581                  var e = element_id("submitBurner");                  var e = element_id("submitBurner");
582                  if (e && e.disabled) {                  debug('enable_button');
583                          debug('enable_button');                  e.disabled = false;
584                          var a = e.getAttributeNode('disabled') || null;                  var a = e.getAttributeNode('disabled') || null;
585                          if (a) e.removeAttributeNode(a);                  if (a) e.removeAttributeNode(a);
586                  }          } else {
         } else if (pcol > _pbar_warn) {  
587                  debug('disable button');                  debug('disable button');
588                  pcol = _pbar_warn;                  pcol = _pbar_warn;
589                  var e = element_id("submitBurner");                  var e = element_id("submitBurner");
590                  if (! e.disabled) e.disabled = true;                  if (!e.disabled) e.disabled = true;
591          }          }
592          var col_g = Math.floor( ( _pbar_warn - pcol ) * 255 / _pbar_warn );          var col_g = Math.floor((_pbar_warn - pcol) * 255 / _pbar_warn);
593          var col = '#ff' + dec2hex( col_g ) + '00';          var col = '#FF' + dec2hex(col_g) + '00';
594    
595          //debug('pcol: '+pcol+' g:'+col_g+' _pbar_warn:'+ _pbar_warn + ' color: '+col);          //debug('pcol: '+pcol+' g:'+col_g+' _pbar_warn:'+ _pbar_warn + ' color: '+col);
596          element_id("gradient").style.backgroundColor = col;          element_id("gradient").style.backgroundColor = col;
597    
         var size = parseInt( _pbar_width * amount / max );  
   
         curWidth = _pbar_width - size;  
         curLeft = size ;  
   
         //debug('size: '+size+' curWidth '+curWidth+' curLeft: '+curLeft);  
   
598          element_id("progressIndicator").innerHTML = pcnt + '%';          element_id("progressIndicator").innerHTML = pcnt + '%';
599          //element_id("progressIndicator").innerHTML = amount;          //element_id("progressIndicator").innerHTML = amount;
600    
601          if (curLeft > _pbar_width) {          element_id("mask").style.clip = 'rect(' + Array(
602                  element_id("mask").style.display = "none";                  '0px',
603                  return;                  element_id("mask").offsetWidth + 'px',
604          } else {                  element_id("mask").offsetHeight + 'px',
605                  element_id("mask").style.display = "";                  Math.round(_pbar_width * amount / max) + 'px'
606          }          ).join(' ') + ')';
   
         //if(parseInt(element_id("mask").offsetWidth)>10)  
         element_id("mask").style.width = curWidth + "px";  
         element_id("mask").style.left = curLeft + "px";  
   
607  }  }
608    
609  if (!self.body) self.body = new Object();  if (!self.body) self.body = new Object();
610  self.onload = self.document.onload = self.body.onload = function() {  self.onload = self.document.onload = self.body.onload = function() {
611          pbar_reset();          //pbar_reset();
612          sumiraj();          sumiraj();
613  }  };
614    
615  //-->  // -->
616  </script>  </script>
617  <div id="fixedBox">  <div id="fixedBox">
618    
619  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>  
620    
621  <div id="mContainer">  <div id="mContainer">
622          <div id="gradient"></div>          <div id="gradient">&nbsp;</div>
623          <div id="mask"></div>          <div id="mask">&nbsp;</div>
624          <div id="progressIndicator">&nbsp;</div>          <div id="progressIndicator">0%</div>
625  </div>  </div>
   
626  <br/>  <br/>
627    
628  Note:  Note:
629  <br/>  <textarea name="note" cols="10" rows="5" id="note"></textarea>
630  <textarea name="note" cols="10" rows="5">  
631  </textarea>  <input type="submit" id="submitBurner" value="Burn selected" name="submitBurner" />
 <br/>  
 <input type="submit" id="submitBurner" value="Burn selected" name="submitBurner">  
632    
633  </div>  </div>
634    <!--
635  <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;">
636  no debug output yet  no debug output yet
637  </div>  </div>
638    -->
639  EOF3  EOF3
640          $retHTML .= q{          $retHTML .= q{
641                          <input type="hidden" value="burn" name="action">                          <input type="hidden" value="burn" name="action">

Legend:
Removed from v.128  
changed lines
  Added in v.142

  ViewVC Help
Powered by ViewVC 1.1.26