updated welcome page to support OPDS multiple Icon

This commit is contained in:
Manan Jethwani 2021-08-07 02:35:29 +05:30
parent 6e26c5aa75
commit fe93035a4c
1 changed files with 9 additions and 5 deletions

View File

@ -4,7 +4,6 @@
start: 0, start: 0,
count: viewPortToCount() count: viewPortToCount()
}; };
const filterTypes = ['lang', 'category', 'q'];
const bookOrderMap = new Map(); const bookOrderMap = new Map();
const filterCookieName = 'filters'; const filterCookieName = 'filters';
const oneDayDelta = 86400000; const oneDayDelta = 86400000;
@ -66,11 +65,16 @@
} }
function generateBookHtml(book, sort = false) { function generateBookHtml(book, sort = false) {
const link = book.querySelector('link').getAttribute('href'); const link = book.querySelector('link[type="text/html"]').getAttribute('href');
let iconUrl;
book.querySelectorAll('link[rel="http://opds-spec.org/image/thumbnail"]').forEach(link => {
if (link.getAttribute('type').split(';')[1] == 'width=48' && !iconUrl) {
iconUrl = link.getAttribute('href');
}
});
const title = getInnerHtml(book, 'title'); const title = getInnerHtml(book, 'title');
const description = getInnerHtml(book, 'summary'); const description = getInnerHtml(book, 'summary');
const id = getInnerHtml(book, 'id'); const id = getInnerHtml(book, 'id');
const iconUrl = getInnerHtml(book, 'icon');
const language = getInnerHtml(book, 'language'); const language = getInnerHtml(book, 'language');
const tags = getInnerHtml(book, 'tags'); const tags = getInnerHtml(book, 'tags');
let tagHtml = tags.split(';').filter(tag => {return !(tag.split(':')[0].startsWith('_'))}) let tagHtml = tags.split(';').filter(tag => {return !(tag.split(':')[0].startsWith('_'))})
@ -85,7 +89,7 @@
} catch { } catch {
downloadLink = ''; downloadLink = '';
} }
humanFriendlyZimSize = humanFriendlySize(zimSize); const humanFriendlyZimSize = humanFriendlySize(zimSize);
const divTag = document.createElement('div'); const divTag = document.createElement('div');
divTag.setAttribute('class', 'book'); divTag.setAttribute('class', 'book');