home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2000 April / VPR0004B.BIN / DRIVER / COMPAQ / SP12255 / sp12255.exe / DMWEBC1.CAB / COND.JS < prev    next >
Text File  |  1999-03-09  |  4KB  |  141 lines

  1. // $Id: condition.js 2.0 1997/10/30 18:51:12 JEllis Development $
  2. // Copyright (C) 1997 Compaq Computer Corporation
  3.  
  4. function setCondition( conditionIn )
  5. {
  6.     if( null==conditionIn )
  7.     {
  8.         conditionIn = 1;
  9.     }
  10.     
  11.     this.state = conditionIn;
  12. }
  13.  
  14.  
  15. function updateCondition( newCondition )
  16. {
  17.     if( null==newCondition || ""==newCondition )    // error/problem data
  18.     {
  19.         newCondition = 1;
  20.     }
  21.     
  22.     
  23.     if(4 == this.state) // failed
  24.     {
  25.         // do nothing, we are already at the worst case
  26.     }
  27.     else if ( 3 == this.state) // degraded
  28.     {
  29.         if(4==newCondition)
  30.             this.state = 4;
  31.     }
  32.     else if ( 2 == this.state) // OK
  33.     {
  34.         if(2<newCondition)
  35.             this.state = newCondition;
  36.     }
  37.     else    // unknown
  38.     {
  39.         this.state = newCondition;
  40.     }
  41. }
  42.  
  43.  
  44. function colorFromCondition()
  45. {
  46.     if(4 == this.state) // failed
  47.     {
  48.         return "FF0000";
  49.     }
  50.     else if ( 3 == this.state) // degraded
  51.     {
  52.         return "FFFF00";
  53.     }
  54.     else if ( 2 == this.state) // OK
  55.     {
  56.         return "00CC00";
  57.     }
  58.     else    // unknown
  59.     {
  60.         return "#0000FF";
  61.     }
  62. }
  63.  
  64. function statusGraphic(alignment)
  65. {
  66.     if(null==alignment)
  67.     {
  68.         alignment = "TOP";
  69.     }
  70.     
  71.     if(5 == this.state) // non-recoverable
  72.     {
  73.         rc = "<IMG SRC=IMAGES/red_x_small.gif ALIGN=" + alignment + " WIDTH=25 HEIGHT=22 HSPACE=0 VSPACE=0 BORDER=0>";
  74.     }
  75.     else if(4 == this.state) // failed
  76.     {
  77.         rc = "<IMG SRC=IMAGES/orange_x_small.gif ALIGN=" + alignment + " WIDTH=25 HEIGHT=22 HSPACE=0 VSPACE=0 BORDER=0>";
  78.     }
  79.     else if ( 3 == this.state) // degraded
  80.     {
  81.         rc = "<IMG SRC=IMAGES/yellow_yield_small.gif ALIGN=" + alignment + " WIDTH=25 HEIGHT=22 HSPACE=0 VSPACE=0 BORDER=0>";
  82.     }
  83.     else if ( 2 == this.state) // OK
  84.     {
  85.         rc = "<IMG SRC=IMAGES/green_check_small.gif ALIGN=" + alignment + " WIDTH=25 HEIGHT=22 HSPACE=0 VSPACE=0 BORDER=0>";
  86.     }
  87.     else    // unknown
  88.     {
  89.         rc = "<IMG SRC=IMAGES/blue_ball_small.gif ALIGN=" + alignment + " WIDTH=25 HEIGHT=22 HSPACE=0 VSPACE=0 BORDER=0>";
  90.     }
  91.     
  92.     return rc;
  93. }
  94.  
  95.  
  96. function statusGraphicSmall(alignment)
  97. {
  98.     if(null==alignment)
  99.     {
  100.         alignment = "TOP";
  101.     }
  102.     
  103.     if(5 == this.state) // non-recoverable
  104.     {
  105.         rc = "<IMG SRC=IMAGES/red_x_small.gif ALIGN=" + alignment + "  HSPACE=0 VSPACE=0 BORDER=0>";
  106.     }
  107.     else if(4 == this.state) // failed
  108.     {
  109.         rc = "<IMG SRC=IMAGES/orange_x_small.gif ALIGN="+ alignment + " HSPACE=0 VSPACE=0 BORDER=0>";
  110.     }
  111.     else if ( 3 == this.state) // degraded
  112.     {
  113.         rc = "<IMG SRC=IMAGES/yellow_yield_small.gif ALIGN="+ alignment + " HSPACE=0 VSPACE=0 BORDER=0>";
  114.     }
  115.     else if ( 2 == this.state) // OK
  116.     {
  117.         rc = "<IMG SRC=IMAGES/green_check_small.gif ALIGN="+ alignment + " HSPACE=0 VSPACE=0 BORDER=0>";
  118.     }
  119.     else    // unknown
  120.     {
  121.         rc = "<IMG SRC=IMAGES/blue_ball_small.gif ALIGN="+ alignment + " HSPACE=0 VSPACE=0 BORDER=0>";
  122.     }
  123.     
  124.     return rc;
  125. }
  126.  
  127.  
  128. function cpqCondition( startingCondition )
  129. {
  130.     if( null == startingCondition )
  131.     {
  132.         startingCondition = 1;  // unknown
  133.     }
  134.     
  135.     this.state = startingCondition;
  136.     this.update = updateCondition;
  137.     this.color = colorFromCondition;
  138.     this.image = statusGraphic;
  139.     this.imageSmall = statusGraphicSmall;
  140.     this.set = setCondition;
  141. }