Permalink
Browse files
experiment with hiding fresh but boring comment scores
- Loading branch information...
|
|
@@ -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(:comment, "cannot be blank.")
|
|
|
@@ -431,6 +433,16 @@ def score |
|
|
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,17 +5,15 @@ |
|
|
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 %>
|
|
|
<a class="upvoter"></a>
|
|
|
<% 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 %>
|
|
|
|
0 comments on commit
08a64ec