From 4b92e46b57d185ca98394f2fd4c19f59bb5ddcdf Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sun, 12 Jan 2020 15:49:18 +0200 Subject: [PATCH] add open on last.fm button --- public/index.html | 1 + public/index.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/public/index.html b/public/index.html index f8573de..768e989 100644 --- a/public/index.html +++ b/public/index.html @@ -73,6 +73,7 @@
  • Queue Track
  • Edit Metadata
  • Download
  • +
  • View on Last.fm
  • diff --git a/public/index.js b/public/index.js index fbaebbb..65e348d 100644 --- a/public/index.js +++ b/public/index.js @@ -294,6 +294,18 @@ }) } + function lfmurl (i) { + return i.replace(/\s/g, '+') + } + + function popLastFMPage (tid) { + httpGet('/api/track/' + tid).then(function (metadata) { + window.open('https://www.last.fm/music/' + lfmurl(metadata.artist) + '/_/' + lfmurl(metadata.title)) + }, function (e) { + console.log(e) + }) + } + function ctxHandle (el) { if (ctxState === 0) return let dt = el.getAttribute("data-action") @@ -310,6 +322,9 @@ case 'download': window.open('/api/serve/by-id/' + ctxState + '?dl=1', '_blank') break + case 'lastfm': + popLastFMPage(ctxState) + break case 'edit': editTrack(ctxState) break