+<html>
+ <head>
+ <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
+
+ <style>
+ .highlighted {
+ background-color: blue;
+ }
+ </style>
+
+ </head>
+
+ <body>
+
<?php
// Check if image file is a actual image or fake image
$g = $rgb['green'];
$b = $rgb['blue'];
$a = $rgb['alpha'];
- $hex = '#' .
+ $hex =
str_pad(dechex($rgb['red']), 2, '0', STR_PAD_LEFT) .
str_pad(dechex($rgb['green']), 2, '0', STR_PAD_LEFT) .
str_pad(dechex($rgb['blue']), 2, '0', STR_PAD_LEFT);
- if($a == 127) $hex = "#ffffff";
- echo "<td width='4' height='4' bgcolor='$hex' r='$r' g='$g' b='$b' a='$a'></td>";
+ if($a == 127) $hex = "ffffff";
- if($a == 0)
+ if($a == 0) {
+ echo "<td width='4' height='4' class='$hex' bgcolor='#$hex' r='$r' g='$g' b='$b' a='$a'></td>";
$colour_count[$hex] = isset($colour_count[$hex]) ? $colour_count[$hex]+1 : 1;
+ } else {
+ echo "<td width='4' height='4' bgcolor='#$hex' r='$r' g='$g' b='$b' a='$a'></td>";
+ }
}
echo '</tr>';
}
<td>Quantity</td>
</tr>';
foreach($colour_count as $colour => $qty) {
- echo "<tr><td bgcolor='$colour'></td><td>$colour</td><td>$qty</td></tr>";
+ echo "<tr class='colour-row' id='$colour'><td bgcolor='$colour'></td><td>$colour</td><td>$qty</td></tr>";
}
echo '</table>';
}
}
?>
+
+ <script>
+ $( ".colour-row" ).hover(function() {
+ var colour = $(this).attr('id');
+ console.log(colour);
+ $("." + colour).toggleClass("highlighted");
+ });
+ </script>
+
+ </body>
+</html>
\ No newline at end of file