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;
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;
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');
}
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');
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';
}
}
break;
case 'playlist':
var clazz = 'plist';
- if (filter !== "||") {
+ if ( (filter !== "") && (filter !== "plist") ) {
clazz += ' hide';
}
$('#salamisandwich > tbody').append(
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")));
}
});
+ $('#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);
function set_filter (c) {
filter = c;
-
- $.each($('#salamisandwich > tbody > tr.dir'), function(i, line) {
- var first = $(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');
- }
- });
+ $('#filter > a').removeClass('active');
+ $('#f' + c).addClass('active');
+
+ 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 === "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>');
}