about summary refs log tree commit diff stats
path: root/app/views/blogs/voted.js.erb
blob: 951c740b66b8f0ae5c279d20d3b6b5d1f1a94da6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
$("#blog-rating-<%= @blog.id %>").html('<%= escape_javascript("#{@blog.upvotes - @blog.downvotes}") %>');

<% if @blog.already_upvoted? request.remote_ip %>
  $("#blog-upvote-link-<%= @blog.id %>").html("👍");
<% elsif @blog.already_downvoted? request.remote_ip %>
  $("#blog-downvote-link-<%= @blog.id %>").html("👎");
<% else %>
  $("#blog-upvote-link-<%= @blog.id %>").html('<%= escape_javascript(link_to("👍", upvote_blog_path(@blog), remote: true, rel: "nofollow", class: "blog-upvote-link", method: :post)) %>');
  $("#blog-downvote-link-<%= @blog.id %>").html('<%= escape_javascript(link_to("👎", downvote_blog_path(@blog), remote: true, rel: "nofollow", class: "blog-downvote-link", method: :post)) %>');
<% end %>

$("#blog-vote-section-<%= @blog.id %>").effect('highlight', {}, 2000);