2 /** Author: Tyler Akins
10 require_once('../functions/strings.php');
12 // Note: The text distance is actually pre-squared
13 // Background range is from 24-64, all three colors are the same
14 // Text range is from 196 to 255
15 $BackgroundTargetDistance = 12;
16 $BackgroundAdjust = 1;
17 $TextTargetDistance = 65536;
20 function IsUnique($Distance, $r, $g, $b, $usedArray)
22 foreach ($usedArray as $data) {
23 $a = abs($data[0] - $r);
24 $b = abs($data[1] - $g);
25 $c = abs($data[2] - $b);
26 $newDistance = $a * $a +
$b * $b +
$c * $c;
27 if ($newDistance < $Distance)
34 // Extra spiffy page fade if left frame
35 // Always tremble background
36 // This might make people go insane. Yes! *Victory dance!*
37 function Darkness_HeaderPlugin() {
38 global $PHP_SELF, $Darkness_Transition;
40 if (substr($PHP_SELF, -18) == '/src/left_main.php') {
41 echo '<meta http-equiv="Page-Enter" content="' .
42 'blendTrans(Duration=2.0)">' . '\n';
45 ?
><script language
=javascript
>
48 darkness_hex
= new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
49 'A', 'B', 'C', 'D', 'E', 'F');
50 function DarknessTremble() {
51 if (darkness_color
>= 32 || darkness_color
<= 0)
52 darkness_dir
= - darkness_dir
;
53 darkness_color +
= darkness_dir
;
54 if (darkness_color
< 0)
56 bigDigit
= Math
.floor(darkness_color
/ 16);
57 littleDigit
= darkness_color
- (bigDigit
* 16);
58 Color
= darkness_hex
[bigDigit
] + darkness_hex
[littleDigit
];
59 document
.bgColor
='#' + Color + Color + Color
;
60 setTimeout('DarknessTremble()', 5000);
62 setTimeout('DarknessTremble()', 10000);
67 global $squirrelmail_plugin_hooks;
68 $squirrelmail_plugin_hooks['generic_header']['theme_darkness'] =
69 'Darkness_HeaderPlugin';
71 /** seed the random number generator **/
74 $color[3] = '#000000';
75 $color[4] = '#000000';
77 $targetDistance = $BackgroundTargetDistance;
78 $Left = array(0, 5, 9, 10, 12);
79 while (count($Left) > 0) {
80 // Some background colors
83 foreach ($used as $col) {
84 if (abs($r - $col) < $targetDistance)
88 $i = array_shift($Left);
89 $color[$i] = sprintf('#%02X%02X%02X',$r,$r, $r);
91 $targetDistance = $BackgroundTargetDistance;
93 $targetDistance -= $BackgroundAdjust;
97 // Set the error color to some shade of red
98 $r = mt_rand(196, 255);
99 $g = mt_rand(144, ($r * .8));
100 $color[2] = sprintf('#%02X%02X%02X', $r, $g, $g);
101 $used = array(array($r, $g, $g));
103 // Set normal text colors
106 foreach (array(6, 8) as $i) {
107 /** generate random color **/
108 $r = mt_rand($cmin,$cmax);
109 $g = mt_rand($cmin,$cmax);
110 $b = mt_rand($cmin,$cmax);
111 $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
112 $used[] = array($r, $g, $b);
115 $Left = array(1, 7, 11, 13, 14, 15);
116 $targetDistance = $TextTargetDistance;
117 while (count($Left) > 0) {
118 // Text colors -- Try to keep the colors distinct
122 /** generate random color **/
123 $r = mt_rand($cmin,$cmax);
124 $g = mt_rand($cmin,$cmax);
125 $b = mt_rand($cmin,$cmax);
127 if (IsUnique($targetDistance, $r, $g, $b, $used)) {
128 $i = array_shift($Left);
129 $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
130 $used[] = array($r, $g, $b);
131 $targetDistance = $TextTargetDistance;
133 $targetDistance *= $TextAdjust;
138 /** Reference from doc/themes.txt
140 b 0: Title Bar at the top of the page header
141 f 1: <not currently used>
142 f 2: Error messages, usually red
143 b 3: Left folder list background color
144 b 4: Normal background color
145 b 5: Header of the message index [From, Date, Subject]
146 f 6: Normal text on the left folder list
147 f 7: Links in the right frame, Folders with subfolders in left frame
148 f 8: Normal text [usually black]
149 b 9: Darker version of #0
150 b 10: Darker version of #9
151 f 11: Special folders color [Inbox, Trash, Sent]
152 b 12: Alternate color for message list [alters between 4 and this one]
153 f 13: Color for single-quoted text ('> text') when reading (default: #800000)
154 f 14: Color for text with more than one quote (default: #FF0000)