Backend changes

master
santic-zombie 5 years ago
parent 2c8ac3901c
commit 129eb040f1
  1. 4
      css/style1.css
  2. 75
      index.html
  3. 6
      js/audio.js
  4. 25
      js/info.js
  5. 63
      js/radio.js
  6. 28
      js/radio.js.bak
  7. BIN
      pic/bg.jpg
  8. BIN
      pic/bg.png
  9. 1
      trackname

@ -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;
}

@ -11,7 +11,8 @@
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous">
</script>
<script src="js/lastfm.api.md5.js" type="text/javascript"></script>
<script src="js/lastfm.api.js" type="text/javascript"></script>
</head>
<body>
@ -23,7 +24,7 @@
<div id="myPlay">-</div>
<div id="title">title</div>
<a name="lastFMlink" href="" target="_blank"><div id="title">title</div></a>
<br>
@ -48,77 +49,11 @@
<span id="duration"></span>
<br>
<br>
<div id="listeners">title</div>
</div>
</div>
<script language="JavaScript">
var audio = new Audio('http://stream.santic-zombie.ru');
var play = document.getElementById('play');
play.addEventListener('click', function() {
$("#myPlay").text("Now playing:");
audio.play();
}, false);
var pause = document.getElementById('pause');
pause.addEventListener('click', function() {
$("#myPlay").text("Paused");
audio.pause();
}, false);
audio.addEventListener("timeupdate", function() {
var duration = document.getElementById('duration');
var s = parseInt(audio.currentTime % 60);
var m = parseInt((audio.currentTime / 60) % 60);
var h = parseInt((audio.currentTime / 3600) % 60);
if (s < 10) s = '0' + s;
if (m < 10) m = '0' + m;
if (h < 10) h = '0' + h;
duration.innerHTML = h + ':' + m + ':' + s;
}, false);
$("#volume").mousemove(function(){
audio.volume = parseFloat(this.value / 10);
});
</script>
<script language="JavaScript">
function show()
{
$.ajax({
url: '/trackname.php',
cache: false,
success: function(html){
$('#title').html(html);
}
});
}
$(document).ready(function(){
show();
setInterval('show()',5000);
});
</script>
<script language="JavaScript">
function show1()
{
$.ajax({
url: '/online.php',
cache: false,
success: function(html){
$('#listeners').html(html);
}
});
}
$(document).ready(function(){
show1();
setInterval('show1()',5000);
});
</script>
<script src="js/audio.js" type="text/javascript"></script>
<script src="js/radio.js" type="text/javascript"></script>
</body>

@ -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;

@ -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);
}});

@ -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(

@ -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);
}
);

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 KiB

@ -0,0 +1 @@
/var/log/trackname
Loading…
Cancel
Save