-
Notifications
You must be signed in to change notification settings - Fork 0
Working #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Working #1
Changes from 1 commit
7dc6389
1bb5267
99b5762
c9fbb06
a05be79
b1cf3e8
cb53124
f1a8512
0936c8a
4b456f2
70f47ff
b6c47d6
d84fe20
a1179f8
0c69b3e
f7cd2a8
3636658
525cf68
7a36f06
c3fd3c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,16 +4,18 @@ var search = document.getElementById("search"); | |
|
|
||
| search.addEventListener("click", () => { | ||
| var searchText = document.getElementById("searchText").value; | ||
| url = `https://www.googleapis.com/books/v1/volumes?q=${searchText}&maxResults=40`; | ||
| url = `https://www.googleapis.com/books/v1/volumes?q=${searchText}&download=pdf&maxResults=40`; | ||
| if (searchText !== "" && searchText.trim(" ").length !== 0) { | ||
| getData(url); | ||
|
|
||
| } else { | ||
| window.alert("Please enter a search term that contains at least one alphanumeric character") | ||
| } | ||
| searchText = ""; | ||
| }) | ||
|
|
||
| window.onload = () => { | ||
| url = "https://www.googleapis.com/books/v1/volumes?q=pride+prejudice&maxResults=40" | ||
| url = "https://www.googleapis.com/books/v1/volumes?q=pride+prejudice&download=epub&maxResults=40" | ||
|
||
| getData(url); | ||
| } | ||
|
|
||
|
|
@@ -25,6 +27,7 @@ const getData = (url) => { | |
| var data = JSON.parse(request.responseText); | ||
| var books = data.items; | ||
| var eligible = []; | ||
| console.log(eligible); | ||
| for (x = 0; x < books.length; x++) { | ||
| if (books[x].volumeInfo.imageLinks != null && books[x].volumeInfo.authors != null && books[x].volumeInfo.industryIdentifiers != null) { | ||
|
||
| eligible.push(books[x]); | ||
|
|
@@ -56,13 +59,14 @@ const displayCards = (books, i) => { | |
| <div class="col-xl-2 text-center"> | ||
| <a href="${info.previewLink}" class="bkCover" target="_blank"><img src="${info.imageLinks.thumbnail}" class="card-img m-2" alt="cover" style="width:200px;"></a> | ||
|
|
||
| <p><a href="${info.infoLink}" class="card-link text-success" target="_blank">Get book</a></p> | ||
| <p><a href="${books[i].accessInfo.pdf.downloadLink}" class="card-link text-success" target="_blank">Download</a></p> | ||
|
|
||
| </div> | ||
|
|
||
| <div class="col-xl-10"> | ||
| <div class="card-body"> | ||
| <h5 class="card-title">${info.title}</h5> | ||
| <h6 class="card-subtitle mb-2 text-muted"></h6> | ||
| <p class="card-text">${info.description}</p> | ||
| </div> | ||
| <ul class="list-group list-group-flush"> | ||
|
|
@@ -73,7 +77,7 @@ const displayCards = (books, i) => { | |
| <li class="list-group-item">Category: ${info.categories}</li> | ||
| </ul> | ||
| <div class="card-footer text-muted"> | ||
| Data from <a href="https://books.google.com/" class="card-link text-success" target="_blank">Google Books</a> | ||
| Data from <a href="${info.infoLink}" class="card-link text-success" target="_blank">Google Books</a> | ||
| </div> | ||
|
|
||
| </div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an abstraction for the repeated code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't think of that before. Will do that now. Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done