Skip to content

Commit

Permalink
add Comics Plus cover images when we have them, closes #41
Browse files Browse the repository at this point in the history
  • Loading branch information
phette23 committed Dec 19, 2023
1 parent 0d0cbe2 commit cf8457f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions catalog-js/comics-plus-cover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// scrape the book cover image URL from the 856$u field and add it as a Koha cover image
if (path.match('/cgi-bin/koha/opac-detail.pl')) {
let hasCover = () => !!$('.cover-image').length

const addCPCover = function () {
if ($('#biblio-cover-slider').length && !hasCover()) {
// COCE cover image lookup still running, we have to wait
return
}

$('.online_resources .resource_list a').each(function () {
let link = $(this)
let url = link.attr('href')
// example URL: https://uniapi.librarypass.com/index.php/images/cover/md/6880002490009385420231110.png
if (url.match('uniapi.librarypass.com') && !hasCover()) {
// html adapted from Koha local cover image
$('.bookcover').first().html(
`<div class="bookcover">
<div id="biblio-cover-slider" class="cover-slider">
<div class="cover-image local-coverimg" style="display: block;">
<a href="${url}">
<img style="max-width:107px;" src="${url}">
</a>
</div>
</div>
</div>`
)
}
// if the text is simply "image" either way, whether we added a cover image or not, remove link
if (link.text().toLowerCase().trim() === 'image') {
link.parent().remove()
}
})

// clear the interval
clearInterval(interval)
}

const interval = setInterval(addCPCover, 400)
}

0 comments on commit cf8457f

Please sign in to comment.