1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-11-26 06:47:17 +00:00

code cleared

This commit is contained in:
Nofre 2015-09-02 19:38:42 +02:00
parent 94869bba92
commit 30bb8161b5
2 changed files with 159 additions and 150 deletions

View File

@ -34,7 +34,7 @@
<ul id="nav_links" class="nav navbar-nav"> <ul id="nav_links" class="nav navbar-nav">
<li id="queue"><a href="#/">Queue</a></li> <li id="queue"><a href="#/">Queue</a></li>
<li id="browse"><a href="#/browse/0/">Browse database</a></li> <li id="browse"><a href="#/browse/0/">Browse database</a></li>
<li id="dible"><a href="#/dirble/">Dirble</a></li> <li id="dirble"><a href="#/dirble/">Dirble</a></li>
<li><a href="#" data-toggle="modal" data-target="#addstream">Add Stream</a></li> <li><a href="#" data-toggle="modal" data-target="#addstream">Add Stream</a></li>
<li><a href="#" data-toggle="modal" data-target="#settings" onclick="getHost();">Settings</a></li> <li><a href="#" data-toggle="modal" data-target="#settings" onclick="getHost();">Settings</a></li>
</ul> </ul>

View File

@ -115,107 +115,7 @@ var app = $.sammy(function() {
dirble_catid = this.params['splat'][0]; dirble_catid = this.params['splat'][0];
dirble_page = this.params['splat'][1]; dirble_page = this.params['splat'][1];
$.getJSON( "http://api.dirble.com/v2/category/"+dirble_catid+"/stations?page="+dirble_page+"&per_page=20&token=2e223c9909593b94fc6577361a", function( data ) { dirble_load_stations();
$('#dirble_loading').addClass('hide');
if (data.length == 20) $('#next').removeClass('hide');
var max = data.length - data.length%2;
for(i = 0; i < max; i+=2) {
$('#dirble_left > tbody').append(
"<tr><td radioid=\""+data[i].id+"\">"+data[i].name+"</td></tr>"
);
$('#dirble_right > tbody').append(
"<tr><td radioid=\""+data[i+1].id+"\">"+data[i+1].name+"</td></tr>"
);
}
if (max != data.length) {
$('#dirble_left > tbody').append(
"<tr><td radioid=\""+data[max].id+"\">"+data[max].name+"</td></tr>"
);
}
$('#dirble_left > tbody > tr > td').on({
click: function() {
var _this = $(this);
$.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream);
$('.top-right').notify({
message:{
text: _this.text() + " added"
}
}).show();
});
},
mouseenter: function() {
var _this = $(this);
$(this).last().append(
"<a role=\"button\" class=\"pull-right btn-group-hover\">" +
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
e.stopPropagation();
$.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream);
$('.top-right').notify({
message:{
text: _this.text() + " added"
}
}).show();
});
}).fadeTo('fast',1);
},
mouseleave: function(){
$(this).last().find("a").stop().remove();
}
});
$('#dirble_right> tbody > tr > td').on({
click: function() {
var _this = $(this);
$.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream);
$('.top-right').notify({
message:{
text: _this.text() + " added"
}
}).show();
});
},
mouseenter: function() {
var _this = $(this);
$(this).last().append(
"<a role=\"button\" class=\"pull-right btn-group-hover\">" +
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
e.stopPropagation();
$.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream);
$('.top-right').notify({
message:{
text: _this.text() + " added"
}
}).show();
});
}).fadeTo('fast',1);
},
mouseleave: function(){
$(this).last().find("a").stop().remove();
}
});
});
}); });
@ -232,54 +132,7 @@ var app = $.sammy(function() {
$('#panel-heading').text("Dirble"); $('#panel-heading').text("Dirble");
$('#dirble').addClass('active'); $('#dirble').addClass('active');
$('#prev').addClass('hide'); dirble_load_categories();
$('#next').addClass('hide');
dirble_page = 1;
$.getJSON( "http://api.dirble.com/v2/categories?token=2e223c9909593b94fc6577361a", function( data ) {
$('#dirble_loading').addClass('hide');
data = data.sort(function(a, b) {
return (a.title > b.title) ? 1 : 0;
});
var max = data.length - data.length%2;
for(i = 0; i < max; i+=2) {
$('#dirble_left > tbody').append(
"<tr><td catid=\""+data[i].id+"\">"+data[i].title+"</td></tr>"
);
$('#dirble_right > tbody').append(
"<tr><td catid=\""+data[i+1].id+"\">"+data[i+1].title+"</td></tr>"
);
}
if (max != data.length) {
$('#dirble_left > tbody').append(
"<tr><td catid=\""+data[max].id+"\">"+data[max].title+"</td></tr>"
);
}
$('#dirble_left > tbody > tr > td').on({
click: function() {
dirble_selected_cat = $(this).text();
dirble_catid = $(this).attr("catid");
app.setLocation("#/dirble/"+dirble_catid+"/"+dirble_page);
}
});
$('#dirble_right > tbody > tr > td').on({
click: function() {
dirble_selected_cat = $(this).text();
dirble_catid = $(this).attr("catid");
app.setLocation("#/dirble/"+dirble_catid+"/"+dirble_page);
}
});
});
}); });
this.get("/", function(context) { this.get("/", function(context) {
@ -834,3 +687,159 @@ function songNotify(title, artist, album) {
notification.close(); notification.close();
}, 3000, notification); }, 3000, notification);
} }
function dirble_load_categories() {
dirble_page = 1;
$.getJSON( "http://api.dirble.com/v2/categories?token=2e223c9909593b94fc6577361a", function( data ) {
$('#dirble_loading').addClass('hide');
data = data.sort(function(a, b) {
return (a.title > b.title) ? 1 : 0;
});
var max = data.length - data.length%2;
for(i = 0; i < max; i+=2) {
$('#dirble_left > tbody').append(
"<tr><td catid=\""+data[i].id+"\">"+data[i].title+"</td></tr>"
);
$('#dirble_right > tbody').append(
"<tr><td catid=\""+data[i+1].id+"\">"+data[i+1].title+"</td></tr>"
);
}
if (max != data.length) {
$('#dirble_left > tbody').append(
"<tr><td catid=\""+data[max].id+"\">"+data[max].title+"</td></tr>"
);
}
$('#dirble_left > tbody > tr > td').on({
click: function() {
dirble_selected_cat = $(this).text();
dirble_catid = $(this).attr("catid");
app.setLocation("#/dirble/"+dirble_catid+"/"+dirble_page);
}
});
$('#dirble_right > tbody > tr > td').on({
click: function() {
dirble_selected_cat = $(this).text();
dirble_catid = $(this).attr("catid");
app.setLocation("#/dirble/"+dirble_catid+"/"+dirble_page);
}
});
});
}
function dirble_load_stations() {
$.getJSON( "http://api.dirble.com/v2/category/"+dirble_catid+"/stations?page="+dirble_page+"&per_page=20&token=2e223c9909593b94fc6577361a", function( data ) {
$('#dirble_loading').addClass('hide');
if (data.length == 20) $('#next').removeClass('hide');
var max = data.length - data.length%2;
for(i = 0; i < max; i+=2) {
$('#dirble_left > tbody').append(
"<tr><td radioid=\""+data[i].id+"\">"+data[i].name+"</td></tr>"
);
$('#dirble_right > tbody').append(
"<tr><td radioid=\""+data[i+1].id+"\">"+data[i+1].name+"</td></tr>"
);
}
if (max != data.length) {
$('#dirble_left > tbody').append(
"<tr><td radioid=\""+data[max].id+"\">"+data[max].name+"</td></tr>"
);
}
$('#dirble_left > tbody > tr > td').on({
click: function() {
var _this = $(this);
$.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream);
$('.top-right').notify({
message:{
text: _this.text() + " added"
}
}).show();
});
},
mouseenter: function() {
var _this = $(this);
$(this).last().append(
"<a role=\"button\" class=\"pull-right btn-group-hover\">" +
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
e.stopPropagation();
$.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream);
$('.top-right').notify({
message:{
text: _this.text() + " added"
}
}).show();
});
}).fadeTo('fast',1);
},
mouseleave: function(){
$(this).last().find("a").stop().remove();
}
});
$('#dirble_right> tbody > tr > td').on({
click: function() {
var _this = $(this);
$.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream);
$('.top-right').notify({
message:{
text: _this.text() + " added"
}
}).show();
});
},
mouseenter: function() {
var _this = $(this);
$(this).last().append(
"<a role=\"button\" class=\"pull-right btn-group-hover\">" +
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
e.stopPropagation();
$.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream);
$('.top-right').notify({
message:{
text: _this.text() + " added"
}
}).show();
});
}).fadeTo('fast',1);
},
mouseleave: function(){
$(this).last().find("a").stop().remove();
}
});
});
}