appdb/ ./apidb.css include/html.php include/ut ...

WineHQ wineowner at wine.codeweavers.com
Thu Jul 12 18:58:01 CDT 2007


ChangeSet ID:	31250
CVSROOT:	/opt/cvs-commit
Module name:	appdb
Changes by:	wineowner at winehq.org	2007/07/12 18:58:01

Modified files:
	.              : apidb.css 
	include        : html.php util.php version.php 

Log message:
	Chris Morgan <cmorgan at alum.wpi.edu>
	Color versions when displaying the version table on the application page. Add dynamic
	highlighting and the ability to click on the row in the version table.

Patch: http://cvs.winehq.org/patch.py?id=31250

Old revision  New revision  Changes     Path
 1.22          1.23          +1 -2       appdb/apidb.css
 1.13          1.14          +2 -1       appdb/include/html.php
 1.95          1.96          +75 -0      appdb/include/util.php
 1.135         1.136         +33 -4      appdb/include/version.php

Index: appdb/apidb.css
diff -u -p appdb/apidb.css:1.22 appdb/apidb.css:1.23
--- appdb/apidb.css:1.22	12 Jul 2007 23:58: 1 -0000
+++ appdb/apidb.css	12 Jul 2007 23:58: 1 -0000
@@ -137,8 +137,7 @@ p.indent            { padding-left: 1em;
 .gold               { background-color: #fff600; }
 .silver             { background-color: silver;  }
 .bronze             { background-color: #fcba0a; }
-.Garbage            { background-color: #999966; }
-
+.garbage            { background-color: #999966; }
 
 /*******************************************************************/
 /* The following styles are used exclusively in appdb              */
Index: appdb/include/html.php
diff -u -p appdb/include/html.php:1.13 appdb/include/html.php:1.14
--- appdb/include/html.php:1.13	12 Jul 2007 23:58: 1 -0000
+++ appdb/include/html.php	12 Jul 2007 23:58: 1 -0000
@@ -70,7 +70,8 @@ function html_tr($arr, $class = "", $ext
 }
 
 function html_tr_highlight_clickable($sUrl, $sClass, $sHighlightColor, $sInactiveColor,
-                                     $sTextDecorationHighlight = "none", $sTextDecorationInactive = "none")
+                                     $sTextDecorationHighlight = "none",
+                                     $sTextDecorationInactive = "none")
 {
     echo '<tr class='.$sClass.' '.
         'onmouseover="ChangeTr(this, true, \''.$sHighlightColor.'\', \''.$sInactiveColor.'\', \''.$sTextDecorationHighlight.'\', \''.$sTextDecorationInactive.'\');"'.
Index: appdb/include/util.php
diff -u -p appdb/include/util.php:1.95 appdb/include/util.php:1.96
--- appdb/include/util.php:1.95	12 Jul 2007 23:58: 1 -0000
+++ appdb/include/util.php	12 Jul 2007 23:58: 1 -0000
@@ -936,4 +936,79 @@ function login_url()
     return $sLoginUrl;
 }
 
+// representation of an html color value
+class color
+{
+  var $iRed;
+  var $iGreen;
+  var $iBlue;
+
+  function color($iRed = 0, $iGreen = 0, $iBlue = 0)
+  {
+    $this->iRed = $iRed;
+    $this->iGreen = $iGreen;
+    $this->iBlue = $iBlue;
+  }
+
+  function setColorByName($sColorName)
+  {
+    switch($sColorName)
+    {
+    case "Platinum":
+      $this->iRed = 0xEC;
+      $this->iGreen = 0xEC;
+      $this->iBlue = 0xEC;
+      break;
+    case "Gold":
+      $this->iRed = 0xFF;
+      $this->iGreen = 0xF6;
+      $this->iBlue = 0x00;
+      break;
+    case "Silver":
+      $this->iRed = 0xC0;
+      $this->iGreen = 0xC0;
+      $this->iBlue = 0xC0;
+      break;
+    case "Bronze":
+      $this->iRed = 0xFC;
+      $this->iGreen = 0xBA;
+      $this->iBlue = 0x0A;
+      break;
+    case "Garbage":
+      $this->iRed = 0x99;
+      $this->iGreen = 0x96;
+      $this->iBlue = 0x66;
+      break;
+    default:
+      break;
+    }
+  }
+
+  // convert the color value into a html rgb hex string
+  function getHexString()
+  {
+    return sprintf("#%02X%02X%02X", $this->iRed, $this->iGreen, $this->iBlue);
+  }
+
+  // add $iAmount to each color value, maxing out at 0xFF, the largest
+  // color value allowed
+  function add($iAmount)
+  {
+    if($this->iRed + $iAmount > 0xFF)
+      $this->iRed = 0xFF;
+    else
+      $this->iRed += $iAmount;
+
+    if($this->iGreen + $iAmount > 0xFF)
+      $this->iGreen = 0xFF;
+    else
+      $this->iGreen += $iAmount;
+
+    if($this->iBlue + $iAmount > 0xFF)
+      $this->iBlue = 0xFF;
+    else
+      $this->iBlue += $iAmount;
+  }
+};
+
 ?>
Index: appdb/include/version.php
diff -u -p appdb/include/version.php:1.135 appdb/include/version.php:1.136
--- appdb/include/version.php:1.135	12 Jul 2007 23:58: 1 -0000
+++ appdb/include/version.php	12 Jul 2007 23:58: 1 -0000
@@ -1023,17 +1023,46 @@ class version {
                     // set row color
                     $bgcolor = ($c % 2 == 0) ? "color0" : "color1";
 
+                    // if we have a valid tested rating
                     if($oVersion->sTestedRating && $oVersion->sTestedRating != "/")
+                    {
                         $sRatingColor = "class=\"$oVersion->sTestedRating\"";
-                    else
+                        $sClass = $oVersion->sTestedRating;
+
+                        $oColor = new Color();
+                        $oColor->setColorByName($oVersion->sTestedRating);
+                        $sInactiveColor = $oColor->getHexString();
+
+                        // increase the brightness of the color to create the
+                        // value used for the highlight color
+                        $oColor->add(50);
+                        $sHighlightColor = $oColor->getHexString();
+                    } else
+                    {
                         $sRatingColor = "class=\"$bgcolor\"";
+                        $sClass = $bgcolor;
+
+                        // convert color values to hex values for the row highlighting
+                        if($bgcolor == "color0")
+                        {
+                          $sHighlightColor = "#E0E0E0";
+                          $sInactiveColor = $sHighlightColor;
+                        } else
+                        {
+                          $sHighlightColor = "#C0C0C0";
+                          $sInactiveColor = $sHighlightColor;
+                        }
+                    }
 
                     //display row
-                    echo "<tr class=$bgcolor>\n";
+                    html_tr_highlight_clickable($oVersion->objectMakeUrl(),
+                                                $sClass, // class
+                                                $sHighlightColor, // highlight color
+                                                $sInactiveColor);// inactive color
                     echo "    <td>".$oVersion->objectMakeLink()."</td>\n";
                     echo "    <td>".util_trim_description($oVersion->sDescription)."</td>\n";
-                    echo "    <td $sRatingColor align=center>".$oVersion->sTestedRating."</td>\n";
-                    echo "    <td $sRatingColor align=center>".$oVersion->sTestedRelease."</td>\n";
+                    echo "    <td align=center>".$oVersion->sTestedRating."</td>\n";
+                    echo "    <td align=center>".$oVersion->sTestedRelease."</td>\n";
                     echo "    <td align=center>".testData::get_testdata_count_for_versionid($oVersion->iVersionId)."</td>\n";
                     echo "    <td align=center>".Comment::get_comment_count_for_versionid($oVersion->iVersionId)."</td>\n";
                     echo "</tr>\n\n";



More information about the wine-cvs mailing list