colours don't scale either D: numbers then...

This commit is contained in:
Shish 2012-02-11 08:33:09 +00:00
parent ce5db719c3
commit 9aa5644504
2 changed files with 32 additions and 19 deletions

View File

@ -372,6 +372,17 @@ function theme_file($filepath) {
} }
function hsl_rainbow() {
$ct = Array();
$s = 100; $l = 25; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 100; $l = 50; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 50; $l = 25; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 100; $l = 25; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 100; $l = 50; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 50; $l = 25; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
return $ct;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* CAPTCHA abstraction * * CAPTCHA abstraction *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

View File

@ -1,6 +1,7 @@
<?php <?php
class CommentListTheme extends Themelet { class CommentListTheme extends Themelet {
var $comments_shown = 0; var $comments_shown = 0;
var $show_anon_id = false;
var $anon_id = 1; var $anon_id = 1;
var $anon_cid = 0; var $anon_cid = 0;
var $anon_map = array(); var $anon_map = array();
@ -8,14 +9,7 @@ class CommentListTheme extends Themelet {
private function get_anon_colour($ip) { private function get_anon_colour($ip) {
if(is_null($this->ct)) { if(is_null($this->ct)) {
$ct = Array(); $this->ct = hsl_rainbow();
$s = 100; $l = 25; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 100; $l = 50; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 50; $l = 25; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 100; $l = 25; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 100; $l = 50; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$s = 50; $l = 25; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";}
$this->ct = $ct;
} }
if(!array_key_exists($ip, $this->anon_map)) { if(!array_key_exists($ip, $this->anon_map)) {
$this->anon_map[$ip] = $this->ct[$this->anon_cid++ % count($this->ct)]; $this->anon_map[$ip] = $this->ct[$this->anon_cid++ % count($this->ct)];
@ -71,11 +65,12 @@ class CommentListTheme extends Themelet {
$hidden = $comment_count - $comment_limit; $hidden = $comment_count - $comment_limit;
$comment_html .= '<p>showing '.$comment_limit.' of '.$comment_count.' comments</p>'; $comment_html .= '<p>showing '.$comment_limit.' of '.$comment_count.' comments</p>';
$comments = array_slice($comments, -$comment_limit); $comments = array_slice($comments, -$comment_limit);
$this->anon_id = -1; $this->show_anon_id = false;
} }
else { else {
$this->anon_id = 1; $this->show_anon_id = true;
} }
$this->anon_id = 1;
foreach($comments as $comment) { foreach($comments as $comment) {
$comment_html .= $this->comment_to_html($comment); $comment_html .= $this->comment_to_html($comment);
} }
@ -113,7 +108,7 @@ class CommentListTheme extends Themelet {
*/ */
public function display_recent_comments($comments) { public function display_recent_comments($comments) {
global $page; global $page;
$this->anon_id = -1; $this->show_anon_id = false;
$html = ""; $html = "";
foreach($comments as $comment) { foreach($comments as $comment) {
$html .= $this->comment_to_html($comment, true); $html .= $this->comment_to_html($comment, true);
@ -128,7 +123,7 @@ class CommentListTheme extends Themelet {
*/ */
public function display_image_comments(Image $image, $comments, $postbox) { public function display_image_comments(Image $image, $comments, $postbox) {
global $page; global $page;
$this->anon_id = 1; $this->show_anon_id = true;
$html = ""; $html = "";
foreach($comments as $comment) { foreach($comments as $comment) {
$html .= $this->comment_to_html($comment); $html .= $this->comment_to_html($comment);
@ -172,15 +167,22 @@ class CommentListTheme extends Themelet {
if($i_uid == $config->get_int("anon_id")) { if($i_uid == $config->get_int("anon_id")) {
$anoncode = ""; $anoncode = "";
if($this->anon_id >= 0) {
$anoncode = '<sup>'.$this->anon_id.'</sup>';
$this->anon_id++;
}
$style = ""; $style = "";
if($user->can("view_ip")) { $anoncode2 = "";
$style = " style='color: ".$this->get_anon_colour($comment->poster_ip).";'"; if($this->show_anon_id) {
$anoncode = '<sup>'.$this->anon_id.'</sup>';
} }
$h_userlink = "<span class='username'$style>" . $h_name . $anoncode . "</span>"; if($user->can("view_ip")) {
#$style = " style='color: ".$this->get_anon_colour($comment->poster_ip).";'";
if(!array_key_exists($comment->poster_ip, $this->anon_map)) {
$this->anon_map[$comment->poster_ip] = $this->anon_id;
}
if($this->anon_map[$comment->poster_ip] != $this->anon_id) {
$anoncode2 = '<sup>('.$this->anon_map[$comment->poster_ip].')</sup>';
}
}
$h_userlink = "<span class='username'$style>" . $h_name . $anoncode . $anoncode2 . "</span>";
$this->anon_id++;
} }
else { else {
$h_userlink = '<a class="username" href="'.make_link('user/'.$h_name).'">'.$h_name.'</a>'; $h_userlink = '<a class="username" href="'.make_link('user/'.$h_name).'">'.$h_name.'</a>';