2020-04-26 12:27:54 +00:00
|
|
|
import { socket } from './socket.js'
|
|
|
|
import { albumView } from './tabs.js'
|
|
|
|
import Utils from './utils.js'
|
|
|
|
|
|
|
|
const LinkAnalyzerTab = new Vue({
|
|
|
|
data() {
|
|
|
|
return {
|
2020-04-26 17:33:09 +00:00
|
|
|
title: '',
|
2020-04-26 12:27:54 +00:00
|
|
|
subtitle: '',
|
2020-04-26 17:33:09 +00:00
|
|
|
image: '',
|
2020-04-26 12:27:54 +00:00
|
|
|
data: {},
|
|
|
|
type: '',
|
|
|
|
link: '',
|
2020-04-26 17:33:09 +00:00
|
|
|
countries: []
|
2020-04-26 12:27:54 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
albumView,
|
2020-04-26 17:33:09 +00:00
|
|
|
convertDuration: Utils.convertDuration,
|
2020-04-26 12:27:54 +00:00
|
|
|
reset() {
|
|
|
|
this.title = 'Loading...'
|
|
|
|
this.subtitle = ''
|
2020-04-26 17:33:09 +00:00
|
|
|
this.image = ''
|
2020-04-26 12:27:54 +00:00
|
|
|
this.data = {}
|
|
|
|
this.type = ''
|
|
|
|
this.link = ''
|
2020-04-26 17:33:09 +00:00
|
|
|
this.countries = []
|
2020-04-26 12:27:54 +00:00
|
|
|
},
|
|
|
|
showTrack(data) {
|
2020-04-26 17:33:09 +00:00
|
|
|
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
|
2020-04-26 12:27:54 +00:00
|
|
|
this.type = 'track'
|
|
|
|
this.link = data.link
|
2020-04-26 17:33:09 +00:00
|
|
|
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
|
2020-04-26 12:27:54 +00:00
|
|
|
},
|
|
|
|
showAlbum(data) {
|
2020-04-26 17:33:09 +00:00
|
|
|
console.log(data)
|
2020-04-26 12:27:54 +00:00
|
|
|
this.title = data.title
|
2020-04-26 17:33:09 +00:00
|
|
|
this.subtitle = `by ${data.artist.name}\n${data.nb_tracks} tracks`
|
|
|
|
this.image = data.cover_xl
|
2020-04-26 12:27:54 +00:00
|
|
|
this.type = 'album'
|
|
|
|
this.link = data.link
|
2020-04-26 17:33:09 +00:00
|
|
|
this.data = data
|
2020-04-26 12:27:54 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-04-26 17:33:09 +00:00
|
|
|
socket.on('analyze_track', this.showTrack)
|
2020-04-26 12:27:54 +00:00
|
|
|
socket.on('analyze_album', this.showAlbum)
|
|
|
|
}
|
|
|
|
}).$mount('#analyzer_tab')
|
|
|
|
|
|
|
|
export default LinkAnalyzerTab
|