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