3.1.1 sway.fm fixed, multiple sub-folder fix

This commit is contained in:
Trevor Squillario 2013-11-01 07:31:43 -04:00
parent 89684032ce
commit 4b116d0024
37 changed files with 1629 additions and 530 deletions

View file

@ -1,7 +1,9 @@
JamStash.controller('ArchiveCtrl',
function ArchiveCtrl($scope, $rootScope, $location, $http, utils, globals, model, notifications, player, json) {
function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, globals, model, notifications, player, json) {
$("#LayoutContainer").layout($scope.layoutThreeCol);
$scope.settings = globals.settings;
$scope.itemType = 'archive';
$rootScope.song = [];
$scope.Protocol = 'jsonp';
$scope.artist = [];
@ -9,20 +11,45 @@ function ArchiveCtrl($scope, $rootScope, $location, $http, utils, globals, model
$scope.selectedArtist;
$scope.selectedAlbum;
$scope.selectedSongs = [];
$scope.SavedCollections = globals.SavedCollections;
$scope.AllCollections = [];
$scope.loadedCollection = false;
json.getCollections(function (data) {
$scope.AllCollections = data;
$scope.loadedCollection = true;
});
$scope.writeSavedCollection = function () {
utils.setValue('SavedCollections', $scope.SavedCollections.join(), false);
/*
$scope.$apply(function () {
});
*/
globals.SavedCollections = $scope.SavedCollections;
}
$scope.addSavedCollection = function (newValue) {
if ($scope.SavedCollections.indexOf(newValue) == -1) {
$scope.SavedCollections.push(newValue);
$scope.writeSavedCollection();
}
}
$scope.deleteSavedCollection = function (index) {
$scope.SavedCollections.splice(index, 1);
$scope.writeSavedCollection();
}
$scope.selectedCollection;
$scope.$watch("selectedCollection", function (newValue, oldValue) {
if (newValue !== oldValue) {
if (globals.SavedCollections.length > 0) {
globals.SavedCollections.push(newValue);
}
$scope.artist.push(new model.Artist('', newValue));
utils.setValue('SavedCollections', globals.SavedCollections.join(), false);
$scope.addSavedCollection(newValue);
}
});
$scope.setupDemoCollections = function () {
var demo = ["YonderMountainStringBand", "GreenskyBluegrass"];
angular.forEach(demo, function (item, key) {
if ($scope.SavedCollections.indexOf(item) == -1) {
$scope.SavedCollections.push(item);
}
});
}
$scope.archiveUrl = 'https://archive.org/';
/* Filter */
@ -72,39 +99,46 @@ function ArchiveCtrl($scope, $rootScope, $location, $http, utils, globals, model
};
$scope.filterSave = function () {
if ($scope.selectedArtist) {
$scope.getAlbums('');
$scope.getAlbums('', '');
}
}
/* End Filter */
/*
$scope.getArtists = function (data) {
var map = function (data) {
return new model.Artist('', data);
};
angular.forEach(globals.SavedCollections, function (item, key) {
$scope.artist.push(map(item));
});
var map = function (data) {
return new model.Artist('', data);
};
$scope.getAlbums = function (name) {
angular.forEach($scope.SavedCollections, function (item, key) {
$scope.artist.push(map(item));
});
};
*/
$scope.getAlbums = function (name, identifier) {
var url = $scope.archiveUrl + 'advancedsearch.php?q=';
if (name != '') {
$scope.selectedArtist = name;
url += 'collection:(' + name + ') AND format:(MP3)';
} else if ($scope.selectedArtist) {
url += 'collection:(' + $scope.selectedArtist + ') AND format:(MP3)';
} else {
url += 'identifier:(' + identifier + ')';
}
var map = function (data) {
var song = data;
var coverart, starred;
var coverartthumb, coverartfull, starred;
var url = $scope.archiveUrl + 'details/' + song.identifier;
coverart = 'images/albumdefault_50.jpg';
coverartthumb = 'images/albumdefault_50.jpg';
coverartfull = 'images/albumdefault_160.jpg';
if (parseInt(song.avg_rating) == 5) { starred = true; } else { starred = false; }
//var description = '<b>Details</b><br />';
var description = '<b>Source</b>: ' + song.source + '<br />';
description += '<b>Date</b>: ' + song.date + '<br />';
description += typeof song.publisher != 'undefined' ? '<b>Transferer</b>: ' + song.publisher + '<br />' : '';
description += typeof song.avg_rating != 'undefined' ? '<b>Rating</b>: ' + song.avg_rating + '<br />' : '';
description += '<b>Downloads</b>: ' + song.downloads + '<br />';
//description += typeof song.description == 'undefined' ? '' : song.description.replace("\n", "<br />");
return new model.Album(song.identifier, null, song.title, null, coverart, $.format.date(new Date(song.publicdate), "yyyy-MM-dd h:mm a"), starred, description, url);
description += typeof song.downloads != 'undefined' ? '<b>Downloads</b>: ' + song.downloads + '<br />' : '';
return new model.Album(song.identifier, null, song.title, song.collection[0], coverartthumb, coverartfull, $.format.date(new Date(song.publicdate), "yyyy-MM-dd h:mm a"), starred, description, url);
}
var url = $scope.archiveUrl + 'advancedsearch.php?q=collection:(' + $scope.selectedArtist + ') AND format:(MP3)';
if ($scope.filter.Source) {
url += ' AND source:(' + $scope.filter.Source + ')';
}
@ -136,8 +170,9 @@ function ArchiveCtrl($scope, $rootScope, $location, $http, utils, globals, model
$scope.album.push(map(item));
});
$scope.$apply();
notifications.updateMessage($scope.album.length, true);
} else {
notifications.updateMessage("0 records returned", true);
notifications.updateMessage("Sorry :(", true);
}
},
error: function () {
@ -145,16 +180,16 @@ function ArchiveCtrl($scope, $rootScope, $location, $http, utils, globals, model
}
});
};
$scope.mapSong = function (key, song, server, dir, coverart) {
$scope.mapSong = function (key, song, server, dir, identifier, coverart) {
var url, time, track, title, rating, starred, contenttype, suffix;
var specs = ''
if (song.format == 'VBR MP3') {
url = 'http://' + server + dir + key;
specs = song.bitrate + 'kbps, ' + song.format.toLowerCase();
if (typeof song.bitrate == 'undefined' || typeof song.format == 'undefined') { specs = '&nbsp;'; } else { specs = song.bitrate + 'kbps, ' + song.format.toLowerCase(); }
if (typeof song.track == 'undefined') { track = '&nbsp;'; } else { track = song.track; }
if (typeof song.title == 'undefined') { title = '&nbsp;'; } else { title = song.title; }
if (typeof song.length == 'undefined') { time = '&nbsp;'; } else { time = utils.timeToSeconds(song.length); }
return new model.Song(song.md5, song.album, song.track, title, song.creator, '', song.album, '', coverart, coverart, time, '', '', 'mp3', specs, url, 0, '');
return new model.Song(song.md5, identifier, song.track, title, song.creator, '', song.album, '', coverart, coverart, time, '', '', 'mp3', specs, url, 0, '');
}
};
$scope.getSongs = function (id, action) {
@ -169,24 +204,25 @@ function ArchiveCtrl($scope, $rootScope, $location, $http, utils, globals, model
var coverart = '';
var server = data.server;
var dir = data.dir;
var identifier = data.metadata.identifier[0];
if (typeof data.misc.image != 'undefined') {
coverart = data.misc.image;
}
var items = data.files;
if (action == 'add') {
angular.forEach(items, function (item, key) {
var song = $scope.mapSong(key, item, server, dir, coverart);
var song = $scope.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
});
$('body').layout().open('south');
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
$scope.$apply();
$('body').layout().open('south');
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function (item, key) {
var song = $scope.mapSong(key, item, server, dir, coverart);
var song = $scope.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
@ -196,11 +232,11 @@ function ArchiveCtrl($scope, $rootScope, $location, $http, utils, globals, model
$rootScope.playSong(false, next);
});
$('body').layout().open('south');
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
} else {
$rootScope.song = [];
angular.forEach(items, function (item, key) {
var song = $scope.mapSong(key, item, server, dir, coverart);
var song = $scope.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.song.push(song);
}
@ -211,12 +247,14 @@ function ArchiveCtrl($scope, $rootScope, $location, $http, utils, globals, model
});
};
$scope.addSongsToQueue = function () {
angular.forEach($scope.selectedSongs, function (item, key) {
$scope.queue.push(item);
item.selected = false;
});
$('body').layout().open('south');
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
if ($scope.selectedSongs.length > 0) {
angular.forEach($scope.selectedSongs, function (item, key) {
$scope.queue.push(item);
item.selected = false;
});
$('body').layout().open('south');
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
}
}
$scope.scrollToTop = function () {
$('#Artists').stop().scrollTo('#auto', 400);
@ -233,16 +271,16 @@ function ArchiveCtrl($scope, $rootScope, $location, $http, utils, globals, model
item.selected = false;
});
}
$scope.setupDemoCollections = function () {
if (globals.SavedCollections.length == 0) {
globals.SavedCollections = ["YonderMountainStringBand", "GreenskyBluegrass"];
$scope.getArtists();
}
}
/* Launch on Startup */
$scope.getArtists();
if ($routeParams.artist) {
if ($routeParams.album) {
//collection:(GreenskyBluegrass) AND format:(MP3) AND identifier:(gsbg2013-09-20.flac16)
$scope.getAlbums('', $routeParams.album);
} else {
$scope.getAlbums($routeParams.artist, '');
}
$scope.addSavedCollection($routeParams.artist);
}
/* End Startup */
});

View file

@ -4,6 +4,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$rootScope.song = [];
$scope.settings = globals.settings;
$scope.itemType = 'ss';
$scope.index = [];
$scope.shortcut = [];
$scope.album = [];
@ -19,20 +20,24 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$scope.selectedAutoAlbum;
$scope.selectedArtist;
$scope.selectedAlbum;
$scope.selectedMusicFolder;
$scope.$watch("selectedMusicFolder", function (newValue, oldValue) {
$scope.selectedSubsonicAlbumSort = 'default';
$scope.SubsonicAlbumSort = [
{ id: "default", name: "Default Sort" },
{ id: "artist", name: "Artist" },
{ id: "album", name: "Album" },
{ id: "createdate desc", name: "Created Date - Desc" },
];
$scope.$watch("selectedSubsonicAlbumSort", function (newValue, oldValue) {
if (newValue !== oldValue) {
if (utils.getValue('MusicFolders') != newValue) {
if (typeof newValue != 'undefined') {
utils.setValue('MusicFolders', newValue, true);
} else {
utils.setValue('MusicFolders', null, true);
}
//alert(newValue);
$scope.getArtists(newValue);
}
$scope.sortSubsonicAlbums(newValue);
}
});
$scope.selectedLayout = 'grid';
$scope.Layouts = [
{ id: "list", name: "List" },
{ id: "grid", name: "Grid" },
];
$scope.rescanLibrary = function (data, event) {
$.ajax({
url: globals.BaseURL() + '/getUser.view?' + globals.BaseParams() + '&username=' + globals.settings.Username,
@ -61,7 +66,8 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$scope.getArtists = function (id) {
var url, id;
if (utils.getValue('MusicFolders')) {
id = utils.getValue('MusicFolders');
var folder = angular.fromJson(utils.getValue('MusicFolders'));
id = folder.id;
}
if (id) {
url = globals.BaseURL() + '/getIndexes.view?' + globals.BaseParams() + '&musicFolderId=' + id;
@ -87,16 +93,15 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
indexes[0] = data["subsonic-response"].indexes.index;
}
}
// TODO: AZContainer, build letters here. Make it a click button somewhere then a larger popup with letters finger friendly size
var shortcuts = [];
// TODO: AZIndex, build letters here. Make it a click button somewhere then a larger popup with letters finger friendly size
$scope.shortcut = [];
if (typeof data["subsonic-response"].indexes.shortcut != 'undefined') {
if (data["subsonic-response"].indexes.shortcut.length > 0) {
shortcuts = data["subsonic-response"].indexes.shortcut;
$scope.shortcut = data["subsonic-response"].indexes.shortcut;
} else {
shortcuts[0] = data["subsonic-response"].indexes.shortcut;
$scope.shortcut[0] = data["subsonic-response"].indexes.shortcut;
}
}
$scope.shortcut = shortcuts;
$scope.index = [];
angular.forEach(indexes, function (item, key) {
$scope.index.push($scope.mapArtist(item));
@ -107,12 +112,13 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
};
$scope.mapAlbum = function (data) {
var album = data;
var coverart, starred;
var coverartthumb, coverartfull, starred;
if (typeof album.coverArt != 'undefined') {
coverart = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&size=50&id=' + album.coverArt;
coverartthumb = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&size=160&id=' + album.coverArt;
coverartfull = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&id=' + album.coverArt;
}
if (typeof album.starred !== 'undefined') { starred = true; } else { starred = false; }
return new model.Album(album.id, album.parent, album.album, album.artist, coverart, $.format.date(new Date(album.created), "yyyy-MM-dd h:mm a"), starred, '', '');
return new model.Album(album.id, album.parent, album.album, album.artist, coverartthumb, coverartfull, $.format.date(new Date(album.created), "yyyy-MM-dd h:mm a"), starred, '', '');
}
$scope.getAlbums = function (id) {
$scope.selectedAutoAlbum = null;
@ -127,7 +133,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
var items = [];
if (typeof data["subsonic-response"].directory.child != 'undefined') {
if (data["subsonic-response"].directory.child.length > 0) {
items = data["subsonic-response"].directory.child;
items = data["subsonic-response"].directory.child;
} else {
items[0] = data["subsonic-response"].directory.child;
}
@ -138,7 +144,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
if (item.isDir) {
$scope.album.push($scope.mapAlbum(item));
} else {
$rootScope.song.push($scope.mapAlbum(item));
$rootScope.song.push($scope.mapSong(item));
}
});
if ($scope.selectedSubsonicAlbumSort != "default") {
@ -231,9 +237,17 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else {
$rootScope.song = [];
var albums = [];
angular.forEach(items, function (item, key) {
$rootScope.song.push($scope.mapSong(item));
if (item.isDir) {
albums.push($scope.mapAlbum(item));
} else {
$rootScope.song.push($scope.mapSong(item));
}
});
if (albums.length > 0) {
$scope.album = albums;
}
$scope.$apply();
}
} else {
@ -290,51 +304,28 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
}
}
});
$('#Search').val("");
//$('#Search').val("");
}
}
$scope.toggleAZ = function (event) {
var submenu = $('div#submenu_AZIndex');
if (submenu.css('display') !== 'none') {
submenu.fadeOut();
} else {
//submenu.fadeIn();
var el = $('#AZContainer');
pos = el.offset();
width = el.width();
height = el.height();
//show the menu directly over the placeholder
submenu.css({ "left": (pos.left + 44) + "px", "top": (pos.top) + "px" }).fadeIn(400);
}
$scope.toggleSubmenu('#submenu_AZIndex', '#AZIndex', 'right', 44);
}
$scope.addSongsToQueue = function () {
angular.forEach($scope.selectedSongs, function (item, key) {
$scope.queue.push(item);
item.selected = false;
});
$('body').layout().open('south');
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
}
$scope.scrollToTop = function () {
$('#Artists').stop().scrollTo('#auto', 400);
}
$scope.selectAll = function () {
angular.forEach($rootScope.song, function (item, key) {
$scope.selectedSongs.push(item);
item.selected = true;
});
}
$scope.selectNone = function () {
angular.forEach($rootScope.song, function (item, key) {
$scope.selectedSongs = [];
item.selected = false;
});
if ($scope.selectedSongs.length !== 0) {
angular.forEach($scope.selectedSongs, function (item, key) {
$scope.queue.push(item);
item.selected = false;
});
$('body').layout().open('south');
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
$scope.selectedSongs.length = 0;
}
}
$scope.updateFavorite = function (item) {
var id = item.id;
var starred = item.starred;
var url;
if (typeof starred !== 'undefined') {
if (starred) {
url = globals.BaseURL() + '/unstar.view?' + globals.BaseParams() + '&id=' + id;
item.starred = undefined;
} else {
@ -367,18 +358,6 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
*/
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
};
$scope.selectedSubsonicAlbumSort = 'default';
$scope.SubsonicAlbumSort = [
"default",
"artist",
"album",
"createdate desc"
];
$scope.$watch("selectedSubsonicAlbumSort", function (newValue, oldValue) {
if (newValue !== oldValue) {
$scope.sortSubsonicAlbums(newValue);
}
});
$scope.sortSubsonicAlbums = function (newValue) {
if (typeof newValue != 'undefined') {
//alert(newValue);
@ -398,7 +377,6 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
/* Launch on Startup */
$scope.getArtists();
$scope.getMusicFolders();
if ($routeParams.albumId) {
$scope.getSongs($routeParams.albumId, '');
}

View file

@ -6,12 +6,27 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
$rootScope.playingSong;
$rootScope.MusicFolders = [];
$rootScope.Genres = [];
$rootScope.selectedPlaylist = "";
$rootScope.selectedAutoPlaylist = "";
$rootScope.selectedMusicFolder = "";
$rootScope.unity;
$rootScope.$watch("selectedMusicFolder", function (newValue, oldValue) {
if (newValue !== oldValue) {
if (typeof newValue != 'undefined' && newValue != null) {
utils.setValue('MusicFolders', angular.toJson(newValue), true);
//$scope.getArtists(newValue.id);
} else {
utils.setValue('MusicFolders', null, true);
//$scope.getArtists();
}
}
});
/*
$scope.playSong = function (loadonly, data) {
$scope.$apply(function () {
$rootScope.playSong(loadonly, data);
});
$scope.$apply(function () {
$rootScope.playSong(loadonly, data);
});
}
*/
@ -37,6 +52,7 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
}
notifications.updateMessage(setting + ' : ' + globals.settings[id], true);
}
$.ajaxSetup({
'beforeSend': function () {
$("#loading").show();
@ -46,6 +62,23 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
}
});
$("a.coverartfancy").live("click", function () {
$("a.coverartfancy").fancybox({
beforeShow: function () {
//this.title = $('#songdetails_artist').html();
},
afterLoad: function () {
//this.inner.prepend( '<h1>1. My custom title</h1>' );
//this.content = '<h1>2. My custom title</h1>';
},
hideOnContentClick: true,
type: 'image',
openEffect: 'none',
closeEffect: 'none'
});
});
var submenu_active = false;
$('div.submenu').mouseenter(function () {
submenu_active = true;
@ -55,19 +88,41 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
$('div.submenu').hide();
//setTimeout(function () { if (submenu_active == false) $('div.submenu').stop().fadeOut(); }, 400);
});
$scope.toggleSubmenu = function (menu, pl, pos, margin) {
var submenu = $(menu);
if (submenu.css('display') !== 'none') {
submenu.fadeOut();
} else {
var el = $(pl);
off = el.offset();
width = el.width();
height = el.height();
switch (pos) {
case 'right':
//show the menu to the right of placeholder
submenu.css({ "left": (off.left + margin) + "px", "top": (off.top) + "px" }).fadeIn(400);
break;
case 'left':
//show the menu to the right of placeholder
submenu.css({ "left": (off.left - margin) + "px", "top": (off.top) + "px" }).fadeIn(400);
break;
}
setTimeout(function () { if (submenu_active == false) $('div.submenu').stop().fadeOut(); }, 10000);
}
}
$("a.coverartfancy").fancybox({
beforeShow : function() {
beforeShow: function () {
//this.title = $('#songdetails_artist').html();
},
afterLoad : function() {
afterLoad: function () {
//this.inner.prepend( '<h1>1. My custom title</h1>' );
//this.content = '<h1>2. My custom title</h1>';
},
hideOnContentClick: true,
type: 'image',
openEffect: 'none',
closeEffect: 'none',
closeEffect: 'none'
});
$('#action_Welcome').fancybox({
@ -82,6 +137,8 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
$('.audiojs .scrubber').stop().animate({ height: '4px' });
});
$('.message').live('click', function () { $(this).remove(); });
// JQuery UI Sortable - Drag and drop sorting
var fixHelper = function (e, ui) {
ui.children().each(function () {
@ -93,6 +150,28 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
helper: fixHelper
});
// Sway.fm Unity Plugin
$rootScope.unity = UnityMusicShim();
$rootScope.unity.setSupports({
playpause: true,
next: true,
previous: true
});
$rootScope.unity.setCallbackObject({
pause: function () {
if (globals.settings.Debug) { console.log("Unity: Recieved playpause command"); }
player.playPauseSong();
},
next: function () {
if (globals.settings.Debug) { console.log("Unity: Recieved next command"); }
$rootScope.nextTrack();
},
previous: function () {
if (globals.settings.Debug) { console.log("Unity: Recieved previous command"); }
$rootScope.previousTrack();
}
});
// JQuery Layout Plugin
function resizePageLayout() {
var pageLayout = $("body").data("layout");
@ -121,13 +200,13 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
var pageLayout = $("body").layout(pageLayoutOptions);
$scope.layoutThreeCol = {
east__size: .5,
east__size: .45,
east__minSize: 400,
east__maxSize: .5, // 50% of layout width
east__initClosed: false,
east__initHidden: false,
//center__size: 'auto',
center__minWidth: .3,
center__minWidth: .35,
center__initClosed: false,
center__initHidden: false,
west__size: .2,
@ -162,9 +241,9 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
}
}
}
$document.keydown(function(e){
$scope.scrollToIndex(e);
$document.keydown(function (e) {
$scope.scrollToIndex(e);
});
$scope.scrollToIndex = function (e) {
var source = e.target.id;
@ -236,7 +315,22 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
$('#SubsonicArtists').stop().scrollTo(el, 400);
}
};
$scope.isActive = function(route) {
$scope.scrollToTop = function () {
$('#Artists').stop().scrollTo('#auto', 400);
}
$scope.selectAll = function () {
angular.forEach($rootScope.song, function (item, key) {
$scope.selectedSongs.push(item);
item.selected = true;
});
}
$scope.selectNone = function () {
angular.forEach($rootScope.song, function (item, key) {
$scope.selectedSongs = [];
item.selected = false;
});
}
$scope.isActive = function (route) {
return route === $location.path();
};
$scope.getMusicFolders = function () {
@ -254,12 +348,18 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
folders[0] = data["subsonic-response"].musicFolders.musicFolder;
}
/* Fix default saved folder
if (utils.getValue('MusicFolders')) {
$scope.selectedMusicFolders = utils.getValue('MusicFolders');
}
*/
$rootScope.MusicFolders = folders;
if (utils.getValue('MusicFolders')) {
var folder = angular.fromJson(utils.getValue('MusicFolders'));
var i = 0, index = "";
angular.forEach($rootScope.MusicFolders, function (item, key) {
if (item.id == folder.id) {
index = i;
}
i++;
});
$rootScope.selectedMusicFolder = $rootScope.MusicFolders[index];
}
$scope.$apply();
}
}
@ -270,23 +370,23 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
$rootScope.Genres = genres.split(',');
/* This is broken in version 4.8, unable to convert XML to JSON
$.ajax({
url: globals.BaseURL() + '/getGenres.view?' + globals.BaseParams(),
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (typeof data["subsonic-response"].genres != 'undefined') {
var items = [];
if (data["subsonic-response"].genres.length > 0) {
items = data["subsonic-response"].genres;
} else {
items[0] = data["subsonic-response"].genres;
}
url: globals.BaseURL() + '/getGenres.view?' + globals.BaseParams(),
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (typeof data["subsonic-response"].genres != 'undefined') {
var items = [];
if (data["subsonic-response"].genres.length > 0) {
items = data["subsonic-response"].genres;
} else {
items[0] = data["subsonic-response"].genres;
}
$rootScope.Genres = items;
$scope.$apply();
}
}
$rootScope.Genres = items;
$scope.$apply();
}
}
});
*/
}
@ -385,26 +485,28 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
}
//$scope.$apply();
}
$scope.getRandomSongs = function (action, genre, folder) {
$rootScope.getRandomSongs = function (action, genre, folder) {
if (globals.settings.Debug) { console.log('action:' + action + ', genre:' + genre + ', folder:' + folder); }
var size = globals.settings.AutoPlaylistSize;
$scope.selectedPlaylist = null;
$rootScope.selectedPlaylist = null;
if (typeof folder == 'number') {
$scope.selectedAutoPlaylist = folder;
$rootScope.selectedAutoPlaylist = folder;
} else if (genre != '') {
$scope.selectedAutoPlaylist = genre;
$rootScope.selectedAutoPlaylist = genre;
} else {
$scope.selectedAutoPlaylist = 'random';
$rootScope.selectedAutoPlaylist = 'random';
}
var genreParams = '';
if (genre != '' && genre != 'Random') {
genreParams = '&genre=' + genre;
}
folderParams = '';
if (typeof folder == 'number' && folder == 0 && folder != 'all') {
folderParams = '&musicFolderId=' + folder;
} else if (folder != '' && folder != 'all') {
if (typeof folder == 'number' && folder != '' && folder != 'all') {
//alert(folder);
folderParams = '&musicFolderId=' + folder;
} else if (typeof $rootScope.selectedMusicFolder.id != 'undefined') {
//alert($rootScope.selectedMusicFolder.id);
folderParams = '&musicFolderId=' + $rootScope.selectedMusicFolder.id;
}
$.ajax({
url: globals.BaseURL() + '/getRandomSongs.view?' + globals.BaseParams() + '&size=' + size + genreParams + folderParams,
@ -454,6 +556,7 @@ function AppCtrl($scope, $rootScope, $document, $location, utils, globals, model
utils.switchTheme(globals.settings.Theme);
if (globals.settings.Server != '' && globals.settings.Username != '' && globals.settings.Password != '') {
$scope.ping();
$scope.getMusicFolders();
if (globals.settings.SaveTrackPosition) {
player.loadTrackPosition();
player.startSaveTrackPosition();

View file

@ -6,8 +6,6 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
$scope.playlists = [];
$scope.playlistsPublic = [];
$scope.playlistsGenre = globals.SavedGenres;
$scope.selectedPlaylist;
$scope.selectedAutoPlaylist;
$scope.selectedGenre;
$scope.$watch("selectedGenre", function (newValue, oldValue) {
if (newValue !== oldValue) {
@ -44,8 +42,8 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
});
}
$scope.getPlaylist = function (id, action) {
$scope.selectedAutoPlaylist = null;
$scope.selectedPlaylist = id;
$rootScope.selectedAutoPlaylist = null;
$rootScope.selectedPlaylist = id;
$.ajax({
url: globals.BaseURL() + '/getPlaylist.view?' + globals.BaseParams() + '&id=' + id,
method: 'GET',
@ -93,8 +91,8 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
}
$scope.getStarred = function (action, type) {
var size = globals.settings.AutoPlaylistSize;
$scope.selectedPlaylist = null;
$scope.selectedAutoPlaylist = 'starred';
$rootScope.selectedPlaylist = null;
$rootScope.selectedAutoPlaylist = 'starred';
$.ajax({
url: globals.BaseURL() + '/getStarred.view?' + globals.BaseParams() + '&size=' + size,
method: 'GET',
@ -225,8 +223,8 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
}
}
$scope.deletePlaylist = function () {
if ($scope.selectedPlaylist != null) {
var id = $scope.selectedPlaylist;
if ($rootScope.selectedPlaylist != null) {
var id = $rootScope.selectedPlaylist;
if (utils.confirmDelete('Are you sure you want to delete the selected playlist?')) {
$.ajax({
url: globals.BaseURL() + '/deletePlaylist.view?' + globals.BaseParams() + '&id=' + id,
@ -241,8 +239,8 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
}
}
$scope.savePlaylist = function () {
if ($scope.selectedPlaylist() != null) {
var id = $scope.selectedPlaylist().id();
if ($rootScope.selectedPlaylist() != null) {
var id = $rootScope.selectedPlaylist().id();
var songs = [];
ko.utils.arrayForEach($rootScope.song(), function (item) {
songs.push(item.id);
@ -297,7 +295,7 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
/* Launch on Startup */
$scope.getPlaylists();
$scope.getMusicFolders();
//$scope.getMusicFolders();
$scope.getGenres();
/* End Startup */
});

View file

@ -15,9 +15,9 @@ function SettingsCtrl($scope, $routeParams, $location, utils, globals, json, not
$scope.Themes = ["Default", "Dark"];
$scope.$watch('settings.HideAZ', function () {
if (globals.settings.HideAZ) {
$('#AZContainer').hide();
$('#AZIndex').hide();
} else {
$('#AZContainer').show();
$('#AZIndex').show();
}
});
$scope.save = function () {
@ -63,10 +63,11 @@ function SettingsCtrl($scope, $routeParams, $location, utils, globals, json, not
var Server = "http://subsonic.org/demo";
var Tab = "tabLibrary";
if (utils.confirmDelete("Do you want to connect to the Subsonic Demo server?")) {
settings.Username(Username);
settings.Password(Password);
settings.Server(Server);
location.reload();
globals.settings.Username = Username;
globals.settings.Password = Password;
globals.settings.Server = Server;
//$scope.save();
$location.url('/library');
}
}