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