# COLOR SETTINGS use RGB; sub is_color { my ($plaid) = @_; return exists($COLORS{$plaid}); } sub color_dropdown { my ($selected, $quick) = @_; $selected = 'plain' if (!defined($selected)); $quick = '0' if (!defined($quick)); print qq!\n!; } sub get_color { my ($t, $k, $row) = @_; print qq! $t->{id}(color) = $t->{color}, $k->{color}
! if ($DEBUG); if (ref($row) eq "HASH") { my $comments = $row; my $color = find_comments_color($row); return $color if $color; } elsif (defined($row) && $row > 0) { if ($t->{color} && $t->{color} ne "plain") { return $t->{color}; } elsif ($k->{color} && $k->{color} ne "plain") { return $k->{color}; } elsif (!length($t->{keyword})) { return $BUCKY_UNSORTED_COLOR; } else { return $BUCKY_DEFAULT_COLOR; } } if ($t != -1 && $t->{color}) { return $t->{color} if ($t->{color} ne "plain"); } if ($k != -1 && $k->{color}) { return $k->{color}; } return "plain"; } sub find_comments_color { my ($comments) = @_; foreach my $comment (values %$comments) { # if ($message->{'body'} =~ /body bgcolor="?([#0-9a-fA-F]+)/) if ($comment->{'comment'} =~ /(body bgcolor="|background-color: )#?([0-9a-fA-F]+)/) { print "1" if $DEBUG; my $color = $2; return "#" . $color; } } return undef; } sub nighttime_quotient { my $nighttime_quotient = -30; my $date = time + get_tz_offset(); # if ($dateoffset == -1); my $x; my ($m,$h,$d,$n,$y) = (localtime $date)[1..5]; if ($h < 5 || $h > 23) { return $nighttime_quotient; } if ($h >= 5 && $h <= 7) { $x = 60*60*3 - 60 * ($h - 5) + $m; } if ($h >= 21 && $h <= 23) { $x = 60 * ($h - 21) + $m; } $x /= 60*60*3; return $nighttime_quotient * $x; } sub get_color_from_time { my ($date) = @_; $date = time; my $offset = get_tz_offset(); # if ($dateoffset == -1); $date += $offset; my ($m,$h,$d,$n,$y) = (localtime $date)[1..5]; if (($h == 4 || $h == 16) && $m == 20) { $c = "green"; } elsif ($h < 5) { $c = "purple"; } elsif ($h >= 5 && $h < 6) { $c = "red"; } elsif ($h >= 6 && $h < 9) { $c = "orange"; } elsif ($h >= 9 && $h < 12) { $c = "yellow"; } elsif ($h >= 12 && $h < 18) { $c = "plain"; } elsif ($h >= 18 && $h < 21) { $c = "blue"; } elsif ($h >= 21) { $c = "purple"; } else { $c = "plain"; } return $c; } 1;