about summary refs log tree commit diff stats
path: root/app/views/blogs/voted.js.erb
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-10-20 21:27:06 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-10-20 21:27:06 -0400
commit2a7a19c93ee0e0d77e4e388d43f36a721c7ab715 (patch)
treec5e775bca4600d111d01d1bd7998d3b6252462e6 /app/views/blogs/voted.js.erb
parent74b1612e49ebd9cb29efb85f3afeb07f0e8d608a (diff)
downloadthoughts-2a7a19c93ee0e0d77e4e388d43f36a721c7ab715.tar.gz
thoughts-2a7a19c93ee0e0d77e4e388d43f36a721c7ab715.tar.bz2
thoughts-2a7a19c93ee0e0d77e4e388d43f36a721c7ab715.zip
Added post voting
Diffstat (limited to 'app/views/blogs/voted.js.erb')
-rw-r--r--app/views/blogs/voted.js.erb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/views/blogs/voted.js.erb b/app/views/blogs/voted.js.erb new file mode 100644 index 0000000..951c740 --- /dev/null +++ b/app/views/blogs/voted.js.erb
@@ -0,0 +1,12 @@
1$("#blog-rating-<%= @blog.id %>").html('<%= escape_javascript("#{@blog.upvotes - @blog.downvotes}") %>');
2
3<% if @blog.already_upvoted? request.remote_ip %>
4 $("#blog-upvote-link-<%= @blog.id %>").html("👍");
5<% elsif @blog.already_downvoted? request.remote_ip %>
6 $("#blog-downvote-link-<%= @blog.id %>").html("👎");
7<% else %>
8 $("#blog-upvote-link-<%= @blog.id %>").html('<%= escape_javascript(link_to("👍", upvote_blog_path(@blog), remote: true, rel: "nofollow", class: "blog-upvote-link", method: :post)) %>');
9 $("#blog-downvote-link-<%= @blog.id %>").html('<%= escape_javascript(link_to("👎", downvote_blog_path(@blog), remote: true, rel: "nofollow", class: "blog-downvote-link", method: :post)) %>');
10<% end %>
11
12$("#blog-vote-section-<%= @blog.id %>").effect('highlight', {}, 2000);