<commit_before>$(document).ready( function() {
	// Add background
	$.backstretch('img/background.jpg');

	if(setupLoaded===true){
		getBooks("getPopularBooks");
	}
	else if(discoveryLoaded===true){
		getBooks("getRandomBook");
	}
	else if(listLoaded===true){
		getBooks("getReadingList?email=<EMAIL>");
	}

}); 

function greyOutElement (event) {
	var target = $(event.target);
	console.log(target);
	target.closest("li").fadeTo('fast',0.3).css('pointer-events','none').css('')
}

var setupLoaded = false;
var loginLoaded = false;
var discoveryLoaded = false;
var listLoaded = false;

var rootURL= "http://localhost:8888/api/index.php";

function checkForSetup(){
	setupLoaded=true;
}
function checkForLogin(){
	loginLoaded=true;
}
function checkForDiscovery(){
	discoveryLoaded=true;
}
function checkForList(){
	listLoaded=true;
}

var userEmail= "";

function setEmail(){
	var emailElem = document.getElementById("email");
	var emailVal=emailElem.getAttribute("value");
	console.log(emailVal);
	userEmail=emailVal;
}

function Book( title, author, cover, description){
	this.title=title;
	this.author=author;
	this.description=description;
	this.cover=cover;
}

//use for api calls to getRandomBook, getPopularBooks, getReadingList
function getBooks(sourceURL) {

	$.ajax({
		type: 'GET',
		url: rootURL + "/" + sourceURL,
		dataType: "json",
		success: function (data) {
			var bookObjs = data.Books; 
		 	if(sourceURL.indexOf("getReadingList") > -1){
		 		for(var i=0; i<bookObjs.length; i+=2){	
					var parsedBooks = $.parseJSON(bookObjs[i].book);	
					var title= parsedBooks.items[0].volumeInfo.title;
					var author =parsedBooks.items[0].volumeInfo.authors.join(', ');
					var description =parsedBooks.items[0].volumeInfo.description;
					var thumbnail=parsedBooks.items[0].volumeInfo.imageLinks.thumbnail;
					var cover = new Image();
					cover.src = thumbnail;
					var newBook= new Book(title, author, cover,description);
				 	generateHTMLForReadingList(newBook);
				} 	
			 
			 }
			else if (sourceURL==="getRandomBook") {
				for(var i=0; i<bookObjs.length; i+=2){	
					var parsedBooks = $.parseJSON(bookObjs[i]);
					console.log(i);	
					console.log(bookObjs[i]);
					var title= parsedBooks.items[0].volumeInfo.title;
					var author =parsedBooks.items[0].volumeInfo.authors.join(', ');
					var description =parsedBooks.items[0].volumeInfo.description;
					var thumbnail=parsedBooks.items[0].volumeInfo.imageLinks.thumbnail;
					var cover = new Image();
					cover.src = thumbnail;
					var newBook= new Book(title, author, cover,description);
				 	generateHTMLForDiscoveryPage(newBook);
				 	
				}
			}
			else if (sourceURL==="getPopularBooks") {
				for(var i=0; i<bookObjs.length; i+=1){	
					var parsedBooks = $.parseJSON(bookObjs[i]);
					console.log(i);	
					if (i === 4) continue; // DELETE THIS LINE WHEN DB IS CLEANED UP
					var title= parsedBooks.items[0].volumeInfo.title;
					var author =parsedBooks.items[0].volumeInfo.authors.join(', ');
					var description =parsedBooks.items[0].volumeInfo.description;
					var thumbnail=parsedBooks.items[0].volumeInfo.imageLinks.thumbnail;
					var cover = new Image();
					cover.src = thumbnail;
					var newBook= new Book(title, author, cover,description);
				 		generateHTMLForSetupPage(newBook);
				 	
				}
				$('.setupratingbutton').click(greyOutElement);
			}
		}	
	});
}


//TODO: implement and test
function addBookToReadingList(email, isbn) {

	$.ajax({
		type: 'POST',
		url: rootURL + "/addBookToReadingList?email=" + email + "&isbn=" + isbn,
		dataType: " ",
		success: function (data) {
			
		}	
	});
}<commit_msg>Prints ISBNs, so we can find the bad DB entries.<commit_after>$(document).ready( function() {
	// Add background
	$.backstretch('img/background.jpg');

	if(setupLoaded===true){
		getBooks("getPopularBooks");
	}
	else if(discoveryLoaded===true){
		getBooks("getRandomBook");
	}
	else if(listLoaded===true){
		getBooks("getReadingList?email=<EMAIL>");
	}

}); 

function greyOutElement (event) {
	var target = $(event.target);
	console.log(target);
	target.closest("li").fadeTo('fast',0.3).css('pointer-events','none').css('')
}

var setupLoaded = false;
var loginLoaded = false;
var discoveryLoaded = false;
var listLoaded = false;

var rootURL= "http://localhost:8888/api/index.php";

function checkForSetup(){
	setupLoaded=true;
}
function checkForLogin(){
	loginLoaded=true;
}
function checkForDiscovery(){
	discoveryLoaded=true;
}
function checkForList(){
	listLoaded=true;
}

var userEmail= "";

function setEmail(){
	var emailElem = document.getElementById("email");
	var emailVal=emailElem.getAttribute("value");
	console.log(emailVal);
	userEmail=emailVal;
}

function Book( title, author, cover, description){
	this.title=title;
	this.author=author;
	this.description=description;
	this.cover=cover;
}

//use for api calls to getRandomBook, getPopularBooks, getReadingList
function getBooks(sourceURL) {

	$.ajax({
		type: 'GET',
		url: rootURL + "/" + sourceURL,
		dataType: "json",
		success: function (data) {
			var bookObjs = data.Books; 
		 	if(sourceURL.indexOf("getReadingList") > -1){
		 		for(var i=0; i<bookObjs.length; i+=2){	
					var parsedBooks = $.parseJSON(bookObjs[i].book);	
					var title= parsedBooks.items[0].volumeInfo.title;
					var author =parsedBooks.items[0].volumeInfo.authors.join(', ');
					var description =parsedBooks.items[0].volumeInfo.description;
					var thumbnail=parsedBooks.items[0].volumeInfo.imageLinks.thumbnail;
					var cover = new Image();
					cover.src = thumbnail;
					var newBook= new Book(title, author, cover,description);
				 	generateHTMLForReadingList(newBook);
				} 	
			 
			 }
			else if (sourceURL==="getRandomBook") {
				for(var i=0; i<bookObjs.length; i+=2){	
					var parsedBooks = $.parseJSON(bookObjs[i]);
					console.log(i);	
					console.log(bookObjs[i]);
					var title= parsedBooks.items[0].volumeInfo.title;
					var author =parsedBooks.items[0].volumeInfo.authors.join(', ');
					var description =parsedBooks.items[0].volumeInfo.description;
					var thumbnail=parsedBooks.items[0].volumeInfo.imageLinks.thumbnail;
					var cover = new Image();
					cover.src = thumbnail;
					var newBook= new Book(title, author, cover,description);
				 	generateHTMLForDiscoveryPage(newBook);
				 	
				}
			}
			else if (sourceURL==="getPopularBooks") {
				for(var i=0; i<bookObjs.length; i+=1){	
					var parsedBooks = $.parseJSON(bookObjs[i]);
					console.log(i);
					if (i === 4) continue; // DELETE THIS LINE WHEN DB IS CLEANED UP
					console.log(parsedBooks.items[0].volumeInfo.industryIdentifiers);
					var title= parsedBooks.items[0].volumeInfo.title;
					var author =parsedBooks.items[0].volumeInfo.authors.join(', ');
					var description =parsedBooks.items[0].volumeInfo.description;
					var thumbnail=parsedBooks.items[0].volumeInfo.imageLinks.thumbnail;
					var cover = new Image();
					cover.src = thumbnail;
					var newBook= new Book(title, author, cover,description);
				 		generateHTMLForSetupPage(newBook);
				 	
				}
				$('.setupratingbutton').click(greyOutElement);
			}
		}	
	});
}


//TODO: implement and test
function addBookToReadingList(email, isbn) {

	$.ajax({
		type: 'POST',
		url: rootURL + "/addBookToReadingList?email=" + email + "&isbn=" + isbn,
		dataType: " ",
		success: function (data) {
			
		}	
	});
}
{'fraction_non_alphanumeric': 0.15140797170453, 'fraction_numerical': 0.007209903414501428, 'mean_word_length': 4.162921348314606, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '4584352', 'n_tokens_mistral': 2898, 'n_tokens_neox': 2437, 'n_words': 470}