2824cc54 |
1 | <?php |
4b4abf93 |
2 | |
c4309fbd |
3 | /** |
c4309fbd |
4 | * Theme Name: 'Darkness' |
5 | * Like black? |
4b4abf93 |
6 | * |
7 | * @author Tyler Akins |
33aab559 |
8 | * @copyright 2001-2024 The SquirrelMail Project Team |
4b4abf93 |
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
10 | * @version $Id$ |
c4309fbd |
11 | * @package squirrelmail |
12 | * @subpackage themes |
13 | */ |
43fdb2a4 |
14 | |
79dd8c72 |
15 | // Note: The text distance is actually pre-squared |
16 | // Background range is from 24-64, all three colors are the same |
17 | // Text range is from 196 to 255 |
18 | $BackgroundTargetDistance = 12; |
19 | $BackgroundAdjust = 1; |
20 | $TextTargetDistance = 65536; |
21 | $TextAdjust = 0.95; |
2824cc54 |
22 | |
23 | function IsUnique($Distance, $r, $g, $b, $usedArray) |
24 | { |
25 | foreach ($usedArray as $data) { |
26 | $a = abs($data[0] - $r); |
27 | $b = abs($data[1] - $g); |
28 | $c = abs($data[2] - $b); |
29 | $newDistance = $a * $a + $b * $b + $c * $c; |
30 | if ($newDistance < $Distance) |
31 | return false; |
32 | } |
33 | return true; |
34 | } |
35 | |
36 | |
37 | // Extra spiffy page fade if left frame |
38 | // Always tremble background |
39 | // This might make people go insane. Yes! *Victory dance!* |
40 | function Darkness_HeaderPlugin() { |
eb548244 |
41 | |
101068d9 |
42 | if (defined('PAGE_NAME') && PAGE_NAME=='left_main') { |
673f9350 |
43 | echo '<meta http-equiv="Page-Enter" content="' . |
04fa3c41 |
44 | 'blendTrans(Duration=2.0)" />' . "\n"; |
2824cc54 |
45 | } |
eb548244 |
46 | |
2c92ea9d |
47 | ?><script type="text/javascript"> |
2824cc54 |
48 | darkness_color = 0; |
49 | darkness_dir = +1; |
eb548244 |
50 | darkness_hex = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
51 | 'a', 'b', 'c', 'd', 'e', 'f'); |
2824cc54 |
52 | function DarknessTremble() { |
53 | if (darkness_color >= 32 || darkness_color <= 0) |
54 | darkness_dir = - darkness_dir; |
55 | darkness_color += darkness_dir; |
56 | if (darkness_color < 0) |
57 | darkness_color = 0; |
58 | bigDigit = Math.floor(darkness_color / 16); |
59 | littleDigit = darkness_color - (bigDigit * 16); |
60 | Color = darkness_hex[bigDigit] + darkness_hex[littleDigit]; |
1681f4d9 |
61 | document.bgColor='#' + Color + Color + Color; |
62 | setTimeout('DarknessTremble()', 5000); |
2824cc54 |
63 | } |
1681f4d9 |
64 | setTimeout('DarknessTremble()', 10000); |
2824cc54 |
65 | </script> |
6fd95361 |
66 | <?php |
2824cc54 |
67 | } |
68 | |
69 | global $squirrelmail_plugin_hooks; |
70 | $squirrelmail_plugin_hooks['generic_header']['theme_darkness'] = |
71 | 'Darkness_HeaderPlugin'; |
72 | |
6c99d1de |
73 | $color[3] = '#000000'; |
74 | $color[4] = '#000000'; |
75 | $used = array(0); |
76 | $targetDistance = $BackgroundTargetDistance; |
77 | $Left = array(0, 5, 9, 10, 12); |
78 | while (count($Left) > 0) { |
79 | // Some background colors |
80 | $r = mt_rand(24,64); |
81 | $unique = true; |
82 | foreach ($used as $col) { |
83 | if (abs($r - $col) < $targetDistance) |
eb548244 |
84 | $unique = false; |
6c99d1de |
85 | } |
86 | if ($unique) { |
87 | $i = array_shift($Left); |
88 | $color[$i] = sprintf('#%02X%02X%02X',$r,$r, $r); |
89 | $used[] = $r; |
90 | $targetDistance = $BackgroundTargetDistance; |
91 | } else { |
92 | $targetDistance -= $BackgroundAdjust; |
93 | } |
94 | } |
2824cc54 |
95 | |
6c99d1de |
96 | // Set the error color to some shade of red |
97 | $r = mt_rand(196, 255); |
98 | $g = mt_rand(144, ($r * .8)); |
99 | $color[2] = sprintf('#%02X%02X%02X', $r, $g, $g); |
100 | $used = array(array($r, $g, $g)); |
101 | |
102 | // Set normal text colors |
103 | $cmin = 196; |
104 | $cmax = 255; |
105 | foreach (array(6, 8) as $i) { |
106 | /** generate random color **/ |
107 | $r = mt_rand($cmin,$cmax); |
108 | $g = mt_rand($cmin,$cmax); |
109 | $b = mt_rand($cmin,$cmax); |
110 | $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b); |
111 | $used[] = array($r, $g, $b); |
112 | } |
2824cc54 |
113 | |
6c99d1de |
114 | $Left = array(1, 7, 11, 13, 14, 15); |
115 | $targetDistance = $TextTargetDistance; |
116 | while (count($Left) > 0) { |
117 | // Text colors -- Try to keep the colors distinct |
118 | $cmin = 196; |
119 | $cmax = 255; |
120 | |
121 | /** generate random color **/ |
122 | $r = mt_rand($cmin,$cmax); |
123 | $g = mt_rand($cmin,$cmax); |
124 | $b = mt_rand($cmin,$cmax); |
125 | |
126 | if (IsUnique($targetDistance, $r, $g, $b, $used)) { |
127 | $i = array_shift($Left); |
128 | $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b); |
129 | $used[] = array($r, $g, $b); |
130 | $targetDistance = $TextTargetDistance; |
131 | } else { |
132 | $targetDistance *= $TextAdjust; |
133 | } |
134 | } |