Commit local changes

This commit is contained in:
Trevor Squillario 2014-02-22 18:56:13 -05:00
parent bb7d018de4
commit 310c79f63c
16 changed files with 2134 additions and 2520 deletions

View file

@ -100,7 +100,7 @@
<div class="albumtext" title="{{o.artist}}" ng-bind-html="o.artist"></div>
</li>
</ul>
<div id="player" ng-click="hideQueue()">
<div id="player">
<div id="playercontainer">
<div id="playerleft" class="floatleft">
<div class="playeractions floatleft">

View file

@ -1,5 +1,6 @@
/* Declare app level module */
var JamStash = angular.module('JamStash', ['ngCookies', 'ngRoute', 'ngSanitize']);
//var JamStash = angular.module('JamStash', ['ngCookies', 'ngRoute']);
/*
JamStash.config(function ($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['/^\s*(https?|file|ms-appx):/', 'self']);
@ -9,73 +10,36 @@ JamStash.config(function ($sceDelegateProvider) {
// URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby
// Route: /Chapter/:chapterId/Section/:sectionId
//
// Then $routeParams ==> {chapterId:1, sectionId:2, search:'moby'}
// Then
$routeParams ==> {chapterId:1, sectionId:2, search:'moby'}
*/
JamStash.config(function($routeProvider) {
JamStash.config(function ($routeProvider) {
$routeProvider
.when('/index', {
redirectTo: '/library'
})
.when('/settings', {
templateUrl: 'js/partials/settings.html',
controller: 'SettingsCtrl'
})
.when('/queue', {
templateUrl: 'js/partials/queue.html',
controller: 'QueueCtrl'
})
.when('/library', {
templateUrl: 'js/partials/library.html',
controller: 'SubsonicCtrl'
})
.when('/library/:artistId', {
templateUrl: 'js/partials/library.html',
controller: 'SubsonicCtrl',
reloadOnSearch: false
})
.when('/library/:artistId/:albumId', {
templateUrl: 'js/partials/library.html',
controller: 'SubsonicCtrl',
reloadOnSearch: false
})
.when('/playlists', {
templateUrl: 'js/partials/playlists.html',
controller: 'PlaylistCtrl'
})
.when('/podcasts', {
templateUrl: 'js/partials/podcasts.html',
controller: 'PodcastCtrl'
})
.when('/archive', {
templateUrl: 'js/partials/archive.html',
controller: 'ArchiveCtrl'
})
.when('/archive/:artist', {
templateUrl: 'js/partials/archive.html',
controller: 'ArchiveCtrl'
})
.when('/archive/:artist/:album', {
templateUrl: 'js/partials/archive.html',
controller: 'ArchiveCtrl'
})
.otherwise({
redirectTo: '/index'
});
.when('/index', { redirectTo: '/library' })
.when('/settings', { templateUrl: 'js/partials/settings.html', controller: 'SettingsCtrl' })
.when('/queue', { templateUrl: 'js/partials/queue.html', controller: 'QueueCtrl' })
.when('/library', { templateUrl: 'js/partials/library.html', controller: 'SubsonicCtrl' })
.when('/library/:artistId', { templateUrl: 'js/partials/library.html', controller: 'SubsonicCtrl', reloadOnSearch: false })
.when('/library/:artistId/:albumId', { templateUrl: 'js/partials/library.html', controller: 'SubsonicCtrl', reloadOnSearch: false })
.when('/playlists', { templateUrl: 'js/partials/playlists.html', controller: 'PlaylistCtrl' })
.when('/podcasts', { templateUrl: 'js/partials/podcasts.html', controller: 'PodcastCtrl' })
.when('/archive', { templateUrl: 'js/partials/archive.html', controller: 'ArchiveCtrl' })
.when('/archive/:artist', { templateUrl: 'js/partials/archive.html', controller: 'ArchiveCtrl' })
.when('/archive/:artist/:album', { templateUrl: 'js/partials/archive.html', controller: 'ArchiveCtrl' })
.otherwise({ redirectTo: '/index' });
})
.run(['$rootScope', '$location', 'globals',
function($rootScope, $location, globals) {
$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') {
$rootScope.loggedIn = true;
}
if (!$rootScope.loggedIn && (path != 'settings' && path != 'archive')) {
$location.path('/settings');
}
});
.run(['$rootScope', '$location', 'globals', function ($rootScope, $location, globals) {
$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') {
$rootScope.loggedIn = true;
}
]);
if (!$rootScope.loggedIn && (path != 'settings' && path != 'archive')) {
$location.path('/settings');
}
});
}]);
/*
JamStash.config(function ($httpProvider, globals) {
$httpProvider.defaults.timeout = globals.settings.Timeout;

View file

@ -1,323 +1,288 @@
JamStash.controller('ArchiveCtrl',
function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, globals, model, notifications, player, json) {
//$("#left-component").layout($scope.layoutThreeCol);
function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, globals, model, notifications, player, json) {
//$("#left-component").layout($scope.layoutThreeCol);
$scope.settings = globals.settings;
$scope.itemType = 'archive';
$rootScope.song = [];
$scope.Protocol = 'jsonp';
$scope.artist = [];
$scope.album = [];
$scope.selectedArtist = null;
$scope.selectedAlbum = null;
$scope.selectedSongs = [];
$scope.SavedCollections = globals.SavedCollections;
$scope.AllCollections = [];
$scope.loadedCollection = false;
json.getCollections(function(data) {
$scope.AllCollections = data;
$scope.loadedCollection = true;
$scope.settings = globals.settings;
$scope.itemType = 'archive';
$rootScope.song = [];
$scope.Protocol = 'jsonp';
$scope.artist = [];
$scope.album = [];
$scope.selectedArtist;
$scope.selectedAlbum;
$scope.selectedSongs = [];
$scope.SavedCollections = globals.SavedCollections;
$scope.AllCollections = [];
$scope.loadedCollection = false;
json.getCollections(function (data) {
$scope.AllCollections = data;
$scope.loadedCollection = true;
});
$scope.writeSavedCollection = function () {
utils.setValue('SavedCollections', $scope.SavedCollections.join(), false);
/*
$scope.$apply(function () {
});
$scope.writeSavedCollection = function() {
utils.setValue('SavedCollections', $scope.SavedCollections.join(), false);
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);
*/
globals.SavedCollections = $scope.SavedCollections;
}
$scope.addSavedCollection = function (newValue) {
if ($scope.SavedCollections.indexOf(newValue) == -1) {
$scope.SavedCollections.push(newValue);
$scope.writeSavedCollection();
};
$scope.selectedCollection = null;
$scope.$watch("selectedCollection", function(newValue, oldValue) {
if (newValue !== oldValue) {
$scope.addSavedCollection(newValue);
}
}
$scope.deleteSavedCollection = function (index) {
$scope.SavedCollections.splice(index, 1);
$scope.writeSavedCollection();
}
$scope.selectedCollection;
$scope.$watch("selectedCollection", function (newValue, oldValue) {
if (newValue !== oldValue) {
$scope.addSavedCollection(newValue);
}
});
$scope.setupDemoCollections = function () {
var demo = ["YonderMountainStringBand", "GreenskyBluegrass"];
angular.forEach(demo, function (item, key) {
if ($scope.SavedCollections.indexOf(item) == -1) {
$scope.SavedCollections.push(item);
}
});
}
$scope.archiveUrl = 'https://archive.org/';
$scope.setupDemoCollections = function() {
var demo = ["YonderMountainStringBand", "GreenskyBluegrass"];
angular.forEach(demo, function(item, key) {
if ($scope.SavedCollections.indexOf(item) == -1) {
$scope.SavedCollections.push(item);
}
});
};
$scope.archiveUrl = 'https://archive.org/';
/* Filter */
$scope.selectedArchiveAlbumSort = "date desc";
$scope.ArchiveAlbumSort = [
'addeddate desc',
'addeddate asc',
'avg_rating desc',
'avg_rating asc',
'createdate desc',
'createdate asc',
'date desc',
'date asc',
'downloads desc',
'downloads asc',
'num_reviews desc',
'num_reviews asc',
'publicdate desc',
'publicdate asc',
'stars desc',
'stars asc'
];
$scope.$watch("selectedArchiveAlbumSort", function(newValue, oldValue) {
if (utils.getValue('AlbumSort') != newValue) {
if (typeof newValue != 'undefined') {
utils.setValue('AlbumSort', newValue, true);
} else {
utils.setValue('AlbumSort', null, true);
}
//alert(newValue);
$scope.getAlbums('');
}
});
$scope.getYears = function(startYear) {
var currentYear = new Date().getFullYear(),
years = [];
startYear = startYear || 1950;
while (startYear <= currentYear) {
years.push(startYear++);
}
return years;
};
$scope.Years = $scope.getYears();
$scope.filter = {
Year: "",
Source: "",
Description: ""
};
$scope.filterSave = function() {
if ($scope.selectedArtist) {
$scope.getAlbums('', '');
}
};
/* End Filter */
$scope.getAlbums = function(name, identifier) {
var url = $scope.archiveUrl + 'advancedsearch.php?q=';
if (name !== '') {
$scope.selectedArtist = name;
url += 'collection:(' + name + ') AND format:(MP3)';
} else if ($scope.selectedArtist) {
url += 'collection:(' + $scope.selectedArtist + ') AND format:(MP3)';
/* Filter */
$scope.selectedArchiveAlbumSort = "date desc";
$scope.ArchiveAlbumSort = [
'addeddate desc',
'addeddate asc',
'avg_rating desc',
'avg_rating asc',
'createdate desc',
'createdate asc',
'date desc',
'date asc',
'downloads desc',
'downloads asc',
'num_reviews desc',
'num_reviews asc',
'publicdate desc',
'publicdate asc',
'stars desc',
'stars asc'
],
$scope.$watch("selectedArchiveAlbumSort", function (newValue, oldValue) {
if (utils.getValue('AlbumSort') != newValue) {
if (typeof newValue != 'undefined') {
utils.setValue('AlbumSort', newValue, true);
} else {
url += 'identifier:(' + identifier + ')';
utils.setValue('AlbumSort', null, true);
}
//alert(newValue);
$scope.getAlbums('');
}
});
$scope.getYears = function (startYear) {
var currentYear = new Date().getFullYear(), years = [];
startYear = startYear || 1950;
while (startYear <= currentYear) {
years.push(startYear++);
}
return years;
}
$scope.Years = $scope.getYears(),
$scope.filter = {
Year: "",
Source: "",
Description: ""
};
$scope.filterSave = function () {
if ($scope.selectedArtist) {
$scope.getAlbums('', '');
}
}
/* End Filter */
var map = function(data) {
var song = data;
var coverartthumb, coverartfull, starred;
var url = $scope.archiveUrl + 'details/' + song.identifier;
coverartthumb = 'images/albumdefault_50.jpg';
coverartfull = 'images/albumdefault_160.jpg';
if (parseInt(song.avg_rating) == 5) {
starred = true;
/*
$scope.getArtists = function (data) {
var map = function (data) {
return new model.Artist('', data);
};
angular.forEach($scope.SavedCollections, function (item, key) {
$scope.artist.push(map(item));
});
};
*/
$scope.getAlbums = function (name, identifier) {
var url = $scope.archiveUrl + 'advancedsearch.php?q=';
if (name != '') {
$scope.selectedArtist = name;
url += 'collection:(' + name + ') AND format:(MP3)';
} else if ($scope.selectedArtist) {
url += 'collection:(' + $scope.selectedArtist + ') AND format:(MP3)';
} else {
url += 'identifier:(' + identifier + ')';
}
var map = function (data) {
var song = data;
var coverartthumb, coverartfull, starred;
var url = $scope.archiveUrl + 'details/' + song.identifier;
coverartthumb = 'images/albumdefault_50.jpg';
coverartfull = 'images/albumdefault_160.jpg';
if (parseInt(song.avg_rating) == 5) { starred = true; } else { starred = false; }
//var description = '<b>Details</b><br />';
var description = '<b>Source</b>: ' + song.source + '<br />';
description += '<b>Date</b>: ' + song.date + '<br />';
description += typeof song.publisher != 'undefined' ? '<b>Transferer</b>: ' + song.publisher + '<br />' : '';
description += typeof song.avg_rating != 'undefined' ? '<b>Rating</b>: ' + song.avg_rating + '<br />' : '';
description += 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 + ')';
}
if ($scope.filter.Year) {
if (parseInt($scope.filter.Year)) {
url += ' AND year:(' + $scope.filter.Year + ')';
}
}
if ($scope.filter.Description) {
url += ' AND description:(' + $scope.filter.Description + ')';
}
if ($scope.selectedArchiveAlbumSort) {
url += '&sort[]=' + $scope.selectedArchiveAlbumSort;
}
url += '&fl[]=avg_rating,collection,date,description,downloads,headerImage,identifier,publisher,publicdate,source,subject,title,year';
url += '&rows=50&page=1&output=json';
$.ajax({
url: url,
method: 'GET',
dataType: $scope.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
var items = [];
if (data["response"].docs.length > 0) {
items = data["response"].docs;
//alert(JSON.stringify(data["response"]));
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function (item, key) {
$scope.album.push(map(item));
});
$scope.$apply();
notifications.updateMessage($scope.album.length, true);
} else {
starred = false;
notifications.updateMessage("Sorry :(", true);
}
//var description = '<b>Details</b><br />';
var description = '<b>Source</b>: ' + song.source + '<br />';
description += '<b>Date</b>: ' + song.date + '<br />';
description += typeof song.publisher != 'undefined' ? '<b>Transferer</b>: ' + song.publisher + '<br />' : '';
description += typeof song.avg_rating != 'undefined' ? '<b>Rating</b>: ' + song.avg_rating + '<br />' : '';
description += 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 + ')';
},
error: function () {
alert('Archive.org service down :(');
}
if ($scope.filter.Year) {
if (parseInt($scope.filter.Year)) {
url += ' AND year:(' + $scope.filter.Year + ')';
});
};
utils.mapSong = function (key, song, server, dir, identifier, coverart) {
var url, time, track, title, rating, starred, contenttype, suffix;
var specs = ''
if (song.format == 'VBR MP3') {
url = 'http://' + server + dir + key;
if (typeof song.bitrate == 'undefined' || typeof song.format == 'undefined') { specs = '&nbsp;'; } else { specs = song.bitrate + 'kbps, ' + song.format.toLowerCase(); }
if (typeof song.track == 'undefined') { track = '&nbsp;'; } else { track = song.track; }
if (typeof song.title == 'undefined') { title = '&nbsp;'; } else { title = song.title; }
if (typeof song.length == 'undefined') { time = '&nbsp;'; } else { time = utils.timeToSeconds(song.length); }
return new model.Song(song.md5, identifier, song.track, title, song.creator, '', song.album, '', coverart, coverart, time, '', '', 'mp3', specs, url, 0, '');
}
};
$scope.getSongs = function (id, action) {
$scope.selectedAlbum = id;
var url = $scope.archiveUrl + 'details/' + id + '?output=json';
$.ajax({
url: url,
method: 'GET',
dataType: $scope.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
var coverart = '';
var server = data.server;
var dir = data.dir;
var identifier = data.metadata.identifier[0];
if (typeof data.misc.image != 'undefined') {
coverart = data.misc.image;
}
}
if ($scope.filter.Description) {
url += ' AND description:(' + $scope.filter.Description + ')';
}
if ($scope.selectedArchiveAlbumSort) {
url += '&sort[]=' + $scope.selectedArchiveAlbumSort;
}
url += '&fl[]=avg_rating,collection,date,description,downloads,headerImage,identifier,publisher,publicdate,source,subject,title,year';
url += '&rows=50&page=1&output=json';
$.ajax({
url: url,
method: 'GET',
dataType: $scope.Protocol,
timeout: globals.settings.Timeout,
success: function(data) {
var items = [];
if (data.response.docs.length > 0) {
items = data.response.docs;
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function(item, key) {
$scope.album.push(map(item));
});
$scope.$apply();
notifications.updateMessage($scope.album.length, true);
} else {
notifications.updateMessage("Sorry :(", true);
}
},
error: function() {
alert('Archive.org service down :(');
}
});
};
utils.mapSong = function(key, song, server, dir, identifier, coverart) {
var url, time, track, title, rating, starred, contenttype, suffix;
var specs = '';
if (song.format == 'VBR MP3') {
url = 'http://' + server + dir + key;
if (typeof song.bitrate == 'undefined' || typeof song.format == 'undefined') {
specs = '&nbsp;';
var items = data.files;
if (action == 'add') {
angular.forEach(items, function (item, key) {
var song = utils.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
});
$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
$scope.$apply();
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function (item, key) {
var song = utils.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
});
var next = $rootScope.queue[0];
$scope.$apply(function () {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
} else {
specs = song.bitrate + 'kbps, ' + song.format.toLowerCase();
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function (item, key) {
var song = utils.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.song.push(song);
}
});
$scope.$apply();
}
if (typeof song.track == 'undefined') {
track = '&nbsp;';
} else {
track = song.track;
}
if (typeof song.title == 'undefined') {
title = '&nbsp;';
} else {
title = song.title;
}
if (typeof song.length == 'undefined') {
time = '&nbsp;';
} else {
time = utils.timeToSeconds(song.length);
}
return new model.Song(song.md5, identifier, song.track, title, song.creator, '', song.album, '', coverart, coverart, time, '', '', 'mp3', specs, url, 0, '');
}
};
$scope.getSongs = function(id, action) {
$scope.selectedAlbum = id;
var url = $scope.archiveUrl + 'details/' + id + '?output=json';
$.ajax({
url: url,
method: 'GET',
dataType: $scope.Protocol,
timeout: globals.settings.Timeout,
success: function(data) {
var coverart = '';
var server = data.server;
var dir = data.dir;
var identifier = data.metadata.identifier[0];
if (typeof data.misc.image != 'undefined') {
coverart = data.misc.image;
}
var items = data.files;
if (action == 'add') {
angular.forEach(items, function(item, key) {
var song = utils.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
});
$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
$scope.$apply();
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function(item, key) {
var song = utils.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
});
var next = $rootScope.queue[0];
$scope.$apply(function() {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
} else {
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function(item, key) {
var song = utils.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.song.push(song);
}
});
$scope.$apply();
}
}
});
};
$scope.addSongsToQueue = function() {
if ($scope.selectedSongs.length > 0) {
angular.forEach($scope.selectedSongs, function(item, key) {
$scope.queue.push(item);
item.selected = false;
});
$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 = [];
});
};
$scope.addSongsToQueue = function () {
if ($scope.selectedSongs.length > 0) {
angular.forEach($scope.selectedSongs, function (item, key) {
$scope.queue.push(item);
item.selected = false;
});
};
/* Launch on Startup */
if ($routeParams.artist) {
if ($routeParams.album) {
//collection:(GreenskyBluegrass) AND format:(MP3) AND identifier:(gsbg2013-09-20.flac16)
$scope.getAlbums('', $routeParams.album);
} else {
$scope.getAlbums($routeParams.artist, '');
}
$scope.addSavedCollection($routeParams.artist);
$rootScope.showQueue();
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
}
/* End Startup */
});
}
$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) {
if ($routeParams.album) {
//collection:(GreenskyBluegrass) AND format:(MP3) AND identifier:(gsbg2013-09-20.flac16)
$scope.getAlbums('', $routeParams.album);
} else {
$scope.getAlbums($routeParams.artist, '');
}
$scope.addSavedCollection($routeParams.artist);
}
/* End Startup */
});

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,244 +1,231 @@
JamStash.controller('PlaylistCtrl',
function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, notifications) {
function PlaylistCtrl($scope, $rootScope, $location, utils, globals, model, notifications) {
//$("#left-component").layout($scope.layoutTwoCol);
$rootScope.song = [];
$scope.itemType = 'pl';
$scope.playlists = [];
$scope.playlistsPublic = [];
$scope.playlistsGenre = globals.SavedGenres;
$scope.selectedGenre = null;
$scope.$watch("selectedGenre", function(newValue, oldValue) {
if (newValue !== oldValue) {
globals.SavedGenres.push(newValue);
//$scope.playlistsGenre.push();
utils.setValue('SavedGenres', globals.SavedGenres.join(), false);
$rootScope.song = [];
$scope.itemType = 'pl';
$scope.playlists = [];
$scope.playlistsPublic = [];
$scope.playlistsGenre = globals.SavedGenres;
$scope.selectedGenre;
$scope.$watch("selectedGenre", function (newValue, oldValue) {
if (newValue !== oldValue) {
globals.SavedGenres.push(newValue);
//$scope.playlistsGenre.push();
utils.setValue('SavedGenres', globals.SavedGenres.join(), false);
}
});
$scope.getPlaylists = function (refresh) {
if (globals.settings.Debug) { console.log("LOAD PLAYLISTS"); }
$.ajax({
url: globals.BaseURL() + '/getPlaylists.view?' + globals.BaseParams(),
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (data["subsonic-response"].playlists.playlist !== undefined) {
var items = [];
if (data["subsonic-response"].playlists.playlist.length > 0) {
items = data["subsonic-response"].playlists.playlist;
} else {
items[0] = data["subsonic-response"].playlists.playlist;
}
angular.forEach(items, function (item, key) {
if (item.owner == globals.settings.Username) {
$scope.playlists.push(item);
} else if (item.public) {
$scope.playlistsPublic.push(item);
}
});
$scope.$apply();
}
}
});
$scope.getPlaylists = function(refresh) {
if (globals.settings.Debug) {
console.log("LOAD PLAYLISTS");
}
$.ajax({
url: globals.BaseURL() + '/getPlaylists.view?' + globals.BaseParams(),
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function(data) {
if (data["subsonic-response"].playlists.playlist !== undefined) {
var items = [];
if (data["subsonic-response"].playlists.playlist.length > 0) {
items = data["subsonic-response"].playlists.playlist;
} else {
items[0] = data["subsonic-response"].playlists.playlist;
}
angular.forEach(items, function(item, key) {
if (item.owner == globals.settings.Username) {
$scope.playlists.push(item);
} else if (item.public) {
$scope.playlistsPublic.push(item);
}
}
$scope.getPlaylist = function (id, action) {
$rootScope.selectedAutoPlaylist = null;
$rootScope.selectedPlaylist = id;
$.ajax({
url: globals.BaseURL() + '/getPlaylist.view?' + globals.BaseParams() + '&id=' + id,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (typeof data["subsonic-response"].playlist.entry != 'undefined') {
var items = [];
var playlist = data["subsonic-response"].playlist;
if (playlist.entry.length > 0) {
items = playlist.entry;
} else {
items[0] = playlist.entry;
}
if (action == 'add') {
angular.forEach(items, function (item, key) {
$rootScope.queue.push(utils.mapSong(item));
});
$scope.$apply();
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function (item, key) {
$rootScope.queue.push(utils.mapSong(item));
});
var next = $rootScope.queue[0];
$scope.$apply(function () {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else {
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function (item, key) {
$rootScope.song.push(utils.mapSong(item));
});
$scope.$apply();
}
} else {
$rootScope.song = [];
}
});
};
$scope.getPlaylist = function(id, action) {
$rootScope.selectedAutoPlaylist = null;
$rootScope.selectedPlaylist = id;
}
});
}
$scope.getStarred = function (action, type) {
var size = globals.settings.AutoPlaylistSize;
$rootScope.selectedPlaylist = null;
$rootScope.selectedAutoPlaylist = 'starred';
$.ajax({
url: globals.BaseURL() + '/getStarred.view?' + globals.BaseParams() + '&size=' + size,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (typeof data["subsonic-response"].starred !== 'undefined') {
var items = [];
switch (type) {
case 'artist':
if (typeof data["subsonic-response"].starred.artist !== 'undefined') {
if (data["subsonic-response"].starred.artist.length > 0) {
items = data["subsonic-response"].starred.artist;
} else {
items[0] = data["subsonic-response"].starred.artist;
}
}
break;
case 'album':
if (typeof data["subsonic-response"].starred.album !== 'undefined') {
if (data["subsonic-response"].starred.album.length > 0) {
items = data["subsonic-response"].starred.album;
} else {
items[0] = data["subsonic-response"].starred.album;
}
}
break;
case 'song':
if (typeof data["subsonic-response"].starred.song !== 'undefined') {
if (data["subsonic-response"].starred.song.length > 0) {
items = data["subsonic-response"].starred.song;
} else {
items[0] = data["subsonic-response"].starred.song;
}
if (action == 'add') {
angular.forEach(items, function (item, key) {
$rootScope.queue.push(utils.mapSong(item));
});
$scope.$apply();
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function (item, key) {
$rootScope.queue.push(utils.mapSong(item));
});
var next = $rootScope.queue[0];
$scope.$apply(function () {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else {
$rootScope.song = [];
angular.forEach(items, function (item, key) {
$rootScope.song.push(utils.mapSong(item));
});
$scope.$apply();
}
}
break;
default:
break;
}
}
}
});
}
$scope.newPlaylist = function (data, event) {
var reply = prompt("Choose a name for your new playlist.", "");
if (reply != 'null' && reply != null && reply != '') {
$.ajax({
url: globals.BaseURL() + '/getPlaylist.view?' + globals.BaseParams() + '&id=' + id,
url: globals.BaseURL() + '/createPlaylist.view?' + globals.BaseParams() + '&name=' + reply,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function(data) {
if (typeof data["subsonic-response"].playlist.entry != 'undefined') {
var items = [];
var playlist = data["subsonic-response"].playlist;
if (playlist.entry.length > 0) {
items = playlist.entry;
} else {
items[0] = playlist.entry;
}
if (action == 'add') {
angular.forEach(items, function(item, key) {
$rootScope.queue.push(utils.mapSong(item));
});
$scope.$apply();
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function(item, key) {
$rootScope.queue.push(utils.mapSong(item));
});
var next = $rootScope.queue[0];
$scope.$apply(function() {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else {
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function(item, key) {
$rootScope.song.push(utils.mapSong(item));
});
$scope.$apply();
}
} else {
$rootScope.song = [];
}
success: function (data) {
loadPlaylists(true);
}
});
};
$scope.getStarred = function(action, type) {
var size = globals.settings.AutoPlaylistSize;
$rootScope.selectedPlaylist = null;
$rootScope.selectedAutoPlaylist = 'starred';
$.ajax({
url: globals.BaseURL() + '/getStarred.view?' + globals.BaseParams() + '&size=' + size,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function(data) {
if (typeof data["subsonic-response"].starred !== 'undefined') {
var items = [];
switch (type) {
case 'artist':
if (typeof data["subsonic-response"].starred.artist !== 'undefined') {
if (data["subsonic-response"].starred.artist.length > 0) {
items = data["subsonic-response"].starred.artist;
} else {
items[0] = data["subsonic-response"].starred.artist;
}
}
break;
case 'album':
if (typeof data["subsonic-response"].starred.album !== 'undefined') {
if (data["subsonic-response"].starred.album.length > 0) {
items = data["subsonic-response"].starred.album;
} else {
items[0] = data["subsonic-response"].starred.album;
}
}
break;
case 'song':
if (typeof data["subsonic-response"].starred.song !== 'undefined') {
if (data["subsonic-response"].starred.song.length > 0) {
items = data["subsonic-response"].starred.song;
} else {
items[0] = data["subsonic-response"].starred.song;
}
if (action == 'add') {
angular.forEach(items, function(item, key) {
$rootScope.queue.push(utils.mapSong(item));
});
$scope.$apply();
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function(item, key) {
$rootScope.queue.push(utils.mapSong(item));
});
var next = $rootScope.queue[0];
$scope.$apply(function() {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else {
$rootScope.song = [];
angular.forEach(items, function(item, key) {
$rootScope.song.push(utils.mapSong(item));
});
$scope.$apply();
}
}
break;
default:
break;
}
}
}
});
};
$scope.newPlaylist = function(data, event) {
var reply = prompt("Choose a name for your new playlist.", "");
if (reply !== 'null' && reply !== null && reply !== '') {
}
}
$scope.deletePlaylist = function () {
if ($rootScope.selectedPlaylist != null) {
var id = $rootScope.selectedPlaylist;
if (utils.confirmDelete('Are you sure you want to delete the selected playlist?')) {
$.ajax({
url: globals.BaseURL() + '/createPlaylist.view?' + globals.BaseParams() + '&name=' + reply,
url: globals.BaseURL() + '/deletePlaylist.view?' + globals.BaseParams() + '&id=' + id,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function(data) {
loadPlaylists(true);
success: function (data) {
$scope.getPlaylists();
}
});
}
};
$scope.deletePlaylist = function() {
if ($rootScope.selectedPlaylist !== null) {
var id = $rootScope.selectedPlaylist;
if (utils.confirmDelete('Are you sure you want to delete the selected playlist?')) {
$.ajax({
url: globals.BaseURL() + '/deletePlaylist.view?' + globals.BaseParams() + '&id=' + id,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function(data) {
$scope.getPlaylists();
}
});
}
}
};
$scope.savePlaylist = function() {
if ($rootScope.selectedPlaylist() !== null) {
var id = $rootScope.selectedPlaylist().id();
var songs = [];
ko.utils.arrayForEach($rootScope.song(), function(item) {
songs.push(item.id);
});
if (songs.length > 0) {
$.ajax({
type: 'GET',
url: globals.BaseURL() + '/createPlaylist.view?' + globals.BaseParams(),
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
data: {
playlistId: id,
songId: songs
},
success: function() {
$scope.getPlaylist(id);
notifications.updateMessage('Playlist Updated!', true);
},
traditional: true // Fixes POST with an array in JQuery 1.4
});
}
}
};
$scope.removeSelectedSongs = function(data, event) {
ko.utils.arrayForEach($scope.selectedSongs(), function(item) {
$rootScope.song.remove(item);
}
}
$scope.savePlaylist = function () {
if ($rootScope.selectedPlaylist() != null) {
var id = $rootScope.selectedPlaylist().id();
var songs = [];
ko.utils.arrayForEach($rootScope.song(), function (item) {
songs.push(item.id);
});
};
if (songs.length > 0) {
$.ajax({
type: 'GET',
url: globals.BaseURL() + '/createPlaylist.view?' + globals.BaseParams(),
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
data: { playlistId: id, songId: songs },
success: function () {
$scope.getPlaylist(id);
notifications.updateMessage('Playlist Updated!', true);
},
traditional: true // Fixes POST with an array in JQuery 1.4
});
}
}
}
$scope.removeSelectedSongs = function (data, event) {
ko.utils.arrayForEach($scope.selectedSongs(), function (item) {
$rootScope.song.remove(item);
});
}
/* End Playlists */
/* End Playlists */
/* Launch on Startup */
$scope.getPlaylists();
//$scope.getMusicFolders();
$scope.getGenres();
/* End Startup */
});
/* Launch on Startup */
$scope.getPlaylists();
//$scope.getMusicFolders();
$scope.getGenres();
/* End Startup */
});

View file

@ -1,142 +1,112 @@
JamStash.controller('PodcastCtrl',
function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notifications) {
function PodcastCtrl($scope, $rootScope, $location, utils, globals, model, notifications) {
//$("#left-component").layout($scope.layoutTwoCol);
$rootScope.song = [];
$scope.podcasts = [];
$scope.selectedPodcast = null;
$scope.getPodcasts = function(refresh) {
if (globals.settings.Debug) {
console.log("LOAD PODCASTS");
$rootScope.song = [];
$scope.podcasts = [];
$scope.selectedPodcast;
$scope.getPodcasts = function (refresh) {
if (globals.settings.Debug) { console.log("LOAD PODCASTS"); }
$.ajax({
url: globals.BaseURL() + '/getPodcasts.view?' + globals.BaseParams(),
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (data["subsonic-response"].podcasts.channel !== undefined) {
var items = [];
if (data["subsonic-response"].podcasts.channel.length > 0) {
items = data["subsonic-response"].podcasts.channel;
} else {
items[0] = data["subsonic-response"].podcasts.channel;
}
$scope.podcasts = items;
$scope.$apply();
}
}
$.ajax({
url: globals.BaseURL() + '/getPodcasts.view?' + globals.BaseParams(),
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function(data) {
if (data["subsonic-response"].podcasts.channel !== undefined) {
var items = [];
if (data["subsonic-response"].podcasts.channel.length > 0) {
items = data["subsonic-response"].podcasts.channel;
} else {
items[0] = data["subsonic-response"].podcasts.channel;
}
$scope.podcasts = items;
$scope.$apply();
});
}
$scope.getPodcast = function (id, action) {
$scope.selectedPodcast = id;
var map = function (data) {
var song = data;
var url, track, rating, starred, contenttype, suffix, description;
var specs = '', coverartthumb = '', coverartfull = '';
if (typeof song.coverArt != 'undefined') {
coverartthumb = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&size=60&id=' + song.coverArt;
coverartfull = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&id=' + song.coverArt;
}
if (typeof song.description == 'undefined') { description = ''; } else { description = song.description; }
if (typeof song.track == 'undefined') { track = '&nbsp;'; } else { track = song.track; }
if (typeof song.starred !== 'undefined') { starred = true; } else { starred = false; }
if (song.bitRate !== undefined) { specs += song.bitRate + ' Kbps'; }
if (song.transcodedSuffix !== undefined) { specs += ', transcoding:' + song.suffix + ' > ' + song.transcodedSuffix; } else { specs += ', ' + song.suffix; }
if (song.transcodedSuffix !== undefined) { suffix = song.transcodedSuffix; } else { suffix = song.suffix; }
if (suffix == 'ogg') { suffix = 'oga'; }
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',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
if (data["subsonic-response"].podcasts.channel !== undefined) {
var podcasts = [];
if (data["subsonic-response"].podcasts.channel.length > 0) {
podcasts = data["subsonic-response"].podcasts.channel;
} else {
podcasts[0] = data["subsonic-response"].podcasts.channel;
}
}
});
};
$scope.getPodcast = function(id, action) {
$scope.selectedPodcast = id;
var map = function(data) {
var song = data;
var url, track, rating, starred, contenttype, suffix, description;
var specs = '',
coverartthumb = '',
coverartfull = '';
if (typeof song.coverArt != 'undefined') {
coverartthumb = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&size=60&id=' + song.coverArt;
coverartfull = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&id=' + song.coverArt;
}
if (typeof song.description == 'undefined') {
description = '';
} else {
description = song.description;
}
if (typeof song.track == 'undefined') {
track = '&nbsp;';
} else {
track = song.track;
}
if (typeof song.starred !== 'undefined') {
starred = true;
} else {
starred = false;
}
if (song.bitRate !== undefined) {
specs += song.bitRate + ' Kbps';
}
if (song.transcodedSuffix !== undefined) {
specs += ', transcoding:' + song.suffix + ' > ' + song.transcodedSuffix;
} else {
specs += ', ' + song.suffix;
}
if (song.transcodedSuffix !== undefined) {
suffix = song.transcodedSuffix;
} else {
suffix = song.suffix;
}
if (suffix == 'ogg') {
suffix = 'oga';
}
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',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function(data) {
if (data["subsonic-response"].podcasts.channel !== undefined) {
var podcasts = [];
if (data["subsonic-response"].podcasts.channel.length > 0) {
podcasts = data["subsonic-response"].podcasts.channel;
} else {
podcasts[0] = data["subsonic-response"].podcasts.channel;
var items = [];
$.each(podcasts, function (i, item) {
if (item.id == id) {
items = item.episode;
}
var items = [];
$.each(podcasts, function(i, item) {
if (item.id == id) {
items = item.episode;
}
});
});
if (typeof items != 'undefined') {
if (action == 'add') {
angular.forEach(items, function(item, key) {
if (item.status != "skipped") {
$rootScope.queue.push(map(item));
}
});
$scope.$apply();
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function(item, key) {
if (item.status != "skipped") {
$rootScope.queue.push(map(item));
}
});
var next = $rootScope.queue[0];
$scope.$apply(function() {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else {
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function(item, key) {
if (item.status != "skipped") {
$rootScope.song.push(map(item));
}
});
$scope.$apply();
}
if (typeof items != 'undefined') {
if (action == 'add') {
angular.forEach(items, function (item, key) {
if (item.status != "skipped") {
$rootScope.queue.push(map(item));
}
});
$scope.$apply();
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function (item, key) {
if (item.status != "skipped") {
$rootScope.queue.push(map(item));
}
});
var next = $rootScope.queue[0];
$scope.$apply(function () {
$rootScope.playSong(false, next);
});
$rootScope.showQueue();
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
} else {
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function (item, key) {
if (item.status != "skipped") {
$rootScope.song.push(map(item));
}
});
$scope.$apply();
}
}
}
});
};
}
});
}
/* Launch on Startup */
$scope.getPodcasts();
/* End Startup */
});
/* Launch on Startup */
$scope.getPodcasts();
/* End Startup */
});

View file

@ -1,8 +1,8 @@
JamStash.controller('QueueCtrl',
function QueueCtrl($scope, $rootScope, $routeParams, $location, utils, globals, json, notifications) {
$scope.settings = globals.settings;
//$scope.song = $rootScope.queue;
//angular.copy($rootScope.queue, $scope.song);
function QueueCtrl($scope, $rootScope, $routeParams, $location, utils, globals, json, notifications) {
$scope.settings = globals.settings;
//$scope.song = $rootScope.queue;
//angular.copy($rootScope.queue, $scope.song);
$scope.song = $rootScope.queue;
});
$scope.song = $rootScope.queue;
});

View file

@ -1,107 +1,84 @@
JamStash.controller('SettingsCtrl',
function SettingsCtrl($scope, $routeParams, $location, utils, globals, json, notifications) {
$scope.settings = globals.settings;
function SettingsCtrl($scope, $routeParams, $location, utils, globals, json, notifications, player) {
$scope.settings = globals.settings;
$scope.Timeouts = [
{ id: 10000, name: 10 },
{ id: 20000, name: 20 },
{ id: 30000, name: 30 },
{ id: 40000, name: 40 },
{ id: 50000, name: 50 },
{ id: 60000, name: 60 },
{ id: 90000, name: 90 },
{ id: 120000, name: 120 }
];
$scope.Protocols = ["json", "jsonp"];
$scope.Themes = ["Default", "Dark"];
$scope.SearchTypes = globals.SearchTypes;
$scope.Layouts = globals.Layouts;
$scope.Timeouts = [{
id: 10000,
name: 10
}, {
id: 20000,
name: 20
}, {
id: 30000,
name: 30
}, {
id: 40000,
name: 40
}, {
id: 50000,
name: 50
}, {
id: 60000,
name: 60
}, {
id: 90000,
name: 90
}, {
id: 120000,
name: 120
}];
$scope.Protocols = ["json", "jsonp"];
$scope.Themes = ["Default", "Dark"];
$scope.SearchTypes = globals.SearchTypes;
$scope.Layouts = globals.Layouts;
$scope.$watch('settings.HideAZ', function() {
if (globals.settings.HideAZ) {
$('#AZIndex').hide();
} else {
$('#AZIndex').show();
}
});
$scope.reset = function() {
utils.setValue('Settings', null, true);
$scope.loadSettings();
};
$scope.save = function() {
if ($scope.settings.Password !== '' && globals.settings.Password.substring(0, 4) != 'enc:') {
$scope.settings.Password = 'enc:' + utils.HexEncode($scope.settings.Password);
}
if (globals.settings.NotificationSong) {
notifications.requestPermissionIfRequired();
if (!notifications.hasNotificationPermission()) {
alert('HTML5 Notifications are not available for your current browser, Sorry :(');
}
}
if (globals.settings.NotificationNowPlaying) {
notifications.requestPermissionIfRequired();
if (!notifications.hasNotificationPermission()) {
alert('HTML5 Notifications are not available for your current browser, Sorry :(');
}
}
if (globals.settings.SaveTrackPosition) {
//saveTrackPosition();
} else {
//deleteCurrentPlaylist();
}
if (globals.settings.Theme) {
utils.switchTheme(globals.settings.Theme);
}
utils.setValue('Settings', $scope.settings, true);
notifications.updateMessage('Settings Updated!', true);
$scope.loadSettings();
if (globals.settings.Server !== '' && globals.settings.Username !== '' && globals.settings.Password !== '') {
$scope.ping();
}
};
json.getChangeLog(function(data) {
$scope.changeLog = data.slice(0, 10);
});
$scope.changeLogShowMore = function() {
json.getChangeLog(function(data) {
$scope.changeLog = data;
});
};
$scope.setupDemo = function() {
var Username = "android-guest";
var Password = "guest";
var Server = "http://subsonic.org/demo";
var Tab = "tabLibrary";
if (utils.confirmDelete("Do you want to connect to the Subsonic Demo server?")) {
globals.settings.Username = Username;
globals.settings.Password = Password;
globals.settings.Server = Server;
//$scope.save();
$location.url('/library');
}
};
/* Load on Startup */
/* End Startup */
$scope.$watch('settings.HideAZ', function () {
if (globals.settings.HideAZ) {
$('#AZIndex').hide();
} else {
$('#AZIndex').show();
}
});
$scope.reset = function () {
utils.setValue('Settings', null, true);
$scope.loadSettings();
}
$scope.save = function () {
if ($scope.settings.Password != '' && globals.settings.Password.substring(0, 4) != 'enc:') { $scope.settings.Password = 'enc:' + utils.HexEncode($scope.settings.Password); }
if ($scope.settings.NotificationSong) {
notifications.requestPermissionIfRequired();
if (!notifications.hasNotificationPermission()) {
alert('HTML5 Notifications are not available for your current browser, Sorry :(');
}
}
if ($scope.settings.NotificationNowPlaying) {
notifications.requestPermissionIfRequired();
if (!notifications.hasNotificationPermission()) {
alert('HTML5 Notifications are not available for your current browser, Sorry :(');
}
}
if ($scope.settings.SaveTrackPosition) {
player.saveTrackPosition();
} else {
player.deleteCurrentQueue();
}
if ($scope.settings.Theme) {
utils.switchTheme(globals.settings.Theme);
}
utils.setValue('Settings', $scope.settings, true);
notifications.updateMessage('Settings Updated!', true);
$scope.loadSettings();
if (globals.settings.Server != '' && globals.settings.Username != '' && globals.settings.Password != '') {
$scope.ping();
}
};
json.getChangeLog(function (data) {
$scope.changeLog = data.slice(0, 10);
//notifications.updateMessage('Latest Version: ' + $scope.changeLog[0].version, true);
});
$scope.changeLogShowMore = function () {
json.getChangeLog(function (data) {
$scope.changeLog = data;
});
}
$scope.setupDemo = function () {
var Username = "android-guest";
var Password = "guest";
var Server = "http://subsonic.org/demo";
var Tab = "tabLibrary";
if (utils.confirmDelete("Do you want to connect to the Subsonic Demo server?")) {
globals.settings.Username = Username;
globals.settings.Password = Password;
globals.settings.Server = Server;
//$scope.save();
$location.url('/library');
}
}
/* Load on Startup */
/* End Startup */
});

View file

@ -2,6 +2,7 @@
{
"date": "2/7/2014", "version": "3.2.2",
"changes": [
{ "text": "- Bug fixes!" },
{ "text": "- Legacy version of <a href=\"http://jamstash.com/mini\" target=\"_blank\">MiniSub</a>" }
]
},

View file

@ -1,5 +1,5 @@
<div id="queue" class="tabcontent">
<div class="section fullsection floatleft">
<ul class="songlist simplelist" ng-include src="'js/partials/songs.html'"></ul>
<ul class="songlist simplelist noselect" ng-include src="'js/partials/songs.html'" sortable></ul>
</div>
</div>

View file

@ -86,10 +86,6 @@
<div class="clear"></div>
<select id="Timeout" name="Timeout" class="" ng-model="settings.Timeout" ng-options="o.id as o.name for o in Timeouts" title="AJAX Request Timeout (Seconds)"></select>
<div class="clear"></div>
<label for="NotificationTimeout">Notification Timeout</label>
<div class="clear"></div>
<select id="NotificationTimeout" name="NotificationTimeout" class="" ng-model="settings.NotificationTimeout" ng-options="o.id as o.name for o in Timeouts" title="Notification Timeout (Seconds)"></select>
<div class="clear"></div>
<label for="Protocol">Protocol</label><br />
<select id="Protocol" name="Protocol" class="" ng-model="settings.Protocol" ng-options="o for o in Protocols" title="Enable Cross-Domain AJAX Requests (Use if hosted in a different domain than Subsonic)"></select>
<!--

View file

@ -1,36 +1,31 @@
JamStash.service('player', function($rootScope, $window, utils, globals, model, notifications) {
JamStash.service('player', function ($rootScope, $window, utils, globals, model, notifications) {
var player1 = '#playdeck_1';
var player2 = '#playdeck_2';
var scrobbled = false;
var timerid = 0;
$rootScope.defaultPlay = function(data, event) {
$rootScope.defaultPlay = function (data, event) {
if (typeof $(player1).data("jPlayer") == 'undefined') {
$rootScope.nextTrack();
}
};
$rootScope.nextTrack = function() {
}
$rootScope.nextTrack = function () {
var next = getNextSong();
if (next) {
$rootScope.playSong(false, next);
}
//$(player1).jPlayer("stop");
//$(player2).jPlayer("play");
};
$rootScope.previousTrack = function() {
}
$rootScope.previousTrack = function () {
var next = getNextSong(true);
if (next) {
$rootScope.playSong(false, next);
}
};
getNextSong = function(previous) {
}
getNextSong = function (previous) {
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); }
if ($rootScope.queue.length > 0) {
angular.forEach($rootScope.queue, function(item, key) {
if (item.playing === true) {
@ -45,9 +40,7 @@
next = $rootScope.queue[index + 1];
}
if (typeof next != 'undefined') {
if (globals.settings.Debug) {
console.log('Next Song: ' + next.id);
}
if (globals.settings.Debug) { console.log('Next Song: ' + next.id); }
return next;
} else {
return false;
@ -55,26 +48,24 @@
} else {
return false;
}
};
this.startSaveTrackPosition = function() {
}
this.startSaveTrackPosition = function () {
if (globals.settings.SaveTrackPosition) {
if (timerid !== 0) {
if (timerid != 0) {
clearInterval(timerid);
}
timerid = $window.setInterval(function() {
timerid = $window.setInterval(function () {
if (globals.settings.SaveTrackPosition) {
saveTrackPosition();
this.saveTrackPosition();
}
}, 30000);
}
};
saveTrackPosition = function() {
}
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) {
if (item.playing === true) {
@ -83,7 +74,7 @@
});
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
@ -91,17 +82,13 @@
try {
var songStr = angular.toJson(song);
localStorage.setItem('CurrentSong', songStr);
if (globals.settings.Debug) {
console.log('Saving Current Position: ' + songStr);
}
if (globals.settings.Debug) { console.log('Saving Current Position: ' + songStr); }
var html = localStorage.getItem('CurrentQueue');
if ($rootScope.queue.length > 0) {
var current = $rootScope.queue;
if (current != html) {
localStorage.setItem('CurrentQueue', angular.toJson(current));
if (globals.settings.Debug) {
console.log('Saving Queue: ' + current.length + ' characters');
}
if (globals.settings.Debug) { console.log('Saving Queue: ' + current.length + ' characters'); }
}
}
} catch (e) {
@ -110,17 +97,16 @@
}
}
} 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'); }
}
}
}
}
} else {
if (globals.settings.Debug) { console.log('Saving Queue: No Audio Loaded'); }
}
};
this.loadTrackPosition = function() {
}
this.loadTrackPosition = function () {
if (utils.browserStorageCheck()) {
// Load Saved Song
var song = angular.fromJson(localStorage.getItem('CurrentSong'));
@ -134,36 +120,24 @@
if ($rootScope.queue.length > 0) {
notifications.updateMessage($rootScope.queue.length + ' Saved Song(s)', true);
}
if (globals.settings.Debug) {
console.log('Play Queue Loaded From localStorage: ' + $rootScope.queue.length + ' song(s)');
}
if (globals.settings.Debug) { console.log('Play Queue Loaded From localStorage: ' + $rootScope.queue.length + ' song(s)'); }
}
}
} 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'); }
}
};
deleteCurrentQueue = function(data) {
}
this.deleteCurrentQueue = function (data) {
if (utils.browserStorageCheck()) {
localStorage.removeItem('CurrentQueue');
utils.setValue('CurrentSong', null, false);
if (globals.settings.Debug) {
console.log('Removing Play Queue');
}
if (globals.settings.Debug) { console.log('Removing Play Queue'); }
} 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));
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) {
item.playing = false;
});
@ -194,8 +168,7 @@
artist: artist,
favorite: false,
albumArt: coverartfull
};
}
if ($rootScope.unity) {
$rootScope.unity.sendState(playerState);
}
@ -206,13 +179,13 @@
$rootScope.showQueue();
}
var spechtml = '';
data = $(player1).data().jPlayer;
var data = $(player1).data().jPlayer;
for (i = 0; i < data.solutions.length; i++) {
var solution = data.solutions[i];
if (data[solution].used) {
spechtml += "<strong class=\"codesyntax\">" + solution + "</strong> is";
spechtml += " currently being used with<strong>";
for (var format in data[solution].support) {
for (format in data[solution].support) {
if (data[solution].support[format]) {
spechtml += " <strong class=\"codesyntax\">" + format + "</strong>";
}
@ -227,18 +200,17 @@
notifications.showNotification(coverartthumb, utils.toHTML.un(title), utils.toHTML.un(artist + ' - ' + album), 'text', '#NextTrack');
}
if (globals.settings.ScrollTitle) {
title = utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title);
var title = utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title);
utils.scrollTitle(title);
} else {
utils.setTitle(utils.toHTML.un(artist) + ' - ' + utils.toHTML.un(title));
}
//utils.safeApply();
if (!$rootScope.$root.$$phase) {
if(!$rootScope.$root.$$phase) {
$rootScope.$apply();
}
};
$rootScope.loadjPlayer = function(el, url, suffix, loadonly, position) {
$rootScope.loadjPlayer = function (el, url, suffix, loadonly, position) {
// jPlayer Setup
var volume = 1;
if (utils.getValue('Volume')) {
@ -272,7 +244,7 @@
currentTime: "#played",
duration: "#duration"
},
ready: function() {
ready: function () {
console.log("File Suffix: " + suffix);
if (suffix == 'oga') {
$(this).jPlayer("setMedia", {
@ -299,14 +271,12 @@
console.log('[jPlayer Options Info]');
utils.logObjectProperties($(el).data("jPlayer").options);
}
},
},
timeupdate: function(event) {
// Scrobble song once percentage is reached
var p = event.jPlayer.status.currentPercentAbsolute;
if (!scrobbled && p > 30) {
if (globals.settings.Debug) {
console.log('LAST.FM SCROBBLE - Percent Played: ' + p);
}
if (globals.settings.Debug) { console.log('LAST.FM SCROBBLE - Percent Played: ' + p); }
scrobbleSong(true);
}
},
@ -342,9 +312,8 @@
}
});
return;
};
this.playPauseSong = function() {
}
this.playPauseSong = function () {
if (typeof $(player1).data("jPlayer") != 'undefined') {
if ($(player1).data("jPlayer").status.paused) {
$(player1).jPlayer("play");
@ -352,24 +321,20 @@
$(player1).jPlayer("pause");
}
}
};
playVideo = function(id, bitrate) {
}
playVideo = function (id, bitrate) {
var w, h;
bitrate = parseInt(bitrate);
if (bitrate <= 600) {
w = 320;
h = 240;
w = 320; h = 240;
} else if (bitrate <= 1000) {
w = 480;
h = 360;
w = 480; h = 360;
} else {
w = 640;
h = 480;
w = 640; h = 480;
}
//$("#jPlayerSelector").jPlayer("option", "fullScreen", true);
$("#videodeck").jPlayer({
ready: function() {
ready: function () {
/*
$.fancybox({
autoSize: false,
@ -378,44 +343,41 @@
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) {
scrobbleSong = function (submission) {
if ($rootScope.loggedIn && submission) {
var id = $rootScope.playingSong.id;
if (globals.settings.Debug) {
console.log('Scrobble Song: ' + id);
}
if (globals.settings.Debug) { console.log('Scrobble Song: ' + id); }
$.ajax({
url: globals.BaseURL() + '/scrobble.view?' + globals.BaseParams() + '&id=' + id + "&submission=" + submission,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: 10000,
success: function() {
success: function () {
scrobbled = true;
}
});
}
};
rateSong = function(songid, rating) {
}
rateSong = function (songid, rating) {
$.ajax({
url: baseURL + '/setRating.view?' + baseParams + '&id=' + songid + "&rating=" + rating,
method: 'GET',
dataType: protocol,
timeout: 10000,
success: function() {
success: function () {
updateMessage('Rating Updated!', true);
}
});
};
}
});

View file

@ -1,6 +1,6 @@
JamStash.service('model', function() {
JamStash.service('model', function () {
// Figure out how to move this, circular dependency with utils
secondsToTime = function(secs) {
secondsToTime = function (secs) {
// secs = 4729
var times = new Array(3600, 60, 1);
var time = '';
@ -12,10 +12,12 @@
// 2: 49/1 = 49
if (tmp < 1) {
tmp = '00';
} else if (tmp < 10) {
}
else if (tmp < 10) {
tmp = '0' + tmp;
}
if (i === 0 && tmp == '00') {} else {
if (i == 0 && tmp == '00') {
} else {
time += tmp;
if (i < 2) {
time += ':';
@ -24,19 +26,16 @@
secs = secs % times[i];
}
return time;
};
this.Index = function(name, artist) {
}
this.Index = function (name, artist) {
this.name = name;
this.artist = artist;
};
this.Artist = function(id, name) {
}
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.Album = function (id, parentid, name, artist, artistId, coverartthumb, coverartfull, date, starred, description, url, type) {
this.id = id;
this.parentid = parentid;
this.name = name;
@ -49,9 +48,8 @@
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.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;
this.track = track;
@ -63,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;
@ -74,56 +72,38 @@
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"
}, ];
this.Layouts = [{
id: "grid",
name: "Grid"
}, {
id: "list",
name: "List"
}];
this.AlbumSorts = [{
id: "default",
name: "Default Sort"
}, {
id: "artist",
name: "Artist"
}, {
id: "album",
name: "Album"
}, {
id: "track",
name: "Track"
}, {
id: "createdate desc",
name: "Date Added"
}, ];
JamStash.service('globals', function () {
this.SearchTypes = [
{ id: "song", name: "Song" },
{ id: "album", name: "Album" },
{ id: "artist", name: "Artist" },
];
this.Layouts = [
{ id: "grid", name: "Grid" },
{ id: "list", name: "List" }
];
this.AlbumSorts = [
{ id: "default", name: "Default Sort" },
{ id: "artist", name: "Artist" },
{ id: "album", name: "Album" },
{ id: "track", name: "Track" },
{ id: "createdate desc", name: "Date Added" },
];
this.settings = {
// Subsonic
/* Demo Server
Username: "android-guest"),
Password: "guest"),
Server: "http://subsonic.org/demo"),
*/
Url: "http://Jamstash.com/beta/#/archive/",
Username: "",
Password: "",
Server: "",
Timeout: 10000,
NotificationTimeout: 20000,
Timeout: 20000,
Protocol: "jsonp",
ApplicationName: "Jamstash",
ApiVersion: "1.6.0",
@ -146,28 +126,21 @@ JamStash.service('globals', function() {
Repeat: false,
Debug: false
};
this.SavedCollections = [];
this.SavedGenres = [];
this.BaseURL = function() {
return this.settings.Server + '/rest';
};
this.BaseParams = function() {
return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=' + this.settings.Protocol + '&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName;
};
this.BaseURL = function () { return this.settings.Server + '/rest'; };
this.BaseParams = function () { return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=' + this.settings.Protocol + '&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName; };
});
// Directives
JamStash.directive('layout', function() {
JamStash.directive('layout', function () {
return {
link: function(scope, elm, attrs) {
link: function (scope, elm, attrs) {
var pageLayoutOptions = {
name: 'pageLayout', // only for debugging
resizeWithWindowDelay: 250, // delay calling resizeAll when window is *still* resizing
resizeWithWindowDelay: 250, // delay calling resizeAll when window is *still* resizing
//, resizeWithWindowMaxDelay: 2000 // force resize every XX ms while window is being resized
//center__children: {},
//north__paneSelector: "#container",
@ -183,16 +156,16 @@ JamStash.directive('layout', function() {
};
var layoutThreeCol = {
east__size: 0.42,
east__size: .42,
east__minSize: 400,
east__maxSize: 0.5, // 50% of layout width
east__maxSize: .5, // 50% of layout width
east__initClosed: false,
east__initHidden: false,
//center__size: 'auto',
center__minWidth: 0.38,
center__minWidth: .38,
center__initClosed: false,
center__initHidden: false,
west__size: 0.2,
west__size: .2,
west__minSize: 200,
west__initClosed: false,
west__initHidden: false,
@ -202,12 +175,12 @@ JamStash.directive('layout', function() {
};
var layoutTwoCol = {
center__size: 0.8,
center__size: .8,
center__minSize: 400,
center__maxSize: 0.5, // 50% of layout width
center__maxSize: .5, // 50% of layout width
center__initClosed: false,
center__initHidden: false,
west__size: 0.2,
west__size: .2,
west__minSize: 200,
west__initClosed: false,
west__initHidden: false,
@ -216,20 +189,17 @@ JamStash.directive('layout', function() {
//applyDefaultStyles: true
};
scope.$watch(attrs.state, function(state) {
var layout;
scope.$watch(attrs.state, function (state) {
if (state == 1) {
layout = elm.layout(pageLayoutOptions);
var layout = elm.layout(pageLayoutOptions);
}
if (state == 2) {
layout = elm.layout(layoutTwoCol);
var layout = elm.layout(layoutTwoCol);
//scope.layout.sizePane('east', 120);
//scope.layout.show('west');
//scope.layout.show('south');
} else if (state == 3) {
layout = elm.layout(layoutThreeCol);
var layout = elm.layout(layoutThreeCol);
//scope.layout.sizePane('east', 60);
//scope.layout.hide('west');
//scope.layout.hide('south');
@ -239,10 +209,9 @@ JamStash.directive('layout', function() {
}
};
});
JamStash.directive('sortable', function() {
JamStash.directive('sortable', function () {
return {
link: function(scope, elm, attrs) {
link: function (scope, elm, attrs) {
elm.sortable({
start: scope.dragStart,
update: scope.dragEnd
@ -251,38 +220,69 @@ JamStash.directive('sortable', function() {
}
};
});
JamStash.directive('split', function() {
JamStash.directive('split', function () {
return {
link: function(scope, elm, attrs) {
link: function (scope, elm, attrs) {
elm.splitPane();
/*
//elm.first().resizable({
$('#SubsonicAlbums > div:first').resizable({
handles: 'e',
minWidth: '100',
maxWidth: '400',
resize: function () {
alert('foo');
var remainingSpace = $(this).parent().width() - $(this).outerWidth();
var divTwo = $(this).next();
var divTwoWidth = remainingSpace - (divTwo.outerWidth() - divTwo.width());
divTwo.css('width', divTwoWidth + 'px');
}
});
*/
/*
scope.$watch(attrs.state, function (state) {
if (state == 1) {
var layout = elm.layout(pageLayoutOptions);
}
if (state == 2) {
var layout = elm.layout(layoutTwoCol);
//scope.layout.sizePane('east', 120);
//scope.layout.show('west');
//scope.layout.show('south');
} else if (state == 3) {
var layout = elm.layout(layoutThreeCol);
//scope.layout.sizePane('east', 60);
//scope.layout.hide('west');
//scope.layout.hide('south');
}
scope.layout = layout;
});
*/
}
};
});
JamStash.directive('fancybox', function($compile) {
JamStash.directive('fancybox', function ($compile) {
return {
restrict: 'A',
replace: false,
link: function($scope, element, attrs) {
$scope.fancyboxOpen = function() {
var el = angular.element(element.html()),
compiled = $compile(el);
compiled = $compile(el);
$.fancybox.open(el);
compiled($scope);
};
$scope.fancyboxOpenUrl = function() {
$scope.fancyboxOpenUrl = function () {
var el = angular.element(element.html()),
compiled = $compile(el);
compiled = $compile(el);
$.fancybox.open(el);
compiled($scope);
};
}
};
});
JamStash.directive('songpreview', function($compile, subsonic) {
JamStash.directive('songpreview', function ($compile, subsonic) {
return {
restrict: 'E',
templateUrl: 'js/partials/songs.html',
@ -291,8 +291,8 @@ JamStash.directive('songpreview', function($compile, subsonic) {
scope: {
song: '@'
},
link: function(scope, element, attrs) {
subsonic.getSongTemplate(function(data) {
link: function (scope, element, attrs) {
subsonic.getSongTemplate(function (data) {
scope.song = data;
//var el = angular.element(element.html()),
//var el = element.html(),
@ -301,25 +301,23 @@ JamStash.directive('songpreview', function($compile, subsonic) {
//compiled($scope);
});
}
};
});
JamStash.directive('stopEvent', function() {
}
})
JamStash.directive('stopEvent', function () {
return {
restrict: 'A',
link: function(scope, element, attr) {
element.bind(attr.stopEvent, function(e) {
link: function (scope, element, attr) {
element.bind(attr.stopEvent, function (e) {
e.stopPropagation();
});
}
};
});
JamStash.directive('ngEnter', function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
JamStash.directive('ngEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if (event.which === 13) {
scope.$apply(function() {
scope.$apply(function () {
scope.$eval(attrs.ngEnter);
});
@ -328,28 +326,23 @@ JamStash.directive('ngEnter', function() {
});
};
});
JamStash.directive('ngDownload', function($compile) {
JamStash.directive('ngDownload', function ($compile) {
return {
restrict: 'E',
scope: {
data: '='
},
link: function(scope, elm, attrs) {
scope: { data: '=' },
link: function (scope, elm, attrs) {
function getUrl() {
return URL.createObjectURL(new Blob([JSON.stringify(scope.data)], {
type: "application/json"
}));
return URL.createObjectURL(new Blob([JSON.stringify(scope.data)], { type: "application/json" }));
}
elm.append($compile(
'<a class="button" download="backup.json"' +
'href="' + getUrl() + '">' +
'Download' +
'</a>'
'<a class="button" download="backup.json"' +
'href="' + getUrl() + '">' +
'Download' +
'</a>'
)(scope));
scope.$watch(scope.data, function() {
scope.$watch(scope.data, function () {
elm.children()[0].href = getUrl();
});
}
@ -357,110 +350,105 @@ JamStash.directive('ngDownload', function($compile) {
});
/* Factory */
JamStash.factory('json', function($http) { // Deferred loading
JamStash.factory('json', function ($http) { // Deferred loading
return {
getCollections: function(callback) {
getCollections: function (callback) {
$http.get('js/json_collections.js').success(callback);
},
getChangeLog: function(callback) {
getChangeLog: function (callback) {
$http.get('js/json_changelog.js').success(callback);
}
};
}
});
JamStash.factory('template', function($compile, $http, $templateCache) { // Deferred loading
JamStash.factory('template', function ($http, $compile, $http, $templateCache) { // Deferred loading
return {
getCollections: function(callback) {
$http.get('js/json_collections.js', {
cache: $templateCache
}).success(callback);
getCollections: function (callback) {
$http.get('js/json_collections.js', { cache: $templateCache }).success(callback);
},
getChangeLog: function(callback) {
$http.get('js/json_changelog.js', {
cache: $templateCache
}).success(callback);
getChangeLog: function (callback) {
$http.get('js/json_changelog.js', { cache: $templateCache }).success(callback);
},
getSongs: function(callback) {
getSongs: function (callback) {
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 {
getSongTemplate: function(callback) {
getSongTemplate: function (callback) {
var id = '16608';
var url = globals.BaseURL() + '/getMusicDirectory.view?' + globals.BaseParams() + '&id=' + id;
/*
$.ajax({
url: url,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
$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);
}
});
*/
$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);
}
});
}
};
}
});
/* Filters */
JamStash.filter('capitalize', function() {
return function(input, scope) {
JamStash.filter('capitalize', function () {
return function (input, scope) {
return input.substring(0, 1).toUpperCase() + input.substring(1);
};
}
});
JamStash.service('notifications', function($rootScope, globals) {
JamStash.service('notifications', function ($rootScope, globals) {
var msgIndex = 1;
this.updateMessage = function(msg, autohide) {
if (msg !== '') {
this.updateMessage = function (msg, autohide) {
if (msg != '') {
var id = msgIndex;
$('#messages').append('<span id=\"msg_' + id + '\" class="message">' + msg + '</span>');
$('#messages').fadeIn();
$("#messages").scrollTo('100%');
var el = '#msg_' + id;
if (autohide) {
setTimeout(function() {
$(el).fadeOut(function() {
$(this).remove();
});
}, globals.settings.NotificationTimeout);
setTimeout(function () {
$(el).fadeOut(function () { $(this).remove(); });
}, globals.settings.Timeout);
}
$(el).click(function() {
$(el).fadeOut(function() {
$(this).remove();
});
$(el).click(function () {
$(el).fadeOut(function () { $(this).remove(); });
return false;
});
msgIndex++;
}
};
this.requestPermissionIfRequired = function() {
}
this.requestPermissionIfRequired = function () {
if (!this.hasNotificationPermission() && (window.webkitNotifications)) {
window.webkitNotifications.requestPermission();
}
};
this.hasNotificationPermission = function() {
return !!(window.webkitNotifications) && (window.webkitNotifications.checkPermission() === 0);
};
var notifications = [];
this.showNotification = function(pic, title, text, type, bind) {
}
this.hasNotificationPermission = function () {
return !!(window.webkitNotifications) && (window.webkitNotifications.checkPermission() == 0);
}
var notifications = new Array();
this.showNotification = function (pic, title, text, type, bind) {
if (this.hasNotificationPermission()) {
//closeAllNotifications()
var popup;
@ -469,26 +457,25 @@ JamStash.service('notifications', function($rootScope, globals) {
} else if (type == 'html') {
popup = window.webkitNotifications.createHTMLNotification(text);
}
if (bind == '#NextTrack') {
popup.addEventListener('click', function(bind) {
if (bind = '#NextTrack') {
popup.addEventListener('click', function (bind) {
//$(bind).click();
$rootScope.nextTrack();
this.cancel();
});
})
}
notifications.push(popup);
setTimeout(function(notWin) {
setTimeout(function (notWin) {
notWin.cancel();
}, globals.settings.NotificationTimeout, popup);
}, globals.settings.Timeout, popup);
popup.show();
} else {
console.log("showNotification: No Permission");
}
};
this.closeAllNotifications = function() {
for (var notification in notifications) {
}
this.closeAllNotifications = function () {
for (notification in notifications) {
notifications[notification].cancel();
}
};
}
});

View file

@ -1,17 +1,15 @@
JamStash.service('utils', function($cookieStore, globals, model) {
this.safeApply = function(fn) {
JamStash.service('utils', function ($cookieStore, globals, model) {
this.safeApply = function (fn) {
var phase = this.$root.$$phase;
if (phase == '$apply' || phase == '$digest') {
if (fn && (typeof(fn) === 'function')) {
if (fn && (typeof (fn) === 'function')) {
fn();
}
} else {
this.$apply(fn);
}
};
this.setValue = function(key, value, notify) {
this.setValue = function (key, value, notify) {
/*
if (value !== null) {
$cookieStore.put(key, value);
@ -24,13 +22,10 @@ JamStash.service('utils', function($cookieStore, globals, model) {
try {
localStorage.setItem(key, JSON.stringify(value));
} 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)) {
return $cookieStore.get(value);
@ -40,93 +35,60 @@ 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;
}
} 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 url, title, track, rating, starred, contenttype, suffix, description;
var specs = '',
coverartthumb = '',
coverartfull = '';
var specs = '', coverartthumb = '', coverartfull = '';
if (typeof song.coverArt != 'undefined') {
coverartthumb = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&size=60&id=' + song.coverArt;
coverartfull = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&id=' + song.coverArt;
}
if (typeof song.description == 'undefined') {
description = '';
} else {
description = song.description;
}
if (typeof song.title == 'undefined') {
title = '&nbsp;';
} else {
title = song.title.toString();
}
if (typeof song.track == 'undefined') {
track = '&nbsp;';
} else {
track = song.track.toString();
}
if (typeof song.starred !== 'undefined') {
starred = true;
} else {
starred = false;
}
if (song.bitRate !== undefined) {
specs += song.bitRate + ' Kbps';
}
if (song.transcodedSuffix !== undefined) {
specs += ', transcoding:' + song.suffix + ' > ' + song.transcodedSuffix;
} else {
specs += ', ' + song.suffix;
}
if (song.transcodedSuffix !== undefined) {
suffix = song.transcodedSuffix;
} else {
suffix = song.suffix;
}
if (suffix == 'ogg') {
suffix = 'oga';
coverartthumb = 'images/albumdefault_60.jpg';
coverartfull = 'images/albumdefault_160.jpg';
}
if (typeof song.description == 'undefined') { description = ''; } else { description = song.description; }
if (typeof song.title == 'undefined') { title = '&nbsp;'; } else { title = song.title.toString(); }
if (typeof song.track == 'undefined') { track = '&nbsp;'; } else { track = song.track.toString(); }
if (typeof song.starred !== 'undefined') { starred = true; } else { starred = false; }
if (song.bitRate !== undefined) { specs += song.bitRate + ' Kbps'; }
if (song.transcodedSuffix !== undefined) { specs += ', transcoding:' + song.suffix + ' > ' + song.transcodedSuffix; } else { specs += ', ' + song.suffix; }
if (song.transcodedSuffix !== undefined) { suffix = song.transcodedSuffix; } else { suffix = song.suffix; }
if (suffix == 'ogg') { suffix = 'oga'; }
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) {
}
this.confirmDelete = function (text) {
var question = confirm(text);
if (question) {
return true;
} else {
}
else {
return false;
}
};
this.makeBaseAuth = function(user, password) {
}
this.makeBaseAuth = function (user, password) {
var tok = user + ':' + password;
var hash = $.base64Encode(tok);
return "Basic " + hash;
};
this.HexEncode = function(n) {
}
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("");
};
this.switchTheme = function(theme) {
return r.join("")
}
this.switchTheme = function (theme) {
switch (theme.toLowerCase()) {
case 'dark':
$('link[data-name=theme]').attr('href', 'style/Dark.css');
@ -137,18 +99,16 @@ JamStash.service('utils', function($cookieStore, globals, model) {
default:
break;
}
};
}
// HTML5
this.browserStorageCheck = function() {
if (typeof(localStorage) == 'undefined') {
this.browserStorageCheck = function () {
if (typeof (localStorage) == 'undefined') {
return false;
} else {
return true;
}
};
this.timeToSeconds = function(time) {
}
this.timeToSeconds = function (time) {
var a = time.split(':'); // split it at the colons
var seconds;
switch (a.length) {
@ -165,9 +125,8 @@ JamStash.service('utils', function($cookieStore, globals, model) {
break;
}
return seconds;
};
this.secondsToTime = function(secs) {
}
this.secondsToTime = function (secs) {
// secs = 4729
var times = new Array(3600, 60, 1);
var time = '';
@ -179,10 +138,12 @@ JamStash.service('utils', function($cookieStore, globals, model) {
// 2: 49/1 = 49
if (tmp < 1) {
tmp = '00';
} else if (tmp < 10) {
}
else if (tmp < 10) {
tmp = '0' + tmp;
}
if (i === 0 && tmp == '00') {} else {
if (i == 0 && tmp == '00') {
} else {
time += tmp;
if (i < 2) {
time += ':';
@ -191,30 +152,27 @@ JamStash.service('utils', function($cookieStore, globals, model) {
secs = secs % times[i];
}
return time;
};
this.arrayObjectIndexOf = function(myArray, searchTerm, property) {
}
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) {
}
this.logObjectProperties = function (obj) {
$.each(obj, function (key, value) {
var parent = key;
if (typeof value === "object") {
$.each(value, function(key, value) {
$.each(value, function (key, value) {
console.log(parent + ' > ' + key + ' : ' + value);
});
} else {
console.log(key + ' : ' + value);
}
});
};
this.clickButton = function(el) {
el = $(el);
}
this.clickButton = function (el) {
var el = $(el);
if (el) {
var classes = $(el).attr('class').split(" ");
for (var i = 0, l = classes.length; i < l; ++i) {
@ -231,143 +189,86 @@ 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
}]
}
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 keyFound = 0;
$.each(map.keymap, function(i, mapping) {
$.each(map.keymap, function (i, mapping) {
if (mapping.code === code) {
keyFound = mapping.key;
}
});
return keyFound;
};
}
this.toHTML = {
on: function(str) {
on: function (str) {
var a = [],
i = 0;
for (; i < str.length;) a[i] = str.charCodeAt(i++);
return "&#" + a.join(";&#") + ";";
i = 0;
for (; i < str.length; ) a[i] = str.charCodeAt(i++);
return "&#" + a.join(";&#") + ";"
},
un: function(str) {
un: function (str) {
return str.replace(/&#(x)?([^;]{1,5});?/g,
function(a, b, c) {
return String.fromCharCode(parseInt(c, b ? 16 : 10));
});
function (a, b, c) {
return String.fromCharCode(parseInt(c, b ? 16 : 10))
})
}
};
this.getParameterByName = function(name) {
this.getParameterByName = function (name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
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) {
}
this.getPathFromUrl = function (url) {
var strurl = url.toString();
var u = strurl.substring(0, strurl.indexOf('?'));
return u;
};
this.setTitle = function(text) {
if (text !== "") {
return u
}
this.setTitle = function (text) {
if (text != "") {
document.title = text;
}
};
}
var timer = 0;
this.scrollTitle = function(text) {
this.scrollTitle = function (text) {
var shift = {
"left": function(a) {
"left": function (a) {
a.push(a.shift());
},
"right": function(a) {
"right": function (a) {
a.unshift(a.pop());
}
};
@ -383,19 +284,23 @@ JamStash.service('utils', function($cookieStore, globals, model) {
}
t.push(" ");
clearInterval(timer);
timer = setInterval(function() {
timer = setInterval(function () {
var f = shift[opts.dir];
if (f) {
f(t);
document.title = t.join("");
}
}, opts.speed);
};
this.parseVersionString = function(str) {
if (typeof(str) != 'string') {
return false;
}
/*
$.marqueeTitle({
text: text,
dir: "left",
speed: 1200
});
*/
}
this.parseVersionString = function (str) {
if (typeof (str) != 'string') { return false; }
var x = str.split('.');
// parse from string or default to 0 if can't parse
var maj = parseInt(x[0]) || 0;
@ -405,10 +310,9 @@ JamStash.service('utils', function($cookieStore, globals, model) {
major: maj,
minor: min,
patch: pat
};
};
this.checkVersion = function(runningVersion, minimumVersion) {
}
}
this.checkVersion = function (runningVersion, minimumVersion) {
if (runningVersion.major >= minimumVersion.major) {
if (runningVersion.minor >= minimumVersion.minor) {
if (runningVersion.patch >= minimumVersion.patch) {
@ -422,9 +326,8 @@ JamStash.service('utils', function($cookieStore, globals, model) {
} else {
return false;
}
};
this.checkVersionNewer = function(runningVersion, newVersion) {
}
this.checkVersionNewer = function (runningVersion, newVersion) {
if (runningVersion.major < newVersion.major) {
return true;
} else {
@ -438,14 +341,14 @@ JamStash.service('utils', function($cookieStore, globals, model) {
}
}
}
};
this.parseDate = function(date) {
}
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;
return months[month] + " " + dateParts[2] + ", " + dateParts[0];
};
var date = months[month] + " " + dateParts[2] + ", " + dateParts[0];
return date;
}
});

View file

@ -527,6 +527,7 @@ ul.mainlist li.item a.add:hover
margin: 0 2px 0 6px;
text-decoration: none;
color: #829FC0;
font-size: 14px;
}
#BreadCrumbs a:hover
{