functional prototype

pull/1/head
Adam Undus 2020-10-07 20:55:50 -04:00
parent 543897a3e8
commit 8790635973
5 changed files with 584 additions and 441 deletions

View File

@ -149,7 +149,9 @@
<h1><span class="icon icon_"></span>My Booklist</h1>
</div>
<div class="body">
My content
<ul id="book-list">
</ul>
</div>
</div>

View File

@ -1,5 +1,20 @@
(function ($) {
const list = JSON.parse(localStorage.getItem('booklist'))
console.log(list)
const body = $('#book-list');
console.log()
Object.keys(list).forEach((bookId) => {
console.log(bookId)
body.append(makeListItem(list[bookId]));
});
function makeListItem(book) {
const a = `<a href="${book.url}"><h3>${book.title}</h3></a>`;
const li = `<li><div class="list-item"><img src="${book.imgSrc}"/>${a}<span>Author: ${book.author}</span><div></li>`;
console.log(li)
return li;
}
})(jQuery);

View File

@ -4,18 +4,18 @@ DON'T USE THIS PAGE FOR SCRAPING.
Seriously. You'll only get your IP blocked.
Read http://www.gutenberg.org/feeds/ to learn how to download Project
Gutenberg metadata much faster than by scraping.
--><html lang="en">
-->
<html lang="en">
<head>
<style>
.icon { background: transparent url(/pics/sprite.png?1600787134) 0 0 no-repeat; }
.icon {
background: transparent url(/pics/sprite.png?1600787134) 0 0 no-repeat;
}
</style>
<link rel="stylesheet" type="text/css" href="/gutenberg/pg-desktop-one.css?1600787134">
<link rel="stylesheet" type="text/css" href="/gutenberg/new_nav.css?1600787134">
<link rel="stylesheet" type="text/css" href="/gutenberg/style.css?1600787134">
<link rel="stylesheet" type="text/css" href="https://www.gutenberg.org/gutenberg/pg-desktop-one.css?1600787134">
<link rel="stylesheet" type="text/css" href="https://www.gutenberg.org/gutenberg/new_nav.css?1600787134">
<link rel="stylesheet" type="text/css" href="https://www.gutenberg.org/gutenberg/style.css?1600787134">
<script>//
var json_search = "/ebooks/suggest/";
var canonical_url = "http://www.gutenberg.org/ebooks/2542";
@ -25,12 +25,15 @@ var msg_load_more = "Load More Results…";
var page_mode = "screen";
var dialog_title = "";
var dialog_message = "";
//</script>
//
</script>
<script src="https://www.gutenberg.org/js/pg-desktop-one.js?1600787134"></script>
<link rel="shortcut icon" href="/gutenberg/favicon.ico">
<link rel="canonical" href="http://www.gutenberg.org/ebooks/2542">
<link rel="search" type="application/opensearchdescription+xml" title="Search Project Gutenberg" href="https://www.gutenberg.org/catalog/osd-books.xml">
<link rel="alternate nofollow" type="application/atom+xml;profile=opds-catalog" title="OPDS feed" href="/ebooks/2542.opds">
<link rel="search" type="application/opensearchdescription+xml" title="Search Project Gutenberg"
href="https://www.gutenberg.org/catalog/osd-books.xml">
<link rel="alternate nofollow" type="application/atom+xml;profile=opds-catalog" title="OPDS feed"
href="/ebooks/2542.opds">
<link rel="apple-touch-icon" href="/gutenberg/apple-icon.png">
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
@ -53,10 +56,13 @@ var dialog_message = "";
<title>A Doll's House : a play by Henrik Ibsen - Free Ebook</title>
<link rel="alternate nofollow" type="application/rdf+xml" href="/ebooks/2542.rdf">
<style>
.qrcode { background: transparent url(/cache/epub/2542/pg2542.qrcode.png) 0 0 no-repeat; }
.qrcode {
background: transparent url(/cache/epub/2542/pg2542.qrcode.png) 0 0 no-repeat;
}
</style>
<meta name="google" content="notranslate">
</head>
<body>
<div class="container">
<nav>
@ -122,8 +128,10 @@ var dialog_message = "";
</div>
<div class="donate">
<div class="searchbox">
<form method="get" action="/ebooks/search/" accept-charset="utf-8" enctype="multipart/form-data" class="searchbox">
<input type="text" value="" id="menu-book-search" name="query" class="searchInput" title="Quick search" tabindex="20" size="20" maxlength="80" placeholder=" Quick search">
<form method="get" action="/ebooks/search/" accept-charset="utf-8" enctype="multipart/form-data"
class="searchbox">
<input type="text" value="" id="menu-book-search" name="query" class="searchInput" title="Quick search"
tabindex="20" size="20" maxlength="80" placeholder=" Quick search">
<input type="submit" name="submit_search" value="Go!" style="vertical-align:middle;">
</form>
</div>
@ -131,7 +139,8 @@ var dialog_message = "";
<p><a href="/donate/">Donation</a></p>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XKAL6BZL3YPSN">
<input class="donbtn" type="image" src="https://www.gutenberg.org/pics/en_US.gif" name="submit" alt="Donate via PayPal">
<input class="donbtn" type="image" src="https://www.gutenberg.org/pics/en_US.gif" name="submit"
alt="Donate via PayPal">
</form>
</div>
</nav>
@ -144,11 +153,13 @@ var dialog_message = "";
</li>
<li class="breadcrumb next" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
<span class="breadcrumb-separator"></span>
<a href="/ebooks/" title="Start a new search." itemprop="url"><span itemprop="title">63,327 free ebooks</span></a>
<a href="/ebooks/" title="Start a new search." itemprop="url"><span itemprop="title">63,327 free
ebooks</span></a>
</li>
<li class="breadcrumb next" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
<span class="breadcrumb-separator"></span>
<a href="/ebooks/author/861" title="Find more ebooks by the same author." itemprop="url"><span itemprop="title">52 by Henrik Ibsen</span></a>
<a href="/ebooks/author/861" title="Find more ebooks by the same author." itemprop="url"><span
itemprop="title">52 by Henrik Ibsen</span></a>
</li>
</ul>
</div>
@ -158,21 +169,25 @@ var dialog_message = "";
<div itemprop="bookFormat" content="EBook"></div>
<div id="cover-social-wrapper">
<div id="cover">
<img class="cover-art" src="https://www.gutenberg.org/cache/epub/2542/pg2542.cover.medium.jpg" title="Book Cover" alt="Book Cover" itemprop="image">
<img class="cover-art" src="https://www.gutenberg.org/cache/epub/2542/pg2542.cover.medium.jpg"
title="Book Cover" alt="Book Cover" itemprop="image">
</div>
<div id="social" class="noprint">
<ul>
<li>
<!-- tweet without javascript -->
<div class="social-button twitter-share-button">
<a href="https://twitter.com/share?url=http%3A%2F%2Fwww.gutenberg.org%2Febooks%2F2542&amp;text=A%20Doll%27s%20House%20%3A%20a%20play%20by%20Henrik%20Ibsen&amp;count=none&amp;lang=en&amp;related=gutenberg_new%3AProject%20Gutenberg%20New%20Books" title="Share on Twitter" onclick="open_share_popup(this.href, this.target, 640, 320)" target="_top">
<a href="https://twitter.com/share?url=http%3A%2F%2Fwww.gutenberg.org%2Febooks%2F2542&amp;text=A%20Doll%27s%20House%20%3A%20a%20play%20by%20Henrik%20Ibsen&amp;count=none&amp;lang=en&amp;related=gutenberg_new%3AProject%20Gutenberg%20New%20Books"
title="Share on Twitter" onclick="open_share_popup(this.href, this.target, 640, 320)" target="_top">
<span class="icon icon_twitter"></span>
</a>
</div>
</li>
<li>
<div class="social-button fb-share-button">
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.gutenberg.org%2Febooks%2F2542" title="Share on Facebook" onclick="open_share_popup(this.href, this.target, 640, 320)" target="_top">
<a href="https://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.gutenberg.org%2Febooks%2F2542"
title="Share on Facebook" onclick="open_share_popup(this.href, this.target, 640, 320)"
target="_top">
<span class="icon icon_facebook"></span>
</a>
</div>
@ -191,6 +206,9 @@ var dialog_message = "";
<div id="download">
<div about="[ebook:2542]" rel="dcterms:hasFormat">
<h2>Download This eBook</h2>
<button id="add-to-booklist"
style="float: right;padding: 3px 5px;margin-top: -50px;background-color: cornflowerblue;">Add to My
Book List</button>
<table class="files">
<colgroup>
<col class="narrow">
@ -204,99 +222,137 @@ var dialog_message = "";
<tr>
<th></th>
<th>Format <span>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#Format" title="Explain Format."><span class="icon icon_help noprint"></span></a>
</span></th>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#Format" title="Explain Format."><span
class="icon icon_help noprint"></span></a>
</span>
</th>
<th class="noscreen">Url</th>
<th class="right">Size</th>
<th class="noprint"><span>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#Dropbox" title="Explain Dropbox."><span class="icon icon_help noprint"></span></a>
</span></th>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#Dropbox"
title="Explain Dropbox."><span class="icon icon_help noprint"></span></a>
</span>
</th>
<th class="noprint"><span>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#Google_Drive" title="Explain Google Drive."><span class="icon icon_help noprint"></span></a>
</span></th>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#Google_Drive"
title="Explain Google Drive."><span class="icon icon_help noprint"></span></a>
</span>
</th>
<th class="noprint"><span>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#OneDrive" title="Explain OneDrive."><span class="icon icon_help noprint"></span></a>
</span></th>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#OneDrive"
title="Explain OneDrive."><span class="icon icon_help noprint"></span></a>
</span>
</th>
</tr>
<tr class="even" about="https://www.gutenberg.org/files/2542/2542-h/2542-h.htm" typeof="pgterms:file">
<td><span class="icon icon_book"></span></td>
<td property="dcterms:format" content="text/html; charset=us-ascii" datatype="dcterms:IMT" class="unpadded icon_save"><a href="/files/2542/2542-h/2542-h.htm" type="text/html; charset=us-ascii" class="link" title="Download">Read this book online: HTML</a></td>
<td property="dcterms:format" content="text/html; charset=us-ascii" datatype="dcterms:IMT"
class="unpadded icon_save"><a href="/files/2542/2542-h/2542-h.htm"
type="text/html; charset=us-ascii" class="link" title="Download">Read this book online: HTML</a>
</td>
<td class="noscreen">https://www.gutenberg.org/files/2542/2542-h/2542-h.htm</td>
<td class="right" property="dcterms:extent" content="259276">253 kB</td>
<td class="noprint">
</td>
<td class="noprint">
</td>
<td class="right" property="dcterms:extent" content="259276">253 kB</td>
<td class="noprint"></td>
<td class="noprint"></td>
<td class="noprint">
<a href="/ebooks/send/megaupload/2542.html" title="Send to MegaUpload." rel="nofollow"></a>
</td>
</tr><tr class="even" about="https://www.gutenberg.org/ebooks/2542.epub.images" typeof="pgterms:file">
</tr>
<tr class="even" about="https://www.gutenberg.org/ebooks/2542.epub.images" typeof="pgterms:file">
<td><span class="icon icon_book"></span></td>
<td property="dcterms:format" content="application/epub+zip" datatype="dcterms:IMT" class="unpadded icon_save"><a href="/ebooks/2542.epub.images?session_id=945185eaedb27a3680d733ac7035fc6b3c4209bb" type="application/epub+zip" class="link" title="Download">EPUB (with images)</a></td>
<td property="dcterms:format" content="application/epub+zip" datatype="dcterms:IMT"
class="unpadded icon_save"><a
href="/ebooks/2542.epub.images?session_id=945185eaedb27a3680d733ac7035fc6b3c4209bb"
type="application/epub+zip" class="link" title="Download">EPUB (with images)</a></td>
<td class="noscreen">https://www.gutenberg.org/ebooks/2542.epub.images</td>
<td class="right" property="dcterms:extent" content="115185">112 kB</td>
<td class="right" property="dcterms:extent" content="115185">112 kB</td>
<td class="noprint">
<a href="/ebooks/send/dropbox/2542.epub.images" title="Send to Dropbox." rel="nofollow"><span class="icon icon_dropbox"></span></a>
<a href="/ebooks/send/dropbox/2542.epub.images" title="Send to Dropbox." rel="nofollow"><span
class="icon icon_dropbox"></span></a>
</td>
<td class="noprint">
<a href="/ebooks/send/gdrive/2542.epub.images" title="Send to Google Drive." rel="nofollow"><span class="icon icon_gdrive"></span></a>
<a href="/ebooks/send/gdrive/2542.epub.images" title="Send to Google Drive." rel="nofollow"><span
class="icon icon_gdrive"></span></a>
</td>
<td class="noprint">
<a href="/ebooks/send/msdrive/2542.epub.images" title="Send to OneDrive." rel="nofollow"><span class="icon icon_msdrive"></span></a>
<a href="/ebooks/send/msdrive/2542.epub.images" title="Send to OneDrive." rel="nofollow"><span
class="icon icon_msdrive"></span></a>
</td>
</tr><tr class="odd" about="https://www.gutenberg.org/ebooks/2542.epub.noimages" typeof="pgterms:file">
</tr>
<tr class="odd" about="https://www.gutenberg.org/ebooks/2542.epub.noimages" typeof="pgterms:file">
<td><span class="icon icon_book"></span></td>
<td property="dcterms:format" content="application/epub+zip" datatype="dcterms:IMT" class="unpadded icon_save"><a href="/ebooks/2542.epub.noimages?session_id=945185eaedb27a3680d733ac7035fc6b3c4209bb" type="application/epub+zip" class="link" title="Download">EPUB (no images)</a></td>
<td property="dcterms:format" content="application/epub+zip" datatype="dcterms:IMT"
class="unpadded icon_save"><a
href="/ebooks/2542.epub.noimages?session_id=945185eaedb27a3680d733ac7035fc6b3c4209bb"
type="application/epub+zip" class="link" title="Download">EPUB (no images)</a></td>
<td class="noscreen">https://www.gutenberg.org/ebooks/2542.epub.noimages</td>
<td class="right" property="dcterms:extent" content="115186">112 kB</td>
<td class="right" property="dcterms:extent" content="115186">112 kB</td>
<td class="noprint">
<a href="/ebooks/send/dropbox/2542.epub.noimages" title="Send to Dropbox." rel="nofollow"><span class="icon icon_dropbox"></span></a>
<a href="/ebooks/send/dropbox/2542.epub.noimages" title="Send to Dropbox." rel="nofollow"><span
class="icon icon_dropbox"></span></a>
</td>
<td class="noprint">
<a href="/ebooks/send/gdrive/2542.epub.noimages" title="Send to Google Drive." rel="nofollow"><span class="icon icon_gdrive"></span></a>
<a href="/ebooks/send/gdrive/2542.epub.noimages" title="Send to Google Drive."
rel="nofollow"><span class="icon icon_gdrive"></span></a>
</td>
<td class="noprint">
<a href="/ebooks/send/msdrive/2542.epub.noimages" title="Send to OneDrive." rel="nofollow"><span class="icon icon_msdrive"></span></a>
<a href="/ebooks/send/msdrive/2542.epub.noimages" title="Send to OneDrive." rel="nofollow"><span
class="icon icon_msdrive"></span></a>
</td>
</tr><tr class="even" about="https://www.gutenberg.org/ebooks/2542.kindle.images" typeof="pgterms:file">
</tr>
<tr class="even" about="https://www.gutenberg.org/ebooks/2542.kindle.images" typeof="pgterms:file">
<td><span class="icon icon_book"></span></td>
<td property="dcterms:format" content="application/x-mobipocket-ebook" datatype="dcterms:IMT" class="unpadded icon_save"><a href="/ebooks/2542.kindle.images?session_id=945185eaedb27a3680d733ac7035fc6b3c4209bb" type="application/x-mobipocket-ebook" class="link" title="Download">Kindle (with images)</a></td>
<td property="dcterms:format" content="application/x-mobipocket-ebook" datatype="dcterms:IMT"
class="unpadded icon_save"><a
href="/ebooks/2542.kindle.images?session_id=945185eaedb27a3680d733ac7035fc6b3c4209bb"
type="application/x-mobipocket-ebook" class="link" title="Download">Kindle (with images)</a>
</td>
<td class="noscreen">https://www.gutenberg.org/ebooks/2542.kindle.images</td>
<td class="right" property="dcterms:extent" content="501389">490 kB</td>
<td class="right" property="dcterms:extent" content="501389">490 kB</td>
<td class="noprint">
<a href="/ebooks/send/dropbox/2542.kindle.images" title="Send to Dropbox." rel="nofollow"><span class="icon icon_dropbox"></span></a>
<a href="/ebooks/send/dropbox/2542.kindle.images" title="Send to Dropbox." rel="nofollow"><span
class="icon icon_dropbox"></span></a>
</td>
<td class="noprint">
<a href="/ebooks/send/gdrive/2542.kindle.images" title="Send to Google Drive." rel="nofollow"><span class="icon icon_gdrive"></span></a>
<a href="/ebooks/send/gdrive/2542.kindle.images" title="Send to Google Drive."
rel="nofollow"><span class="icon icon_gdrive"></span></a>
</td>
<td class="noprint">
<a href="/ebooks/send/msdrive/2542.kindle.images" title="Send to OneDrive." rel="nofollow"><span class="icon icon_msdrive"></span></a>
<a href="/ebooks/send/msdrive/2542.kindle.images" title="Send to OneDrive." rel="nofollow"><span
class="icon icon_msdrive"></span></a>
</td>
</tr><tr class="odd" about="https://www.gutenberg.org/ebooks/2542.kindle.noimages" typeof="pgterms:file">
</tr>
<tr class="odd" about="https://www.gutenberg.org/ebooks/2542.kindle.noimages" typeof="pgterms:file">
<td><span class="icon icon_book"></span></td>
<td property="dcterms:format" content="application/x-mobipocket-ebook" datatype="dcterms:IMT" class="unpadded icon_save"><a href="/ebooks/2542.kindle.noimages?session_id=945185eaedb27a3680d733ac7035fc6b3c4209bb" type="application/x-mobipocket-ebook" class="link" title="Download">Kindle (no images)</a></td>
<td property="dcterms:format" content="application/x-mobipocket-ebook" datatype="dcterms:IMT"
class="unpadded icon_save"><a
href="/ebooks/2542.kindle.noimages?session_id=945185eaedb27a3680d733ac7035fc6b3c4209bb"
type="application/x-mobipocket-ebook" class="link" title="Download">Kindle (no images)</a></td>
<td class="noscreen">https://www.gutenberg.org/ebooks/2542.kindle.noimages</td>
<td class="right" property="dcterms:extent" content="501378">490 kB</td>
<td class="right" property="dcterms:extent" content="501378">490 kB</td>
<td class="noprint">
<a href="/ebooks/send/dropbox/2542.kindle.noimages" title="Send to Dropbox." rel="nofollow"><span class="icon icon_dropbox"></span></a>
<a href="/ebooks/send/dropbox/2542.kindle.noimages" title="Send to Dropbox." rel="nofollow"><span
class="icon icon_dropbox"></span></a>
</td>
<td class="noprint">
<a href="/ebooks/send/gdrive/2542.kindle.noimages" title="Send to Google Drive." rel="nofollow"><span class="icon icon_gdrive"></span></a>
<a href="/ebooks/send/gdrive/2542.kindle.noimages" title="Send to Google Drive."
rel="nofollow"><span class="icon icon_gdrive"></span></a>
</td>
<td class="noprint">
<a href="/ebooks/send/msdrive/2542.kindle.noimages" title="Send to OneDrive." rel="nofollow"><span class="icon icon_msdrive"></span></a>
<a href="/ebooks/send/msdrive/2542.kindle.noimages" title="Send to OneDrive." rel="nofollow"><span
class="icon icon_msdrive"></span></a>
</td>
</tr><tr class="even" about="https://www.gutenberg.org/ebooks/2542.txt.utf-8" typeof="pgterms:file">
</tr>
<tr class="even" about="https://www.gutenberg.org/ebooks/2542.txt.utf-8" typeof="pgterms:file">
<td><span class="icon icon_book"></span></td>
<td property="dcterms:format" content="text/plain" datatype="dcterms:IMT" class="unpadded icon_save"><a href="/ebooks/2542.txt.utf-8" type="text/plain" class="link" title="Download">Plain Text UTF-8</a></td>
<td property="dcterms:format" content="text/plain" datatype="dcterms:IMT"
class="unpadded icon_save"><a href="/ebooks/2542.txt.utf-8" type="text/plain" class="link"
title="Download">Plain Text UTF-8</a></td>
<td class="noscreen">https://www.gutenberg.org/ebooks/2542.txt.utf-8</td>
<td class="right" property="dcterms:extent" content="165572">162 kB</td>
<td class="noprint">
</td>
<td class="noprint">
</td>
<td class="noprint">
</td>
<td class="right" property="dcterms:extent" content="165572">162 kB</td>
<td class="noprint"></td>
<td class="noprint"></td>
<td class="noprint"></td>
</tr>
<tr class="even">
<td><span class="icon icon_folder"></span></td>
@ -309,7 +365,8 @@ var dialog_message = "";
</tr>
</table>
</div>
</div> <!-- download -->
</div>
<!-- download -->
<div id="more_stuff">
<h2 class="header">Similar Books</h2>
<div class="navlink noprint grayed">
@ -334,12 +391,15 @@ var dialog_message = "";
<span class="hstrut"></span>
</a>
</div>
</div> <!-- more stuff -->
</div>
<!-- more stuff -->
<div id="bibrec">
<div typeof="pgterms:ebook" about="[ebook:2542]">
<h2>Bibliographic Record <span>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#Table:_Bibliographic_Record" title="Explain Table: Bibliographic Record."><span class="icon icon_help noprint"></span></a>
</span></h2>
<a href="/wiki/Gutenberg:Help_on_Bibliographic_Record_Page#Table:_Bibliographic_Record"
title="Explain Table: Bibliographic Record."><span class="icon icon_help noprint"></span></a>
</span>
</h2>
<table class="bibrec">
<colgroup>
<col class="narrow">
@ -348,19 +408,23 @@ var dialog_message = "";
<tr>
<th>Author</th>
<td>
<a href="/ebooks/author/861" rel="marcrel:aut" about="/authors/861" typeof="pgterms:agent" itemprop="creator">Ibsen, Henrik, 1828-1906</a></td>
<a href="/ebooks/author/861" rel="marcrel:aut" about="/authors/861" typeof="pgterms:agent"
itemprop="creator">Ibsen, Henrik, 1828-1906</a>
</td>
</tr>
<tr>
<th>Uniform Title</th>
<td itemprop="alternativeHeadline">
Et dukkehjem. English
</td>
</tr><tr>
</tr>
<tr>
<th>Title</th>
<td itemprop="headline">
A Doll's House : a play
</td>
</tr><tr>
</tr>
<tr>
<th>Note</th>
<td>
Translation of: Et dukkehjem
@ -373,7 +437,8 @@ Translation of: Et dukkehjem
<tr property="dcterms:subject" datatype="dcterms:LCC" content="PT">
<th>LoC Class</th>
<td>
<a href="/browse/loccs/pt">PT: Language and Literatures: Germanic, Scandinavian, and Icelandic literatures</a>
<a href="/browse/loccs/pt">PT: Language and Literatures: Germanic, Scandinavian, and Icelandic
literatures</a>
</td>
</tr>
<tr>
@ -383,21 +448,24 @@ Translation of: Et dukkehjem
Marriage -- Drama
</a>
</td>
</tr><tr>
</tr>
<tr>
<th>Subject</th>
<td property="dcterms:subject" datatype="dcterms:LCSH">
<a class="block" href="/ebooks/subject/2813">
Man-woman relationships -- Drama
</a>
</td>
</tr><tr>
</tr>
<tr>
<th>Subject</th>
<td property="dcterms:subject" datatype="dcterms:LCSH">
<a class="block" href="/ebooks/subject/13173">
Norwegian drama -- Translations into English
</a>
</td>
</tr><tr>
</tr>
<tr>
<th>Subject</th>
<td property="dcterms:subject" datatype="dcterms:LCSH">
<a class="block" href="/ebooks/subject/13507">
@ -427,7 +495,8 @@ Wives -- Drama
</tr>
<tr itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer">
<th>Price</th>
<td><span itemprop="priceCurrency" content="USD"></span><span itemprop="price">$0.00</span><span itemprop="availability" content="In Stock"><a href="http://schema.org/InStock"></a></span></td>
<td><span itemprop="priceCurrency" content="USD"></span><span itemprop="price">$0.00</span><span
itemprop="availability" content="In Stock"><a href="http://schema.org/InStock"></a></span></td>
</tr>
</table>
</div>
@ -436,10 +505,10 @@ Wives -- Drama
</div>
</div>
</div>
<div id="dialog" class="hidden">
</div>
<div class="footer">
</div>
<div id="dialog" class="hidden"></div>
<div class="footer"></div>
</div>
<script src="./book.js"></script>
</body>
</html>

57
ebooks/book.js Normal file
View File

@ -0,0 +1,57 @@
(function ($) {
const addbtn = $('#add-to-booklist');
const url = window.location && window.location.toString().split('/');
const bookId = url[url.length - 1].match(/(\d+)/)[0];
if (JSON.parse(localStorage.getItem('booklist'))[bookId]) {
// book already in list
addbtn.html('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
};
const newList = { ...JSON.parse(localStorage.getItem('booklist')) };
newList[bookId] = bookData;
addbtn.addClass('book-in-list')
addbtn.html('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('Add to My Book List')
addbtn.css("background-color", "cornflowerblue")
}
})(jQuery);

View File

@ -198,7 +198,7 @@ which contains *all* Project Gutenberg metadata in one RDF/XML file.
</a>
</li>
<li class="booklink">
<a class="link" href="/ebooks/25344" accesskey="9">
<a class="link" href="./ebooks/25344.html" accesskey="9">
<span class="cell leftcell with-cover">
<img class="cover-thumb"
src="https://www.gutenberg.org/cache/epub/25344/pg25344.cover.small.jpg" alt="">
@ -225,8 +225,8 @@ which contains *all* Project Gutenberg metadata in one RDF/XML file.
<span class="hstrut"></span>
</a>
</li>
<li class="booklink">
<a class="link" href="/ebooks/2542" accesskey="1">
<li class="booklink" style=" border: 1px red solid">
<a class="link" href="./ebooks/2542.html" accesskey="1">
<span class="cell leftcell with-cover">
<img class="cover-thumb"
src="https://www.gutenberg.org/cache/epub/2542/pg2542.cover.small.jpg" alt="">