2021-08-21 23:23:35 +02:00
|
|
|
<template>
|
|
|
|
<div class="flex h-full px-1 overflow-hidden">
|
2021-11-07 02:31:46 +01:00
|
|
|
<covers-book-cover :audiobook="audiobook" :width="50" />
|
2021-10-17 18:29:52 +02:00
|
|
|
<div class="flex-grow px-2 audiobookSearchCardContent">
|
|
|
|
<p v-if="matchKey !== 'title'" class="truncate text-sm">{{ title }}</p>
|
|
|
|
<p v-else class="truncate text-sm" v-html="matchHtml" />
|
|
|
|
|
|
|
|
<p v-if="matchKey === 'subtitle'" class="truncate text-xs text-gray-300">{{ matchHtml }}</p>
|
|
|
|
|
2021-10-24 03:31:48 +02:00
|
|
|
<p v-if="matchKey !== 'authorFL'" class="text-xs text-gray-200 truncate">by {{ authorFL }}</p>
|
2021-10-17 18:29:52 +02:00
|
|
|
<p v-else class="truncate text-xs text-gray-200" v-html="matchHtml" />
|
|
|
|
|
|
|
|
<div v-if="matchKey === 'series' || matchKey === 'tags'" class="m-0 p-0 truncate" v-html="matchHtml" />
|
2021-08-21 23:23:35 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
audiobook: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
2021-10-17 18:29:52 +02:00
|
|
|
},
|
|
|
|
search: String,
|
|
|
|
matchKey: String,
|
|
|
|
matchText: String
|
2021-08-21 23:23:35 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
book() {
|
|
|
|
return this.audiobook ? this.audiobook.book || {} : {}
|
|
|
|
},
|
|
|
|
title() {
|
|
|
|
return this.book ? this.book.title : 'No Title'
|
|
|
|
},
|
2021-10-17 18:29:52 +02:00
|
|
|
subtitle() {
|
|
|
|
return this.book ? this.book.subtitle : ''
|
|
|
|
},
|
2021-10-24 03:31:48 +02:00
|
|
|
authorFL() {
|
|
|
|
return this.book ? this.book.authorFL : 'Unknown'
|
2021-10-17 18:29:52 +02:00
|
|
|
},
|
|
|
|
matchHtml() {
|
|
|
|
if (!this.matchText || !this.search) return ''
|
|
|
|
if (this.matchKey === 'subtitle') return ''
|
|
|
|
var matchSplit = this.matchText.toLowerCase().split(this.search.toLowerCase().trim())
|
|
|
|
if (matchSplit.length < 2) return ''
|
|
|
|
|
|
|
|
var html = ''
|
|
|
|
var totalLenSoFar = 0
|
|
|
|
for (let i = 0; i < matchSplit.length - 1; i++) {
|
|
|
|
var indexOf = matchSplit[i].length
|
|
|
|
var firstPart = this.matchText.substr(totalLenSoFar, indexOf)
|
|
|
|
var actualWasThere = this.matchText.substr(totalLenSoFar + indexOf, this.search.length)
|
|
|
|
totalLenSoFar += indexOf + this.search.length
|
|
|
|
|
|
|
|
html += `${firstPart}<strong class="text-warning">${actualWasThere}</strong>`
|
|
|
|
}
|
|
|
|
var lastPart = this.matchText.substr(totalLenSoFar)
|
|
|
|
html += lastPart
|
|
|
|
|
|
|
|
if (this.matchKey === 'tags') return `<p class="truncate">Tags: ${html}</p>`
|
2021-10-24 03:31:48 +02:00
|
|
|
if (this.matchKey === 'authorFL') return `by ${html}`
|
2021-10-17 19:18:26 +02:00
|
|
|
if (this.matchKey === 'series') return `<p class="truncate">Series: ${html}</p>`
|
2021-10-17 18:29:52 +02:00
|
|
|
return `${html}`
|
2021-08-21 23:23:35 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2021-10-17 18:29:52 +02:00
|
|
|
.audiobookSearchCardContent {
|
2021-08-21 23:23:35 +02:00
|
|
|
width: calc(100% - 80px);
|
2021-10-17 18:29:52 +02:00
|
|
|
height: 75px;
|
2021-08-21 23:23:35 +02:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
</style>
|