diff --git a/css/style1.css b/css/style1.css index 6a086ea..5dbd12b 100644 --- a/css/style1.css +++ b/css/style1.css @@ -1,8 +1,8 @@ body { background-color: rgb(62, 50, 64); - background-image: url("/pic/bg.png"); + background-image: url("/pic/bg.jpg"); background-repeat: no-repeat; - background-position: top center; + background-position: center center; background-size: cover; } @@ -14,9 +14,9 @@ body { left: 0; display: flex; align-items: center; - align-content: center; - justify-content: center; - overflow: auto; + align-content: center; + justify-content: center; + overflow: auto; } #song{ diff --git a/index.html b/index.html index 965aae8..ce5655e 100755 --- a/index.html +++ b/index.html @@ -11,7 +11,8 @@ integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"> - + + @@ -23,7 +24,7 @@
-
-
title
+
title

@@ -48,77 +49,11 @@
-
-
title
- - - - - - - + + diff --git a/js/audio.js b/js/audio.js index a645769..3210b82 100644 --- a/js/audio.js +++ b/js/audio.js @@ -1,4 +1,6 @@ -var audio = new Audio('http://stream.santic-zombie.ru'); +var stream_url = 'http://stream.santic-zombie.ru'; + +var audio = new Audio(stream_url); var play = document.getElementById('play'); play.addEventListener('click', function() { @@ -26,3 +28,5 @@ audio.addEventListener("timeupdate", function() { $("#volume").mousemove(function(){ audio.volume = parseFloat(this.value / 10); }); + +//audio.muted = true; diff --git a/js/info.js b/js/info.js deleted file mode 100644 index ca1d8c6..0000000 --- a/js/info.js +++ /dev/null @@ -1,25 +0,0 @@ -/* Create a cache object */ -//var cache = new LastFMCache(); - -/* Create a LastFM object */ -var lastfm = new LastFM({ - apiKey : '59ab8307ec00a5ec90574ac91885798e', - apiSecret : 'e09bec215fdc3100ff998167e5b401f8', -// cache : cache -}); - -/* Load some artist info. */ -/* -lastfm.artist.getInfo({artist: 'Boris'}, {success: function(data){ - $('#curr_artist').html( - $('#lastfmTemplateArtistInfo').render(data.artist)); -}, error: function(code, message){ - alert('Error #'+code+': '+message); -}}); -*/ - -lastfm.artist.getInfo({artist: 'Boris'}, {success: function(data){ - alert(data.artist.url) -}, error: function(code, message){ - alert('Error #'+code+': '+message); -}}); diff --git a/js/radio.js b/js/radio.js index 7af623d..3844c12 100644 --- a/js/radio.js +++ b/js/radio.js @@ -1,19 +1,56 @@ function show() { - $.ajax({ - url: '../trackname.php', - cache: false, - success: function(html){ - $('#title').html(html); - } - }); - $.ajax({ - url: '../online.php', - cache: false, - success: function(html){ - $('#listeners').html(html); - } + + var lastfm = new LastFM({ + apiKey : '59ab8307ec00a5ec90574ac91885798e', + apiSecret : 'e09bec215fdc3100ff998167e5b401f8', }); + + let xmlHttpRequest = function() { + return new Promise(function(resolve, reject) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', '../trackname'); + var temp = 'empty'; + xhr.onload = function (e) { + if (xhr.readyState == 4 && xhr.status == 200) { + resolve(xhr.responseText); + } + }; + xhr.send(); + }); + }; + + xmlHttpRequest() + .then(function(temp){ + var MPDartist, MPDsong, MPDfile; + MPDartist = MPDsong = MPDfile = 'empty'; + var array = temp.toString().split("\n"); + // вывод в консоль информации о файле + for(i in array) { + console.log(array[i]);} + // .replace - удаление пробелов в начале и конце строки + MPDartist = array[0].replace(/^\s*/,'').replace(/\s*$/,''); + MPDsong = array[1]; + MPDfile = array[2].replace(/^vk_kun\//,'').replace(/\.mp3/,''); + console.log(MPDfile); + + if (MPDartist !== null) { + lastfm.artist.getInfo({artist: MPDartist}, {success: function(data){ + var artistLink = data.artist.url; + // формируем ссылку на артиста в LastFM + document.querySelector('a[name="lastFMlink"]').setAttribute('href', artistLink); + // выводим название артиста и трека ссылкой + $('#title').html(MPDartist+' - '+MPDsong); + }, error: function(code, message){ + console.log('Error #'+code+': '+message); + MPDartist = null; + }});} + else { + //document.querySelector('a[name="lastFMlink"]').setAttribute('href', null); + //$('#title').html(MPDfile); + alert('WTF!?');} + }); + } $(document).ready( diff --git a/js/radio.js.bak b/js/radio.js.bak new file mode 100644 index 0000000..4bf01df --- /dev/null +++ b/js/radio.js.bak @@ -0,0 +1,28 @@ +function show() +{ + /* +// php-scrip exec mpc current command + $.ajax({ + url: '../trackname.php', + cache: false, + success: function(data){ + $('#title').html(data); + } + }); */ + + $.ajax({ + url: '../online.php', + cache: false, + success: function(html){ + $('#listeners').html(html); + } + }); + +} + +$(document).ready( + () => { + show(); + setInterval(show, 5000); + } +); diff --git a/pic/bg.jpg b/pic/bg.jpg new file mode 100644 index 0000000..561d90e Binary files /dev/null and b/pic/bg.jpg differ diff --git a/pic/bg.png b/pic/bg.png deleted file mode 100755 index 817b903..0000000 Binary files a/pic/bg.png and /dev/null differ diff --git a/trackname b/trackname new file mode 120000 index 0000000..1bbf778 --- /dev/null +++ b/trackname @@ -0,0 +1 @@ +/var/log/trackname \ No newline at end of file