Compare commits

..

No commits in common. "7ee118c1cdaa900287dad4fe62bf7f5aa2a7feaa" and "b52949f3e900a24fb6aaba98fc4d8e276ab7ddd6" have entirely different histories.

2 changed files with 20 additions and 19 deletions

View File

@ -16,6 +16,20 @@ function init() {
}); });
} }
function apiResponseParsing(book) {
book.sortTitle = titleCleaner(book.title);
if (!book["isbn-10"] && book["isbn-13"]) {
book["isbn-10"] = ISBNfromEAN(book["isbn-13"]);
}
if (!book.coverurl && book["isbn-10"]) {
book.coverurl =
`https://images-na.ssl-images-amazon.com/images/P/` +
book["isbn-10"] +
`.01.LZZ.jpg`;
}
return book;
}
function renderTable(books, sortField) { function renderTable(books, sortField) {
if (sortField) { if (sortField) {
if (sortState.sortBy === sortField && sortState.sortOrder === "asc") { if (sortState.sortBy === sortField && sortState.sortOrder === "asc") {
@ -64,20 +78,6 @@ function renderTable(books, sortField) {
.classList.add(sortState.sortOrder); .classList.add(sortState.sortOrder);
} }
function apiResponseParsing(book) {
book.sortTitle = titleCleaner(book.title);
if (!book["isbn-10"] && book["isbn-13"]) {
book["isbn-10"] = ISBNfromEAN(book["isbn-13"]);
}
if (!book.coverURL && book["isbn-10"]) {
book.coverURL =
`https://images-na.ssl-images-amazon.com/images/P/` +
book["isbn-10"] +
`.01.LZZ.jpg`;
}
return book;
}
function search(books, searchBy) { function search(books, searchBy) {
searchBy = searchCleaner(searchBy); searchBy = searchCleaner(searchBy);
if (searchBy !== "") { if (searchBy !== "") {
@ -123,7 +123,7 @@ function ISBNfromEAN(EAN) {
function BookTemplate({ function BookTemplate({
"isbn-13": isbn13, "isbn-13": isbn13,
authors, authors,
coverURL, coverurl,
description, description,
format, format,
notes, notes,
@ -135,7 +135,7 @@ function BookTemplate({
volume, volume,
year, year,
}) { }) {
return `${coverURL ? `<img src="${coverURL}"/>` : ""} return `${coverurl ? `<img src="${coverurl}"/>` : ""}
<h1 ${onLoan ? "class='onLoan' " : ""}>${title}</h1> <h1 ${onLoan ? "class='onLoan' " : ""}>${title}</h1>
<h2>${authors}</h2> <h2>${authors}</h2>
<span>${isbn13}</span><br/> <span>${isbn13}</span><br/>
@ -189,3 +189,7 @@ function TableTemplate(books) {
return acc.concat(TableRowTemplate(book)); return acc.concat(TableRowTemplate(book));
}, "")} </table>`; }, "")} </table>`;
} }
window.addEventListener("DOMContentLoaded", () => {
init();
});

View File

@ -14,9 +14,6 @@
rel="stylesheet preload prefetch" rel="stylesheet preload prefetch"
/> />
<script type="text/javascript" src="app.js"></script> <script type="text/javascript" src="app.js"></script>
<script type="text/javascript">
window.addEventListener("DOMContentLoaded", init);
</script>
</head> </head>
<body> <body>
<div class="wrapper"> <div class="wrapper">