mirror of
https://github.com/SuperBFG7/ympd
synced 2025-01-21 22:47:13 +00:00
filtering on all levels and fix playlist filter
This commit is contained in:
parent
612f8fc0b2
commit
b0ec3be02f
@ -21,6 +21,10 @@ body {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
#breadcrump > li > a{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#counter {
|
||||
font-size: 24px;
|
||||
margin-top: -6px;
|
||||
@ -99,3 +103,11 @@ button {
|
||||
text-align:left;
|
||||
width:2.8em;
|
||||
}
|
||||
|
||||
#filter > a.active {
|
||||
font-weight: bold;
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ var last_state;
|
||||
var last_outputs;
|
||||
var current_app;
|
||||
var pagination = 0;
|
||||
var browsepath;
|
||||
var browsepath = "";
|
||||
var lastSongTitle = "";
|
||||
var current_song = new Object();
|
||||
var MAX_ELEMENTS_PER_PAGE = 512;
|
||||
@ -29,7 +29,7 @@ var dirble_selected_cat = "";
|
||||
var dirble_catid = "";
|
||||
var dirble_page = 1;
|
||||
var isTouch = Modernizr.touch ? 1 : 0;
|
||||
var filter = undefined;
|
||||
var filter = "";
|
||||
var dirble_api_token = "";
|
||||
var dirble_stations = false;
|
||||
|
||||
@ -67,7 +67,7 @@ var app = $.sammy(function() {
|
||||
browsepath = this.params['splat'][1];
|
||||
pagination = parseInt(this.params['splat'][0]);
|
||||
current_app = 'browse';
|
||||
$('#breadcrump').removeClass('hide').empty().append("<li><a href=\"#/browse/0/\" onclick=\"set_filter()\">root</a></li>");
|
||||
$('#breadcrump').removeClass('hide').empty().append("<li><a uri=\"\" onclick=\"set_filter('')\">root</a></li>");
|
||||
$('#filter').removeClass('hide');
|
||||
$('#salamisandwich').removeClass('hide').find("tr:gt(0)").remove();
|
||||
$('#dirble_panel').addClass('hide');
|
||||
@ -92,7 +92,7 @@ var app = $.sammy(function() {
|
||||
}
|
||||
|
||||
full_path = full_path + chunk;
|
||||
$('#breadcrump').append("<li><a href=\"#/browse/0/" + full_path + "\">"+chunk+"</a></li>");
|
||||
$('#breadcrump').append("<li><a uri=\"" + full_path + "\">"+chunk+"</a></li>");
|
||||
full_path += "/";
|
||||
});
|
||||
$('#browse').addClass('active');
|
||||
@ -313,13 +313,13 @@ function webSocketConnect() {
|
||||
switch(obj.data[item].type) {
|
||||
case 'directory':
|
||||
var clazz = 'dir';
|
||||
if (filter !== undefined) {
|
||||
if (filter !== "") {
|
||||
var first = obj.data[item].dir[0];
|
||||
if (filter === "#" && isNaN(first)) {
|
||||
if (filter === "num" && isNaN(first)) {
|
||||
clazz += ' hide';
|
||||
} else if (filter >= "A" && filter <= "Z" && first.toUpperCase() !== filter) {
|
||||
clazz += ' hide';
|
||||
} else if (filter === "||") {
|
||||
} else if (filter === "plist") {
|
||||
clazz += ' hide';
|
||||
}
|
||||
}
|
||||
@ -332,7 +332,7 @@ function webSocketConnect() {
|
||||
break;
|
||||
case 'playlist':
|
||||
var clazz = 'plist';
|
||||
if (filter !== "||") {
|
||||
if ( (filter !== "") && (filter !== "plist") ) {
|
||||
clazz += ' hide';
|
||||
}
|
||||
$('#salamisandwich > tbody').append(
|
||||
@ -414,7 +414,9 @@ function webSocketConnect() {
|
||||
pagination = 0;
|
||||
browsepath = $(this).attr("uri");
|
||||
$("#browse > a").attr("href", '#/browse/'+pagination+'/'+browsepath);
|
||||
$('#filter > a').attr("href", '#/browse/'+pagination+'/'+browsepath);
|
||||
app.setLocation('#/browse/'+pagination+'/'+browsepath);
|
||||
set_filter('');
|
||||
break;
|
||||
case 'song':
|
||||
socket.send("MPD_API_ADD_TRACK," + decodeURI($(this).attr("uri")));
|
||||
@ -436,6 +438,17 @@ function webSocketConnect() {
|
||||
}
|
||||
});
|
||||
|
||||
$('#breadcrump > li > a').on({
|
||||
click: function() {
|
||||
pagination = 0;
|
||||
browsepath = $(this).attr("uri");
|
||||
$("#browse > a").attr("href", '#/browse/'+pagination+'/'+browsepath);
|
||||
$('#filter > a').attr("href", '#/browse/'+pagination+'/'+browsepath);
|
||||
app.setLocation('#/browse/'+pagination+'/'+browsepath);
|
||||
set_filter('');
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
case 'state':
|
||||
updatePlayIcon(obj.data.state);
|
||||
@ -1060,53 +1073,45 @@ function dirble_load_stations() {
|
||||
|
||||
function set_filter (c) {
|
||||
filter = c;
|
||||
$('#filter > a').removeClass('active');
|
||||
$('#f' + c).addClass('active');
|
||||
|
||||
$.each($('#salamisandwich > tbody > tr.dir'), function(i, line) {
|
||||
var first = $(line).attr('uri')[0];
|
||||
if (filter === "") {
|
||||
$('#salamisandwich > tbody > tr').removeClass('hide');
|
||||
} else if (filter === "plist") {
|
||||
$('#salamisandwich > tbody > tr.dir').addClass('hide');
|
||||
$('#salamisandwich > tbody > tr.song').addClass('hide');
|
||||
$('#salamisandwich > tbody > tr.plist').removeClass('hide');
|
||||
} else {
|
||||
$('#salamisandwich > tbody > tr.plist').addClass('hide');
|
||||
$.each($('#salamisandwich > tbody > tr.dir'), function(i, line) {
|
||||
var first = basename($(line).attr('uri'))[0];
|
||||
|
||||
if (filter === undefined) {
|
||||
$(line).removeClass('hide');
|
||||
}
|
||||
|
||||
else if (filter === "#") {
|
||||
if (!isNaN(first)) {
|
||||
$(line).removeClass('hide');
|
||||
} else {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
}
|
||||
|
||||
else if (filter >= "A" && filter <= "Z") {
|
||||
if (first.toUpperCase() === filter) {
|
||||
$(line).removeClass('hide');
|
||||
} else {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
}
|
||||
|
||||
else if (filter === "||") {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
});
|
||||
|
||||
$.each($('#salamisandwich > tbody > tr.plist'), function(i, line) {
|
||||
if (filter === undefined) {
|
||||
$(line).removeClass('hide');
|
||||
} else if (filter === "||") {
|
||||
$(line).removeClass('hide');
|
||||
} else {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
});
|
||||
if (filter === "num") {
|
||||
if (!isNaN(first)) {
|
||||
$(line).removeClass('hide');
|
||||
} else {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
} else if (filter >= "A" && filter <= "Z") {
|
||||
if (first.toUpperCase() === filter) {
|
||||
$(line).removeClass('hide');
|
||||
} else {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function add_filter () {
|
||||
$('#filter').append(' <a onclick="set_filter(\'#\')" href="#/browse/0/">#</a>');
|
||||
$('#filter').append(' <a onclick="set_filter(\'\')" href="#/browse/'+pagination+'/'+browsepath+'">All</a>');
|
||||
$('#filter').append(' <a id="fnum" onclick="set_filter(\'num\')" href="#/browse/'+pagination+'/'+browsepath+'">#</a>');
|
||||
|
||||
for (i = 65; i <= 90; i++) {
|
||||
var c = String.fromCharCode(i);
|
||||
$('#filter').append(' <a onclick="set_filter(\'' + c + '\')" href="#/browse/0/">' + c + '</a>');
|
||||
$('#filter').append(' <a id="f' + c + '" onclick="set_filter(\'' + c + '\');" href="#/browse/' + pagination + '/' + browsepath + '">' + c + '</a>');
|
||||
}
|
||||
|
||||
$('#filter').append(' <a onclick="set_filter(\'||\')" href="#/browse/0/" class="glyphicon glyphicon-list"></a>');
|
||||
$('#filter').append(' <a id="fplist" onclick="set_filter(\'plist\')" href="#/browse/'+pagination+'/'+browsepath+'" class="glyphicon glyphicon-list"></a>');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user