From 3e1b06e95afdd1cab86257381fda590ef98e161b Mon Sep 17 00:00:00 2001 From: David Ashby Date: Sun, 31 Oct 2021 20:07:41 -0400 Subject: [PATCH] move actual onload trigger back into the html file --- frontend/files/app.js | 32 ++++++++++++++------------------ frontend/files/index.html | 3 +++ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/frontend/files/app.js b/frontend/files/app.js index b7ada36..87d0b4e 100644 --- a/frontend/files/app.js +++ b/frontend/files/app.js @@ -16,20 +16,6 @@ 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) { if (sortField) { if (sortState.sortBy === sortField && sortState.sortOrder === "asc") { @@ -78,6 +64,20 @@ function renderTable(books, sortField) { .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) { searchBy = searchCleaner(searchBy); if (searchBy !== "") { @@ -189,7 +189,3 @@ function TableTemplate(books) { return acc.concat(TableRowTemplate(book)); }, "")} `; } - -window.addEventListener("DOMContentLoaded", () => { - init(); -}); diff --git a/frontend/files/index.html b/frontend/files/index.html index 46b09a9..5e0b3b1 100644 --- a/frontend/files/index.html +++ b/frontend/files/index.html @@ -14,6 +14,9 @@ rel="stylesheet preload prefetch" /> +