Started implementing Link Analyzer's tab
This commit is contained in:
62
public/js/modules/link-analyzer-tab.js
Normal file
62
public/js/modules/link-analyzer-tab.js
Normal file
File diff suppressed because one or more lines are too long
@@ -3,6 +3,7 @@ import { artistView, albumView, playlistView } from './tabs.js'
|
||||
import Downloads from './downloads.js'
|
||||
import QualityModal from './quality-modal.js'
|
||||
import { playPausePreview, previewMouseEnter, previewMouseLeave } from './track-preview.js'
|
||||
import Utils from './utils.js'
|
||||
|
||||
const MainSearch = new Vue({
|
||||
data: {
|
||||
@@ -87,20 +88,8 @@ const MainSearch = new Vue({
|
||||
e.preventDefault()
|
||||
QualityModal.open(e.currentTarget.dataset.link)
|
||||
},
|
||||
numberWithDots(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.')
|
||||
},
|
||||
convertDuration(duration) {
|
||||
//convert from seconds only to mm:ss format
|
||||
let mm, ss
|
||||
mm = Math.floor(duration / 60)
|
||||
ss = duration - mm * 60
|
||||
//add leading zero if ss < 0
|
||||
if (ss < 10) {
|
||||
ss = '0' + ss
|
||||
}
|
||||
return mm + ':' + ss
|
||||
},
|
||||
numberWithDots: Utils.numberWithDots,
|
||||
convertDuration: Utils.convertDuration,
|
||||
search(type) {
|
||||
socket.emit('search', {
|
||||
term: this.results.query,
|
||||
|
||||
@@ -3,6 +3,7 @@ import Utils from './utils.js'
|
||||
import QualityModal from './quality-modal.js'
|
||||
import Downloads from './downloads.js'
|
||||
import { socket } from './socket.js'
|
||||
import { analyzeLink } from './tabs.js'
|
||||
|
||||
export default class Search {
|
||||
static linkListeners() {
|
||||
@@ -31,7 +32,11 @@ export default class Search {
|
||||
if (e.ctrlKey) {
|
||||
QualityModal.open(term)
|
||||
} else {
|
||||
Downloads.sendAddToQueue(term)
|
||||
if (window.main_selected == 'analyzer_tab'){
|
||||
analyzeLink(term)
|
||||
}else{
|
||||
Downloads.sendAddToQueue(term)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (term != MainSearch.query || main_selected == 'search_tab') {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import ArtistTab from './artist-tab.js'
|
||||
import TracklistTab from './tracklist-tab.js'
|
||||
import LinkAnalyzerTab from './link-analyzer-tab.js'
|
||||
import { socket } from './socket.js'
|
||||
import SettingsTab from './settings-tab.js'
|
||||
import MainSearch from './main-search.js'
|
||||
@@ -34,6 +35,12 @@ export function playlistView(ev) {
|
||||
showTab('playlist', id)
|
||||
}
|
||||
|
||||
export function analyzeLink(link) {
|
||||
console.log("Analyzing: "+link)
|
||||
LinkAnalyzerTab.reset()
|
||||
socket.emit('analyzeLink', link)
|
||||
}
|
||||
|
||||
export class Tabs {
|
||||
static linkListeners() {
|
||||
document.getElementById('search_tab').addEventListener('click', handleTabClick)
|
||||
|
||||
@@ -27,6 +27,10 @@ function convertDurationSeparated(duration) {
|
||||
return [hh, mm, ss]
|
||||
}
|
||||
|
||||
function numberWithDots(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.')
|
||||
}
|
||||
|
||||
// On scroll event, returns currentTarget = null
|
||||
// Probably on other events too
|
||||
function debounce(func, wait, immediate) {
|
||||
@@ -49,5 +53,6 @@ export default {
|
||||
isValidURL,
|
||||
convertDuration,
|
||||
convertDurationSeparated,
|
||||
numberWithDots,
|
||||
debounce
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user