-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbookSearchJS.js
More file actions
63 lines (57 loc) · 2.52 KB
/
bookSearchJS.js
File metadata and controls
63 lines (57 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
$(document).ready(function(){
$("#searchBookForm").submit(function(event){
event.preventDefault();
var search = $("#searchISBN").val();
if (search == '') {
alert("Please enter an ISBN");
}else{
var url = '';
var img = '';
var title = '';
var author = '';
var description = '';
//var genre = ''; //No Genre in Google Books API
var edition = '';
var isbn_13 = '';
var year = '';
var publisher = '';
var pages = '';
$.get("https://www.googleapis.com/books/v1/volumes?q="+search, function(response){
if ((response.items[0].volumeInfo.title) != undefined) {
title = response.items[0].volumeInfo.title;
}
if ((response.items[0].volumeInfo.subtitle) != undefined) {
title = title + ": " + response.items[0].volumeInfo.subtitle;
}
if ((response.items[0].volumeInfo.authors) != undefined) {
author = response.items[0].volumeInfo.authors;
}
if ((response.items[0].volumeInfo.imageLinks.thumbnail) != undefined) {
image = response.items[0].volumeInfo.imageLinks.thumbnail;
}
if ((response.items[0].volumeInfo.infoLink) != undefined) {
url = response.items[0].volumeInfo.infoLink;
}
if ((response.items[0].volumeInfo.description) != undefined) {
description = response.items[0].volumeInfo.description;
}
if ((response.items[0].volumeInfo.industryIdentifiers[0].identifier) != undefined) {
isbn_13 = response.items[0].volumeInfo.industryIdentifiers[0].identifier;
}
if ((response.items[0].volumeInfo.publishedDate) != undefined) {
year = response.items[0].volumeInfo.publishedDate;
}
if ((response.items[0].volumeInfo.publisher) != undefined) {
publisher = response.items[0].volumeInfo.publisher;
}
if ((response.items[0].volumeInfo.pageCount) != undefined) {
pages = response.items[0].volumeInfo.pageCount;
}
window.location.href = "bookinfo.php?title=" + title + "&author=" + author
+ "&url=" + url + "&description=" + description + "&ISBN=" +isbn_13+ "&year="+year
+ "&publisher="+publisher+"&pages="+pages+"&image="+image;
});
}
});
return false;
});