4 * Theme Name: 'Darkness'
6 * @package squirrelmail
11 * Load up the usual suspects.. */
12 require_once(SM_PATH
. 'functions/strings.php');
14 // Note: The text distance is actually pre-squared
15 // Background range is from 24-64, all three colors are the same
16 // Text range is from 196 to 255
17 $BackgroundTargetDistance = 12;
18 $BackgroundAdjust = 1;
19 $TextTargetDistance = 65536;
22 function IsUnique($Distance, $r, $g, $b, $usedArray)
24 foreach ($usedArray as $data) {
25 $a = abs($data[0] - $r);
26 $b = abs($data[1] - $g);
27 $c = abs($data[2] - $b);
28 $newDistance = $a * $a +
$b * $b +
$c * $c;
29 if ($newDistance < $Distance)
36 // Extra spiffy page fade if left frame
37 // Always tremble background
38 // This might make people go insane. Yes! *Victory dance!*
39 function Darkness_HeaderPlugin() {
42 if (substr($PHP_SELF, -18) == '/src/left_main.php') {
43 echo '<meta http-equiv="Page-Enter" content="' .
44 'blendTrans(Duration=2.0)" />' . "\n";
47 ?
><script language
="javascript">
50 darkness_hex
= new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
51 'a', 'b', 'c', 'd', 'e', 'f');
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)
58 bigDigit
= Math
.floor(darkness_color
/ 16);
59 littleDigit
= darkness_color
- (bigDigit
* 16);
60 Color
= darkness_hex
[bigDigit
] + darkness_hex
[littleDigit
];
61 document
.bgColor
='#' + Color + Color + Color
;
62 setTimeout('DarknessTremble()', 5000);
64 setTimeout('DarknessTremble()', 10000);
69 global $squirrelmail_plugin_hooks;
70 $squirrelmail_plugin_hooks['generic_header']['theme_darkness'] =
71 'Darkness_HeaderPlugin';
73 /** seed the random number generator **/
76 $color[3] = '#000000';
77 $color[4] = '#000000';
79 $targetDistance = $BackgroundTargetDistance;
80 $Left = array(0, 5, 9, 10, 12);
81 while (count($Left) > 0) {
82 // Some background colors
85 foreach ($used as $col) {
86 if (abs($r - $col) < $targetDistance)
90 $i = array_shift($Left);
91 $color[$i] = sprintf('#%02X%02X%02X',$r,$r, $r);
93 $targetDistance = $BackgroundTargetDistance;
95 $targetDistance -= $BackgroundAdjust;
99 // Set the error color to some shade of red
100 $r = mt_rand(196, 255);
101 $g = mt_rand(144, ($r * .8));
102 $color[2] = sprintf('#%02X%02X%02X', $r, $g, $g);
103 $used = array(array($r, $g, $g));
105 // Set normal text colors
108 foreach (array(6, 8) as $i) {
109 /** generate random color **/
110 $r = mt_rand($cmin,$cmax);
111 $g = mt_rand($cmin,$cmax);
112 $b = mt_rand($cmin,$cmax);
113 $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
114 $used[] = array($r, $g, $b);
117 $Left = array(1, 7, 11, 13, 14, 15);
118 $targetDistance = $TextTargetDistance;
119 while (count($Left) > 0) {
120 // Text colors -- Try to keep the colors distinct
124 /** generate random color **/
125 $r = mt_rand($cmin,$cmax);
126 $g = mt_rand($cmin,$cmax);
127 $b = mt_rand($cmin,$cmax);
129 if (IsUnique($targetDistance, $r, $g, $b, $used)) {
130 $i = array_shift($Left);
131 $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
132 $used[] = array($r, $g, $b);
133 $targetDistance = $TextTargetDistance;
135 $targetDistance *= $TextAdjust;
140 /** Reference from doc/themes.txt
142 b 0: Title Bar at the top of the page header
143 f 1: <not currently used>
144 f 2: Error messages, usually red
145 b 3: Left folder list background color
146 b 4: Normal background color
147 b 5: Header of the message index [From, Date, Subject]
148 f 6: Normal text on the left folder list
149 f 7: Links in the right frame, Folders with subfolders in left frame
150 f 8: Normal text [usually black]
151 b 9: Darker version of #0
152 b 10: Darker version of #9
153 f 11: Special folders color [Inbox, Trash, Sent]
154 b 12: Alternate color for message list [alters between 4 and this one]
155 f 13: Color for single-quoted text ('> text') when reading (default: #800000)
156 f 14: Color for text with more than one quote (default: #FF0000)