Created
October 14, 2013 06:51
-
-
Save richardgv/6971774 to your computer and use it in GitHub Desktop.
gazelle-colorful-votes.patch, for Nex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/classes/class_format.php b/classes/class_format.php | |
index ab46d71..7b518df 100644 | |
--- a/classes/class_format.php | |
+++ b/classes/class_format.php | |
@@ -30,6 +30,33 @@ class Format { | |
} | |
} | |
+ /** | |
+ * Format a vote count. | |
+ * | |
+ * @param votes number of votes | |
+ * @return string formatted vote count HTML | |
+ */ | |
+ public static function get_votes_html($votes) { | |
+ // Sanity check | |
+ if (!settype($votes, 'float')) | |
+ return 'Shit happened!'; | |
+ | |
+ $cl = 'r50'; | |
+ if ($votes < 0.1) $cl = 'r00'; | |
+ elseif ($votes < 0.2) $cl = 'r01'; | |
+ elseif ($votes < 0.3) $cl = 'r02'; | |
+ elseif ($votes < 0.4) $cl = 'r03'; | |
+ elseif ($votes < 0.5) $cl = 'r04'; | |
+ elseif ($votes < 0.6) $cl = 'r05'; | |
+ elseif ($votes < 0.7) $cl = 'r06'; | |
+ elseif ($votes < 0.8) $cl = 'r07'; | |
+ elseif ($votes < 0.9) $cl = 'r08'; | |
+ elseif ($votes < 1.0) $cl = 'r09'; | |
+ elseif ($votes < 2.0) $cl = 'r10'; | |
+ elseif ($votes < 5.0) $cl = 'r20'; | |
+ | |
+ return "<span class=\"$cl\">$votes</span>"; | |
+ } | |
/** | |
* Gets the CSS class corresponding to a ratio | |
@@ -463,4 +490,4 @@ class Format { | |
); | |
} | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/sections/torrents/browse2.php b/sections/torrents/browse2.php | |
index fe2767b..28e5f02 100644 | |
--- a/sections/torrents/browse2.php | |
+++ b/sections/torrents/browse2.php | |
@@ -935,7 +935,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr | |
<div class="torrent_info"><?=$ExtraInfo?></div>--> | |
<!--<div class="tags"><?//=$TorrentTags?></div>--> | |
</td> | |
- <td><?=$ResultVotes?></td> | |
+ <td><?php echo Format::get_votes_html($ResultVotes); ?></td> | |
<td><?=$Data['FileCount']?></td> | |
<td class="nobr"><?=time_diff($Data['Time'],1)?></td> | |
<td class="nobr"><?=Format::get_size($Data['Size'])?></td> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment