Skip to content

Commit

Permalink
[web] Lint source code
Browse files Browse the repository at this point in the history
  • Loading branch information
hacketiwack committed Apr 21, 2024
1 parent 2fda829 commit b8373a4
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 61 deletions.
12 changes: 4 additions & 8 deletions web-src/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,13 @@ export default {
return
}
const vm = this
let protocol = 'ws://'
if (window.location.protocol === 'https:') {
protocol = 'wss://'
}
let wsUrl = `${protocol + window.location.hostname}:${
vm.$store.state.config.websocket_port
this.$store.state.config.websocket_port
}`
if (import.meta.env.DEV && import.meta.env.VITE_OWNTONE_URL) {
Expand All @@ -161,7 +159,7 @@ export default {
*/
const owntoneUrl = new URL(import.meta.env.VITE_OWNTONE_URL)
wsUrl = `${protocol + owntoneUrl.hostname}:${
vm.$store.state.config.websocket_port
this.$store.state.config.websocket_port
}`
}
Expand All @@ -170,6 +168,7 @@ export default {
maxReconnectInterval: 2000
})
const vm = this
socket.onopen = () => {
vm.reconnect_attempts = 0
socket.send(
Expand All @@ -188,7 +187,6 @@ export default {
]
})
)
vm.update_outputs()
vm.update_player_status()
vm.update_library_stats()
Expand All @@ -207,11 +205,10 @@ export default {
*/
let update_throttled = false
function update_info() {
const update_info = () => {
if (update_throttled) {
return
}
vm.update_outputs()
vm.update_player_status()
vm.update_library_stats()
Expand All @@ -220,7 +217,6 @@ export default {
vm.update_spotify()
vm.update_lastfm()
vm.update_pairing()
update_throttled = true
setTimeout(() => {
update_throttled = false
Expand Down
3 changes: 2 additions & 1 deletion web-src/src/components/IndexButtonList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
:key="index"
class="button is-small"
:to="{ hash: `#index_${index}`, query: $route.query }"
>{{ index }}</router-link
>
{{ index }}
</router-link>
</nav>
</section>
</template>
Expand Down
16 changes: 9 additions & 7 deletions web-src/src/components/LyricsPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,19 @@ export default {
(this.lastIndex < la.length - 1 &&
la[this.lastIndex + 1].time > currentTime) ||
this.lastIndex === la.length - 1
)
) {
return this.lastIndex
}
if (
this.lastIndex < la.length - 2 &&
la[this.lastIndex + 2].time > currentTime
)
) {
return this.lastIndex + 1
}
// Not found, then start a binary search
let start = 0,
end = la.length - 1,
index
let end = la.length - 1,
index = 0,
start = 0
while (start <= end) {
index = (start + end) >> 1
const currentVerse = la[index]
Expand All @@ -103,7 +105,7 @@ export default {
const parsed = []
if (raw) {
// Parse the lyrics
const regex = /(\[(\d+):(\d+)(?:\.\d+)?\] ?)?(.*)/
const regex = /(\[(\d+):(\d+)(?:\.\d+)?\] ?)?(.*)/u
raw.split('\n').forEach((item, index) => {
const matches = regex.exec(item)
if (matches && matches[4]) {
Expand All @@ -120,7 +122,7 @@ export default {
index < lyrics.length - 1 ? lyrics[index + 1].time - verse.time : 3
const unitDuration = duration / verse.text.length
let delay = 0
verse.words = verse.text.match(/\S+\s*/g).map((text) => {
verse.words = verse.text.match(/\S+\s*/gu).map((text) => {
const duration = text.length * unitDuration
delay += duration
return {
Expand Down
22 changes: 12 additions & 10 deletions web-src/src/components/NavbarBottom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
'is-loading': loading
}"
@click="togglePlay"
><mdicon class="icon" name="broadcast" size="18" />
>
<mdicon class="icon" name="broadcast" size="18" />
</a>
</div>
<div class="level-item">
Expand All @@ -70,8 +71,8 @@
:class="{ 'has-text-grey-light': !playing }"
>
<p class="heading" v-text="$t('navigation.stream')" />
<a href="stream.mp3" class="heading ml-2" target="_blank"
><mdicon
<a href="stream.mp3" class="heading ml-2" target="_blank">
<mdicon
class="icon is-small"
name="open-in-new"
size="16"
Expand Down Expand Up @@ -218,7 +219,8 @@
'is-loading': loading
}"
@click="togglePlay"
><mdicon class="icon" name="radio-tower" size="16" />
>
<mdicon class="icon" name="radio-tower" size="16" />
</a>
</div>
<div class="level-item">
Expand All @@ -228,8 +230,8 @@
:class="{ 'has-text-grey-light': !playing }"
>
<p class="heading" v-text="$t('navigation.stream')" />
<a href="stream.mp3" class="heading ml-2" target="_blank"
><mdicon
<a href="stream.mp3" class="heading ml-2" target="_blank">
<mdicon
class="icon is-small"
name="open-in-new"
size="16"
Expand Down Expand Up @@ -367,19 +369,19 @@ export default {
},
setupAudio() {
const a = audio.setup()
a.addEventListener('waiting', (e) => {
a.addEventListener('waiting', () => {
this.playing = false
this.loading = true
})
a.addEventListener('playing', (e) => {
a.addEventListener('playing', () => {
this.playing = true
this.loading = false
})
a.addEventListener('ended', (e) => {
a.addEventListener('ended', () => {
this.playing = false
this.loading = false
})
a.addEventListener('error', (e) => {
a.addEventListener('error', () => {
this.closeAudio()
this.$store.dispatch('add_notification', {
text: this.$t('navigation.stream-error'),
Expand Down
12 changes: 6 additions & 6 deletions web-src/src/components/NavbarTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@
<b v-text="$t('navigation.search')" />
</navbar-item-link>
<hr class="my-3" />
<navbar-item-link :to="{ name: 'settings-webinterface' }">{{
$t('navigation.settings')
}}</navbar-item-link>
<navbar-item-link :to="{ name: 'settings-webinterface' }">
{{ $t('navigation.settings') }}
</navbar-item-link>
<a
class="navbar-item"
@click.stop.prevent="open_update_dialog()"
v-text="$t('navigation.update-library')"
/>
<navbar-item-link :to="{ name: 'about' }">{{
$t('navigation.about')
}}</navbar-item-link>
<navbar-item-link :to="{ name: 'about' }">
{{ $t('navigation.about') }}
</navbar-item-link>
</div>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions web-src/src/lib/GroupedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ const stringComparator = (a, b) => a.localeCompare(b, locale.value)
const dateComparator = (a, b) =>
new Date(a) - new Date(b) || (!a ? -1 : !b ? 1 : 0)

function createComparators(criteria) {
return criteria.map(({ field, type, order = 1 }) => {
const createComparators = (criteria) => {
criteria.map(({ field, type, order = 1 }) => {
switch (type) {
case String:
return (a, b) => stringComparator(a[field], b[field]) * order
case Number:
return (a, b) => numberComparator(a[field], b[field]) * order
case Date:
return (a, b) => dateComparator(a[field], b[field]) * order
default:
return null
}
})
}
Expand Down Expand Up @@ -49,7 +51,7 @@ const timeIndex = (string) => {
return times.find((item) => isNaN(diff) || diff < item.difference)?.text(date)
}

function createIndexer({ field, type = undefined } = {}) {
const createIndexer = ({ field, type = undefined } = {}) => {
switch (type) {
case String:
return (item) => characterIndex(item[field])
Expand Down
35 changes: 18 additions & 17 deletions web-src/src/pages/PageAbout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,26 @@
keypath="page.about.built-with"
scope="global"
>
<template #bulma><a href="https://bulma.io">Bulma</a></template>
<template #mdi
><a href="https://pictogrammers.com/library/mdi/"
>Material Design Icons</a
></template
>
<template #vuejs
><a href="https://vuejs.org/">Vue.js</a></template
>
<template #axios
><a href="https://github.com/mzabriskie/axios"
>axios</a
></template
>
<template #others
><a
<template #bulma>
<a href="https://bulma.io">Bulma</a>
</template>
<template #mdi>
<a href="https://pictogrammers.com/library/mdi/">
Material Design Icons
</a>
</template>
<template #vuejs>
<a href="https://vuejs.org/">Vue.js</a>
</template>
<template #axios>
<a href="https://github.com/mzabriskie/axios">axios</a>
</template>
<template #others>
<a
href="https://github.com/owntone/owntone-server/network/dependencies"
v-text="$t('page.about.more')"
/></template>
/>
</template>
</i18n-t>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions web-src/src/pages/PageMusic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
<router-link
class="button is-light is-small is-rounded"
:to="{ name: 'music-recently-added' }"
>{{ $t('page.music.show-more') }}</router-link
>
{{ $t('page.music.show-more') }}
</router-link>
</p>
</nav>
</template>
Expand All @@ -35,8 +36,9 @@
<router-link
class="button is-light is-small is-rounded"
:to="{ name: 'music-recently-played' }"
>{{ $t('page.music.show-more') }}</router-link
>
{{ $t('page.music.show-more') }}
</router-link>
</p>
</nav>
</template>
Expand Down
6 changes: 4 additions & 2 deletions web-src/src/pages/PageMusicSpotify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
<router-link
:to="{ name: 'music-spotify-new-releases' }"
class="button is-light is-small is-rounded"
>{{ $t('page.spotify.music.show-more') }}</router-link
>
{{ $t('page.spotify.music.show-more') }}
</router-link>
</p>
</nav>
</template>
Expand All @@ -38,8 +39,9 @@
<router-link
:to="{ name: 'music-spotify-featured-playlists' }"
class="button is-light is-small is-rounded"
>{{ $t('page.spotify.music.show-more') }}</router-link
>
{{ $t('page.spotify.music.show-more') }}
</router-link>
</p>
</nav>
</template>
Expand Down
6 changes: 3 additions & 3 deletions web-src/src/templates/ContentWithHeading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<div ref="options_ref" style="height: 1px" />
<slot name="options" />
<nav class="buttons is-centered mt-4 mb-2">
<router-link class="button is-small is-white" :to="position"
><mdicon class="icon is-small" :name="icon_name" size="16"
/></router-link>
<router-link class="button is-small is-white" :to="position">
<mdicon class="icon is-small" :name="icon_name" size="16" />
</router-link>
</nav>
</section>
<div :class="{ 'is-full-height': $slots.options }">
Expand Down
4 changes: 2 additions & 2 deletions web-src/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import i18n from '@intlify/unplugin-vue-i18n/vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'

/*
* In development mode, use the VITE_OWNTONE_URL environment variable to set
Expand Down

0 comments on commit b8373a4

Please sign in to comment.