From cc7cb81a1b360d98314849228e9e85d50bd04f68 Mon Sep 17 00:00:00 2001 From: aundus Date: Thu, 26 Nov 2020 12:51:08 -0500 Subject: [PATCH] link script externally --- templates/bibrec.html | 3 ++- templates/book.js | 59 ------------------------------------------- 2 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 templates/book.js diff --git a/templates/bibrec.html b/templates/bibrec.html index 427bc24..dd0764a 100644 --- a/templates/bibrec.html +++ b/templates/bibrec.html @@ -62,6 +62,7 @@ Gutenberg metadata much faster than by scraping. .qrcode { background: transparent url(${os.qrcode_url}) 0 0 no-repeat; } + @@ -384,7 +385,7 @@ ${site_top()} - + diff --git a/templates/book.js b/templates/book.js deleted file mode 100644 index 0456844..0000000 --- a/templates/book.js +++ /dev/null @@ -1,59 +0,0 @@ -(function ($) { - const addbtn = $('#add-to-booklist') - const url = window.location && window.location.toString().split('/') - const bookId = url[url.length - 1].match(/(\d+)/)[0] - - const currentList = JSON.parse(localStorage.getItem('booklist')) - if (currentList && currentList[bookId]) { - // book already in list - addbtn.html('-') - addbtn.attr('title', 'Remove book from My Book List') - addbtn.css('background-color', 'indianred') - addbtn.addClass('book-in-list') - } - - addbtn.on('click', function (event) { - if (addbtn.hasClass('book-in-list')) { - removeBook() - return - } - // add book to list - let author = '' - $('tbody>tr').each(function (index) { - const row = $(this) - const rowTitle = row.find('th:first').html() - if (rowTitle === 'Author') { - const tableRow = row.find('td:first') - author = tableRow.find('a:first').html() - } - }) - const bookData = { - title: $('h1').html(), - bookId: bookId, - imgSrc: $('img.cover-art').attr('src'), - author: author, - url: window.location.href - } - - const newList = { ...JSON.parse(localStorage.getItem('booklist')) } - newList[bookId] = bookData - addbtn.addClass('book-in-list') - addbtn.html('-') - addbtn.attr('title', 'Remove book from My Book List') - addbtn.css('background-color', 'indianred') - - localStorage.setItem('booklist', JSON.stringify(newList)) - console.log(localStorage.getItem('booklist')) - }) - - function removeBook () { - const newlist = JSON.parse(localStorage.getItem('booklist')) - delete newlist[bookId] - localStorage.setItem('booklist', JSON.stringify(newlist)) - console.log(localStorage.getItem('booklist')) - addbtn.removeClass('book-in-list') - addbtn.html('+') - addbtn.attr('title', 'Add book to My Book List') - addbtn.css('background-color', 'cornflowerblue') - } -})(jQuery) // eslint-disable-line