From d69a4f022c4b5178b29ebcfa8525146b43712c64 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sun, 3 May 2020 15:52:42 +0200 Subject: [PATCH] Implemented barebones charts tab --- public/index.html | 35 +++++++++++- public/js/modules/components/charts-tab.js | 66 ++++++++++++++++++++++ public/js/modules/tabs.js | 1 + 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 public/js/modules/components/charts-tab.js diff --git a/public/index.html b/public/index.html index 5306cb9..eb3ae4d 100644 --- a/public/index.html +++ b/public/index.html @@ -321,6 +321,39 @@

Top Playlists

Charts

+
+
+
+ +
+
+
+
+ + + + + + + + + + + + +
{{ track.position }} + play_arrow + {{track.title + (track.title_version ? ' '+track.title_version : '')}} + {{track.artist.name}} + {{track.album.title}}{{convertDuration(track.duration)}}get_app +
+
@@ -743,4 +776,4 @@

{{ metadata }} - \ No newline at end of file + diff --git a/public/js/modules/components/charts-tab.js b/public/js/modules/components/charts-tab.js new file mode 100644 index 0000000..1615c42 --- /dev/null +++ b/public/js/modules/components/charts-tab.js @@ -0,0 +1,66 @@ +import { socket } from '../socket.js' +import { artistView, albumView } from '../tabs.js' +import Downloads from '../downloads.js' +import QualityModal from '../quality-modal.js' +import TrackPreview from '../track-preview.js' +import Utils from '../utils.js' + +const ChartsTab = new Vue({ + data() { + return { + country: '', + id: 0, + countries: [], + chart: [] + } + }, + methods: { + artistView, + albumView, + playPausePreview: TrackPreview.playPausePreview, + previewMouseEnter: TrackPreview.previewMouseEnter, + previewMouseLeave: TrackPreview.previewMouseLeave, + convertDuration: Utils.convertDuration, + addToQueue(e) { + e.stopPropagation() + Downloads.sendAddToQueue(e.currentTarget.dataset.link) + }, + openQualityModal(e) { + QualityModal.open(e.currentTarget.dataset.link) + }, + getTrackList(e){ + this.country = e.currentTarget.dataset.title + localStorage.setItem('chart', this.country) + this.id = e.currentTarget.dataset.id + socket.emit('getChartTracks', this.id) + }, + setTracklist(data){ + this.chart = data + }, + changeCountry(){ + this.country = '' + this.id = 0 + }, + initCharts(data) { + this.countries = data + this.country = localStorage.getItem('chart') || '' + if (this.country){ + let i = 0 + for (i; i < this.countries.length; i++) if (this.countries[i].title == this.country) break + if (i != this.countries.length){ + this.id = this.countries[i].id + socket.emit('getChartTracks', this.id) + }else{ + this.country = '' + localStorage.setItem('chart', this.country) + } + } + } + }, + mounted() { + socket.on('init_charts', this.initCharts) + socket.on('setChartTracks', this.setTracklist) + } +}).$mount('#charts_tab') + +export default ChartsTab diff --git a/public/js/modules/tabs.js b/public/js/modules/tabs.js index 01895b8..268a0e3 100644 --- a/public/js/modules/tabs.js +++ b/public/js/modules/tabs.js @@ -2,6 +2,7 @@ import ArtistTab from './components/artist-tab.js' import TracklistTab from './components/tracklist-tab.js' import LinkAnalyzerTab from './components/link-analyzer-tab.js' import HomeTab from './components/home-tab.js' +import ChartsTab from './components/charts-tab.js' import { socket } from './socket.js' import SettingsTab from './components/settings-tab.js' import MainSearch from './components/main-search.js'