-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (70 loc) · 2.84 KB
/
index.html
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
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="./styles/style.css">
<script src="/scripts/scripts.js"></script>
<script src="https://kit.fontawesome.com/026f86d8a9.js" crossorigin="anonymous"></script>
<title>Book search App</title>
</head>
<body>
<header><a href="#" class="header-logo">BookFinder app</a><div class="navbar-links">
<a href="#contact">Contact</a></li>
<a href="#about">About</a>
</div></header>
<div class="root-container">
<div class="search">
<h1 class="title">Search some books!</h1>
<div class="lookup">
<input type="text" class="search-box" placeholder="search by name"><button title="Search" class="lookup-button"><i class="fa-solid fa-magnifying-glass"></i></button>
</div>
</div><div id="loading-spinner" class="hidden"></div>
<div id="books-container" class="hidden">
</div>
</div>
<footer>Made by <a href="https://github.com/alexander15M" class="personal-link">Alexander M</a></footer>
<script>
async function createBookCards () {
const items = await retrieveData() || [];
let finalHtml = "";
for (let i = 0; i < items.length; i++) {
if (i > 8) {
break
}
const book = items[i];
let thumbnail = book?.volumeInfo?.imageLinks?.thumbnail || "#";
thumbnail = thumbnail.replace("http://", "https://")
let title = book?.volumeInfo?.title || "";
title = title.split(" /")[0];
if (title.length > 110) {
title = `${title.substring(0, 109)}...`
}
const author = book?.volumeInfo?.authors ? book.volumeInfo.authors[0] : 'Not available';
const publisher = book?.volumeInfo?.publisher || "Not available"
const publishedDate = book?.volumeInfo?.publishedDate || "Not available"
const div_book_card = `<div class="book-card">
<div class="book-content">
<div class=thumbnail-container>
<img class="book-thumbnail" src="${thumbnail}" alt="">
</div>
<div class="book-info">
<h2 class="book-title">${title}</h2>
<p><b class="book-info-title">Author</b>: ${author}</p>
<p><b class="book-info-title">Publisher</b>: ${publisher}</p>
<p><b class="book-info-title">Published Date</b>: ${publishedDate}</p>
<a class="know-more" href="${book?.volumeInfo?.previewLink || '#'}">Preview</a>
</div>
</div>
</div>`;
finalHtml += div_book_card + "\n";
}
const bookContainer = document.getElementById("books-container");
bookContainer.innerHTML = finalHtml;
hideLoading();
bookContainer.classList.remove("hidden")
}
</script>
</body>
</html>