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="NextTrack" title="Next Track" ng-click="nextTrack()"><img src="images/last_24x24.png" /></a>
</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>
<ul>
<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.loggedIn = false;
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;
}
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.artist = [];
$scope.album = [];
$scope.selectedArtist;
$scope.selectedAlbum;
$scope.selectedArtist = null;
$scope.selectedAlbum = null;
$scope.selectedSongs = [];
$scope.SavedCollections = globals.SavedCollections;
$scope.AllCollections = [];
@ -25,18 +25,18 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
});
*/
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.selectedCollection = null;
$scope.$watch("selectedCollection", function (newValue, oldValue) {
if (newValue !== oldValue) {
$scope.addSavedCollection(newValue);
@ -49,7 +49,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.SavedCollections.push(item);
}
});
}
};
$scope.archiveUrl = 'https://archive.org/';
/* Filter */
@ -71,7 +71,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
'publicdate asc',
'stars desc',
'stars asc'
],
];
$scope.$watch("selectedArchiveAlbumSort", function (newValue, oldValue) {
if (utils.getValue('AlbumSort') != newValue) {
if (typeof newValue != 'undefined') {
@ -90,8 +90,8 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
years.push(startYear++);
}
return years;
}
$scope.Years = $scope.getYears(),
};
$scope.Years = $scope.getYears();
$scope.filter = {
Year: "",
Source: "",
@ -101,7 +101,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
if ($scope.selectedArtist) {
$scope.getAlbums('', '');
}
}
};
/* End Filter */
/*
@ -116,7 +116,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
*/
$scope.getAlbums = function (name, identifier) {
var url = $scope.archiveUrl + 'advancedsearch.php?q=';
if (name != '') {
if (name !== '') {
$scope.selectedArtist = name;
url += 'collection:(' + name + ') AND format:(MP3)';
} 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.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);
}
};
if ($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,
success: function (data) {
var items = [];
if (data["response"].docs.length > 0) {
items = data["response"].docs;
if (data.response.docs.length > 0) {
items = data.response.docs;
//alert(JSON.stringify(data["response"]));
$scope.album = [];
$rootScope.song = [];
@ -183,7 +183,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
};
utils.mapSong = function (key, song, server, dir, identifier, coverart) {
var url, time, track, title, rating, starred, contenttype, suffix;
var specs = ''
var specs = '';
if (song.format == 'VBR MP3') {
url = 'http://' + server + dir + key;
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.showQueue();
//$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
$scope.$apply();
} else if (action == 'play') {
@ -232,7 +232,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.$apply(function () {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
//$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
} else {
$scope.album = [];
@ -254,25 +254,25 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.queue.push(item);
item.selected = false;
});
$rootScope.showQueue();
//$rootScope.showQueue();
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;
});
}
};
/* Launch on Startup */
if ($routeParams.artist) {

View file

@ -20,9 +20,9 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
{ id: "frequent", name: "Most Played" },
{ id: "recent", name: "Recently Played" }
];
$scope.selectedAutoAlbum;
$scope.selectedArtist;
$scope.selectedAlbum;
$scope.selectedAutoAlbum = null;
$scope.selectedArtist = null;
$scope.selectedAlbum = null;
$scope.SelectedAlbumSort = globals.settings.DefaultAlbumSort;
$scope.AlbumSort = globals.AlbumSorts;
$scope.BreadCrumbs = [];
@ -36,7 +36,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
if (obj.id == newValue) {
return index;
}
})
});
globals.settings.DefaultAlbumSort = globals.AlbumSorts[indexes];
}
}
@ -56,14 +56,14 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (data["subsonic-response"].user.adminRole == true) {
if (data["subsonic-response"].user.adminRole === true) {
$.get(globals.settings.Server + '/musicFolderSettings.view?scanNow');
} else {
alert('You are not logged in as an admin user!');
}
}
});
}
};
$scope.mapArtist = function (data) {
var name = '';
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(); }
return new model.Index(name, artists);
}
};
$scope.mapIndex = function (data) {
var name, id = '';
if (typeof data.id !== 'undefined') { id = data.id; }
if (typeof data.name !== 'undefined') { name = data.name.toString(); }
return new model.Artist(id, name);
}
};
$scope.mapPlaylist = function (data) {
return new model.Artist(data.id, data.name);
}
};
$scope.getArtists = function (id) {
var url, id;
var url;
if (utils.getValue('MusicFolders')) {
var folder = angular.fromJson(utils.getValue('MusicFolders'));
id = folder.id;
@ -155,12 +155,12 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
if (typeof album.title !== 'undefined') { title = album.title; } else { title = album.name; }
var type;
if (album.isDir) {
type = 'byfolder';
type = 'byfolder';
} else {
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);
}
};
$scope.getAlbums = function (id, name) {
$scope.selectedAutoAlbum = null;
$scope.selectedArtist = id;
@ -340,7 +340,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$rootScope.queue.push(utils.mapSong(item));
});
$scope.$apply();
$rootScope.showQueue();
//$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
@ -351,7 +351,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
$scope.$apply(function () {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
//$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'preview') {
$scope.songpreview = [];
@ -365,7 +365,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
if (typeof data["subsonic-response"].directory.id != 'undefined') {
var albumId = data["subsonic-response"].directory.id;
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 });
}
$rootScope.song = [];
@ -394,7 +394,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
};
$scope.search = function () {
var query = $('#Search').val();
if (query != '') {
if (query !== '') {
var type = $('#SearchType').val();
$.ajax({
url: globals.BaseURL() + '/search2.view?' + globals.BaseParams() + '&query=' + query,
@ -455,10 +455,10 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
});
//$('#Search').val("");
}
}
};
$scope.toggleAZ = function (event) {
$scope.toggleSubmenu('#submenu_AZIndex', '#AZIndex', 'right', 44);
}
};
$scope.loadPlaylistsForMenu = function (data, event) {
$.ajax({
url: globals.BaseURL() + '/getPlaylists.view?' + globals.BaseParams(),
@ -494,7 +494,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
*/
}
});
}
};
$scope.addToPlaylist = function (id) {
var songs = [];
if ($scope.selectedSongs.length !== 0) {
@ -518,7 +518,7 @@ function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, util
});
}
}
}
};
$scope.sortDateFunction = function (a, b) {
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.song = [];
$rootScope.queue = [];
$rootScope.playingSong;
$rootScope.playingSong = null;
$rootScope.MusicFolders = [];
$rootScope.Genres = [];
$rootScope.selectedPlaylist = "";
$rootScope.selectedAutoPlaylist = "";
$rootScope.SelectedMusicFolder = "";
$rootScope.unity;
$rootScope.unity = null;
$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;
} else {
return false;
}
}
};
$rootScope.totalDisplayed = 50;
$rootScope.loadMore = function () {
$scope.totalDisplayed += 50;
};
$rootScope.go = function (path) {
$location.path(path);
};
/*
$scope.playSong = function (loadonly, data) {
$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("SavedGenres")) { globals.SavedGenres = utils.getValue("SavedGenres").split(","); }
if (globals.settings.Debug) { console.log('Settings: ' + JSON.stringify(globals.settings, null, 2)); }
}
};
$scope.toggleSetting = function (setting) {
var id = setting;
if (globals.settings[id]) {
@ -55,7 +58,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
globals.settings[id] = true;
}
notifications.updateMessage(setting + ' : ' + globals.settings[id], true);
}
};
$.ajaxSetup({
'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);
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 () {
var submenu = $('#QueuePreview');
submenu.fadeIn(400);
var timeout = globals.settings.Timeout;
setTimeout(function () { submenu.fadeOut(); }, timeout);
}
};
$rootScope.hideQueue = function () {
var submenu = $('#QueuePreview');
submenu.fadeOut();
}
};
$scope.toggleQueue = function () {
var submenu = $('#QueuePreview');
if (submenu.css('display') == 'none') {
@ -131,7 +134,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
} else {
$rootScope.hideQueue();
}
}
};
$("a.coverartfancy").fancybox({
beforeShow: function () {
//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?";
}
}
}
};
$scope.dragStart = function (e, ui) {
ui.item.data('start', ui.item.index());
}
};
$scope.dragEnd = function (e, ui) {
var start = ui.item.data('start'),
end = ui.item.index();
$rootScope.queue.splice(end, 0,
$rootScope.queue.splice(start, 1)[0]);
$scope.$apply();
}
};
$document.keydown(function (e) {
$scope.scrollToIndex(e);
});
@ -265,8 +268,8 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
}
if (unicode == 189) { // dash - volume down
var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
if (volume <= 1 && volume > 0 && source == '') {
volume += -.1;
if (volume <= 1 && volume > 0 && source === '') {
volume += -0.1;
$(player1).jPlayer({
volume: volume
});
@ -276,8 +279,8 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
}
if (unicode == 187) { // equals - volume up
var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
if (volume < 1 && volume >= 0 && source == '') {
volume += .1;
if (volume < 1 && volume >= 0 && source ==- '') {
volume += 0.1;
$(player1).jPlayer({
volume: volume
});
@ -296,37 +299,37 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
};
$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.playAll = function () {
$rootScope.queue = [];
$scope.selectAll();
$scope.addSongsToQueue();
var next = $rootScope.queue[0];
$rootScope.playSong(false, next);
}
};
$scope.selectNone = function () {
angular.forEach($rootScope.song, function (item, key) {
$scope.selectedSongs = [];
item.selected = false;
});
}
};
$scope.addSongsToQueue = function () {
if ($scope.selectedSongs.length !== 0) {
angular.forEach($scope.selectedSongs, function (item, key) {
$scope.queue.push(item);
item.selected = false;
});
$rootScope.showQueue();
//$rootScope.showQueue();
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
$scope.selectedSongs.length = 0;
}
}
};
$scope.isActive = function (route) {
return route === $location.path();
};
@ -345,6 +348,10 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
folders[0] = data["subsonic-response"].musicFolders.musicFolder;
}
folders.unshift({
"id": -1,
"name": "All Folders"
});
$rootScope.MusicFolders = folders;
if (utils.getValue('MusicFolders')) {
var folder = angular.fromJson(utils.getValue('MusicFolders'));
@ -356,12 +363,14 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
i++;
});
$rootScope.SelectedMusicFolder = $rootScope.MusicFolders[index];
} else {
$rootScope.SelectedMusicFolder = $rootScope.MusicFolders[0];
}
$scope.$apply();
}
}
});
}
};
$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';
$rootScope.Genres = genres.split(',');
@ -386,7 +395,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
}
});
*/
}
};
$scope.download = function (id) {
$.ajax({
url: globals.BaseURL() + '/getUser.view?' + globals.BaseParams() + '&username=' + globals.settings.Username,
@ -395,9 +404,9 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
timeout: globals.settings.Timeout,
success: function (data) {
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 {
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;
} else {
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 () {
$.ajax({
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');
}
});
}
};
$scope.addSongToQueue = function (data) {
$rootScope.queue.push(data);
}
};
$scope.queueRemoveSelected = function (data, event) {
angular.forEach($scope.selectedSongs, function (item, key) {
var index = $rootScope.queue.indexOf(item);
@ -436,11 +445,11 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
$rootScope.queue.splice(index, 1);
}
});
}
};
$scope.queueEmpty = function () {
//self.selectedSongs([]);
$rootScope.queue = [];
}
};
$scope.queueTotal = function () {
var total = 0;
ko.utils.arrayForEach(self.queue(), function (item) {
@ -451,10 +460,10 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
} else {
return '0 song(s), 00:00:00 total time';
}
}
};
$scope.queueShuffle = function () {
$rootScope.queue.sort(function () { return 0.5 - Math.random() });
}
$rootScope.queue.sort(function () { return 0.5 - Math.random(); });
};
$scope.selectedSongs = [];
$scope.selectSong = function (data) {
var i = $scope.selectedSongs.indexOf(data);
@ -466,24 +475,24 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
data.selected = true;
}
//$scope.$apply();
}
};
$rootScope.getRandomSongs = function (action, genre, folder) {
if (globals.settings.Debug) { console.log('action:' + action + ', genre:' + genre + ', folder:' + folder); }
var size = globals.settings.AutoPlaylistSize;
$rootScope.selectedPlaylist = null;
if (typeof folder == 'number') {
$rootScope.selectedAutoPlaylist = folder;
} else if (genre != '') {
} else if (genre !== '') {
$rootScope.selectedAutoPlaylist = genre;
} else {
$rootScope.selectedAutoPlaylist = 'random';
}
var genreParams = '';
if (genre != '' && genre != 'Random') {
if (genre !== '' && genre != 'Random') {
genreParams = '&genre=' + genre;
}
folderParams = '';
if (typeof folder == 'number' && folder != '' && folder != 'all') {
if (typeof folder == 'number' && folder !== '' && folder != 'all') {
//alert(folder);
folderParams = '&musicFolderId=' + folder;
} 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));
});
$scope.$apply();
$rootScope.showQueue();
//$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
@ -519,7 +528,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
$scope.$apply(function () {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
//$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else {
$rootScope.song = [];
@ -531,7 +540,7 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
}
}
});
}
};
$scope.updateFavorite = function (item) {
var id = item.id;
var starred = item.starred;
@ -552,10 +561,10 @@ function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils,
notifications.updateMessage('Favorite Updated!', true);
}
});
}
};
$scope.toTrusted = function (html) {
return $sce.trustAsHtml(html);
}
};
/* Launch on Startup */
$scope.loadSettings();

View file

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

View file

@ -4,7 +4,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
$rootScope.song = [];
$scope.podcasts = [];
$scope.selectedPodcast;
$scope.selectedPodcast = null;
$scope.getPodcasts = function (refresh) {
if (globals.settings.Debug) { console.log("LOAD PODCASTS"); }
$.ajax({
@ -25,7 +25,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
}
}
});
}
};
$scope.getPodcast = function (id, action) {
$scope.selectedPodcast = id;
var map = function (data) {
@ -46,7 +46,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
var salt = Math.floor(Math.random() * 100000);
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);
}
};
$.ajax({
url: globals.BaseURL() + '/getPodcasts.view?' + globals.BaseParams(),
method: 'GET',
@ -75,7 +75,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
}
});
$scope.$apply();
$rootScope.showQueue();
//$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
@ -88,7 +88,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
$scope.$apply(function () {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
//$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else {
$scope.album = [];
@ -104,7 +104,7 @@ function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notif
}
}
});
}
};
/* Launch on Startup */
$scope.getPodcasts();

View file

@ -21,14 +21,11 @@
</div>
</div>
<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="AZIndex" ng-show="!settings.HideAZ" class="subactionsfixed">
<a href="" ng-click="toggleAZ()" stop-event="click">A-Z</a>
</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 id="MusicFolders" class="folders" ng-model="$root.SelectedMusicFolder" ng-options="o.name for o in MusicFolders">
</select>
<ul id="AutoAlbumContainer" class="simplelist mainlist noselect">
<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 scrobbled = false;
var timerid = 0;
$rootScope.defaultPlay = function (data, event) {
if (typeof $(player1).data("jPlayer") == 'undefined') {
$rootScope.nextTrack();
}
}
};
$rootScope.nextTrack = function () {
var next = getNextSong();
if (next) {
@ -16,18 +15,18 @@
}
//$(player1).jPlayer("stop");
//$(player2).jPlayer("play");
}
};
$rootScope.previousTrack = function () {
var next = getNextSong(true);
if (next) {
$rootScope.playSong(false, next);
}
}
};
getNextSong = function (previous) {
var song;
if (globals.settings.Debug) { console.log('Getting Next Song > ' + 'Queue length: ' + $rootScope.queue.length); }
if ($rootScope.queue.length > 0) {
angular.forEach($rootScope.queue, function(item, key) {
angular.forEach($rootScope.queue, function (item, key) {
if (item.playing === true) {
song = item;
}
@ -48,10 +47,10 @@
} else {
return false;
}
}
};
this.startSaveTrackPosition = function () {
if (globals.settings.SaveTrackPosition) {
if (timerid != 0) {
if (timerid !== 0) {
clearInterval(timerid);
}
timerid = $window.setInterval(function () {
@ -60,21 +59,21 @@
}
}, 30000);
}
}
};
this.saveTrackPosition = function () {
//var audio = typeof $(player1).data("jPlayer") != 'undefined' ? true : false;
var audio = $(player1).data("jPlayer");
if (typeof audio != 'undefined') {
if (audio.status.currentTime > 0 && audio.status.paused == false) {
if (audio.status.currentTime > 0 && audio.status.paused === false) {
var song;
angular.forEach($rootScope.queue, function(item, key) {
angular.forEach($rootScope.queue, function (item, key) {
if (item.playing === true) {
song = item;
}
});
if (song) {
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);
song.position = position;
// Save Queue
@ -105,7 +104,7 @@
} else {
if (globals.settings.Debug) { console.log('Saving Queue: No Audio Loaded'); }
}
}
};
this.loadTrackPosition = function () {
if (utils.browserStorageCheck()) {
// Load Saved Song
@ -126,7 +125,7 @@
} else {
if (globals.settings.Debug) { console.log('HTML5::loadStorage not supported on your browser'); }
}
}
};
this.deleteCurrentQueue = function (data) {
if (utils.browserStorageCheck()) {
localStorage.removeItem('CurrentQueue');
@ -135,7 +134,7 @@
} else {
if (globals.settings.Debug) { console.log('HTML5::loadStorage not supported on your browser, ' + html.length + ' characters'); }
}
}
};
$rootScope.playSong = function (loadonly, data) {
if (globals.settings.Debug) { console.log('Play: ' + JSON.stringify(data, null, 2)); }
angular.forEach($rootScope.queue, function(item, key) {
@ -168,7 +167,7 @@
artist: artist,
favorite: false,
albumArt: coverartfull
}
};
if ($rootScope.unity) {
$rootScope.unity.sendState(playerState);
}
@ -176,7 +175,7 @@
}
if ($rootScope.queue.length > 0) {
$('#QueuePreview').stop().scrollTo('#' + id, 400);
$rootScope.showQueue();
//$rootScope.showQueue();
}
var spechtml = '';
var data = $(player1).data().jPlayer;
@ -185,11 +184,11 @@
if (data[solution].used) {
spechtml += "<strong class=\"codesyntax\">" + solution + "</strong> is";
spechtml += " currently being used with<strong>";
for (format in data[solution].support) {
angular.forEach(data[solution].support, function (format) {
if (data[solution].support[format]) {
spechtml += " <strong class=\"codesyntax\">" + format + "</strong>";
}
}
});
spechtml += "</strong> support";
}
}
@ -200,8 +199,7 @@
notifications.showNotification(coverartthumb, utils.toHTML.un(title), utils.toHTML.un(artist + ' - ' + album), 'text', '#NextTrack');
}
if (globals.settings.ScrollTitle) {
var title = utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title);
utils.scrollTitle(title);
utils.scrollTitle(utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title));
} else {
utils.setTitle(utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title));
}
@ -223,7 +221,7 @@
//var salt = Math.floor(Math.random() * 100000);
//url += '&salt=' + salt;
$(el).jPlayer("destroy");
$.jPlayer.timeFormat.showHour = true;
$.jPlayer.timeFormat.showHour = true;
$(el).jPlayer({
swfPath: "js/plugins/jplayer",
wmode: "window",
@ -248,11 +246,11 @@
console.log("File Suffix: " + suffix);
if (suffix == 'oga') {
$(this).jPlayer("setMedia", {
oga: url,
oga: url
});
} else if (suffix == 'mp3') {
$(this).jPlayer("setMedia", {
mp3: url,
mp3: url
});
}
if (!loadonly) { // Start playing
@ -271,8 +269,8 @@
console.log('[jPlayer Options Info]');
utils.logObjectProperties($(el).data("jPlayer").options);
}
},
timeupdate: function(event) {
},
timeupdate: function (event) {
// Scrobble song once percentage is reached
var p = event.jPlayer.status.currentPercentAbsolute;
if (!scrobbled && p > 30) {
@ -280,17 +278,17 @@
scrobbleSong(true);
}
},
volumechange: function(event) {
volumechange: function (event) {
utils.setValue('Volume', event.jPlayer.options.volume, true);
},
ended: function(event) {
ended: function (event) {
if (globals.settings.Repeat) { // Repeat current track if enabled
$(this).jPlayer("play");
} else {
if (!getNextSong()) { // Action if we are at the last song in queue
if (globals.settings.LoopQueue) { // Loop to first track in queue if enabled
var next = $rootScope.queue[0];
$rootScope.playSong(false, next);
$rootScope.playSong(false, next);
} else if (globals.settings.AutoPlay) { // Load more tracks if enabled
$rootScope.getRandomSongs('play', '', '');
notifications.updateMessage('Auto Play Activated...', true);
@ -300,19 +298,19 @@
}
}
},
error: function(event) {
error: function (event) {
var time = $(player1).data("jPlayer").status.currentTime;
$(player1).jPlayer("play", time);
if (globals.settings.Debug) {
console.log("Error Type: " + event.jPlayer.error.type);
console.log("Error Context: " + event.jPlayer.error.context);
console.log("Error Message: " + event.jPlayer.error.message);
if (globals.settings.Debug) {
console.log("Error Type: " + event.jPlayer.error.type);
console.log("Error Context: " + event.jPlayer.error.context);
console.log("Error Message: " + event.jPlayer.error.message);
console.log("Stream interrupted, retrying from position: " + time);
}
}
});
return;
}
};
this.playPauseSong = function () {
if (typeof $(player1).data("jPlayer") != 'undefined') {
if ($(player1).data("jPlayer").status.paused) {
@ -320,21 +318,21 @@
} else {
$(player1).jPlayer("pause");
}
}
}
}
};
playVideo = function (id, bitrate) {
var w, h;
bitrate = parseInt(bitrate);
if (bitrate <= 600) {
w = 320; h = 240;
} else if (bitrate <= 1000) {
w = 480; h = 360;
} else {
w = 640; h = 480;
}
if (bitrate <= 600) {
w = 320; h = 240;
} else if (bitrate <= 1000) {
w = 480; h = 360;
} else {
w = 640; h = 480;
}
//$("#jPlayerSelector").jPlayer("option", "fullScreen", true);
$("#videodeck").jPlayer({
ready: function () {
ready: function () {
/*
$.fancybox({
autoSize: false,
@ -343,17 +341,16 @@
content: $('#videodeck')
});
*/
$(this).jPlayer("setMedia", {
m4v: 'https://&id=' + id + '&salt=83132'
}).jPlayer("play");
$(this).jPlayer("setMedia", {
m4v: 'https://&id=' + id + '&salt=83132'
}).jPlayer("play");
$('#videooverlay').show();
},
swfPath: "js/jplayer",
solution: "html, flash",
supplied: "m4v"
});
}
},
swfPath: "js/jplayer",
solution: "html, flash",
supplied: "m4v"
});
};
scrobbleSong = function (submission) {
if ($rootScope.loggedIn && submission) {
var id = $rootScope.playingSong.id;
@ -368,7 +365,7 @@
}
});
}
}
};
rateSong = function (songid, rating) {
$.ajax({
url: baseURL + '/setRating.view?' + baseParams + '&id=' + songid + "&rating=" + rating,
@ -379,5 +376,5 @@
updateMessage('Rating Updated!', true);
}
});
}
};
});

View file

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

View file

@ -24,7 +24,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} catch (e) {
if (globals.settings.Debug) { console.log(e); }
}
}
};
this.getValue = function (value) {
/*
if ($cookieStore.get(value)) {
@ -35,7 +35,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
*/
try {
var item = localStorage.getItem(value);
if (item != '' && typeof item != 'undefined') {
if (item !== '' && typeof item != 'undefined') {
return JSON.parse(item);
} else {
return false;
@ -43,7 +43,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} catch (e) {
if (globals.settings.Debug) { console.log(e); }
}
}
};
this.mapSong = function (data) {
var song = data;
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);
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);
}
};
this.confirmDelete = function (text) {
var question = confirm(text);
if (question) {
@ -75,19 +75,19 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
else {
return false;
}
}
};
this.makeBaseAuth = function (user, password) {
var tok = user + ':' + password;
var hash = $.base64Encode(tok);
return "Basic " + hash;
}
};
this.HexEncode = function (n) {
for (var u = "0123456789abcdef", i = [], r = [], t = 0; t < 256; t++)
i[t] = u.charAt(t >> 4) + u.charAt(t & 15);
for (t = 0; t < n.length; t++)
r[t] = i[n.charCodeAt(t)];
return r.join("")
}
return r.join("");
};
this.switchTheme = function (theme) {
switch (theme.toLowerCase()) {
case 'dark':
@ -99,7 +99,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
default:
break;
}
}
};
// HTML5
this.browserStorageCheck = function () {
if (typeof (localStorage) == 'undefined') {
@ -107,7 +107,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} else {
return true;
}
}
};
this.timeToSeconds = function (time) {
var a = time.split(':'); // split it at the colons
var seconds;
@ -125,7 +125,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
break;
}
return seconds;
}
};
this.secondsToTime = function (secs) {
// secs = 4729
var times = new Array(3600, 60, 1);
@ -142,7 +142,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
else if (tmp < 10) {
tmp = '0' + tmp;
}
if (i == 0 && tmp == '00') {
if (i === 0 && tmp == '00') {
} else {
time += tmp;
if (i < 2) {
@ -152,13 +152,13 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
secs = secs % times[i];
}
return time;
}
};
this.arrayObjectIndexOf = function (myArray, searchTerm, property) {
for (var i = 0, len = myArray.length; i < len; i++) {
if (myArray[i][property] === searchTerm) return i;
}
return -1;
}
};
this.logObjectProperties = function (obj) {
$.each(obj, function (key, value) {
var parent = key;
@ -170,7 +170,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
console.log(key + ' : ' + value);
}
});
}
};
this.clickButton = function (el) {
var el = $(el);
if (el) {
@ -189,36 +189,37 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
}
}
}
}
};
this.findKeyForCode = function (code) {
var map = { 'keymap': [
{ 'key': 'a', 'code': 65 },
{ 'key': 'b', 'code': 66 },
{ 'key': 'c', 'code': 67 },
{ 'key': 'd', 'code': 68 },
{ 'key': 'e', 'code': 69 },
{ 'key': 'f', 'code': 70 },
{ 'key': 'g', 'code': 71 },
{ 'key': 'h', 'code': 72 },
{ 'key': 'i', 'code': 73 },
{ 'key': 'j', 'code': 74 },
{ 'key': 'k', 'code': 75 },
{ 'key': 'l', 'code': 76 },
{ 'key': 'm', 'code': 77 },
{ 'key': 'n', 'code': 78 },
{ 'key': 'o', 'code': 79 },
{ 'key': 'p', 'code': 80 },
{ 'key': 'q', 'code': 81 },
{ 'key': 'r', 'code': 82 },
{ 'key': 's', 'code': 83 },
{ 'key': 't', 'code': 84 },
{ 'key': 'u', 'code': 85 },
{ 'key': 'v', 'code': 86 },
{ 'key': 'w', 'code': 87 },
{ 'key': 'x', 'code': 88 },
{ 'key': 'y', 'code': 89 },
{ 'key': 'z', 'code': 90 }
]
var map = {
'keymap': [
{ 'key': 'a', 'code': 65 },
{ 'key': 'b', 'code': 66 },
{ 'key': 'c', 'code': 67 },
{ 'key': 'd', 'code': 68 },
{ 'key': 'e', 'code': 69 },
{ 'key': 'f', 'code': 70 },
{ 'key': 'g', 'code': 71 },
{ 'key': 'h', 'code': 72 },
{ 'key': 'i', 'code': 73 },
{ 'key': 'j', 'code': 74 },
{ 'key': 'k', 'code': 75 },
{ 'key': 'l', 'code': 76 },
{ 'key': 'm', 'code': 77 },
{ 'key': 'n', 'code': 78 },
{ 'key': 'o', 'code': 79 },
{ 'key': 'p', 'code': 80 },
{ 'key': 'q', 'code': 81 },
{ 'key': 'r', 'code': 82 },
{ 'key': 's', 'code': 83 },
{ 'key': 't', 'code': 84 },
{ 'key': 'u', 'code': 85 },
{ 'key': 'v', 'code': 86 },
{ 'key': 'w', 'code': 87 },
{ 'key': 'x', 'code': 88 },
{ 'key': 'y', 'code': 89 },
{ 'key': 'z', 'code': 90 }
]
};
var keyFound = 0;
$.each(map.keymap, function (i, mapping) {
@ -227,19 +228,19 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
}
});
return keyFound;
}
};
this.toHTML = {
on: function (str) {
var a = [],
i = 0;
for (; i < str.length; ) a[i] = str.charCodeAt(i++);
return "&#" + a.join(";&#") + ";"
return "&#" + a.join(";&#") + ";";
},
un: function (str) {
return str.replace(/&#(x)?([^;]{1,5});?/g,
function (a, b, c) {
return String.fromCharCode(parseInt(c, b ? 16 : 10))
})
return String.fromCharCode(parseInt(c, b ? 16 : 10));
});
}
};
this.getParameterByName = function (name) {
@ -247,21 +248,21 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if (results == null)
if (results === null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
};
this.getPathFromUrl = function (url) {
var strurl = url.toString();
var u = strurl.substring(0, strurl.indexOf('?'));
return u
}
return u;
};
this.setTitle = function (text) {
if (text != "") {
if (text !== "") {
document.title = text;
}
}
};
var timer = 0;
this.scrollTitle = function (text) {
var shift = {
@ -298,7 +299,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
speed: 1200
});
*/
}
};
this.parseVersionString = function (str) {
if (typeof (str) != 'string') { return false; }
var x = str.split('.');
@ -310,8 +311,8 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
major: maj,
minor: min,
patch: pat
}
}
};
};
this.checkVersion = function (runningVersion, minimumVersion) {
if (runningVersion.major >= minimumVersion.major) {
if (runningVersion.minor >= minimumVersion.minor) {
@ -326,7 +327,7 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
} else {
return false;
}
}
};
this.checkVersionNewer = function (runningVersion, newVersion) {
if (runningVersion.major < newVersion.major) {
return true;
@ -341,14 +342,14 @@ JamStash.service('utils', function ($cookieStore, globals, model) {
}
}
}
}
};
this.parseDate = function (date) {
// input: "2012-09-23 20:00:00.0"
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var parts = date.split(" ");
var dateParts = parts[0].split("-");
var month = parseInt(dateParts[1], 10) - 1;
var date = months[month] + " " + dateParts[2] + ", " + dateParts[0];
return date;
}
var newDate = months[month] + " " + dateParts[2] + ", " + dateParts[0];
return newDate;
};
});