From 96813a5e508a54257ef03be613a704f1f71af53d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 21 Oct 2023 00:25:50 -0400 Subject: Added quotes database --- app/views/quotes/voted.js.erb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 app/views/quotes/voted.js.erb (limited to 'app/views/quotes/voted.js.erb') diff --git a/app/views/quotes/voted.js.erb b/app/views/quotes/voted.js.erb new file mode 100644 index 0000000..c697c7d --- /dev/null +++ b/app/views/quotes/voted.js.erb @@ -0,0 +1,12 @@ +$("#quote-rating-<%= @quote.id %>").html('<%= escape_javascript("+#{@quote.upvotes}/-#{@quote.downvotes}") %>'); + +<% if @quote.already_upvoted? request.remote_ip %> + $("#quote-upvote-link-<%= @quote.id %>").html("Up"); +<% elsif @quote.already_downvoted? request.remote_ip %> + $("#quote-downvote-link-<%= @quote.id %>").html("Down"); +<% else %> + $("#quote-upvote-link-<%= @quote.id %>").html('<%= escape_javascript(link_to("Up", upvote_quote_path(@quote.id), :remote => true, :rel => "nofollow", :class => "quote-upvote-link", method: :post)) %>'); + $("#quote-downvote-link-<%= @quote.id %>").html('<%= escape_javascript(link_to("Down", downvote_quote_path(@quote.id), :remote => true, :rel => "nofollow", :class => "quote-downvote-link", method: :post)) %>'); +<% end %> + +$("#quote-header-<%= @quote.id %>").effect('highlight', {}, 2000); -- cgit 1.4.1