Commit 653d8e64 authored by Carl Chenet's avatar Carl Chenet

experiment with hiding fresh but boring comment scores

parent 31e06e47
......@@ -116,7 +116,12 @@ var _Lobsters = Class.extend({
var li = $(voterEl).closest(".story, .comment");
var scoreDiv = li.find("div.score").get(0);
var score = parseInt(scoreDiv.innerHTML);
var score = 0;
var showScore = true;
if (scoreDiv.innerHTML == "-")
showScore = false;
else
score = parseInt(scoreDiv.innerHTML);
var action = "";
if (li.hasClass("upvoted") && point > 0) {
......@@ -150,7 +155,8 @@ var _Lobsters = Class.extend({
action = "downvote";
}
scoreDiv.innerHTML = score;
if (showScore)
scoreDiv.innerHTML = score;
if (action == "upvote" || action == "unvote") {
li.find(".reason").html("");
......
......@@ -487,6 +487,10 @@ li div.details {
opacity: 0.5;
}
.comment.bad {
opacity: 0.7;
}
.comment:target {
background-color: #fffcd7;
border-radius: 20px;
......
......@@ -32,6 +32,8 @@ class Comment < ActiveRecord::Base
# after this many minutes old, a comment cannot be edited
MAX_EDIT_MINS = (60 * 6)
SCORE_RANGE_TO_HIDE = (-2 .. 4)
validate do
self.comment.to_s.strip == "" &&
errors.add(" ", I18n.t( 'models.comment.commentcannotbeblank'))
......@@ -429,6 +431,16 @@ class Comment < ActiveRecord::Base
self.upvotes - self.downvotes
end
def score_for_user(user)
if (user && user.is_moderator?) ||
(self.created_at && self.created_at < 24.hours.ago) ||
!SCORE_RANGE_TO_HIDE.include?(score)
score
else
"-"
end
end
def short_id_url
Rails.application.root_url + "c/#{self.short_id}"
end
......
......@@ -5,9 +5,7 @@
data-shortid="<%= comment.short_id if comment.persisted? %>"
class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
"upvoted" : "downvoted") : "" %>
<%= comment.score <= -1 ? "negative_1" : "" %>
<%= comment.score <= -3 ? "negative_3" : "" %>
<%= comment.score <= -5 ? "negative_5" : "" %>">
<%= comment.score < Comment::SCORE_RANGE_TO_HIDE.first ? "bad" : "" %>">
<% if !comment.is_gone? %>
<div class="voters">
<% if @user %>
......@@ -15,7 +13,7 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
<% else %>
<%= link_to "", login_path, :class => "upvoter" %>
<% end %>
<div class="score"><%= comment.score %></div>
<div class="score"><%= comment.score_for_user(@user) %></div>
<% if @user && @user.can_downvote?(comment) %>
<a class="downvoter"></a>
<% else %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment