From 957bdda3ab6278fc405478961233934915de33ae Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Thu, 3 Aug 2023 23:39:02 +0300 Subject: [PATCH] lastfm recent track --- app/assets/css/styles.css | 2 -- app/assets/js/app.js | 10 ++++++++++ app/assets/js/routes.js | 1 + app/index.html | 11 ++++++++--- app/partitial/footer.html | 7 ++++++- app/partitial/header.html | 20 +++++++++----------- app/partitial/menu.html | 5 ++++- package.json | 2 +- public/js/lastfm-nowplay.js | 32 ++++++++++++++++++++++++++++++++ public/pages/personal.html | 25 ++++++++++++++++++++++++- 10 files changed, 95 insertions(+), 20 deletions(-) create mode 100644 public/js/lastfm-nowplay.js diff --git a/app/assets/css/styles.css b/app/assets/css/styles.css index 1ed8e22..47cb0a2 100644 --- a/app/assets/css/styles.css +++ b/app/assets/css/styles.css @@ -1,5 +1,3 @@ -@import url('bootstrap-v5.3.1.min.css'); - .nav-masthead .nav-link { color: rgba(255, 255, 255, 0.5); border-bottom: 0.25rem solid transparent; diff --git a/app/assets/js/app.js b/app/assets/js/app.js index cfb833d..afad133 100644 --- a/app/assets/js/app.js +++ b/app/assets/js/app.js @@ -55,4 +55,14 @@ const location_handler = async () => { document .querySelector('meta[name="description"]') .setAttribute('content', route.description); + + if (route.script) { + let script = document.getElementById('content').querySelector('script'); + document.querySelector('#autorun').innerHTML = script.innerHTML; + script.remove(); + + eval(document.querySelector('#autorun').innerHTML); + } else { + document.querySelector('#autorun').innerHTML = ''; + } }; diff --git a/app/assets/js/routes.js b/app/assets/js/routes.js index 381f126..396954f 100644 --- a/app/assets/js/routes.js +++ b/app/assets/js/routes.js @@ -28,5 +28,6 @@ export const routes = { template: '/pages/personal.html', title: 'Personal', description: '...', + script: true, }, }; diff --git a/app/index.html b/app/index.html index 48f30d7..93d9606 100644 --- a/app/index.html +++ b/app/index.html @@ -6,9 +6,12 @@ a2s - + + @@ -30,5 +33,7 @@ + + diff --git a/app/partitial/footer.html b/app/partitial/footer.html index d71cda2..e9d0fb2 100644 --- a/app/partitial/footer.html +++ b/app/partitial/footer.html @@ -1,6 +1,11 @@ diff --git a/app/partitial/header.html b/app/partitial/header.html index f9eff32..287ad71 100644 --- a/app/partitial/header.html +++ b/app/partitial/header.html @@ -1,16 +1,18 @@

- inet://
-

// licking and assemble //

+ inet://
+

+ // licking and assemble // +

diff --git a/app/partitial/menu.html b/app/partitial/menu.html index 5d4e38b..9f6ba09 100644 --- a/app/partitial/menu.html +++ b/app/partitial/menu.html @@ -47,7 +47,10 @@
  • - + response.json()) + .then((data) => { + // update desc + let desc_string = `Всего прослушано ${data.recenttracks['@attr'].total} треков`; + desc_text.innerText = desc_string; + + // update content + let track_string = `${data.recenttracks.track[0].artist['#text']} — ${data.recenttracks.track[0].name}`; + song_text.innerText = track_string; + + // TODO: get play now + status_text.innerText = 'Последняя проигранная композиция'; + }) + .catch((err) => console.warn('Something went wrong.', err)); +} + +/* + Application name a2s + API key 5556942dcf4c422dca68d57fbbfdee23 + Shared secret e1e1baa61478c5745c35b985ed2a49a9 + Registered to Alex_Popov +*/ diff --git a/public/pages/personal.html b/public/pages/personal.html index 7764490..93414c0 100644 --- a/public/pages/personal.html +++ b/public/pages/personal.html @@ -5,4 +5,27 @@ -

    Тут ничего нет... пока!

    +
    +
    Загружается...
    +
    +
    + +
    +
    + +
    + +