deemixer/public/js/modules/components/link-analyzer-tab.js

63 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-04-28 18:42:22 +00:00
import { socket } from '../socket.js'
import { albumView } from '../tabs.js'
import Utils from '../utils.js'
const LinkAnalyzerTab = new Vue({
data() {
return {
title: '',
subtitle: '',
image: '',
data: {},
type: '',
link: '',
countries: []
}
},
methods: {
albumView,
convertDuration: Utils.convertDuration,
reset() {
this.title = 'Loading...'
this.subtitle = ''
this.image = ''
this.data = {}
this.type = ''
this.link = ''
this.countries = []
},
showTrack(data) {
this.title =
data.title +
(data.title_version && data.title.indexOf(data.title_version) == -1 ? ' ' + data.title_version : '')
this.subtitle = `by ${data.artist.name}\nin ${data.album.title}`
this.image = data.album.cover_xl
this.type = 'track'
this.link = data.link
data.available_countries.forEach(cc => {
let temp = []
let chars = [...cc].map(c => c.charCodeAt() + 127397)
temp.push(String.fromCodePoint(...chars))
temp.push(Utils.COUNTRIES[cc])
this.countries.push(temp)
})
this.data = data
},
showAlbum(data) {
console.log(data)
this.title = data.title
this.subtitle = `by ${data.artist.name}\n${data.nb_tracks} tracks`
this.image = data.cover_xl
this.type = 'album'
this.link = data.link
this.data = data
}
},
mounted() {
socket.on('analyze_track', this.showTrack)
socket.on('analyze_album', this.showAlbum)
}
}).$mount('#analyzer_tab')
export default LinkAnalyzerTab