<commit_before>var quoteFavorites = {

	init: function() {
		// user favorites a quote
		$(".quotes, .show-quote").on("click", "button.unliked-quote", this.addToFavorites.bind(this));
		// user unfavorites a quote
		$(".quotes, .show-quote").on("click", "button.liked-quote", this.removeFromFavorites.bind(this));
	},

	displayLikeQuote: function (selector) {
		$(selector).removeClass("unliked-quote");
		$(selector).addClass("liked-quote");
	},

	displayUnlikeQuote: function(selector) {
		$(selector).removeClass("liked-quote");
		$(selector).addClass("unliked-quote");
	},

	addToFavorites: function(e) {
		e.preventDefault();
		this.displayLikeQuote(e.target);

		var quoteId = $(e.target).parent().parent().attr("id");
		var ajaxRequest = $.ajax({
			url: "/quotes/" + quoteId + "/favorite",
			type: "post"
		});
	},

	removeFromFavorites: function(e) {
		e.preventDefault();
		this.displayUnlikeQuote(e.target);

		var quoteId = $(e.target).parent().parent().attr("id");
		var ajaxRequest = $.ajax({
			url: "/quotes/" + quoteId + "/unfavorite",
			type: "delete"
		});
	}
};

var userFavorites = {
	init: function() {
		$(".nav-favorites").on("click", this.getFavoriteQuotes.bind(this));
	},

	getFavoriteQuotes: function(e) {

		// if user is on /quotes/:id or /bookclubs, redirect to /quotes/favorites
		// else, user is on / and we can render favorite quotes via ajax
		if ((!window.location.pathname.match(/\/bookclubs/)) && (!window.location.pathname.match(/\/quotes\/\d+/))) {
			e.preventDefault();
			var ajaxRequest = $.ajax({
				url: "/favorites",
				type: "get"
			});

			ajaxRequest.done(this.renderFavorites.bind(this));

		}

	},

	renderFavorites: function(response) {
		$(".quotes").html("");	

		$(".page-info").html("My Favorites");
		
		for (var i = 0; i < response.quotes.length; i++) {
			var html = this.getQuoteHtml(response.quotes[i]);
			$(".quotes").append(html);
		}
		makeDraggable();
	},

	getQuoteHtml: function(quote) {
		var html = "<div class='quote' id='" + quote.id + "'>" +
			"<div class='content'><img src='/icons/openingquote.png'><p>" + quote.content + "</p><img src='/icons/closingquote.png'></div>" +
				"<div class='quote-info'><a class='search-author' data-method='get'" +
				"href='/search?q%5Bauthor_name_cont%5D=" + encodeURI(quote.author_name) + "' rel='nofollow'>" + quote.author_name + "</a>"
		if (quote.book_title != "") {
			html = html + "<br/>" +
				"<a class='search-title' data-method='get'" +
				"href='/search?q%5Bbook_title_cont%5D=" + encodeURI(quote.book_title) + 
				"' rel='nofollow'>" + quote.book_title + "</a>";
		}			<commit_msg>When favs generated via ajax, display empty message if there are no favorited quotes<commit_after>var quoteFavorites = {

	init: function() {
		// user favorites a quote
		$(".quotes, .show-quote").on("click", "button.unliked-quote", this.addToFavorites.bind(this));
		// user unfavorites a quote
		$(".quotes, .show-quote").on("click", "button.liked-quote", this.removeFromFavorites.bind(this));
	},

	displayLikeQuote: function (selector) {
		$(selector).removeClass("unliked-quote");
		$(selector).addClass("liked-quote");
	},

	displayUnlikeQuote: function(selector) {
		$(selector).removeClass("liked-quote");
		$(selector).addClass("unliked-quote");
	},

	addToFavorites: function(e) {
		e.preventDefault();
		this.displayLikeQuote(e.target);

		var quoteId = $(e.target).parent().parent().attr("id");
		var ajaxRequest = $.ajax({
			url: "/quotes/" + quoteId + "/favorite",
			type: "post"
		});
	},

	removeFromFavorites: function(e) {
		e.preventDefault();
		this.displayUnlikeQuote(e.target);

		var quoteId = $(e.target).parent().parent().attr("id");
		var ajaxRequest = $.ajax({
			url: "/quotes/" + quoteId + "/unfavorite",
			type: "delete"
		});
	}
};

var userFavorites = {
	init: function() {
		$(".nav-favorites").on("click", this.getFavoriteQuotes.bind(this));
	},

	getFavoriteQuotes: function(e) {

		// if user is on /quotes/:id or /bookclubs, redirect to /quotes/favorites
		// else, user is on / and we can render favorite quotes via ajax
		if ((!window.location.pathname.match(/\/bookclubs/)) && (!window.location.pathname.match(/\/quotes\/\d+/))) {
			e.preventDefault();
			var ajaxRequest = $.ajax({
				url: "/favorites",
				type: "get"
			});

			ajaxRequest.done(this.renderFavorites.bind(this));

		}

	},

	renderFavorites: function(response) {
		$(".quotes").html("");	

		$(".page-info").html("My Favorites");

		this.displayEmptyMessage(response.quotes);
		
		for (var i = 0; i < response.quotes.length; i++) {
			var html = this.getQuoteHtml(response.quotes[i]);
			$(".quotes").append(html);
		}
		makeDraggable();
	},

	displayEmptyMessage: function(quotes) {
		$(".no-search-results, .no-favorites, .no-bookclub-quotes, .no-user-quotes").html("");
		if (quotes.length == 0) {
			$(".no-favorites").html("You currently have no favorited quotes.");
		}
	},

	getQuoteHtml: function(quote) {
		var html = "<div class='quote' id='" + quote.id + "'>" +
			"<div class='content'><img src='/icons/openingquote.png'><p>" + quote.content + "</p><img src='/icons/closingquote.png'></div>" +
				"<div class='quote-info'><a class='search-author' data-method='get'" +
				"href='/search?q%5Bauthor_name_cont%5D=" + encodeURI(quote.author_name) + "' rel='nofollow'>" + quote.author_name + "</a>"
		if (quote.book_title != "") {
			html = html + "<br/>" +
				"<a class='search-title' data-method='get'" +
				"href='/search?q%5Bbook_title_cont%5D=" + encodeURI(quote.book_title) + 
				"' rel='nofollow'>" + quote.book_title + "</a>";
		}			
{'fraction_non_alphanumeric': 0.21135590184488626, 'fraction_numerical': 0.001970266881604872, 'mean_word_length': 4.035166816952209, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2252087', 'n_tokens_mistral': 2206, 'n_tokens_neox': 1975, 'n_words': 341}