mirror of
https://github.com/owntone/owntone-server.git
synced 2025-10-29 15:55:02 -04:00
[web] Remove ternary statements
This commit is contained in:
parent
78ffba97d8
commit
b251a4e418
@ -20,8 +20,6 @@ export default [
|
||||
'max-statements': 'off',
|
||||
'no-bitwise': 'off',
|
||||
'no-magic-numbers': 'off',
|
||||
'no-nested-ternary': 'off',
|
||||
'no-ternary': 'off',
|
||||
'no-undef': 'off',
|
||||
'no-unused-vars': ['error', { args: 'none', caughtErrors: 'none' }],
|
||||
'one-var': 'off',
|
||||
|
||||
@ -25,14 +25,10 @@ export default {
|
||||
name: 'ControlVolume',
|
||||
components: { ControlSlider },
|
||||
setup() {
|
||||
return {
|
||||
playerStore: usePlayerStore()
|
||||
}
|
||||
return { playerStore: usePlayerStore() }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
volume: 0
|
||||
}
|
||||
return { volume: 0 }
|
||||
},
|
||||
computed: {
|
||||
icon() {
|
||||
@ -54,7 +50,11 @@ export default {
|
||||
player.setVolume(this.playerStore.volume)
|
||||
},
|
||||
toggle() {
|
||||
this.playerStore.volume = this.playerStore.isMuted ? this.volume : 0
|
||||
if (this.playerStore.isMuted) {
|
||||
this.playerStore.volume = this.volume
|
||||
} else {
|
||||
this.playerStore.volume = 0
|
||||
}
|
||||
this.changeVolume()
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,13 +36,9 @@ export default {
|
||||
ControlSlider
|
||||
},
|
||||
props: { output: { required: true, type: Object } },
|
||||
|
||||
data() {
|
||||
return {
|
||||
volume: this.output.selected ? this.output.volume : 0
|
||||
}
|
||||
return { volume: this.output.volume }
|
||||
},
|
||||
|
||||
computed: {
|
||||
icon() {
|
||||
if (this.output.type.startsWith('AirPlay')) {
|
||||
@ -55,13 +51,11 @@ export default {
|
||||
return 'server'
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
output() {
|
||||
this.volume = this.output.volume
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
changeVolume() {
|
||||
player.setVolume(this.volume, this.output.id)
|
||||
|
||||
@ -21,9 +21,10 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
icon() {
|
||||
return this.playerStore.showLyrics
|
||||
? 'script-text-play'
|
||||
: 'script-text-outline'
|
||||
if (this.playerStore.showLyrics) {
|
||||
return 'script-text-play'
|
||||
}
|
||||
return 'script-text-outline'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@ -5,8 +5,16 @@ const NO_INDEX = 'NO_INDEX'
|
||||
|
||||
const numberComparator = (a, b) => a - b
|
||||
const stringComparator = (a, b) => a.localeCompare(b, locale.value)
|
||||
const dateComparator = (a, b) =>
|
||||
new Date(a) - new Date(b) || (a ? (b ? 0 : 1) : -1)
|
||||
const dateComparator = (a, b) => {
|
||||
const timeA = Date.parse(a)
|
||||
const timeB = Date.parse(b)
|
||||
const isInvalidA = isNaN(timeA)
|
||||
const isInvalidB = isNaN(timeB)
|
||||
if (isInvalidA && isInvalidB) {
|
||||
return 0
|
||||
}
|
||||
return (isInvalidA && 1) || (isInvalidB && -1) || timeA - timeB
|
||||
}
|
||||
|
||||
const createComparators = (criteria) =>
|
||||
criteria.map(({ field, type, order = 1 }) => {
|
||||
|
||||
@ -14,14 +14,18 @@ const luminance = (color) =>
|
||||
) / 255
|
||||
|
||||
export const renderSVG = (data) => {
|
||||
const color = toColor(data.alternate),
|
||||
svg = `<svg xmlns="http://www.w3.org/2000/svg"
|
||||
const background = toColor(data.alternate)
|
||||
let text = '#FFFFFF'
|
||||
if (luminance(background) > 0.5) {
|
||||
text = '#000000'
|
||||
}
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="${data.size}" height="${data.size}"
|
||||
viewBox="0 0 ${data.size} ${data.size}">
|
||||
<rect width="100%" height="100%" fill="#${color}"/>
|
||||
<rect width="100%" height="100%" fill="#${background}"/>
|
||||
<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle"
|
||||
font-weight="${data.font.weight}" font-family="${data.font.family}"
|
||||
font-size="${data.size / 3}" fill="${luminance(color) > 0.5 ? '#000000' : '#FFFFFF'}">
|
||||
font-size="${data.size / 3}" fill="${text}">
|
||||
${data.caption}
|
||||
</text>
|
||||
</svg>`
|
||||
|
||||
@ -126,7 +126,7 @@ export default {
|
||||
}
|
||||
},
|
||||
trackProgressMax() {
|
||||
return this.isLive ? 1 : Math.floor(this.track.length_ms / INTERVAL)
|
||||
return Number(this.isLive) || Math.floor(this.track.length_ms / INTERVAL)
|
||||
},
|
||||
trackTotalTime() {
|
||||
return this.$t('page.now-playing.time', this.track.length_ms, {
|
||||
|
||||
@ -127,10 +127,10 @@ export default {
|
||||
},
|
||||
searchItems(type) {
|
||||
const music = type !== 'audiobook' && type !== 'podcast'
|
||||
const kind = music ? 'music' : type
|
||||
const kind = (music && 'music') || type
|
||||
const parameters = {
|
||||
limit: this.limit,
|
||||
type: music ? type : 'album'
|
||||
type: (music && type) || 'album'
|
||||
}
|
||||
if (this.searchStore.query.startsWith('query:')) {
|
||||
parameters.expression = `(${this.searchStore.query.replace(/^query:/u, '').trim()}) and media_kind is ${kind}`
|
||||
|
||||
@ -55,7 +55,10 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
icon() {
|
||||
return this.hidden ? 'chevron-down' : 'chevron-up'
|
||||
if (this.hidden) {
|
||||
return 'chevron-down'
|
||||
}
|
||||
return 'chevron-up'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user