This commit is contained in:
Trevor Squillario 2014-02-22 21:00:12 -05:00
parent 310c79f63c
commit c46265340c
12 changed files with 282 additions and 397 deletions

View file

@ -109,7 +109,7 @@
<a class="button" id="PauseTrack" title="Play/Pause" style="display: none;"><img src="images/pause_24x32.png" /></a> <a class="button" id="PauseTrack" title="Play/Pause" style="display: none;"><img src="images/pause_24x32.png" /></a>
<a class="button" id="NextTrack" title="Next Track" ng-click="nextTrack()"><img src="images/last_24x24.png" /></a> <a class="button" id="NextTrack" title="Next Track" ng-click="nextTrack()"><img src="images/last_24x24.png" /></a>
</div> </div>
<div id="songdetails" ng-click="toggleQueue()"> <div id="songdetails" ng-click="go('/queue')">
<div id="coverart"><a class="coverartfancy" href="{{playingSong.coverartfull}}"><img ng-src="{{playingSong.coverartthumb}}" src="images/albumdefault_60.jpg" alt="" /></a></div> <div id="coverart"><a class="coverartfancy" href="{{playingSong.coverartfull}}"><img ng-src="{{playingSong.coverartthumb}}" src="images/albumdefault_60.jpg" alt="" /></a></div>
<ul> <ul>
<li class="song" id="{{playingSong.id}}" ng-bind-html="playingSong.name"></li> <li class="song" id="{{playingSong.id}}" ng-bind-html="playingSong.name"></li>

View file

@ -32,7 +32,7 @@ JamStash.config(function ($routeProvider) {
$rootScope.$on("$locationChangeStart", function (event, next, current) { $rootScope.$on("$locationChangeStart", function (event, next, current) {
$rootScope.loggedIn = false; $rootScope.loggedIn = false;
var path = $location.path().replace(/^\/([^\/]*).*$/, '$1'); var path = $location.path().replace(/^\/([^\/]*).*$/, '$1');
if (globals.settings.Username != "" && globals.settings.Password != "" && globals.settings.Server != "" && path != 'archive') { if (globals.settings.Username !== "" && globals.settings.Password !== "" && globals.settings.Server !== "" && path != 'archive') {
$rootScope.loggedIn = true; $rootScope.loggedIn = true;
} }
if (!$rootScope.loggedIn && (path != 'settings' && path != 'archive')) { if (!$rootScope.loggedIn && (path != 'settings' && path != 'archive')) {

View file

@ -8,8 +8,8 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.Protocol = 'jsonp'; $scope.Protocol = 'jsonp';
$scope.artist = []; $scope.artist = [];
$scope.album = []; $scope.album = [];
$scope.selectedArtist; $scope.selectedArtist = null;
$scope.selectedAlbum; $scope.selectedAlbum = null;
$scope.selectedSongs = []; $scope.selectedSongs = [];
$scope.SavedCollections = globals.SavedCollections; $scope.SavedCollections = globals.SavedCollections;
$scope.AllCollections = []; $scope.AllCollections = [];
@ -25,18 +25,18 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
}); });
*/ */
globals.SavedCollections = $scope.SavedCollections; globals.SavedCollections = $scope.SavedCollections;
} };
$scope.addSavedCollection = function (newValue) { $scope.addSavedCollection = function (newValue) {
if ($scope.SavedCollections.indexOf(newValue) == -1) { if ($scope.SavedCollections.indexOf(newValue) == -1) {
$scope.SavedCollections.push(newValue); $scope.SavedCollections.push(newValue);
$scope.writeSavedCollection(); $scope.writeSavedCollection();
} }
} };
$scope.deleteSavedCollection = function (index) { $scope.deleteSavedCollection = function (index) {
$scope.SavedCollections.splice(index, 1); $scope.SavedCollections.splice(index, 1);
$scope.writeSavedCollection(); $scope.writeSavedCollection();
} };
$scope.selectedCollection; $scope.selectedCollection = null;
$scope.$watch("selectedCollection", function (newValue, oldValue) { $scope.$watch("selectedCollection", function (newValue, oldValue) {
if (newValue !== oldValue) { if (newValue !== oldValue) {
$scope.addSavedCollection(newValue); $scope.addSavedCollection(newValue);
@ -49,7 +49,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.SavedCollections.push(item); $scope.SavedCollections.push(item);
} }
}); });
} };
$scope.archiveUrl = 'https://archive.org/'; $scope.archiveUrl = 'https://archive.org/';
/* Filter */ /* Filter */
@ -71,7 +71,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
'publicdate asc', 'publicdate asc',
'stars desc', 'stars desc',
'stars asc' 'stars asc'
], ];
$scope.$watch("selectedArchiveAlbumSort", function (newValue, oldValue) { $scope.$watch("selectedArchiveAlbumSort", function (newValue, oldValue) {
if (utils.getValue('AlbumSort') != newValue) { if (utils.getValue('AlbumSort') != newValue) {
if (typeof newValue != 'undefined') { if (typeof newValue != 'undefined') {
@ -90,8 +90,8 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
years.push(startYear++); years.push(startYear++);
} }
return years; return years;
} };
$scope.Years = $scope.getYears(), $scope.Years = $scope.getYears();
$scope.filter = { $scope.filter = {
Year: "", Year: "",
Source: "", Source: "",
@ -101,7 +101,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
if ($scope.selectedArtist) { if ($scope.selectedArtist) {
$scope.getAlbums('', ''); $scope.getAlbums('', '');
} }
} };
/* End Filter */ /* End Filter */
/* /*
@ -116,7 +116,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
*/ */
$scope.getAlbums = function (name, identifier) { $scope.getAlbums = function (name, identifier) {
var url = $scope.archiveUrl + 'advancedsearch.php?q='; var url = $scope.archiveUrl + 'advancedsearch.php?q=';
if (name != '') { if (name !== '') {
$scope.selectedArtist = name; $scope.selectedArtist = name;
url += 'collection:(' + name + ') AND format:(MP3)'; url += 'collection:(' + name + ') AND format:(MP3)';
} else if ($scope.selectedArtist) { } else if ($scope.selectedArtist) {
@ -138,7 +138,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
description += typeof song.avg_rating != 'undefined' ? '<b>Rating</b>: ' + song.avg_rating + '<br />' : ''; description += typeof song.avg_rating != 'undefined' ? '<b>Rating</b>: ' + song.avg_rating + '<br />' : '';
description += typeof song.downloads != 'undefined' ? '<b>Downloads</b>: ' + song.downloads + '<br />' : ''; 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); 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);
} };
if ($scope.filter.Source) { if ($scope.filter.Source) {
url += ' AND source:(' + $scope.filter.Source + ')'; url += ' AND source:(' + $scope.filter.Source + ')';
} }
@ -162,8 +162,8 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
timeout: globals.settings.Timeout, timeout: globals.settings.Timeout,
success: function (data) { success: function (data) {
var items = []; var items = [];
if (data["response"].docs.length > 0) { if (data.response.docs.length > 0) {
items = data["response"].docs; items = data.response.docs;
//alert(JSON.stringify(data["response"])); //alert(JSON.stringify(data["response"]));
$scope.album = []; $scope.album = [];
$rootScope.song = []; $rootScope.song = [];
@ -183,7 +183,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
}; };
utils.mapSong = function (key, song, server, dir, identifier, coverart) { utils.mapSong = function (key, song, server, dir, identifier, coverart) {
var url, time, track, title, rating, starred, contenttype, suffix; var url, time, track, title, rating, starred, contenttype, suffix;
var specs = '' var specs = '';
if (song.format == 'VBR MP3') { if (song.format == 'VBR MP3') {
url = 'http://' + server + dir + key; url = 'http://' + server + dir + key;
if (typeof song.bitrate == 'undefined' || typeof song.format == 'undefined') { specs = '&nbsp;'; } else { 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(); }
@ -217,7 +217,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$rootScope.queue.push(song); $rootScope.queue.push(song);
} }
}); });
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true); notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
$scope.$apply(); $scope.$apply();
} else if (action == 'play') { } else if (action == 'play') {
@ -232,7 +232,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.$apply(function () { $scope.$apply(function () {
$rootScope.playSong(false, next); $rootScope.playSong(false, next);
}); });
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true); notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
} else { } else {
$scope.album = []; $scope.album = [];
@ -254,25 +254,25 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.queue.push(item); $scope.queue.push(item);
item.selected = false; item.selected = false;
}); });
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true); notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
} }
} };
$scope.scrollToTop = function () { $scope.scrollToTop = function () {
$('#Artists').stop().scrollTo('#auto', 400); $('#Artists').stop().scrollTo('#auto', 400);
} };
$scope.selectAll = function () { $scope.selectAll = function () {
angular.forEach($rootScope.song, function (item, key) { angular.forEach($rootScope.song, function (item, key) {
$scope.selectedSongs.push(item); $scope.selectedSongs.push(item);
item.selected = true; item.selected = true;
}); });
} };
$scope.selectNone = function () { $scope.selectNone = function () {
angular.forEach($rootScope.song, function (item, key) { angular.forEach($rootScope.song, function (item, key) {
$scope.selectedSongs = []; $scope.selectedSongs = [];
item.selected = false; item.selected = false;
}); });
} };
/* Launch on Startup */ /* Launch on Startup */
if ($routeParams.artist) { if ($routeParams.artist) {

View file

@ -20,9 +20,9 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
{ id: "frequent", name: "Most Played" }, { id: "frequent", name: "Most Played" },
{ id: "recent", name: "Recently Played" } { id: "recent", name: "Recently Played" }
]; ];
$scope.selectedAutoAlbum; $scope.selectedAutoAlbum = null;
$scope.selectedArtist; $scope.selectedArtist = null;
$scope.selectedAlbum; $scope.selectedAlbum = null;
$scope.SelectedAlbumSort = globals.settings.DefaultAlbumSort; $scope.SelectedAlbumSort = globals.settings.DefaultAlbumSort;
$scope.AlbumSort = globals.AlbumSorts; $scope.AlbumSort = globals.AlbumSorts;
$scope.BreadCrumbs = []; $scope.BreadCrumbs = [];
@ -36,7 +36,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
if (obj.id == newValue) { if (obj.id == newValue) {
return index; return index;
} }
}) });
globals.settings.DefaultAlbumSort = globals.AlbumSorts[indexes]; globals.settings.DefaultAlbumSort = globals.AlbumSorts[indexes];
} }
} }
@ -56,14 +56,14 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
dataType: globals.settings.Protocol, dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout, timeout: globals.settings.Timeout,
success: function (data) { success: function (data) {
if (data["subsonic-response"].user.adminRole == true) { if (data["subsonic-response"].user.adminRole === true) {
$.get(globals.settings.Server + '/musicFolderSettings.view?scanNow'); $.get(globals.settings.Server + '/musicFolderSettings.view?scanNow');
} else { } else {
alert('You are not logged in as an admin user!'); alert('You are not logged in as an admin user!');
} }
} }
}); });
} };
$scope.mapArtist = function (data) { $scope.mapArtist = function (data) {
var name = ''; var name = '';
var artist = data.artist; var artist = data.artist;
@ -78,18 +78,18 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
}); });
if (typeof data.name !== 'undefined') { name = data.name.toString(); } if (typeof data.name !== 'undefined') { name = data.name.toString(); }
return new model.Index(name, artists); return new model.Index(name, artists);
} };
$scope.mapIndex = function (data) { $scope.mapIndex = function (data) {
var name, id = ''; var name, id = '';
if (typeof data.id !== 'undefined') { id = data.id; } if (typeof data.id !== 'undefined') { id = data.id; }
if (typeof data.name !== 'undefined') { name = data.name.toString(); } if (typeof data.name !== 'undefined') { name = data.name.toString(); }
return new model.Artist(id, name); return new model.Artist(id, name);
} };
$scope.mapPlaylist = function (data) { $scope.mapPlaylist = function (data) {
return new model.Artist(data.id, data.name); return new model.Artist(data.id, data.name);
} };
$scope.getArtists = function (id) { $scope.getArtists = function (id) {
var url, id; var url;
if (utils.getValue('MusicFolders')) { if (utils.getValue('MusicFolders')) {
var folder = angular.fromJson(utils.getValue('MusicFolders')); var folder = angular.fromJson(utils.getValue('MusicFolders'));
id = folder.id; id = folder.id;
@ -160,7 +160,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
type = 'bytag'; type = 'bytag';
} }
return new model.Album(album.id, album.parent, title, album.artist, album.artistId, coverartthumb, coverartfull, $.format.date(new Date(album.created), "yyyy-MM-dd h:mm a"), starred, '', '', type); return new model.Album(album.id, album.parent, title, album.artist, album.artistId, coverartthumb, coverartfull, $.format.date(new Date(album.created), "yyyy-MM-dd h:mm a"), starred, '', '', type);
} };
$scope.getAlbums = function (id, name) { $scope.getAlbums = function (id, name) {
$scope.selectedAutoAlbum = null; $scope.selectedAutoAlbum = null;
$scope.selectedArtist = id; $scope.selectedArtist = id;
@ -340,7 +340,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$rootScope.queue.push(utils.mapSong(item)); $rootScope.queue.push(utils.mapSong(item));
}); });
$scope.$apply(); $scope.$apply();
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') { } else if (action == 'play') {
$rootScope.queue = []; $rootScope.queue = [];
@ -351,7 +351,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$scope.$apply(function () { $scope.$apply(function () {
$rootScope.playSong(false, next); $rootScope.playSong(false, next);
}); });
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'preview') { } else if (action == 'preview') {
$scope.songpreview = []; $scope.songpreview = [];
@ -365,7 +365,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
if (typeof data["subsonic-response"].directory.id != 'undefined') { if (typeof data["subsonic-response"].directory.id != 'undefined') {
var albumId = data["subsonic-response"].directory.id; var albumId = data["subsonic-response"].directory.id;
var albumName = data["subsonic-response"].directory.name; var albumName = data["subsonic-response"].directory.name;
if ($scope.BreadCrumbs.length > 0) { $scope.BreadCrumbs.splice(1, ($scope.BreadCrumbs.length - 1)) }; if ($scope.BreadCrumbs.length > 0) { $scope.BreadCrumbs.splice(1, ($scope.BreadCrumbs.length - 1)); }
$scope.BreadCrumbs.push({ 'type': 'album', 'id': albumId, 'name': albumName }); $scope.BreadCrumbs.push({ 'type': 'album', 'id': albumId, 'name': albumName });
} }
$rootScope.song = []; $rootScope.song = [];
@ -394,7 +394,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
}; };
$scope.search = function () { $scope.search = function () {
var query = $('#Search').val(); var query = $('#Search').val();
if (query != '') { if (query !== '') {
var type = $('#SearchType').val(); var type = $('#SearchType').val();
$.ajax({ $.ajax({
url: globals.BaseURL() + '/search2.view?' + globals.BaseParams() + '&query=' + query, url: globals.BaseURL() + '/search2.view?' + globals.BaseParams() + '&query=' + query,
@ -455,10 +455,10 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
}); });
//$('#Search').val(""); //$('#Search').val("");
} }
} };
$scope.toggleAZ = function (event) { $scope.toggleAZ = function (event) {
$scope.toggleSubmenu('#submenu_AZIndex', '#AZIndex', 'right', 44); $scope.toggleSubmenu('#submenu_AZIndex', '#AZIndex', 'right', 44);
} };
$scope.loadPlaylistsForMenu = function (data, event) { $scope.loadPlaylistsForMenu = function (data, event) {
$.ajax({ $.ajax({
url: globals.BaseURL() + '/getPlaylists.view?' + globals.BaseParams(), url: globals.BaseURL() + '/getPlaylists.view?' + globals.BaseParams(),
@ -494,7 +494,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
*/ */
} }
}); });
} };
$scope.addToPlaylist = function (id) { $scope.addToPlaylist = function (id) {
var songs = []; var songs = [];
if ($scope.selectedSongs.length !== 0) { if ($scope.selectedSongs.length !== 0) {
@ -518,7 +518,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
}); });
} }
} }
} };
$scope.sortDateFunction = function (a, b) { $scope.sortDateFunction = function (a, b) {
return a.date < b.date ? 1 : -1; return a.date < b.date ? 1 : -1;
}; };

View file

@ -3,24 +3,27 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
$rootScope.settings = globals.settings; $rootScope.settings = globals.settings;
$rootScope.song = []; $rootScope.song = [];
$rootScope.queue = []; $rootScope.queue = [];
$rootScope.playingSong; $rootScope.playingSong = null;
$rootScope.MusicFolders = []; $rootScope.MusicFolders = [];
$rootScope.Genres = []; $rootScope.Genres = [];
$rootScope.selectedPlaylist = ""; $rootScope.selectedPlaylist = "";
$rootScope.selectedAutoPlaylist = ""; $rootScope.selectedAutoPlaylist = "";
$rootScope.SelectedMusicFolder = ""; $rootScope.SelectedMusicFolder = "";
$rootScope.unity; $rootScope.unity = null;
$rootScope.loggedIn = function () { $rootScope.loggedIn = function () {
if (globals.settings.Server != '' && globals.settings.Username != '' && globals.settings.Password != '') { if (globals.settings.Server !== '' && globals.settings.Username !== '' && globals.settings.Password !== '') {
return true; return true;
} else { } else {
return false; return false;
} }
} };
$rootScope.totalDisplayed = 50; $rootScope.totalDisplayed = 50;
$rootScope.loadMore = function () { $rootScope.loadMore = function () {
$scope.totalDisplayed += 50; $scope.totalDisplayed += 50;
}; };
$rootScope.go = function (path) {
$location.path(path);
};
/* /*
$scope.playSong = function (loadonly, data) { $scope.playSong = function (loadonly, data) {
$scope.$apply(function () { $scope.$apply(function () {
@ -46,7 +49,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
if (utils.getValue("SavedCollections")) { globals.SavedCollections = utils.getValue("SavedCollections").split(","); } if (utils.getValue("SavedCollections")) { globals.SavedCollections = utils.getValue("SavedCollections").split(","); }
if (utils.getValue("SavedGenres")) { globals.SavedGenres = utils.getValue("SavedGenres").split(","); } if (utils.getValue("SavedGenres")) { globals.SavedGenres = utils.getValue("SavedGenres").split(","); }
if (globals.settings.Debug) { console.log('Settings: ' + JSON.stringify(globals.settings, null, 2)); } if (globals.settings.Debug) { console.log('Settings: ' + JSON.stringify(globals.settings, null, 2)); }
} };
$scope.toggleSetting = function (setting) { $scope.toggleSetting = function (setting) {
var id = setting; var id = setting;
if (globals.settings[id]) { if (globals.settings[id]) {
@ -55,7 +58,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
globals.settings[id] = true; globals.settings[id] = true;
} }
notifications.updateMessage(setting + ' : ' + globals.settings[id], true); notifications.updateMessage(setting + ' : ' + globals.settings[id], true);
} };
$.ajaxSetup({ $.ajaxSetup({
'beforeSend': function () { 'beforeSend': function () {
@ -111,19 +114,19 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
submenu.css({ "left": (off.left - margin) + "px", "top": (off.top) + "px" }).fadeIn(400); submenu.css({ "left": (off.left - margin) + "px", "top": (off.top) + "px" }).fadeIn(400);
break; break;
} }
setTimeout(function () { if (submenu_active == false) $('div.submenu').stop().fadeOut(); }, 10000); setTimeout(function () { if (submenu_active === false) $('div.submenu').stop().fadeOut(); }, 10000);
}
} }
};
$rootScope.showQueue = function () { $rootScope.showQueue = function () {
var submenu = $('#QueuePreview'); var submenu = $('#QueuePreview');
submenu.fadeIn(400); submenu.fadeIn(400);
var timeout = globals.settings.Timeout; var timeout = globals.settings.Timeout;
setTimeout(function () { submenu.fadeOut(); }, timeout); setTimeout(function () { submenu.fadeOut(); }, timeout);
} };
$rootScope.hideQueue = function () { $rootScope.hideQueue = function () {
var submenu = $('#QueuePreview'); var submenu = $('#QueuePreview');
submenu.fadeOut(); submenu.fadeOut();
} };
$scope.toggleQueue = function () { $scope.toggleQueue = function () {
var submenu = $('#QueuePreview'); var submenu = $('#QueuePreview');
if (submenu.css('display') == 'none') { if (submenu.css('display') == 'none') {
@ -131,7 +134,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
} else { } else {
$rootScope.hideQueue(); $rootScope.hideQueue();
} }
} };
$("a.coverartfancy").fancybox({ $("a.coverartfancy").fancybox({
beforeShow: function () { beforeShow: function () {
//this.title = $('#songdetails_artist').html(); //this.title = $('#songdetails_artist').html();
@ -209,18 +212,18 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
return "You're about to end your session, are you sure?"; return "You're about to end your session, are you sure?";
} }
} }
} };
$scope.dragStart = function (e, ui) { $scope.dragStart = function (e, ui) {
ui.item.data('start', ui.item.index()); ui.item.data('start', ui.item.index());
} };
$scope.dragEnd = function (e, ui) { $scope.dragEnd = function (e, ui) {
var start = ui.item.data('start'), var start = ui.item.data('start'),
end = ui.item.index(); end = ui.item.index();
$rootScope.queue.splice(end, 0, $rootScope.queue.splice(end, 0,
$rootScope.queue.splice(start, 1)[0]); $rootScope.queue.splice(start, 1)[0]);
$scope.$apply(); $scope.$apply();
} };
$document.keydown(function (e) { $document.keydown(function (e) {
$scope.scrollToIndex(e); $scope.scrollToIndex(e);
}); });
@ -265,8 +268,8 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
} }
if (unicode == 189) { // dash - volume down if (unicode == 189) { // dash - volume down
var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1; var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
if (volume <= 1 && volume > 0 && source == '') { if (volume <= 1 && volume > 0 && source === '') {
volume += -.1; volume += -0.1;
$(player1).jPlayer({ $(player1).jPlayer({
volume: volume volume: volume
}); });
@ -276,8 +279,8 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
} }
if (unicode == 187) { // equals - volume up if (unicode == 187) { // equals - volume up
var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1; var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
if (volume < 1 && volume >= 0 && source == '') { if (volume < 1 && volume >= 0 && source ==- '') {
volume += .1; volume += 0.1;
$(player1).jPlayer({ $(player1).jPlayer({
volume: volume volume: volume
}); });
@ -296,37 +299,37 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
}; };
$scope.scrollToTop = function () { $scope.scrollToTop = function () {
$('#Artists').stop().scrollTo('#auto', 400); $('#Artists').stop().scrollTo('#auto', 400);
} };
$scope.selectAll = function () { $scope.selectAll = function () {
angular.forEach($rootScope.song, function (item, key) { angular.forEach($rootScope.song, function (item, key) {
$scope.selectedSongs.push(item); $scope.selectedSongs.push(item);
item.selected = true; item.selected = true;
}); });
} };
$scope.playAll = function () { $scope.playAll = function () {
$rootScope.queue = []; $rootScope.queue = [];
$scope.selectAll(); $scope.selectAll();
$scope.addSongsToQueue(); $scope.addSongsToQueue();
var next = $rootScope.queue[0]; var next = $rootScope.queue[0];
$rootScope.playSong(false, next); $rootScope.playSong(false, next);
} };
$scope.selectNone = function () { $scope.selectNone = function () {
angular.forEach($rootScope.song, function (item, key) { angular.forEach($rootScope.song, function (item, key) {
$scope.selectedSongs = []; $scope.selectedSongs = [];
item.selected = false; item.selected = false;
}); });
} };
$scope.addSongsToQueue = function () { $scope.addSongsToQueue = function () {
if ($scope.selectedSongs.length !== 0) { if ($scope.selectedSongs.length !== 0) {
angular.forEach($scope.selectedSongs, function (item, key) { angular.forEach($scope.selectedSongs, function (item, key) {
$scope.queue.push(item); $scope.queue.push(item);
item.selected = false; item.selected = false;
}); });
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true); notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
$scope.selectedSongs.length = 0; $scope.selectedSongs.length = 0;
} }
} };
$scope.isActive = function (route) { $scope.isActive = function (route) {
return route === $location.path(); return route === $location.path();
}; };
@ -345,6 +348,10 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
folders[0] = data["subsonic-response"].musicFolders.musicFolder; folders[0] = data["subsonic-response"].musicFolders.musicFolder;
} }
folders.unshift({
"id": -1,
"name": "All Folders"
});
$rootScope.MusicFolders = folders; $rootScope.MusicFolders = folders;
if (utils.getValue('MusicFolders')) { if (utils.getValue('MusicFolders')) {
var folder = angular.fromJson(utils.getValue('MusicFolders')); var folder = angular.fromJson(utils.getValue('MusicFolders'));
@ -356,12 +363,14 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
i++; i++;
}); });
$rootScope.SelectedMusicFolder = $rootScope.MusicFolders[index]; $rootScope.SelectedMusicFolder = $rootScope.MusicFolders[index];
} else {
$rootScope.SelectedMusicFolder = $rootScope.MusicFolders[0];
} }
$scope.$apply(); $scope.$apply();
} }
} }
}); });
} };
$scope.getGenres = function () { $scope.getGenres = function () {
var genres = 'Acid Rock,Acoustic,Alt Country,Alt/Indie,Alternative & Punk,Alternative Metal,Alternative,AlternRock,Awesome,Bluegrass,Blues,Blues-Rock,Classic Hard Rock,Classic Rock,Comedy,Country,Country-Rock,Dance,Dance-Rock,Deep Funk,Easy Listening,Electronic,Electronica,Electronica/Dance,Folk,Folk/Rock,Funk,Grunge,Hard Rock,Heavy Metal,Holiday,House,Improg,Indie Rock,Indie,International,Irish,Jam Band,Jam,Jazz Fusion,Jazz,Latin,Live Albums,Metal,Music,Oldies,Other,Pop,Pop/Rock,Post Rock,Progressive Rock,Psychedelic Rock,Psychedelic,Punk,R&B,Rap & Hip-Hop,Reggae,Rock & Roll,Rock,Rock/Pop,Roots,Ska,Soft Rock,Soul,Southern Rock,Thrash Metal,Unknown,Vocal,World'; var genres = 'Acid Rock,Acoustic,Alt Country,Alt/Indie,Alternative & Punk,Alternative Metal,Alternative,AlternRock,Awesome,Bluegrass,Blues,Blues-Rock,Classic Hard Rock,Classic Rock,Comedy,Country,Country-Rock,Dance,Dance-Rock,Deep Funk,Easy Listening,Electronic,Electronica,Electronica/Dance,Folk,Folk/Rock,Funk,Grunge,Hard Rock,Heavy Metal,Holiday,House,Improg,Indie Rock,Indie,International,Irish,Jam Band,Jam,Jazz Fusion,Jazz,Latin,Live Albums,Metal,Music,Oldies,Other,Pop,Pop/Rock,Post Rock,Progressive Rock,Psychedelic Rock,Psychedelic,Punk,R&B,Rap & Hip-Hop,Reggae,Rock & Roll,Rock,Rock/Pop,Roots,Ska,Soft Rock,Soul,Southern Rock,Thrash Metal,Unknown,Vocal,World';
$rootScope.Genres = genres.split(','); $rootScope.Genres = genres.split(',');
@ -386,7 +395,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
} }
}); });
*/ */
} };
$scope.download = function (id) { $scope.download = function (id) {
$.ajax({ $.ajax({
url: globals.BaseURL() + '/getUser.view?' + globals.BaseParams() + '&username=' + globals.settings.Username, url: globals.BaseURL() + '/getUser.view?' + globals.BaseParams() + '&username=' + globals.settings.Username,
@ -397,7 +406,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
if (typeof data["subsonic-response"].error != 'undefined') { if (typeof data["subsonic-response"].error != 'undefined') {
notifications.updateMessage('Error: ' + data["subsonic-response"].error.message, true); notifications.updateMessage('Error: ' + data["subsonic-response"].error.message, true);
} else { } else {
if (data["subsonic-response"].user.downloadRole == true) { if (data["subsonic-response"].user.downloadRole === true) {
$window.location.href = globals.BaseURL() + '/download.view?' + globals.BaseParams() + '&id=' + id; $window.location.href = globals.BaseURL() + '/download.view?' + globals.BaseParams() + '&id=' + id;
} else { } else {
notifications.updateMessage('You do not have permission to Download', true); notifications.updateMessage('You do not have permission to Download', true);
@ -405,7 +414,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
} }
} }
}); });
} };
$scope.ping = function () { $scope.ping = function () {
$.ajax({ $.ajax({
url: globals.BaseURL() + '/ping.view?' + globals.BaseParams(), url: globals.BaseURL() + '/ping.view?' + globals.BaseParams(),
@ -425,10 +434,10 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
notifications.updateMessage('Unable to connect to Subsonic server'); notifications.updateMessage('Unable to connect to Subsonic server');
} }
}); });
} };
$scope.addSongToQueue = function (data) { $scope.addSongToQueue = function (data) {
$rootScope.queue.push(data); $rootScope.queue.push(data);
} };
$scope.queueRemoveSelected = function (data, event) { $scope.queueRemoveSelected = function (data, event) {
angular.forEach($scope.selectedSongs, function (item, key) { angular.forEach($scope.selectedSongs, function (item, key) {
var index = $rootScope.queue.indexOf(item); var index = $rootScope.queue.indexOf(item);
@ -436,11 +445,11 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
$rootScope.queue.splice(index, 1); $rootScope.queue.splice(index, 1);
} }
}); });
} };
$scope.queueEmpty = function () { $scope.queueEmpty = function () {
//self.selectedSongs([]); //self.selectedSongs([]);
$rootScope.queue = []; $rootScope.queue = [];
} };
$scope.queueTotal = function () { $scope.queueTotal = function () {
var total = 0; var total = 0;
ko.utils.arrayForEach(self.queue(), function (item) { ko.utils.arrayForEach(self.queue(), function (item) {
@ -451,10 +460,10 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
} else { } else {
return '0 song(s), 00:00:00 total time'; return '0 song(s), 00:00:00 total time';
} }
} };
$scope.queueShuffle = function () { $scope.queueShuffle = function () {
$rootScope.queue.sort(function () { return 0.5 - Math.random() }); $rootScope.queue.sort(function () { return 0.5 - Math.random(); });
} };
$scope.selectedSongs = []; $scope.selectedSongs = [];
$scope.selectSong = function (data) { $scope.selectSong = function (data) {
var i = $scope.selectedSongs.indexOf(data); var i = $scope.selectedSongs.indexOf(data);
@ -466,24 +475,24 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
data.selected = true; data.selected = true;
} }
//$scope.$apply(); //$scope.$apply();
} };
$rootScope.getRandomSongs = function (action, genre, folder) { $rootScope.getRandomSongs = function (action, genre, folder) {
if (globals.settings.Debug) { console.log('action:' + action + ', genre:' + genre + ', folder:' + folder); } if (globals.settings.Debug) { console.log('action:' + action + ', genre:' + genre + ', folder:' + folder); }
var size = globals.settings.AutoPlaylistSize; var size = globals.settings.AutoPlaylistSize;
$rootScope.selectedPlaylist = null; $rootScope.selectedPlaylist = null;
if (typeof folder == 'number') { if (typeof folder == 'number') {
$rootScope.selectedAutoPlaylist = folder; $rootScope.selectedAutoPlaylist = folder;
} else if (genre != '') { } else if (genre !== '') {
$rootScope.selectedAutoPlaylist = genre; $rootScope.selectedAutoPlaylist = genre;
} else { } else {
$rootScope.selectedAutoPlaylist = 'random'; $rootScope.selectedAutoPlaylist = 'random';
} }
var genreParams = ''; var genreParams = '';
if (genre != '' && genre != 'Random') { if (genre !== '' && genre != 'Random') {
genreParams = '&genre=' + genre; genreParams = '&genre=' + genre;
} }
folderParams = ''; folderParams = '';
if (typeof folder == 'number' && folder != '' && folder != 'all') { if (typeof folder == 'number' && folder !== '' && folder != 'all') {
//alert(folder); //alert(folder);
folderParams = '&musicFolderId=' + folder; folderParams = '&musicFolderId=' + folder;
} else if (typeof $rootScope.SelectedMusicFolder.id != 'undefined') { } else if (typeof $rootScope.SelectedMusicFolder.id != 'undefined') {
@ -508,7 +517,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
$rootScope.queue.push(utils.mapSong(item)); $rootScope.queue.push(utils.mapSong(item));
}); });
$scope.$apply(); $scope.$apply();
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') { } else if (action == 'play') {
$rootScope.queue = []; $rootScope.queue = [];
@ -519,7 +528,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
$scope.$apply(function () { $scope.$apply(function () {
$rootScope.playSong(false, next); $rootScope.playSong(false, next);
}); });
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else { } else {
$rootScope.song = []; $rootScope.song = [];
@ -531,7 +540,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
} }
} }
}); });
} };
$scope.updateFavorite = function (item) { $scope.updateFavorite = function (item) {
var id = item.id; var id = item.id;
var starred = item.starred; var starred = item.starred;
@ -552,10 +561,10 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
notifications.updateMessage('Favorite Updated!', true); notifications.updateMessage('Favorite Updated!', true);
} }
}); });
} };
$scope.toTrusted = function (html) { $scope.toTrusted = function (html) {
return $sce.trustAsHtml(html); return $sce.trustAsHtml(html);
} };
/* Launch on Startup */ /* Launch on Startup */
$scope.loadSettings(); $scope.loadSettings();

View file

@ -7,7 +7,7 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
$scope.playlists = []; $scope.playlists = [];
$scope.playlistsPublic = []; $scope.playlistsPublic = [];
$scope.playlistsGenre = globals.SavedGenres; $scope.playlistsGenre = globals.SavedGenres;
$scope.selectedGenre; $scope.selectedGenre = null;
$scope.$watch("selectedGenre", function (newValue, oldValue) { $scope.$watch("selectedGenre", function (newValue, oldValue) {
if (newValue !== oldValue) { if (newValue !== oldValue) {
globals.SavedGenres.push(newValue); globals.SavedGenres.push(newValue);
@ -41,7 +41,7 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
} }
} }
}); });
} };
$scope.getPlaylist = function (id, action) { $scope.getPlaylist = function (id, action) {
$rootScope.selectedAutoPlaylist = null; $rootScope.selectedAutoPlaylist = null;
$rootScope.selectedPlaylist = id; $rootScope.selectedPlaylist = id;
@ -64,7 +64,7 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
$rootScope.queue.push(utils.mapSong(item)); $rootScope.queue.push(utils.mapSong(item));
}); });
$scope.$apply(); $scope.$apply();
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') { } else if (action == 'play') {
$rootScope.queue = []; $rootScope.queue = [];
@ -75,7 +75,7 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
$scope.$apply(function () { $scope.$apply(function () {
$rootScope.playSong(false, next); $rootScope.playSong(false, next);
}); });
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else { } else {
$scope.album = []; $scope.album = [];
@ -90,7 +90,7 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
} }
} }
}); });
} };
$scope.getStarred = function (action, type) { $scope.getStarred = function (action, type) {
var size = globals.settings.AutoPlaylistSize; var size = globals.settings.AutoPlaylistSize;
$rootScope.selectedPlaylist = null; $rootScope.selectedPlaylist = null;
@ -134,7 +134,7 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
$rootScope.queue.push(utils.mapSong(item)); $rootScope.queue.push(utils.mapSong(item));
}); });
$scope.$apply(); $scope.$apply();
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') { } else if (action == 'play') {
$rootScope.queue = []; $rootScope.queue = [];
@ -145,7 +145,7 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
$scope.$apply(function () { $scope.$apply(function () {
$rootScope.playSong(false, next); $rootScope.playSong(false, next);
}); });
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else { } else {
$rootScope.song = []; $rootScope.song = [];
@ -162,10 +162,10 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
} }
} }
}); });
} };
$scope.newPlaylist = function (data, event) { $scope.newPlaylist = function (data, event) {
var reply = prompt("Choose a name for your new playlist.", ""); var reply = prompt("Choose a name for your new playlist.", "");
if (reply != 'null' && reply != null && reply != '') { if (reply != 'null' && reply !== null && reply !== '') {
$.ajax({ $.ajax({
url: globals.BaseURL() + '/createPlaylist.view?' + globals.BaseParams() + '&name=' + reply, url: globals.BaseURL() + '/createPlaylist.view?' + globals.BaseParams() + '&name=' + reply,
method: 'GET', method: 'GET',
@ -176,9 +176,9 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
} }
}); });
} }
} };
$scope.deletePlaylist = function () { $scope.deletePlaylist = function () {
if ($rootScope.selectedPlaylist != null) { if ($rootScope.selectedPlaylist !== null) {
var id = $rootScope.selectedPlaylist; var id = $rootScope.selectedPlaylist;
if (utils.confirmDelete('Are you sure you want to delete the selected playlist?')) { if (utils.confirmDelete('Are you sure you want to delete the selected playlist?')) {
$.ajax({ $.ajax({
@ -192,9 +192,9 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
}); });
} }
} }
} };
$scope.savePlaylist = function () { $scope.savePlaylist = function () {
if ($rootScope.selectedPlaylist() != null) { if ($rootScope.selectedPlaylist() !== null) {
var id = $rootScope.selectedPlaylist().id(); var id = $rootScope.selectedPlaylist().id();
var songs = []; var songs = [];
ko.utils.arrayForEach($rootScope.song(), function (item) { ko.utils.arrayForEach($rootScope.song(), function (item) {
@ -215,12 +215,12 @@ function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, noti
}); });
} }
} }
} };
$scope.removeSelectedSongs = function (data, event) { $scope.removeSelectedSongs = function (data, event) {
ko.utils.arrayForEach($scope.selectedSongs(), function (item) { ko.utils.arrayForEach($scope.selectedSongs(), function (item) {
$rootScope.song.remove(item); $rootScope.song.remove(item);
}); });
} };
/* End Playlists */ /* End Playlists */
/* Launch on Startup */ /* Launch on Startup */

View file

@ -4,7 +4,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
$rootScope.song = []; $rootScope.song = [];
$scope.podcasts = []; $scope.podcasts = [];
$scope.selectedPodcast; $scope.selectedPodcast = null;
$scope.getPodcasts = function (refresh) { $scope.getPodcasts = function (refresh) {
if (globals.settings.Debug) { console.log("LOAD PODCASTS"); } if (globals.settings.Debug) { console.log("LOAD PODCASTS"); }
$.ajax({ $.ajax({
@ -25,7 +25,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
} }
} }
}); });
} };
$scope.getPodcast = function (id, action) { $scope.getPodcast = function (id, action) {
$scope.selectedPodcast = id; $scope.selectedPodcast = id;
var map = function (data) { var map = function (data) {
@ -46,7 +46,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
var salt = Math.floor(Math.random() * 100000); var salt = Math.floor(Math.random() * 100000);
url = globals.BaseURL() + '/stream.view?' + globals.BaseParams() + '&id=' + song.streamId + '&salt=' + salt; url = globals.BaseURL() + '/stream.view?' + globals.BaseParams() + '&id=' + song.streamId + '&salt=' + salt;
return new model.Song(song.streamId, song.parent, track, song.title, song.artist, song.artistId, song.album, song.albumId, coverartthumb, coverartfull, song.duration, song.userRating, starred, suffix, specs, url, 0, description); return new model.Song(song.streamId, song.parent, track, song.title, song.artist, song.artistId, song.album, song.albumId, coverartthumb, coverartfull, song.duration, song.userRating, starred, suffix, specs, url, 0, description);
} };
$.ajax({ $.ajax({
url: globals.BaseURL() + '/getPodcasts.view?' + globals.BaseParams(), url: globals.BaseURL() + '/getPodcasts.view?' + globals.BaseParams(),
method: 'GET', method: 'GET',
@ -75,7 +75,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
} }
}); });
$scope.$apply(); $scope.$apply();
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') { } else if (action == 'play') {
$rootScope.queue = []; $rootScope.queue = [];
@ -88,7 +88,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
$scope.$apply(function () { $scope.$apply(function () {
$rootScope.playSong(false, next); $rootScope.playSong(false, next);
}); });
$rootScope.showQueue(); //$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true); notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else { } else {
$scope.album = []; $scope.album = [];
@ -104,7 +104,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
} }
} }
}); });
} };
/* Launch on Startup */ /* Launch on Startup */
$scope.getPodcasts(); $scope.getPodcasts();

View file

@ -21,14 +21,11 @@
</div> </div>
</div> </div>
<div id="SubsonicAlbums" class="section lgsection split-pane fixed-left" split> <div id="SubsonicAlbums" class="section lgsection split-pane fixed-left" split>
<!--<div id="SubsonicAlbums" class="section lgsection" layout state="bodyState" ng-init="bodyState = 3">-->
<!--<div id="SubsonicAlbums" class="section lgsection">-->
<div id="left-component" class="split-pane-component smcolumn noselect" tabindex="0"> <div id="left-component" class="split-pane-component smcolumn noselect" tabindex="0">
<div id="AZIndex" ng-show="!settings.HideAZ" class="subactionsfixed"> <div id="AZIndex" ng-show="!settings.HideAZ" class="subactionsfixed">
<a href="" ng-click="toggleAZ()" stop-event="click">A-Z</a> <a href="" ng-click="toggleAZ()" stop-event="click">A-Z</a>
</div> </div>
<select id="MusicFolders" class="folders" ng-model="$root.SelectedMusicFolder" ng-options="o as o.name for o in MusicFolders"> <select id="MusicFolders" class="folders" ng-model="$root.SelectedMusicFolder" ng-options="o.name for o in MusicFolders">
<option value="">All Folders</option>
</select> </select>
<ul id="AutoAlbumContainer" class="simplelist mainlist noselect"> <ul id="AutoAlbumContainer" class="simplelist mainlist noselect">
<li class="index" id="auto">Auto Albums</li> <li class="index" id="auto">Auto Albums</li>

View file

@ -1,119 +0,0 @@
<!-- Start: Library Tab -->
<div id="tab1" class="tabcontent">
<div id="tabLibrary">
<div class="actions floatleft">
<a href="" class="button" id="action_RefreshArtists" title="Refresh Artists" ng-click="getArtists()"><img class="pad" src="images/reload_9x11.png" /></a>
<a href="" class="button" id="action_RescanLibrary" title="Rescan Library" ng-click="rescanLibrary()"><img class="pad" src="images/loop_alt1_gd_12x9.png" /></a>
</div>
<div id="search">
<input type="text" id="Search" class="medium" title="Wildcards (*) supported" placeholder="Search..." ng-enter="search()"/>
<select id="SearchType" name="SearchType">
<option value="song">Song</option>
<option value="album">Album</option>
</select>
<a href="" class="button" id="action_Search" title="Search" ng-click="search()"><img class="pad" src="images/magnifying_glass_alt_12x12.png" /></a>
</div>
<div class="subactions">
<a href="" class="button" id="action_SelectAll" title="Select All" ng-click="selectAll()">All</a>
<a href="" class="button" id="action_SelectNone" title="Select None" ng-click="selectNone()">None</a>
<a href="" class="button" id="action_AddToQueue" title="Add To Queue" ng-click="addSongsToQueue()">+ Queue</a>
<a href="" class="button" id="action_AddToPlaylist" title="Add Selected To Playlist" ng-click="loadPlaylistsForMenu()">+ Playlist</a>
<div id="submenu_AddToPlaylist" class="submenu shadow" style="display: none;">
<a href="" ng-repeat="o in playlistMenu" ng-click="addToPlaylist(o.id)">{{o.name}}</a>
</div>
</div>
<div class="clear"></div>
<!--<div id="SubsonicAlbums" class="section lgsection" layout state="bodyState" ng-init="bodyState = 3">-->
<div id="SubsonicAlbums" class="section lgsection">
<div id="SubsonicArtists" class="ui-layout-west noselect hide" tabindex="0">
<div id="AZIndex" ng-show="!settings.HideAZ" class="subactionsfixed">
<a href="" ng-click="toggleAZ()" stop-event="click">A-Z</a>
</div>
<div id="submenu_AZIndex" class="submenu shadow" style="display: none;">
<ul>
<li ng-repeat="o in index"><a href="" ng-click="scrollToIndexName(o.name)">{{o.name}}</a></li>
<li><a href="" class="close" ng-click="scrollToIndexName('AZIndex')">[Top]</a></li>
<li><a href="" class="close" ng-click="toggleAZ()">[Close]</a></li>
</ul>
</div>
<select id="MusicFolders" class="folders" ng-model="$root.selectedMusicFolder" ng-options="o as o.name for o in MusicFolders">
<option value="">All Folders</option>
</select>
<ul id="AutoAlbumContainer" class="simplelist mainlist noselect">
<li class="index" id="auto">Auto Albums</li>
<li class="item" ng-repeat="o in AutoAlbums" id="{{o.id}}" ng-click="getAlbumListBy(o.id)" ng-class="{'selected': selectedAutoAlbum == o.id }">
<span>{{o.name}}</span>
<div class="floatright">
<a href="" class="nextprev hover" id="random" title="Previous" ng-click="getAlbumListBy(o.id, 'prev')" stop-event="click">&lsaquo;</a>
<a href="" class="nextprev hover" id="random" title="Next" ng-click="getAlbumListBy(o.id, 'next')" stop-event="click">&rsaquo;</a>
</div>
</li>
</ul>
<!-- Shortcut -->
<ul class="simplelist mainlist noselect" ng-show="shortcut.length">
<li class="index" title="Scroll to Top" data-bind="click: $root.scrollToTop"><a>Shortcuts</a></li>
<ul class="simplelist mainlist noselect" ng-repeat="o in shortcut">
<li class="item" id="{{o.id}}" ng-click="getAlbums(o.id)" ng-class="{'selected': selectedArtist == o.id}"><span ng-bind-html-unsafe="o.name"></span></li>
</ul>
</ul>
<!-- Artist -->
<ul class="simplelist mainlist noselect" ng-repeat="o in index">
<li class="index" title="Scroll to Top" id="{{o.name}}" ng-click="scrollToTop()"><a>{{o.name}}</a><span class="floatright">?</span></li>
<ul class="simplelist mainlist noselect">
<li class="item" id="{{a.id}}" ng-repeat="a in o.artist" ng-class="{'selected': selectedArtist == a.id}" ng-click="getAlbums(a.id)"><a ng-href="" ng-bind-html-unsafe="a.name"></a></li>
</ul>
</ul>
</div>
<!-- Album -->
<div class="ui-layout-center">
<ul class="actionlist">
<li>
<form class="form">
<select id="selectedSubsonicAlbumSort" ng-model="selectedSubsonicAlbumSort" ng-options="o.id as o.name for o in SubsonicSort"></select>
<select id="selectedLayout" ng-model="selectedLayout" ng-options="o.id as o.name for o in Layouts"></select>
</form>
<!--
<div id="BreadCrumb">
<a href="#" id="BreadHome"><img src="images/home_gl_12x12.png"></a>
<div id="BreadCrumbs" class="floatleft"><a ng-show="artistId" ng-href="#/library/{{artistId}}">AC/DC</a> &gt;<a ng-show="albumId" ng-href="#/library/{{albumId}}">Back In Black</a></div>
</div>
-->
</li>
</ul>
<div class="clear"></div>
<ul class="simplelist songlist noselect">
<div class="animate-switch-container" ng-repeat="o in album" ng-switch on="o.type">
<!--<div class="animate-switch" ng-switch-default>default</div>-->
<li class="album" ng-switch-when="byfolder" id="{{o.id}}" ng-class="{'selected': selectedAlbum == o.id, 'albumgrid': selectedLayout == 'grid'}" ng-click="getSongs(o.id, '')" parentid="{{o.parentid}}">
<div class="itemactions">
<a class="add" href="" title="Add To Play Queue" ng-click="getSongs(o.id, 'add')" stop-event="click"></a>
<a class="play" href="" title="Play" ng-click="getSongs(o.id, 'play')" stop-event="click"></a>
<a class="download" href="" ng-click="download(o.id)" title="Download" stop-event="click"></a>
<a title="Favorite" href="" ng-class="{'favorite': o.starred, 'rate': !o.starred}" ng-click="updateFavorite(o)" stop-event="click"></a>
<a class="info hover" href="" title="{{'Created: ' + o.date}}"></a>
</div>
<div class="albumart"><img ng-src="{{o.coverartthumb}}" src="images/albumdefault_160.jpg"></div>
<div class="albuminfo">
<div class="title" title="{{o.name}}" ng-bind-html-unsafe="o.name"></div>
<div class="artist" title="{{o.artist}}"><a href="" id="{{o.parentid}}" ng-click="getAlbums(o.parentid)" stop-event="click" ng-bind-html-unsafe="o.artist"></a></div>
</div>
<div class="clear"></div>
</li>
<li class="album" ng-switch-when="bytag" id="{{o.id}}" ng-class="{'selected': selectedAlbum == o.id, 'albumgrid': selectedLayout == 'grid'}" ng-click="getAlbumByTag(o.id)">
<div class="albumart"><img ng-src="{{o.coverartthumb}}" src="images/albumdefault_160.jpg"></div>
<div class="albuminfo">
<div class="title" title="{{o.name}}" ng-bind-html-unsafe="o.name"></div>
<div class="artist" title="{{o.artist}}"><a href="" ng-click="getArtistByTag(o.artistId)" stop-event="click" ng-bind-html-unsafe="o.artist"></a></div>
</div>
<div class="clear"></div>
</li>
</div>
</ul>
</div>
<!-- Song -->
<div class="ui-layout-east noselect hide" ng-include src="'js/partials/songs.html'"></div>
</div>
</div>
<div class="clear"></div>
</div>
<!-- End: Library Tab -->

View file

@ -3,12 +3,11 @@
var player2 = '#playdeck_2'; var player2 = '#playdeck_2';
var scrobbled = false; var scrobbled = false;
var timerid = 0; var timerid = 0;
$rootScope.defaultPlay = function (data, event) { $rootScope.defaultPlay = function (data, event) {
if (typeof $(player1).data("jPlayer") == 'undefined') { if (typeof $(player1).data("jPlayer") == 'undefined') {
$rootScope.nextTrack(); $rootScope.nextTrack();
} }
} };
$rootScope.nextTrack = function () { $rootScope.nextTrack = function () {
var next = getNextSong(); var next = getNextSong();
if (next) { if (next) {
@ -16,13 +15,13 @@
} }
//$(player1).jPlayer("stop"); //$(player1).jPlayer("stop");
//$(player2).jPlayer("play"); //$(player2).jPlayer("play");
} };
$rootScope.previousTrack = function () { $rootScope.previousTrack = function () {
var next = getNextSong(true); var next = getNextSong(true);
if (next) { if (next) {
$rootScope.playSong(false, next); $rootScope.playSong(false, next);
} }
} };
getNextSong = function (previous) { getNextSong = function (previous) {
var song; var song;
if (globals.settings.Debug) { console.log('Getting Next Song > ' + 'Queue length: ' + $rootScope.queue.length); } if (globals.settings.Debug) { console.log('Getting Next Song > ' + 'Queue length: ' + $rootScope.queue.length); }
@ -48,10 +47,10 @@
} else { } else {
return false; return false;
} }
} };
this.startSaveTrackPosition = function () { this.startSaveTrackPosition = function () {
if (globals.settings.SaveTrackPosition) { if (globals.settings.SaveTrackPosition) {
if (timerid != 0) { if (timerid !== 0) {
clearInterval(timerid); clearInterval(timerid);
} }
timerid = $window.setInterval(function () { timerid = $window.setInterval(function () {
@ -60,12 +59,12 @@
} }
}, 30000); }, 30000);
} }
} };
this.saveTrackPosition = function () { this.saveTrackPosition = function () {
//var audio = typeof $(player1).data("jPlayer") != 'undefined' ? true : false; //var audio = typeof $(player1).data("jPlayer") != 'undefined' ? true : false;
var audio = $(player1).data("jPlayer"); var audio = $(player1).data("jPlayer");
if (typeof audio != 'undefined') { if (typeof audio != 'undefined') {
if (audio.status.currentTime > 0 && audio.status.paused == false) { if (audio.status.currentTime > 0 && audio.status.paused === false) {
var song; var song;
angular.forEach($rootScope.queue, function (item, key) { angular.forEach($rootScope.queue, function (item, key) {
if (item.playing === true) { if (item.playing === true) {
@ -74,7 +73,7 @@
}); });
if (song) { if (song) {
var position = audio.status.currentTime; var position = audio.status.currentTime;
if (position != null) { if (position !== null) {
$('#action_SaveProgress').fadeTo("slow", 0).delay(500).fadeTo("slow", 1).delay(500).fadeTo("slow", 0).delay(500).fadeTo("slow", 1); $('#action_SaveProgress').fadeTo("slow", 0).delay(500).fadeTo("slow", 1).delay(500).fadeTo("slow", 0).delay(500).fadeTo("slow", 1);
song.position = position; song.position = position;
// Save Queue // Save Queue
@ -105,7 +104,7 @@
} else { } else {
if (globals.settings.Debug) { console.log('Saving Queue: No Audio Loaded'); } if (globals.settings.Debug) { console.log('Saving Queue: No Audio Loaded'); }
} }
} };
this.loadTrackPosition = function () { this.loadTrackPosition = function () {
if (utils.browserStorageCheck()) { if (utils.browserStorageCheck()) {
// Load Saved Song // Load Saved Song
@ -126,7 +125,7 @@
} else { } else {
if (globals.settings.Debug) { console.log('HTML5::loadStorage not supported on your browser'); } if (globals.settings.Debug) { console.log('HTML5::loadStorage not supported on your browser'); }
} }
} };
this.deleteCurrentQueue = function (data) { this.deleteCurrentQueue = function (data) {
if (utils.browserStorageCheck()) { if (utils.browserStorageCheck()) {
localStorage.removeItem('CurrentQueue'); localStorage.removeItem('CurrentQueue');
@ -135,7 +134,7 @@
} else { } else {
if (globals.settings.Debug) { console.log('HTML5::loadStorage not supported on your browser, ' + html.length + ' characters'); } if (globals.settings.Debug) { console.log('HTML5::loadStorage not supported on your browser, ' + html.length + ' characters'); }
} }
} };
$rootScope.playSong = function (loadonly, data) { $rootScope.playSong = function (loadonly, data) {
if (globals.settings.Debug) { console.log('Play: ' + JSON.stringify(data, null, 2)); } if (globals.settings.Debug) { console.log('Play: ' + JSON.stringify(data, null, 2)); }
angular.forEach($rootScope.queue, function(item, key) { angular.forEach($rootScope.queue, function(item, key) {
@ -168,7 +167,7 @@
artist: artist, artist: artist,
favorite: false, favorite: false,
albumArt: coverartfull albumArt: coverartfull
} };
if ($rootScope.unity) { if ($rootScope.unity) {
$rootScope.unity.sendState(playerState); $rootScope.unity.sendState(playerState);
} }
@ -176,7 +175,7 @@
} }
if ($rootScope.queue.length > 0) { if ($rootScope.queue.length > 0) {
$('#QueuePreview').stop().scrollTo('#' + id, 400); $('#QueuePreview').stop().scrollTo('#' + id, 400);
$rootScope.showQueue(); //$rootScope.showQueue();
} }
var spechtml = ''; var spechtml = '';
var data = $(player1).data().jPlayer; var data = $(player1).data().jPlayer;
@ -185,11 +184,11 @@
if (data[solution].used) { if (data[solution].used) {
spechtml += "<strong class=\"codesyntax\">" + solution + "</strong> is"; spechtml += "<strong class=\"codesyntax\">" + solution + "</strong> is";
spechtml += " currently being used with<strong>"; spechtml += " currently being used with<strong>";
for (format in data[solution].support) { angular.forEach(data[solution].support, function (format) {
if (data[solution].support[format]) { if (data[solution].support[format]) {
spechtml += " <strong class=\"codesyntax\">" + format + "</strong>"; spechtml += " <strong class=\"codesyntax\">" + format + "</strong>";
} }
} });
spechtml += "</strong> support"; spechtml += "</strong> support";
} }
} }
@ -200,8 +199,7 @@
notifications.showNotification(coverartthumb, utils.toHTML.un(title), utils.toHTML.un(artist + ' - ' + album), 'text', '#NextTrack'); notifications.showNotification(coverartthumb, utils.toHTML.un(title), utils.toHTML.un(artist + ' - ' + album), 'text', '#NextTrack');
} }
if (globals.settings.ScrollTitle) { if (globals.settings.ScrollTitle) {
var title = utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title); utils.scrollTitle(utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title));
utils.scrollTitle(title);
} else { } else {
utils.setTitle(utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title)); utils.setTitle(utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title));
} }
@ -248,11 +246,11 @@
console.log("File Suffix: " + suffix); console.log("File Suffix: " + suffix);
if (suffix == 'oga') { if (suffix == 'oga') {
$(this).jPlayer("setMedia", { $(this).jPlayer("setMedia", {
oga: url, oga: url
}); });
} else if (suffix == 'mp3') { } else if (suffix == 'mp3') {
$(this).jPlayer("setMedia", { $(this).jPlayer("setMedia", {
mp3: url, mp3: url
}); });
} }
if (!loadonly) { // Start playing if (!loadonly) { // Start playing
@ -312,7 +310,7 @@
} }
}); });
return; return;
} };
this.playPauseSong = function () { this.playPauseSong = function () {
if (typeof $(player1).data("jPlayer") != 'undefined') { if (typeof $(player1).data("jPlayer") != 'undefined') {
if ($(player1).data("jPlayer").status.paused) { if ($(player1).data("jPlayer").status.paused) {
@ -321,7 +319,7 @@
$(player1).jPlayer("pause"); $(player1).jPlayer("pause");
} }
} }
} };
playVideo = function (id, bitrate) { playVideo = function (id, bitrate) {
var w, h; var w, h;
bitrate = parseInt(bitrate); bitrate = parseInt(bitrate);
@ -352,8 +350,7 @@
solution: "html, flash", solution: "html, flash",
supplied: "m4v" supplied: "m4v"
}); });
} };
scrobbleSong = function (submission) { scrobbleSong = function (submission) {
if ($rootScope.loggedIn && submission) { if ($rootScope.loggedIn && submission) {
var id = $rootScope.playingSong.id; var id = $rootScope.playingSong.id;
@ -368,7 +365,7 @@
} }
}); });
} }
} };
rateSong = function (songid, rating) { rateSong = function (songid, rating) {
$.ajax({ $.ajax({
url: baseURL + '/setRating.view?' + baseParams + '&id=' + songid + "&rating=" + rating, url: baseURL + '/setRating.view?' + baseParams + '&id=' + songid + "&rating=" + rating,
@ -379,5 +376,5 @@
updateMessage('Rating Updated!', true); updateMessage('Rating Updated!', true);
} }
}); });
} };
}); });

View file

@ -16,7 +16,7 @@
else if (tmp < 10) { else if (tmp < 10) {
tmp = '0' + tmp; tmp = '0' + tmp;
} }
if (i == 0 && tmp == '00') { if (i === 0 && tmp == '00') {
} else { } else {
time += tmp; time += tmp;
if (i < 2) { if (i < 2) {
@ -26,15 +26,15 @@
secs = secs % times[i]; secs = secs % times[i];
} }
return time; return time;
} };
this.Index = function (name, artist) { this.Index = function (name, artist) {
this.name = name; this.name = name;
this.artist = artist; this.artist = artist;
} };
this.Artist = function (id, name) { this.Artist = function (id, name) {
this.id = id; this.id = id;
this.name = name; this.name = name;
} };
this.Album = function (id, parentid, name, artist, artistId, coverartthumb, coverartfull, date, starred, description, url, type) { this.Album = function (id, parentid, name, artist, artistId, coverartthumb, coverartfull, date, starred, description, url, type) {
this.id = id; this.id = id;
this.parentid = parentid; this.parentid = parentid;
@ -48,7 +48,7 @@
this.description = description; this.description = description;
this.url = url; this.url = url;
this.type = type; this.type = type;
} };
this.Song = function (id, parentid, track, name, artist, artistId, album, albumId, coverartthumb, coverartfull, duration, rating, starred, suffix, specs, url, position, description) { this.Song = function (id, parentid, track, name, artist, artistId, album, albumId, coverartthumb, coverartfull, duration, rating, starred, suffix, specs, url, position, description) {
this.id = id; this.id = id;
this.parentid = parentid; this.parentid = parentid;
@ -61,7 +61,7 @@
this.coverartthumb = coverartthumb; this.coverartthumb = coverartthumb;
this.coverartfull = coverartfull; this.coverartfull = coverartfull;
this.duration = duration; this.duration = duration;
this.time = duration == '' ? '00:00' : secondsToTime(duration); this.time = duration === '' ? '00:00' : secondsToTime(duration);
this.rating = rating; this.rating = rating;
this.starred = starred; this.starred = starred;
this.suffix = suffix; this.suffix = suffix;
@ -72,14 +72,14 @@
this.playing = false; this.playing = false;
this.description = description; this.description = description;
this.displayName = this.name + " - " + this.album + " - " + this.artist; this.displayName = this.name + " - " + this.album + " - " + this.artist;
} };
}); });
JamStash.service('globals', function () { JamStash.service('globals', function () {
this.SearchTypes = [ this.SearchTypes = [
{ id: "song", name: "Song" }, { id: "song", name: "Song" },
{ id: "album", name: "Album" }, { id: "album", name: "Album" },
{ id: "artist", name: "Artist" }, { id: "artist", name: "Artist" }
]; ];
this.Layouts = [ this.Layouts = [
{ id: "grid", name: "Grid" }, { id: "grid", name: "Grid" },
@ -90,7 +90,7 @@ JamStash.service('globals', function () {
{ id: "artist", name: "Artist" }, { id: "artist", name: "Artist" },
{ id: "album", name: "Album" }, { id: "album", name: "Album" },
{ id: "track", name: "Track" }, { id: "track", name: "Track" },
{ id: "createdate desc", name: "Date Added" }, { id: "createdate desc", name: "Date Added" }
]; ];
this.settings = { this.settings = {
// Subsonic // Subsonic
@ -156,16 +156,16 @@ JamStash.directive('layout', function () {
}; };
var layoutThreeCol = { var layoutThreeCol = {
east__size: .42, east__size: 0.42,
east__minSize: 400, east__minSize: 400,
east__maxSize: .5, // 50% of layout width east__maxSize: 0.5, // 50% of layout width
east__initClosed: false, east__initClosed: false,
east__initHidden: false, east__initHidden: false,
//center__size: 'auto', //center__size: 'auto',
center__minWidth: .38, center__minWidth: 0.38,
center__initClosed: false, center__initClosed: false,
center__initHidden: false, center__initHidden: false,
west__size: .2, west__size: 0.2,
west__minSize: 200, west__minSize: 200,
west__initClosed: false, west__initClosed: false,
west__initHidden: false, west__initHidden: false,
@ -175,12 +175,12 @@ JamStash.directive('layout', function () {
}; };
var layoutTwoCol = { var layoutTwoCol = {
center__size: .8, center__size: 0.8,
center__minSize: 400, center__minSize: 400,
center__maxSize: .5, // 50% of layout width center__maxSize: 0.5, // 50% of layout width
center__initClosed: false, center__initClosed: false,
center__initHidden: false, center__initHidden: false,
west__size: .2, west__size: 0.2,
west__minSize: 200, west__minSize: 200,
west__initClosed: false, west__initClosed: false,
west__initHidden: false, west__initHidden: false,
@ -301,8 +301,8 @@ JamStash.directive('songpreview', function ($compile, subsonic) {
//compiled($scope); //compiled($scope);
}); });
} }
} };
}) });
JamStash.directive('stopEvent', function () { JamStash.directive('stopEvent', function () {
return { return {
restrict: 'A', restrict: 'A',
@ -358,7 +358,7 @@ JamStash.factory('json', function ($http) { // Deferred loading
getChangeLog: function (callback) { getChangeLog: function (callback) {
$http.get('js/json_changelog.js').success(callback); $http.get('js/json_changelog.js').success(callback);
} }
} };
}); });
JamStash.factory('template', function ($http, $compile, $http, $templateCache) { // Deferred loading JamStash.factory('template', function ($http, $compile, $http, $templateCache) { // Deferred loading
return { return {
@ -372,7 +372,7 @@ JamStash.factory('template', function ($http, $compile, $http, $templateCache) {
templateUrl = 'js/partials/songs.html'; templateUrl = 'js/partials/songs.html';
$http.get(templateUrl, { cache: $templateCache }).success(callback); $http.get(templateUrl, { cache: $templateCache }).success(callback);
} }
} };
}); });
JamStash.factory('subsonic', function ($http, globals, utils) { JamStash.factory('subsonic', function ($http, globals, utils) {
return { return {
@ -408,20 +408,20 @@ JamStash.factory('subsonic', function ($http, globals, utils) {
} }
}); });
} }
} };
}); });
/* Filters */ /* Filters */
JamStash.filter('capitalize', function () { JamStash.filter('capitalize', function () {
return function (input, scope) { return function (input, scope) {
return input.substring(0, 1).toUpperCase() + input.substring(1); return input.substring(0, 1).toUpperCase() + input.substring(1);
} };
}); });
JamStash.service('notifications', function ($rootScope, globals) { JamStash.service('notifications', function ($rootScope, globals) {
var msgIndex = 1; var msgIndex = 1;
this.updateMessage = function (msg, autohide) { this.updateMessage = function (msg, autohide) {
if (msg != '') { if (msg !== '') {
var id = msgIndex; var id = msgIndex;
$('#messages').append('<span id=\"msg_' + id + '\" class="message">' + msg + '</span>'); $('#messages').append('<span id=\"msg_' + id + '\" class="message">' + msg + '</span>');
$('#messages').fadeIn(); $('#messages').fadeIn();
@ -438,16 +438,16 @@ JamStash.service('notifications', function ($rootScope, globals) {
}); });
msgIndex++; msgIndex++;
} }
} };
this.requestPermissionIfRequired = function () { this.requestPermissionIfRequired = function () {
if (!this.hasNotificationPermission() && (window.webkitNotifications)) { if (!this.hasNotificationPermission() && (window.webkitNotifications)) {
window.webkitNotifications.requestPermission(); window.webkitNotifications.requestPermission();
} }
} };
this.hasNotificationPermission = function () { this.hasNotificationPermission = function () {
return !!(window.webkitNotifications) && (window.webkitNotifications.checkPermission() == 0); return !!(window.webkitNotifications) && (window.webkitNotifications.checkPermission() === 0);
} };
var notifications = new Array(); var notifications = [];
this.showNotification = function (pic, title, text, type, bind) { this.showNotification = function (pic, title, text, type, bind) {
if (this.hasNotificationPermission()) { if (this.hasNotificationPermission()) {
//closeAllNotifications() //closeAllNotifications()
@ -457,12 +457,12 @@ JamStash.service('notifications', function ($rootScope, globals) {
} else if (type == 'html') { } else if (type == 'html') {
popup = window.webkitNotifications.createHTMLNotification(text); popup = window.webkitNotifications.createHTMLNotification(text);
} }
if (bind = '#NextTrack') { if (bind == '#NextTrack') {
popup.addEventListener('click', function (bind) { popup.addEventListener('click', function (bind) {
//$(bind).click(); //$(bind).click();
$rootScope.nextTrack(); $rootScope.nextTrack();
this.cancel(); this.cancel();
}) });
} }
notifications.push(popup); notifications.push(popup);
setTimeout(function (notWin) { setTimeout(function (notWin) {
@ -472,10 +472,10 @@ JamStash.service('notifications', function ($rootScope, globals) {
} else { } else {
console.log("showNotification: No Permission"); console.log("showNotification: No Permission");
} }
} };
this.closeAllNotifications = function () { this.closeAllNotifications = function () {
for (notification in notifications) { for (notification in notifications) {
notifications[notification].cancel(); notifications[notification].cancel();
} }
} };
}); });

View file

@ -24,7 +24,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} catch (e) { } catch (e) {
if (globals.settings.Debug) { console.log(e); } if (globals.settings.Debug) { console.log(e); }
} }
} };
this.getValue = function (value) { this.getValue = function (value) {
/* /*
if ($cookieStore.get(value)) { if ($cookieStore.get(value)) {
@ -35,7 +35,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
*/ */
try { try {
var item = localStorage.getItem(value); var item = localStorage.getItem(value);
if (item != '' && typeof item != 'undefined') { if (item !== '' && typeof item != 'undefined') {
return JSON.parse(item); return JSON.parse(item);
} else { } else {
return false; return false;
@ -43,7 +43,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} catch (e) { } catch (e) {
if (globals.settings.Debug) { console.log(e); } if (globals.settings.Debug) { console.log(e); }
} }
} };
this.mapSong = function (data) { this.mapSong = function (data) {
var song = data; var song = data;
var url, title, track, rating, starred, contenttype, suffix, description; var url, title, track, rating, starred, contenttype, suffix, description;
@ -66,7 +66,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
var salt = Math.floor(Math.random() * 100000); var salt = Math.floor(Math.random() * 100000);
url = globals.BaseURL() + '/stream.view?' + globals.BaseParams() + '&id=' + song.id + '&salt=' + salt; url = globals.BaseURL() + '/stream.view?' + globals.BaseParams() + '&id=' + song.id + '&salt=' + salt;
return new model.Song(song.id, song.parent, track, title, song.artist, song.artistId, song.album, song.albumId, coverartthumb, coverartfull, song.duration, song.userRating, starred, suffix, specs, url, 0, description); return new model.Song(song.id, song.parent, track, title, song.artist, song.artistId, song.album, song.albumId, coverartthumb, coverartfull, song.duration, song.userRating, starred, suffix, specs, url, 0, description);
} };
this.confirmDelete = function (text) { this.confirmDelete = function (text) {
var question = confirm(text); var question = confirm(text);
if (question) { if (question) {
@ -75,19 +75,19 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
else { else {
return false; return false;
} }
} };
this.makeBaseAuth = function (user, password) { this.makeBaseAuth = function (user, password) {
var tok = user + ':' + password; var tok = user + ':' + password;
var hash = $.base64Encode(tok); var hash = $.base64Encode(tok);
return "Basic " + hash; return "Basic " + hash;
} };
this.HexEncode = function (n) { this.HexEncode = function (n) {
for (var u = "0123456789abcdef", i = [], r = [], t = 0; t < 256; t++) for (var u = "0123456789abcdef", i = [], r = [], t = 0; t < 256; t++)
i[t] = u.charAt(t >> 4) + u.charAt(t & 15); i[t] = u.charAt(t >> 4) + u.charAt(t & 15);
for (t = 0; t < n.length; t++) for (t = 0; t < n.length; t++)
r[t] = i[n.charCodeAt(t)]; r[t] = i[n.charCodeAt(t)];
return r.join("") return r.join("");
} };
this.switchTheme = function (theme) { this.switchTheme = function (theme) {
switch (theme.toLowerCase()) { switch (theme.toLowerCase()) {
case 'dark': case 'dark':
@ -99,7 +99,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
default: default:
break; break;
} }
} };
// HTML5 // HTML5
this.browserStorageCheck = function () { this.browserStorageCheck = function () {
if (typeof (localStorage) == 'undefined') { if (typeof (localStorage) == 'undefined') {
@ -107,7 +107,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} else { } else {
return true; return true;
} }
} };
this.timeToSeconds = function (time) { this.timeToSeconds = function (time) {
var a = time.split(':'); // split it at the colons var a = time.split(':'); // split it at the colons
var seconds; var seconds;
@ -125,7 +125,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
break; break;
} }
return seconds; return seconds;
} };
this.secondsToTime = function (secs) { this.secondsToTime = function (secs) {
// secs = 4729 // secs = 4729
var times = new Array(3600, 60, 1); var times = new Array(3600, 60, 1);
@ -142,7 +142,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
else if (tmp < 10) { else if (tmp < 10) {
tmp = '0' + tmp; tmp = '0' + tmp;
} }
if (i == 0 && tmp == '00') { if (i === 0 && tmp == '00') {
} else { } else {
time += tmp; time += tmp;
if (i < 2) { if (i < 2) {
@ -152,13 +152,13 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
secs = secs % times[i]; secs = secs % times[i];
} }
return time; return time;
} };
this.arrayObjectIndexOf = function (myArray, searchTerm, property) { this.arrayObjectIndexOf = function (myArray, searchTerm, property) {
for (var i = 0, len = myArray.length; i < len; i++) { for (var i = 0, len = myArray.length; i < len; i++) {
if (myArray[i][property] === searchTerm) return i; if (myArray[i][property] === searchTerm) return i;
} }
return -1; return -1;
} };
this.logObjectProperties = function (obj) { this.logObjectProperties = function (obj) {
$.each(obj, function (key, value) { $.each(obj, function (key, value) {
var parent = key; var parent = key;
@ -170,7 +170,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
console.log(key + ' : ' + value); console.log(key + ' : ' + value);
} }
}); });
} };
this.clickButton = function (el) { this.clickButton = function (el) {
var el = $(el); var el = $(el);
if (el) { if (el) {
@ -189,9 +189,10 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} }
} }
} }
} };
this.findKeyForCode = function (code) { this.findKeyForCode = function (code) {
var map = { 'keymap': [ var map = {
'keymap': [
{ 'key': 'a', 'code': 65 }, { 'key': 'a', 'code': 65 },
{ 'key': 'b', 'code': 66 }, { 'key': 'b', 'code': 66 },
{ 'key': 'c', 'code': 67 }, { 'key': 'c', 'code': 67 },
@ -227,19 +228,19 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} }
}); });
return keyFound; return keyFound;
} };
this.toHTML = { this.toHTML = {
on: function (str) { on: function (str) {
var a = [], var a = [],
i = 0; i = 0;
for (; i < str.length; ) a[i] = str.charCodeAt(i++); for (; i < str.length; ) a[i] = str.charCodeAt(i++);
return "&#" + a.join(";&#") + ";" return "&#" + a.join(";&#") + ";";
}, },
un: function (str) { un: function (str) {
return str.replace(/&#(x)?([^;]{1,5});?/g, return str.replace(/&#(x)?([^;]{1,5});?/g,
function (a, b, c) { function (a, b, c) {
return String.fromCharCode(parseInt(c, b ? 16 : 10)) return String.fromCharCode(parseInt(c, b ? 16 : 10));
}) });
} }
}; };
this.getParameterByName = function (name) { this.getParameterByName = function (name) {
@ -247,21 +248,21 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
var regexS = "[\\?&]" + name + "=([^&#]*)"; var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS); var regex = new RegExp(regexS);
var results = regex.exec(window.location.search); var results = regex.exec(window.location.search);
if (results == null) if (results === null)
return ""; return "";
else else
return decodeURIComponent(results[1].replace(/\+/g, " ")); return decodeURIComponent(results[1].replace(/\+/g, " "));
} };
this.getPathFromUrl = function (url) { this.getPathFromUrl = function (url) {
var strurl = url.toString(); var strurl = url.toString();
var u = strurl.substring(0, strurl.indexOf('?')); var u = strurl.substring(0, strurl.indexOf('?'));
return u return u;
} };
this.setTitle = function (text) { this.setTitle = function (text) {
if (text != "") { if (text !== "") {
document.title = text; document.title = text;
} }
} };
var timer = 0; var timer = 0;
this.scrollTitle = function (text) { this.scrollTitle = function (text) {
var shift = { var shift = {
@ -298,7 +299,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
speed: 1200 speed: 1200
}); });
*/ */
} };
this.parseVersionString = function (str) { this.parseVersionString = function (str) {
if (typeof (str) != 'string') { return false; } if (typeof (str) != 'string') { return false; }
var x = str.split('.'); var x = str.split('.');
@ -310,8 +311,8 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
major: maj, major: maj,
minor: min, minor: min,
patch: pat patch: pat
} };
} };
this.checkVersion = function (runningVersion, minimumVersion) { this.checkVersion = function (runningVersion, minimumVersion) {
if (runningVersion.major >= minimumVersion.major) { if (runningVersion.major >= minimumVersion.major) {
if (runningVersion.minor >= minimumVersion.minor) { if (runningVersion.minor >= minimumVersion.minor) {
@ -326,7 +327,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} else { } else {
return false; return false;
} }
} };
this.checkVersionNewer = function (runningVersion, newVersion) { this.checkVersionNewer = function (runningVersion, newVersion) {
if (runningVersion.major < newVersion.major) { if (runningVersion.major < newVersion.major) {
return true; return true;
@ -341,14 +342,14 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} }
} }
} }
} };
this.parseDate = function (date) { this.parseDate = function (date) {
// input: "2012-09-23 20:00:00.0" // input: "2012-09-23 20:00:00.0"
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var parts = date.split(" "); var parts = date.split(" ");
var dateParts = parts[0].split("-"); var dateParts = parts[0].split("-");
var month = parseInt(dateParts[1], 10) - 1; var month = parseInt(dateParts[1], 10) - 1;
var date = months[month] + " " + dateParts[2] + ", " + dateParts[0]; var newDate = months[month] + " " + dateParts[2] + ", " + dateParts[0];
return date; return newDate;
} };
}); });