Commit local changes
This commit is contained in:
parent
bb7d018de4
commit
310c79f63c
16 changed files with 2134 additions and 2520 deletions
|
@ -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">
|
||||
|
|
78
js/app.js
78
js/app.js
|
@ -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) {
|
||||
.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') {
|
||||
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;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
JamStash.controller('ArchiveCtrl',
|
||||
function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, globals, model, notifications, player, json) {
|
||||
function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils, globals, model, notifications, player, json) {
|
||||
//$("#left-component").layout($scope.layoutThreeCol);
|
||||
|
||||
$scope.settings = globals.settings;
|
||||
|
@ -8,57 +8,52 @@
|
|||
$scope.Protocol = 'jsonp';
|
||||
$scope.artist = [];
|
||||
$scope.album = [];
|
||||
$scope.selectedArtist = null;
|
||||
$scope.selectedAlbum = null;
|
||||
$scope.selectedArtist;
|
||||
$scope.selectedAlbum;
|
||||
$scope.selectedSongs = [];
|
||||
$scope.SavedCollections = globals.SavedCollections;
|
||||
$scope.AllCollections = [];
|
||||
$scope.loadedCollection = false;
|
||||
|
||||
json.getCollections(function(data) {
|
||||
json.getCollections(function (data) {
|
||||
$scope.AllCollections = data;
|
||||
$scope.loadedCollection = true;
|
||||
});
|
||||
|
||||
$scope.writeSavedCollection = function() {
|
||||
$scope.writeSavedCollection = function () {
|
||||
utils.setValue('SavedCollections', $scope.SavedCollections.join(), false);
|
||||
/*
|
||||
$scope.$apply(function () {
|
||||
});
|
||||
*/
|
||||
globals.SavedCollections = $scope.SavedCollections;
|
||||
};
|
||||
|
||||
$scope.addSavedCollection = function(newValue) {
|
||||
}
|
||||
$scope.addSavedCollection = function (newValue) {
|
||||
if ($scope.SavedCollections.indexOf(newValue) == -1) {
|
||||
$scope.SavedCollections.push(newValue);
|
||||
$scope.writeSavedCollection();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.deleteSavedCollection = function(index) {
|
||||
}
|
||||
$scope.deleteSavedCollection = function (index) {
|
||||
$scope.SavedCollections.splice(index, 1);
|
||||
$scope.writeSavedCollection();
|
||||
};
|
||||
|
||||
$scope.selectedCollection = null;
|
||||
|
||||
$scope.$watch("selectedCollection", function(newValue, oldValue) {
|
||||
}
|
||||
$scope.selectedCollection;
|
||||
$scope.$watch("selectedCollection", function (newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
$scope.addSavedCollection(newValue);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.setupDemoCollections = function() {
|
||||
$scope.setupDemoCollections = function () {
|
||||
var demo = ["YonderMountainStringBand", "GreenskyBluegrass"];
|
||||
angular.forEach(demo, function(item, key) {
|
||||
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',
|
||||
|
@ -76,9 +71,8 @@
|
|||
'publicdate asc',
|
||||
'stars desc',
|
||||
'stars asc'
|
||||
];
|
||||
|
||||
$scope.$watch("selectedArchiveAlbumSort", function(newValue, oldValue) {
|
||||
],
|
||||
$scope.$watch("selectedArchiveAlbumSort", function (newValue, oldValue) {
|
||||
if (utils.getValue('AlbumSort') != newValue) {
|
||||
if (typeof newValue != 'undefined') {
|
||||
utils.setValue('AlbumSort', newValue, true);
|
||||
|
@ -89,37 +83,40 @@
|
|||
$scope.getAlbums('');
|
||||
}
|
||||
});
|
||||
|
||||
$scope.getYears = function(startYear) {
|
||||
var currentYear = new Date().getFullYear(),
|
||||
years = [];
|
||||
$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.Years = $scope.getYears(),
|
||||
$scope.filter = {
|
||||
Year: "",
|
||||
Source: "",
|
||||
Description: ""
|
||||
};
|
||||
|
||||
$scope.filterSave = function() {
|
||||
$scope.filterSave = function () {
|
||||
if ($scope.selectedArtist) {
|
||||
$scope.getAlbums('', '');
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
/* End Filter */
|
||||
|
||||
$scope.getAlbums = function(name, identifier) {
|
||||
/*
|
||||
$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 !== '') {
|
||||
if (name != '') {
|
||||
$scope.selectedArtist = name;
|
||||
url += 'collection:(' + name + ') AND format:(MP3)';
|
||||
} else if ($scope.selectedArtist) {
|
||||
|
@ -127,18 +124,13 @@
|
|||
} else {
|
||||
url += 'identifier:(' + identifier + ')';
|
||||
}
|
||||
|
||||
var map = function(data) {
|
||||
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;
|
||||
}
|
||||
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 />';
|
||||
|
@ -146,41 +138,36 @@
|
|||
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) {
|
||||
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 = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$scope.album.push(map(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -189,42 +176,24 @@
|
|||
notifications.updateMessage("Sorry :(", true);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
alert('Archive.org service down :(');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
utils.mapSong = function(key, song, server, dir, identifier, coverart) {
|
||||
utils.mapSong = function (key, song, server, dir, identifier, coverart) {
|
||||
var url, time, track, title, rating, starred, contenttype, suffix;
|
||||
var specs = '';
|
||||
var specs = ''
|
||||
if (song.format == 'VBR MP3') {
|
||||
url = 'http://' + server + dir + key;
|
||||
if (typeof song.bitrate == 'undefined' || typeof song.format == 'undefined') {
|
||||
specs = ' ';
|
||||
} else {
|
||||
specs = song.bitrate + 'kbps, ' + song.format.toLowerCase();
|
||||
}
|
||||
if (typeof song.track == 'undefined') {
|
||||
track = ' ';
|
||||
} else {
|
||||
track = song.track;
|
||||
}
|
||||
if (typeof song.title == 'undefined') {
|
||||
title = ' ';
|
||||
} else {
|
||||
title = song.title;
|
||||
}
|
||||
if (typeof song.length == 'undefined') {
|
||||
time = ' ';
|
||||
} else {
|
||||
time = utils.timeToSeconds(song.length);
|
||||
}
|
||||
if (typeof song.bitrate == 'undefined' || typeof song.format == 'undefined') { specs = ' '; } else { specs = song.bitrate + 'kbps, ' + song.format.toLowerCase(); }
|
||||
if (typeof song.track == 'undefined') { track = ' '; } else { track = song.track; }
|
||||
if (typeof song.title == 'undefined') { title = ' '; } else { title = song.title; }
|
||||
if (typeof song.length == 'undefined') { time = ' '; } 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.getSongs = function (id, action) {
|
||||
$scope.selectedAlbum = id;
|
||||
var url = $scope.archiveUrl + 'details/' + id + '?output=json';
|
||||
$.ajax({
|
||||
|
@ -232,7 +201,7 @@
|
|||
method: 'GET',
|
||||
dataType: $scope.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
var coverart = '';
|
||||
var server = data.server;
|
||||
var dir = data.dir;
|
||||
|
@ -242,7 +211,7 @@
|
|||
}
|
||||
var items = data.files;
|
||||
if (action == 'add') {
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
var song = utils.mapSong(key, item, server, dir, identifier, coverart);
|
||||
if (song) {
|
||||
$rootScope.queue.push(song);
|
||||
|
@ -253,14 +222,14 @@
|
|||
$scope.$apply();
|
||||
} else if (action == 'play') {
|
||||
$rootScope.queue = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
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() {
|
||||
$scope.$apply(function () {
|
||||
$rootScope.playSong(false, next);
|
||||
});
|
||||
$rootScope.showQueue();
|
||||
|
@ -268,7 +237,7 @@
|
|||
} else {
|
||||
$scope.album = [];
|
||||
$rootScope.song = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
var song = utils.mapSong(key, item, server, dir, identifier, coverart);
|
||||
if (song) {
|
||||
$rootScope.song.push(song);
|
||||
|
@ -279,35 +248,31 @@
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addSongsToQueue = function() {
|
||||
$scope.addSongsToQueue = function () {
|
||||
if ($scope.selectedSongs.length > 0) {
|
||||
angular.forEach($scope.selectedSongs, function(item, key) {
|
||||
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() {
|
||||
}
|
||||
$scope.scrollToTop = function () {
|
||||
$('#Artists').stop().scrollTo('#auto', 400);
|
||||
};
|
||||
|
||||
$scope.selectAll = function() {
|
||||
angular.forEach($rootScope.song, function(item, key) {
|
||||
}
|
||||
$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.selectNone = function () {
|
||||
angular.forEach($rootScope.song, function (item, key) {
|
||||
$scope.selectedSongs = [];
|
||||
item.selected = false;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/* Launch on Startup */
|
||||
if ($routeParams.artist) {
|
||||
|
@ -320,4 +285,4 @@
|
|||
$scope.addSavedCollection($routeParams.artist);
|
||||
}
|
||||
/* End Startup */
|
||||
});
|
||||
});
|
|
@ -1,5 +1,6 @@
|
|||
JamStash.controller('SubsonicCtrl',
|
||||
function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, utils, globals, model, notifications, player) {
|
||||
function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, utils, globals, model, notifications, player) {
|
||||
//$("#SubsonicAlbums").layout($scope.layoutThreeCol);
|
||||
|
||||
$rootScope.song = [];
|
||||
//$scope.artistId = $routeParams.artistId;
|
||||
|
@ -11,79 +12,59 @@
|
|||
$scope.album = [];
|
||||
$scope.Server = globals.settings.Server;
|
||||
$scope.playlistMenu = [];
|
||||
$scope.AutoAlbums = [{
|
||||
id: "random",
|
||||
name: "Random"
|
||||
}, {
|
||||
id: "newest",
|
||||
name: "Recently Added"
|
||||
}, {
|
||||
id: "starred",
|
||||
name: "Starred"
|
||||
}, {
|
||||
id: "highest",
|
||||
name: "Top Rated"
|
||||
}, {
|
||||
id: "frequent",
|
||||
name: "Most Played"
|
||||
}, {
|
||||
id: "recent",
|
||||
name: "Recently Played"
|
||||
}];
|
||||
|
||||
$scope.selectedAutoAlbum = null;
|
||||
$scope.selectedArtist = null;
|
||||
$scope.selectedAlbum = null;
|
||||
|
||||
$scope.AutoAlbums = [
|
||||
{ id: "random", name: "Random" },
|
||||
{ id: "newest", name: "Recently Added" },
|
||||
{ id: "starred", name: "Starred" },
|
||||
{ id: "highest", name: "Top Rated" },
|
||||
{ id: "frequent", name: "Most Played" },
|
||||
{ id: "recent", name: "Recently Played" }
|
||||
];
|
||||
$scope.selectedAutoAlbum;
|
||||
$scope.selectedArtist;
|
||||
$scope.selectedAlbum;
|
||||
$scope.SelectedAlbumSort = globals.settings.DefaultAlbumSort;
|
||||
$scope.AlbumSort = globals.AlbumSorts;
|
||||
$scope.BreadCrumbs = [];
|
||||
|
||||
$scope.$watch("SelectedAlbumSort.id", function(newValue, oldValue) {
|
||||
$scope.$watch("SelectedAlbumSort.id", function (newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
if ($rootScope.song.length > 0) {
|
||||
$scope.sortSubsonicSongs(newValue);
|
||||
} else if ($scope.album.length > 0) {
|
||||
$scope.sortSubsonicAlbums(newValue);
|
||||
|
||||
indexes = $.map(globals.AlbumSorts, function(obj, index) {
|
||||
indexes = $.map(globals.AlbumSorts, function (obj, index) {
|
||||
if (obj.id == newValue) {
|
||||
return index;
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
globals.settings.DefaultAlbumSort = globals.AlbumSorts[indexes];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.$watch("SelectedMusicFolder", function(newValue, oldValue) {
|
||||
$rootScope.$watch("SelectedMusicFolder", function (newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
utils.setValue('MusicFolders', angular.toJson(newValue), true);
|
||||
$scope.getArtists(newValue.id);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.SearchType = globals.settings.DefaultSearchType;
|
||||
$scope.SearchTypes = globals.SearchTypes;
|
||||
|
||||
$scope.rescanLibrary = function(data, event) {
|
||||
$scope.rescanLibrary = function (data, event) {
|
||||
$.ajax({
|
||||
url: globals.BaseURL() + '/getUser.view?' + globals.BaseParams() + '&username=' + globals.settings.Username,
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
if (data["subsonic-response"].user.adminRole === true) {
|
||||
success: function (data) {
|
||||
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) {
|
||||
}
|
||||
$scope.mapArtist = function (data) {
|
||||
var name = '';
|
||||
var artist = data.artist;
|
||||
var artists = [];
|
||||
|
@ -92,34 +73,23 @@
|
|||
} else {
|
||||
artists[0] = artist;
|
||||
}
|
||||
angular.forEach(artists, function(item, key) {
|
||||
if (typeof item.name !== 'undefined') {
|
||||
item.name = item.name.toString();
|
||||
}
|
||||
angular.forEach(artists, function (item, key) {
|
||||
if (typeof item.name !== 'undefined') { item.name = item.name.toString(); }
|
||||
});
|
||||
if (typeof data.name !== 'undefined') {
|
||||
name = data.name.toString();
|
||||
}
|
||||
if (typeof data.name !== 'undefined') { name = data.name.toString(); }
|
||||
return new model.Index(name, artists);
|
||||
};
|
||||
|
||||
$scope.mapIndex = function(data) {
|
||||
}
|
||||
$scope.mapIndex = function (data) {
|
||||
var name, id = '';
|
||||
if (typeof data.id !== 'undefined') {
|
||||
id = data.id;
|
||||
}
|
||||
if (typeof data.name !== 'undefined') {
|
||||
name = data.name.toString();
|
||||
}
|
||||
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) {
|
||||
}
|
||||
$scope.mapPlaylist = function (data) {
|
||||
return new model.Artist(data.id, data.name);
|
||||
};
|
||||
|
||||
$scope.getArtists = function(id) {
|
||||
var url;
|
||||
}
|
||||
$scope.getArtists = function (id) {
|
||||
var url, id;
|
||||
if (utils.getValue('MusicFolders')) {
|
||||
var folder = angular.fromJson(utils.getValue('MusicFolders'));
|
||||
id = folder.id;
|
||||
|
@ -134,17 +104,9 @@
|
|||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
done: function() {
|
||||
if (globals.settings.Debug) {
|
||||
console.log("DONE!");
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
if (globals.settings.Debug) {
|
||||
console.log("ERROR!");
|
||||
}
|
||||
},
|
||||
success: function(data) {
|
||||
done: function () { if (globals.settings.Debug) { console.log("DONE!"); } },
|
||||
error: function () { if (globals.settings.Debug) { console.log("ERROR!"); } },
|
||||
success: function (data) {
|
||||
var indexes = [];
|
||||
if (typeof data["subsonic-response"].indexes.index != 'undefined') {
|
||||
if (data["subsonic-response"].indexes.index.length > 0) {
|
||||
|
@ -165,41 +127,32 @@
|
|||
} else {
|
||||
items[0] = data["subsonic-response"].indexes.shortcut;
|
||||
}
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$scope.shortcut.push($scope.mapIndex(item));
|
||||
});
|
||||
}
|
||||
$scope.index = [];
|
||||
angular.forEach(indexes, function(item, key) {
|
||||
angular.forEach(indexes, function (item, key) {
|
||||
$scope.index.push($scope.mapArtist(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.refreshArtists = function(id) {
|
||||
$scope.refreshArtists = function (id) {
|
||||
utils.setValue('MusicFolders', null, true);
|
||||
$scope.getArtists();
|
||||
};
|
||||
|
||||
$scope.mapAlbum = function(data) {
|
||||
$scope.mapAlbum = function (data) {
|
||||
var album = data;
|
||||
var title, coverartthumb, coverartfull, starred;
|
||||
if (typeof album.coverArt != 'undefined') {
|
||||
coverartthumb = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&size=160&id=' + album.coverArt;
|
||||
coverartfull = globals.BaseURL() + '/getCoverArt.view?' + globals.BaseParams() + '&id=' + album.coverArt;
|
||||
}
|
||||
if (typeof album.starred !== 'undefined') {
|
||||
starred = true;
|
||||
} else {
|
||||
starred = false;
|
||||
}
|
||||
if (typeof album.title !== 'undefined') {
|
||||
title = album.title;
|
||||
} else {
|
||||
title = album.name;
|
||||
}
|
||||
if (typeof album.starred !== 'undefined') { starred = true; } else { starred = false; }
|
||||
if (typeof album.title !== 'undefined') { title = album.title; } else { title = album.name; }
|
||||
var type;
|
||||
if (album.isDir) {
|
||||
type = 'byfolder';
|
||||
|
@ -207,24 +160,19 @@
|
|||
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.getAlbums = function (id, name) {
|
||||
$scope.selectedAutoAlbum = null;
|
||||
$scope.selectedArtist = id;
|
||||
$scope.BreadCrumbs = [];
|
||||
$scope.BreadCrumbs.push({
|
||||
'type': 'artist',
|
||||
'id': id,
|
||||
'name': name
|
||||
});
|
||||
$scope.BreadCrumbs.push({ 'type': 'artist', 'id': id, 'name': name });
|
||||
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) {
|
||||
success: function (data) {
|
||||
var items = [];
|
||||
if (typeof data["subsonic-response"].directory.child != 'undefined') {
|
||||
if (data["subsonic-response"].directory.child.length > 0) {
|
||||
|
@ -235,7 +183,7 @@
|
|||
$scope.album = [];
|
||||
$rootScope.song = [];
|
||||
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (item.isDir) {
|
||||
$scope.album.push($scope.mapAlbum(item));
|
||||
} else {
|
||||
|
@ -252,8 +200,21 @@
|
|||
}
|
||||
});
|
||||
};
|
||||
$scope.getArtistByTag = function (id) { // Gets Artist by ID3 tag
|
||||
/*
|
||||
var map = {
|
||||
create: function (options) {
|
||||
var album = options.data;
|
||||
var coverart, starred;
|
||||
if (typeof album.coverArt != 'undefined') {
|
||||
coverart = self.settings.BaseURL() + '/getCoverArt.view?' + self.settings.BaseParams() + '&size=50&id=' + album.coverArt;
|
||||
}
|
||||
if (typeof album.starred !== 'undefined') { starred = true; } else { starred = false; }
|
||||
return new model.Album(album.id, album.parent, album.name, album.artist, coverart, album.created, starred, '', '');
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$scope.getArtistByTag = function(id) { // Gets Artist by ID3 tag
|
||||
$scope.selectedAutoAlbum = null;
|
||||
$scope.selectedArtist = id;
|
||||
var url = globals.BaseURL() + '/getArtist.view?' + globals.BaseParams() + '&id=' + id;
|
||||
|
@ -262,7 +223,7 @@
|
|||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
var items = [];
|
||||
if (typeof data["subsonic-response"].artist != 'undefined') {
|
||||
if (data["subsonic-response"].artist.album.length > 0) {
|
||||
|
@ -273,7 +234,7 @@
|
|||
$scope.album = [];
|
||||
$rootScope.song = [];
|
||||
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$scope.album.push($scope.mapAlbum(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -283,14 +244,13 @@
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getAlbumByTag = function(id) { // Gets Album by ID3 tag
|
||||
$scope.getAlbumByTag = function (id) { // Gets Album by ID3 tag
|
||||
$.ajax({
|
||||
url: globals.BaseURL() + '/getAlbum.view?' + globals.BaseParams() + '&id=' + id,
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
if (typeof data["subsonic-response"].album != 'undefined') {
|
||||
$scope.album = [];
|
||||
$rootScope.song = [];
|
||||
|
@ -303,7 +263,7 @@
|
|||
} else {
|
||||
items[0] = data["subsonic-response"].album.song;
|
||||
}
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.song.push(utils.mapSong(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -311,32 +271,28 @@
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.offset = 0;
|
||||
$scope.getAlbumListBy = function(id, offset) {
|
||||
$scope.getAlbumListBy = function (id, offset) {
|
||||
var size, url;
|
||||
$scope.selectedArtist = null;
|
||||
$scope.selectedAutoAlbum = id;
|
||||
$scope.BreadCrumbs = [];
|
||||
|
||||
if (offset == 'next') {
|
||||
$scope.offset = $scope.offset + globals.settings.AutoAlbumSize;
|
||||
} else if (offset == 'prev') {
|
||||
$scope.offset = $scope.offset - globals.settings.AutoAlbumSize;
|
||||
}
|
||||
|
||||
if ($scope.offset > 0) {
|
||||
url = globals.BaseURL() + '/getAlbumList.view?' + globals.BaseParams() + '&size=' + globals.settings.AutoAlbumSize.toString() + '&type=' + id + '&offset=' + $scope.offset;
|
||||
} else {
|
||||
url = globals.BaseURL() + '/getAlbumList.view?' + globals.BaseParams() + '&size=' + globals.settings.AutoAlbumSize.toString() + '&type=' + id;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
var items = [];
|
||||
if (typeof data["subsonic-response"].albumList.album != 'undefined') {
|
||||
if (data["subsonic-response"].albumList.album.length > 0) {
|
||||
|
@ -346,7 +302,7 @@
|
|||
}
|
||||
$scope.album = [];
|
||||
$rootScope.song = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (item.isDir) {
|
||||
$scope.album.push($scope.mapAlbum(item));
|
||||
} else {
|
||||
|
@ -363,8 +319,7 @@
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getSongs = function(id, action) {
|
||||
$scope.getSongs = function (id, action) {
|
||||
$scope.selectedAlbum = id;
|
||||
var url = globals.BaseURL() + '/getMusicDirectory.view?' + globals.BaseParams() + '&id=' + id;
|
||||
$.ajax({
|
||||
|
@ -372,7 +327,7 @@
|
|||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
var items = [];
|
||||
if (typeof data["subsonic-response"].directory.child != 'undefined') {
|
||||
if (data["subsonic-response"].directory.child.length > 0) {
|
||||
|
@ -381,7 +336,7 @@
|
|||
items[0] = data["subsonic-response"].directory.child;
|
||||
}
|
||||
if (action == 'add') {
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.queue.push(utils.mapSong(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -389,18 +344,18 @@
|
|||
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
|
||||
} else if (action == 'play') {
|
||||
$rootScope.queue = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.queue.push(utils.mapSong(item));
|
||||
});
|
||||
var next = $rootScope.queue[0];
|
||||
$scope.$apply(function() {
|
||||
$scope.$apply(function () {
|
||||
$rootScope.playSong(false, next);
|
||||
});
|
||||
$rootScope.showQueue();
|
||||
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
|
||||
} else if (action == 'preview') {
|
||||
$scope.songpreview = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (!item.isDir) {
|
||||
$rootScope.songpreview.push(utils.mapSong(item));
|
||||
}
|
||||
|
@ -410,21 +365,13 @@
|
|||
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));
|
||||
}
|
||||
|
||||
$scope.BreadCrumbs.push({
|
||||
'type': 'album',
|
||||
'id': albumId,
|
||||
'name': albumName
|
||||
});
|
||||
if ($scope.BreadCrumbs.length > 0) { $scope.BreadCrumbs.splice(1, ($scope.BreadCrumbs.length - 1)) };
|
||||
$scope.BreadCrumbs.push({ 'type': 'album', 'id': albumId, 'name': albumName });
|
||||
}
|
||||
$rootScope.song = [];
|
||||
$scope.album = [];
|
||||
var albums = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (item.isDir) {
|
||||
albums.push($scope.mapAlbum(item));
|
||||
} else {
|
||||
|
@ -445,17 +392,16 @@
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.search = function() {
|
||||
$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,
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
if (data["subsonic-response"].searchResult2 !== "") {
|
||||
var header;
|
||||
var items = [];
|
||||
|
@ -467,7 +413,7 @@
|
|||
items[0] = data["subsonic-response"].searchResult2.song;
|
||||
}
|
||||
$rootScope.song = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.song.push(utils.mapSong(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -481,7 +427,7 @@
|
|||
items[0] = data["subsonic-response"].searchResult2.album;
|
||||
}
|
||||
$scope.album = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (item.isDir) {
|
||||
$scope.album.push($scope.mapAlbum(item));
|
||||
} else {
|
||||
|
@ -498,7 +444,7 @@
|
|||
} else {
|
||||
items[0] = data["subsonic-response"].searchResult2.artist;
|
||||
}
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$scope.shortcut.push(item);
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -507,20 +453,19 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
//$('#Search').val("");
|
||||
}
|
||||
};
|
||||
|
||||
$scope.toggleAZ = function(event) {
|
||||
}
|
||||
$scope.toggleAZ = function (event) {
|
||||
$scope.toggleSubmenu('#submenu_AZIndex', '#AZIndex', 'right', 44);
|
||||
};
|
||||
|
||||
$scope.loadPlaylistsForMenu = function(data, event) {
|
||||
}
|
||||
$scope.loadPlaylistsForMenu = function (data, event) {
|
||||
$.ajax({
|
||||
url: globals.BaseURL() + '/getPlaylists.view?' + globals.BaseParams(),
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
var playlists = [];
|
||||
$scope.playlistMenu = [];
|
||||
if (typeof data["subsonic-response"].playlists.playlist != 'undefined') {
|
||||
|
@ -529,7 +474,7 @@
|
|||
} else {
|
||||
playlists[0] = data["subsonic-response"].playlists.playlist;
|
||||
}
|
||||
angular.forEach(playlists, function(item, key) {
|
||||
angular.forEach(playlists, function (item, key) {
|
||||
if (item.owner == globals.settings.Username) {
|
||||
$scope.playlistMenu.push($scope.mapPlaylist(item));
|
||||
}
|
||||
|
@ -549,12 +494,11 @@
|
|||
*/
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addToPlaylist = function(id) {
|
||||
}
|
||||
$scope.addToPlaylist = function (id) {
|
||||
var songs = [];
|
||||
if ($scope.selectedSongs.length !== 0) {
|
||||
angular.forEach($scope.selectedSongs, function(item, key) {
|
||||
angular.forEach($scope.selectedSongs, function (item, key) {
|
||||
songs.push(item.id);
|
||||
});
|
||||
var runningVersion = utils.parseVersionString(globals.settings.ApiVersion);
|
||||
|
@ -565,11 +509,8 @@
|
|||
url: globals.BaseURL() + '/updatePlaylist.view?' + globals.BaseParams(),
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
data: {
|
||||
playlistId: id,
|
||||
songIdToAdd: songs
|
||||
},
|
||||
success: function(data) {
|
||||
data: { playlistId: id, songIdToAdd: songs },
|
||||
success: function (data) {
|
||||
$scope.selectedSongs.length = 0;
|
||||
notifications.updateMessage('Playlist Updated!', true);
|
||||
},
|
||||
|
@ -577,25 +518,20 @@
|
|||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.sortDateFunction = function(a, b) {
|
||||
}
|
||||
$scope.sortDateFunction = function (a, b) {
|
||||
return a.date < b.date ? 1 : -1;
|
||||
};
|
||||
|
||||
$scope.sortArtistFunction = function(a, b) {
|
||||
$scope.sortArtistFunction = function (a, b) {
|
||||
return a.artist.toLowerCase() < b.artist.toLowerCase() ? -1 : 1;
|
||||
};
|
||||
|
||||
$scope.sortAlbumFunction = function(a, b) {
|
||||
$scope.sortAlbumFunction = function (a, b) {
|
||||
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
|
||||
};
|
||||
|
||||
$scope.sortTrackFunction = function(a, b) {
|
||||
$scope.sortTrackFunction = function (a, b) {
|
||||
return parseInt(a.track) > parseInt(b.track) ? -1 : 1;
|
||||
};
|
||||
|
||||
$scope.sortSubsonicAlbums = function(newValue) {
|
||||
$scope.sortSubsonicAlbums = function (newValue) {
|
||||
if (typeof newValue != 'undefined') {
|
||||
//alert(newValue);
|
||||
switch (newValue) {
|
||||
|
@ -611,8 +547,7 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.sortSubsonicSongs = function(newValue) {
|
||||
$scope.sortSubsonicSongs = function (newValue) {
|
||||
if (typeof newValue != 'undefined') {
|
||||
//alert(newValue);
|
||||
switch (newValue) {
|
||||
|
@ -640,4 +575,4 @@
|
|||
$scope.getAlbums($routeParams.artistId);
|
||||
}
|
||||
/* End Startup */
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,60 +1,53 @@
|
|||
JamStash.controller('AppCtrl',
|
||||
function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils, globals, model, notifications, player) {
|
||||
function AppCtrl($scope, $rootScope, $document, $location, $cookieStore, utils, globals, model, notifications, player) {
|
||||
$rootScope.settings = globals.settings;
|
||||
$rootScope.song = [];
|
||||
$rootScope.queue = [];
|
||||
$rootScope.playingSong = null;
|
||||
$rootScope.playingSong;
|
||||
$rootScope.MusicFolders = [];
|
||||
$rootScope.Genres = [];
|
||||
$rootScope.selectedPlaylist = "";
|
||||
$rootScope.selectedAutoPlaylist = "";
|
||||
$rootScope.SelectedMusicFolder = "";
|
||||
$rootScope.unity = null;
|
||||
|
||||
$rootScope.loggedIn = function() {
|
||||
if (globals.settings.Server !== '' && globals.settings.Username !== '' && globals.settings.Password !== '') {
|
||||
$rootScope.unity;
|
||||
$rootScope.loggedIn = function () {
|
||||
if (globals.settings.Server != '' && globals.settings.Username != '' && globals.settings.Password != '') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
$rootScope.totalDisplayed = 50;
|
||||
|
||||
$rootScope.loadMore = function() {
|
||||
$rootScope.loadMore = function () {
|
||||
$scope.totalDisplayed += 50;
|
||||
};
|
||||
/*
|
||||
$scope.playSong = function (loadonly, data) {
|
||||
$scope.$apply(function () {
|
||||
$rootScope.playSong(loadonly, data);
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
// Reads cookies and sets globals.settings values
|
||||
$scope.loadSettings = function() {
|
||||
$scope.loadSettings = function () {
|
||||
// Temporary Code to Convert Cookies added 2/2/2014
|
||||
if ($cookieStore.get('Settings')) {
|
||||
utils.setValue('Settings', $cookieStore.get('Settings'), false);
|
||||
$cookieStore.remove('Settings');
|
||||
}
|
||||
if (utils.getValue('Settings')) {
|
||||
$.each(utils.getValue('Settings'), function(k, v) {
|
||||
if (v == 'false') {
|
||||
v = false;
|
||||
}
|
||||
if (v == 'true') {
|
||||
v = true;
|
||||
}
|
||||
$.each(utils.getValue('Settings'), function (k, v) {
|
||||
if (v == 'false') { v = false; }
|
||||
if (v == 'true') { v = true; }
|
||||
globals.settings[k] = v;
|
||||
});
|
||||
}
|
||||
if (utils.getValue("SavedCollections")) {
|
||||
globals.SavedCollections = utils.getValue("SavedCollections").split(",");
|
||||
if (utils.getValue("SavedCollections")) { globals.SavedCollections = utils.getValue("SavedCollections").split(","); }
|
||||
if (utils.getValue("SavedGenres")) { globals.SavedGenres = utils.getValue("SavedGenres").split(","); }
|
||||
if (globals.settings.Debug) { console.log('Settings: ' + JSON.stringify(globals.settings, null, 2)); }
|
||||
}
|
||||
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) {
|
||||
$scope.toggleSetting = function (setting) {
|
||||
var id = setting;
|
||||
if (globals.settings[id]) {
|
||||
globals.settings[id] = false;
|
||||
|
@ -62,23 +55,24 @@
|
|||
globals.settings[id] = true;
|
||||
}
|
||||
notifications.updateMessage(setting + ' : ' + globals.settings[id], true);
|
||||
};
|
||||
}
|
||||
|
||||
$.ajaxSetup({
|
||||
'beforeSend': function() {
|
||||
'beforeSend': function () {
|
||||
$("#loading").show();
|
||||
},
|
||||
'complete': function() {
|
||||
'complete': function () {
|
||||
$("#loading").hide();
|
||||
}
|
||||
});
|
||||
|
||||
$(".coverartfancy").on("click", "a", function() {
|
||||
|
||||
$(".coverartfancy").on("click", "a", function () {
|
||||
$("a.coverartfancy").fancybox({
|
||||
beforeShow: function() {
|
||||
beforeShow: function () {
|
||||
//this.title = $('#songdetails_artist').html();
|
||||
},
|
||||
afterLoad: function() {
|
||||
afterLoad: function () {
|
||||
//this.inner.prepend( '<h1>1. My custom title</h1>' );
|
||||
//this.content = '<h1>2. My custom title</h1>';
|
||||
},
|
||||
|
@ -90,17 +84,15 @@
|
|||
});
|
||||
|
||||
var submenu_active = false;
|
||||
$('div.submenu').mouseenter(function() {
|
||||
$('div.submenu').mouseenter(function () {
|
||||
submenu_active = true;
|
||||
});
|
||||
|
||||
$('div.submenu').mouseleave(function() {
|
||||
$('div.submenu').mouseleave(function () {
|
||||
submenu_active = false;
|
||||
$('div.submenu').hide();
|
||||
//setTimeout(function () { if (submenu_active == false) $('div.submenu').stop().fadeOut(); }, 400);
|
||||
});
|
||||
|
||||
$scope.toggleSubmenu = function(menu, pl, pos, margin) {
|
||||
$scope.toggleSubmenu = function (menu, pl, pos, margin) {
|
||||
var submenu = $(menu);
|
||||
if (submenu.css('display') !== 'none') {
|
||||
submenu.fadeOut();
|
||||
|
@ -112,53 +104,39 @@
|
|||
switch (pos) {
|
||||
case 'right':
|
||||
//show the menu to the right of placeholder
|
||||
submenu.css({
|
||||
"left": (off.left + margin) + "px",
|
||||
"top": (off.top) + "px"
|
||||
}).fadeIn(400);
|
||||
submenu.css({ "left": (off.left + margin) + "px", "top": (off.top) + "px" }).fadeIn(400);
|
||||
break;
|
||||
case 'left':
|
||||
//show the menu to the right of placeholder
|
||||
submenu.css({
|
||||
"left": (off.left - margin) + "px",
|
||||
"top": (off.top) + "px"
|
||||
}).fadeIn(400);
|
||||
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() {
|
||||
}
|
||||
$rootScope.showQueue = function () {
|
||||
var submenu = $('#QueuePreview');
|
||||
submenu.fadeIn(400);
|
||||
var timeout = globals.settings.Timeout;
|
||||
setTimeout(function() {
|
||||
submenu.fadeOut();
|
||||
}, timeout);
|
||||
};
|
||||
|
||||
$rootScope.hideQueue = function() {
|
||||
setTimeout(function () { submenu.fadeOut(); }, timeout);
|
||||
}
|
||||
$rootScope.hideQueue = function () {
|
||||
var submenu = $('#QueuePreview');
|
||||
submenu.fadeOut();
|
||||
};
|
||||
|
||||
$scope.toggleQueue = function() {
|
||||
}
|
||||
$scope.toggleQueue = function () {
|
||||
var submenu = $('#QueuePreview');
|
||||
if (submenu.css('display') == 'none') {
|
||||
$rootScope.showQueue();
|
||||
} else {
|
||||
$rootScope.hideQueue();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
$("a.coverartfancy").fancybox({
|
||||
beforeShow: function() {
|
||||
beforeShow: function () {
|
||||
//this.title = $('#songdetails_artist').html();
|
||||
},
|
||||
afterLoad: function() {
|
||||
afterLoad: function () {
|
||||
//this.inner.prepend( '<h1>1. My custom title</h1>' );
|
||||
//this.content = '<h1>2. My custom title</h1>';
|
||||
},
|
||||
|
@ -173,20 +151,14 @@
|
|||
closeEffect: 'none'
|
||||
});
|
||||
|
||||
$('#audiocontainer .scrubber').mouseover(function(e) {
|
||||
$('.audiojs .scrubber').stop().animate({
|
||||
height: '8px'
|
||||
});
|
||||
});
|
||||
$('#audiocontainer .scrubber').mouseout(function(e) {
|
||||
$('.audiojs .scrubber').stop().animate({
|
||||
height: '4px'
|
||||
$('#audiocontainer .scrubber').mouseover(function (e) {
|
||||
$('.audiojs .scrubber').stop().animate({ height: '8px' });
|
||||
});
|
||||
$('#audiocontainer .scrubber').mouseout(function (e) {
|
||||
$('.audiojs .scrubber').stop().animate({ height: '4px' });
|
||||
});
|
||||
|
||||
$('.message').on('click', function() {
|
||||
$(this).remove();
|
||||
});
|
||||
$('.message').on('click', function () { $(this).remove(); });
|
||||
|
||||
// Sway.fm Unity Plugin
|
||||
$rootScope.unity = UnityMusicShim();
|
||||
|
@ -195,60 +167,68 @@
|
|||
next: true,
|
||||
previous: true
|
||||
});
|
||||
|
||||
$rootScope.unity.setCallbackObject({
|
||||
pause: function() {
|
||||
if (globals.settings.Debug) {
|
||||
console.log("Unity: Recieved playpause command");
|
||||
}
|
||||
pause: function () {
|
||||
if (globals.settings.Debug) { console.log("Unity: Recieved playpause command"); }
|
||||
player.playPauseSong();
|
||||
},
|
||||
next: function() {
|
||||
if (globals.settings.Debug) {
|
||||
console.log("Unity: Recieved next command");
|
||||
}
|
||||
next: function () {
|
||||
if (globals.settings.Debug) { console.log("Unity: Recieved next command"); }
|
||||
$rootScope.nextTrack();
|
||||
},
|
||||
previous: function() {
|
||||
if (globals.settings.Debug) {
|
||||
console.log("Unity: Recieved previous command");
|
||||
}
|
||||
previous: function () {
|
||||
if (globals.settings.Debug) { console.log("Unity: Recieved previous command"); }
|
||||
$rootScope.previousTrack();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// JQuery UI Sortable - Drag and drop sorting
|
||||
/*
|
||||
var fixHelper = function (e, ui) {
|
||||
ui.children().each(function () {
|
||||
$(this).width($(this).width());
|
||||
});
|
||||
return ui;
|
||||
};
|
||||
$("#QueuePreview ul.songlist").sortable({
|
||||
helper: fixHelper
|
||||
});
|
||||
*/
|
||||
/* JQuery Layout Plugin - I don't think this is used anywhere
|
||||
function resizePageLayout() {
|
||||
var pageLayout = $("body").data("layout");
|
||||
if (pageLayout) pageLayout.resizeAll();
|
||||
};
|
||||
*/
|
||||
|
||||
// Global Functions
|
||||
window.onbeforeunload = function() {
|
||||
window.onbeforeunload = function () {
|
||||
if (!globals.settings.Debug) {
|
||||
if ($rootScope.queue.length > 0) {
|
||||
return "You're about to end your session, are you sure?";
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$scope.dragStart = function(e, ui) {
|
||||
$scope.dragStart = function (e, ui) {
|
||||
ui.item.data('start', ui.item.index());
|
||||
};
|
||||
|
||||
$scope.dragEnd = function(e, ui) {
|
||||
}
|
||||
$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) {
|
||||
}
|
||||
$document.keydown(function (e) {
|
||||
$scope.scrollToIndex(e);
|
||||
});
|
||||
|
||||
$scope.scrollToIndex = function(e) {
|
||||
$scope.scrollToIndex = function (e) {
|
||||
var source = e.target.id;
|
||||
if (source != 'Search' && source != 'Source' && source != 'Description' && source != 'ChatMsg' && source != 'AutoPlaylists') {
|
||||
var unicode = e.charCode ? e.charCode : e.keyCode;
|
||||
if (globals.settings.Debug) {
|
||||
console.log('Keycode Triggered: ' + unicode);
|
||||
}
|
||||
if (globals.settings.Debug) { console.log('Keycode Triggered: ' + unicode); }
|
||||
/*
|
||||
if (unicode == 49) {
|
||||
utils.changeTab('tabQueue');
|
||||
|
@ -283,13 +263,10 @@
|
|||
} else if (unicode == 36 && $('#tabLibrary').is(':visible')) { // home
|
||||
$('#left-component').stop().scrollTo('#MusicFolders', 400);
|
||||
}
|
||||
|
||||
var volume;
|
||||
|
||||
if (unicode == 189) { // dash - volume down
|
||||
volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
|
||||
if (volume <= 1 && volume > 0 && source === '') {
|
||||
volume += -0.1;
|
||||
var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
|
||||
if (volume <= 1 && volume > 0 && source == '') {
|
||||
volume += -.1;
|
||||
$(player1).jPlayer({
|
||||
volume: volume
|
||||
});
|
||||
|
@ -297,11 +274,10 @@
|
|||
//updateMessage('Volume: ' + Math.round(volume * 100) + '%');
|
||||
}
|
||||
}
|
||||
|
||||
if (unicode == 187) { // equals - volume up
|
||||
volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
|
||||
if (volume < 1 && volume >= 0 && source === '') {
|
||||
volume += 0.1;
|
||||
var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
|
||||
if (volume < 1 && volume >= 0 && source == '') {
|
||||
volume += .1;
|
||||
$(player1).jPlayer({
|
||||
volume: volume
|
||||
});
|
||||
|
@ -312,43 +288,37 @@
|
|||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
$scope.scrollToIndexName = function(index) {
|
||||
$scope.scrollToIndexName = function (index) {
|
||||
var el = '#' + index;
|
||||
if ($(el).length > 0) {
|
||||
$('#left-component').stop().scrollTo(el, 400);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.scrollToTop = function() {
|
||||
$scope.scrollToTop = function () {
|
||||
$('#Artists').stop().scrollTo('#auto', 400);
|
||||
};
|
||||
|
||||
$scope.selectAll = function() {
|
||||
angular.forEach($rootScope.song, function(item, key) {
|
||||
}
|
||||
$scope.selectAll = function () {
|
||||
angular.forEach($rootScope.song, function (item, key) {
|
||||
$scope.selectedSongs.push(item);
|
||||
item.selected = true;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.playAll = function() {
|
||||
}
|
||||
$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.selectNone = function () {
|
||||
angular.forEach($rootScope.song, function (item, key) {
|
||||
$scope.selectedSongs = [];
|
||||
item.selected = false;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addSongsToQueue = function() {
|
||||
}
|
||||
$scope.addSongsToQueue = function () {
|
||||
if ($scope.selectedSongs.length !== 0) {
|
||||
angular.forEach($scope.selectedSongs, function(item, key) {
|
||||
angular.forEach($scope.selectedSongs, function (item, key) {
|
||||
$scope.queue.push(item);
|
||||
item.selected = false;
|
||||
});
|
||||
|
@ -356,19 +326,17 @@
|
|||
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
|
||||
$scope.selectedSongs.length = 0;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.isActive = function(route) {
|
||||
}
|
||||
$scope.isActive = function (route) {
|
||||
return route === $location.path();
|
||||
};
|
||||
|
||||
$scope.getMusicFolders = function() {
|
||||
$scope.getMusicFolders = function () {
|
||||
$.ajax({
|
||||
url: globals.BaseURL() + '/getMusicFolders.view?' + globals.BaseParams(),
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
if (data["subsonic-response"].musicFolders.musicFolder !== undefined) {
|
||||
var folders = [];
|
||||
if (data["subsonic-response"].musicFolders.musicFolder.length > 0) {
|
||||
|
@ -380,9 +348,8 @@
|
|||
$rootScope.MusicFolders = folders;
|
||||
if (utils.getValue('MusicFolders')) {
|
||||
var folder = angular.fromJson(utils.getValue('MusicFolders'));
|
||||
var i = 0,
|
||||
index = "";
|
||||
angular.forEach($rootScope.MusicFolders, function(item, key) {
|
||||
var i = 0, index = "";
|
||||
angular.forEach($rootScope.MusicFolders, function (item, key) {
|
||||
if (item.id == folder.id) {
|
||||
index = i;
|
||||
}
|
||||
|
@ -394,25 +361,43 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getGenres = function() {
|
||||
}
|
||||
$scope.getGenres = function () {
|
||||
var genres = 'Acid Rock,Acoustic,Alt Country,Alt/Indie,Alternative & Punk,Alternative Metal,Alternative,AlternRock,Awesome,Bluegrass,Blues,Blues-Rock,Classic Hard Rock,Classic Rock,Comedy,Country,Country-Rock,Dance,Dance-Rock,Deep Funk,Easy Listening,Electronic,Electronica,Electronica/Dance,Folk,Folk/Rock,Funk,Grunge,Hard Rock,Heavy Metal,Holiday,House,Improg,Indie Rock,Indie,International,Irish,Jam Band,Jam,Jazz Fusion,Jazz,Latin,Live Albums,Metal,Music,Oldies,Other,Pop,Pop/Rock,Post Rock,Progressive Rock,Psychedelic Rock,Psychedelic,Punk,R&B,Rap & Hip-Hop,Reggae,Rock & Roll,Rock,Rock/Pop,Roots,Ska,Soft Rock,Soul,Southern Rock,Thrash Metal,Unknown,Vocal,World';
|
||||
$rootScope.Genres = genres.split(',');
|
||||
// TODO: fix this
|
||||
};
|
||||
/* This is broken in version 4.8, unable to convert XML to JSON
|
||||
$.ajax({
|
||||
url: globals.BaseURL() + '/getGenres.view?' + globals.BaseParams(),
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function (data) {
|
||||
if (typeof data["subsonic-response"].genres != 'undefined') {
|
||||
var items = [];
|
||||
if (data["subsonic-response"].genres.length > 0) {
|
||||
items = data["subsonic-response"].genres;
|
||||
} else {
|
||||
items[0] = data["subsonic-response"].genres;
|
||||
}
|
||||
|
||||
$scope.download = function(id) {
|
||||
$rootScope.Genres = items;
|
||||
$scope.$apply();
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
$scope.download = function (id) {
|
||||
$.ajax({
|
||||
url: globals.BaseURL() + '/getUser.view?' + globals.BaseParams() + '&username=' + globals.settings.Username,
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
if (typeof data["subsonic-response"].error != 'undefined') {
|
||||
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);
|
||||
|
@ -420,15 +405,14 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.ping = function() {
|
||||
}
|
||||
$scope.ping = function () {
|
||||
$.ajax({
|
||||
url: globals.BaseURL() + '/ping.view?' + globals.BaseParams(),
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
if (data["subsonic-response"].status == 'ok') {
|
||||
globals.settings.ApiVersion = data["subsonic-response"].version;
|
||||
} else {
|
||||
|
@ -437,33 +421,29 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
error: function () {
|
||||
notifications.updateMessage('Unable to connect to Subsonic server');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addSongToQueue = function(data) {
|
||||
}
|
||||
$scope.addSongToQueue = function (data) {
|
||||
$rootScope.queue.push(data);
|
||||
};
|
||||
|
||||
$scope.queueRemoveSelected = function(data, event) {
|
||||
angular.forEach($scope.selectedSongs, function(item, key) {
|
||||
}
|
||||
$scope.queueRemoveSelected = function (data, event) {
|
||||
angular.forEach($scope.selectedSongs, function (item, key) {
|
||||
var index = $rootScope.queue.indexOf(item);
|
||||
if (index > -1) {
|
||||
$rootScope.queue.splice(index, 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.queueEmpty = function() {
|
||||
}
|
||||
$scope.queueEmpty = function () {
|
||||
//self.selectedSongs([]);
|
||||
$rootScope.queue = [];
|
||||
};
|
||||
|
||||
$scope.queueTotal = function() {
|
||||
}
|
||||
$scope.queueTotal = function () {
|
||||
var total = 0;
|
||||
ko.utils.arrayForEach(self.queue(), function(item) {
|
||||
ko.utils.arrayForEach(self.queue(), function (item) {
|
||||
total += parseInt(item.duration());
|
||||
});
|
||||
if (self.queue().length > 0) {
|
||||
|
@ -471,16 +451,12 @@
|
|||
} else {
|
||||
return '0 song(s), 00:00:00 total time';
|
||||
}
|
||||
};
|
||||
|
||||
$scope.queueShuffle = function() {
|
||||
$rootScope.queue.sort(function() {
|
||||
return 0.5 - Math.random();
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
$scope.queueShuffle = function () {
|
||||
$rootScope.queue.sort(function () { return 0.5 - Math.random() });
|
||||
}
|
||||
$scope.selectedSongs = [];
|
||||
$scope.selectSong = function(data) {
|
||||
$scope.selectSong = function (data) {
|
||||
var i = $scope.selectedSongs.indexOf(data);
|
||||
if (i >= 0) {
|
||||
$scope.selectedSongs.splice(i, 1);
|
||||
|
@ -490,44 +466,36 @@
|
|||
data.selected = true;
|
||||
}
|
||||
//$scope.$apply();
|
||||
};
|
||||
|
||||
$rootScope.getRandomSongs = function(action, genre, folder) {
|
||||
if (globals.settings.Debug) {
|
||||
console.log('action:' + action + ', genre:' + genre + ', folder:' + folder);
|
||||
}
|
||||
$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') {
|
||||
//alert($rootScope.SelectedMusicFolder.id);
|
||||
folderParams = '&musicFolderId=' + $rootScope.SelectedMusicFolder.id;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: globals.BaseURL() + '/getRandomSongs.view?' + globals.BaseParams() + '&size=' + size + genreParams + folderParams,
|
||||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
if (typeof data["subsonic-response"].randomSongs.song != 'undefined') {
|
||||
var items = [];
|
||||
if (data["subsonic-response"].randomSongs.song.length > 0) {
|
||||
|
@ -536,7 +504,7 @@
|
|||
items[0] = data["subsonic-response"].randomSongs.song;
|
||||
}
|
||||
if (action == 'add') {
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.queue.push(utils.mapSong(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -544,18 +512,18 @@
|
|||
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
|
||||
} else if (action == 'play') {
|
||||
$rootScope.queue = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.queue.push(utils.mapSong(item));
|
||||
});
|
||||
var next = $rootScope.queue[0];
|
||||
$scope.$apply(function() {
|
||||
$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) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.song.push(utils.mapSong(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -563,9 +531,8 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateFavorite = function(item) {
|
||||
}
|
||||
$scope.updateFavorite = function (item) {
|
||||
var id = item.id;
|
||||
var starred = item.starred;
|
||||
var url;
|
||||
|
@ -581,15 +548,14 @@
|
|||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function() {
|
||||
success: function () {
|
||||
notifications.updateMessage('Favorite Updated!', true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.toTrusted = function(html) {
|
||||
}
|
||||
$scope.toTrusted = function (html) {
|
||||
return $sce.trustAsHtml(html);
|
||||
};
|
||||
}
|
||||
|
||||
/* Launch on Startup */
|
||||
$scope.loadSettings();
|
||||
|
@ -603,4 +569,4 @@
|
|||
}
|
||||
}
|
||||
/* End Startup */
|
||||
});
|
||||
});
|
|
@ -1,31 +1,28 @@
|
|||
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) {
|
||||
$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");
|
||||
}
|
||||
$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) {
|
||||
success: function (data) {
|
||||
if (data["subsonic-response"].playlists.playlist !== undefined) {
|
||||
var items = [];
|
||||
if (data["subsonic-response"].playlists.playlist.length > 0) {
|
||||
|
@ -33,7 +30,7 @@
|
|||
} else {
|
||||
items[0] = data["subsonic-response"].playlists.playlist;
|
||||
}
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (item.owner == globals.settings.Username) {
|
||||
$scope.playlists.push(item);
|
||||
} else if (item.public) {
|
||||
|
@ -44,9 +41,8 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getPlaylist = function(id, action) {
|
||||
}
|
||||
$scope.getPlaylist = function (id, action) {
|
||||
$rootScope.selectedAutoPlaylist = null;
|
||||
$rootScope.selectedPlaylist = id;
|
||||
$.ajax({
|
||||
|
@ -54,7 +50,7 @@
|
|||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
if (typeof data["subsonic-response"].playlist.entry != 'undefined') {
|
||||
var items = [];
|
||||
var playlist = data["subsonic-response"].playlist;
|
||||
|
@ -64,7 +60,7 @@
|
|||
items[0] = playlist.entry;
|
||||
}
|
||||
if (action == 'add') {
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.queue.push(utils.mapSong(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -72,11 +68,11 @@
|
|||
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
|
||||
} else if (action == 'play') {
|
||||
$rootScope.queue = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.queue.push(utils.mapSong(item));
|
||||
});
|
||||
var next = $rootScope.queue[0];
|
||||
$scope.$apply(function() {
|
||||
$scope.$apply(function () {
|
||||
$rootScope.playSong(false, next);
|
||||
});
|
||||
$rootScope.showQueue();
|
||||
|
@ -84,7 +80,7 @@
|
|||
} else {
|
||||
$scope.album = [];
|
||||
$rootScope.song = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.song.push(utils.mapSong(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -94,9 +90,8 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getStarred = function(action, type) {
|
||||
}
|
||||
$scope.getStarred = function (action, type) {
|
||||
var size = globals.settings.AutoPlaylistSize;
|
||||
$rootScope.selectedPlaylist = null;
|
||||
$rootScope.selectedAutoPlaylist = 'starred';
|
||||
|
@ -105,7 +100,7 @@
|
|||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
if (typeof data["subsonic-response"].starred !== 'undefined') {
|
||||
var items = [];
|
||||
switch (type) {
|
||||
|
@ -135,7 +130,7 @@
|
|||
items[0] = data["subsonic-response"].starred.song;
|
||||
}
|
||||
if (action == 'add') {
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.queue.push(utils.mapSong(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -143,18 +138,18 @@
|
|||
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
|
||||
} else if (action == 'play') {
|
||||
$rootScope.queue = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.queue.push(utils.mapSong(item));
|
||||
});
|
||||
var next = $rootScope.queue[0];
|
||||
$scope.$apply(function() {
|
||||
$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) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
$rootScope.song.push(utils.mapSong(item));
|
||||
});
|
||||
$scope.$apply();
|
||||
|
@ -167,25 +162,23 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.newPlaylist = function(data, event) {
|
||||
}
|
||||
$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',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
loadPlaylists(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.deletePlaylist = function() {
|
||||
if ($rootScope.selectedPlaylist !== null) {
|
||||
}
|
||||
$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({
|
||||
|
@ -193,19 +186,18 @@
|
|||
method: 'GET',
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
$scope.getPlaylists();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.savePlaylist = function() {
|
||||
if ($rootScope.selectedPlaylist() !== null) {
|
||||
}
|
||||
$scope.savePlaylist = function () {
|
||||
if ($rootScope.selectedPlaylist() != null) {
|
||||
var id = $rootScope.selectedPlaylist().id();
|
||||
var songs = [];
|
||||
ko.utils.arrayForEach($rootScope.song(), function(item) {
|
||||
ko.utils.arrayForEach($rootScope.song(), function (item) {
|
||||
songs.push(item.id);
|
||||
});
|
||||
if (songs.length > 0) {
|
||||
|
@ -214,11 +206,8 @@
|
|||
url: globals.BaseURL() + '/createPlaylist.view?' + globals.BaseParams(),
|
||||
dataType: globals.settings.Protocol,
|
||||
timeout: globals.settings.Timeout,
|
||||
data: {
|
||||
playlistId: id,
|
||||
songId: songs
|
||||
},
|
||||
success: function() {
|
||||
data: { playlistId: id, songId: songs },
|
||||
success: function () {
|
||||
$scope.getPlaylist(id);
|
||||
notifications.updateMessage('Playlist Updated!', true);
|
||||
},
|
||||
|
@ -226,14 +215,12 @@
|
|||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.removeSelectedSongs = function(data, event) {
|
||||
ko.utils.arrayForEach($scope.selectedSongs(), function(item) {
|
||||
}
|
||||
$scope.removeSelectedSongs = function (data, event) {
|
||||
ko.utils.arrayForEach($scope.selectedSongs(), function (item) {
|
||||
$rootScope.song.remove(item);
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
/* End Playlists */
|
||||
|
||||
/* Launch on Startup */
|
||||
|
@ -241,4 +228,4 @@
|
|||
//$scope.getMusicFolders();
|
||||
$scope.getGenres();
|
||||
/* End Startup */
|
||||
});
|
||||
});
|
|
@ -1,20 +1,18 @@
|
|||
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");
|
||||
}
|
||||
$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) {
|
||||
success: function (data) {
|
||||
if (data["subsonic-response"].podcasts.channel !== undefined) {
|
||||
var items = [];
|
||||
if (data["subsonic-response"].podcasts.channel.length > 0) {
|
||||
|
@ -27,62 +25,34 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getPodcast = function(id, action) {
|
||||
}
|
||||
$scope.getPodcast = function (id, action) {
|
||||
$scope.selectedPodcast = id;
|
||||
var map = function(data) {
|
||||
var map = function (data) {
|
||||
var song = data;
|
||||
var url, 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.track == 'undefined') {
|
||||
track = ' ';
|
||||
} 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';
|
||||
}
|
||||
if (typeof song.description == 'undefined') { description = ''; } else { description = song.description; }
|
||||
if (typeof song.track == 'undefined') { track = ' '; } 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) {
|
||||
success: function (data) {
|
||||
if (data["subsonic-response"].podcasts.channel !== undefined) {
|
||||
var podcasts = [];
|
||||
if (data["subsonic-response"].podcasts.channel.length > 0) {
|
||||
|
@ -91,7 +61,7 @@
|
|||
podcasts[0] = data["subsonic-response"].podcasts.channel;
|
||||
}
|
||||
var items = [];
|
||||
$.each(podcasts, function(i, item) {
|
||||
$.each(podcasts, function (i, item) {
|
||||
if (item.id == id) {
|
||||
items = item.episode;
|
||||
}
|
||||
|
@ -99,7 +69,7 @@
|
|||
|
||||
if (typeof items != 'undefined') {
|
||||
if (action == 'add') {
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (item.status != "skipped") {
|
||||
$rootScope.queue.push(map(item));
|
||||
}
|
||||
|
@ -109,13 +79,13 @@
|
|||
notifications.updateMessage(items.length + ' Song(s) Added to Queue', true);
|
||||
} else if (action == 'play') {
|
||||
$rootScope.queue = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (item.status != "skipped") {
|
||||
$rootScope.queue.push(map(item));
|
||||
}
|
||||
});
|
||||
var next = $rootScope.queue[0];
|
||||
$scope.$apply(function() {
|
||||
$scope.$apply(function () {
|
||||
$rootScope.playSong(false, next);
|
||||
});
|
||||
$rootScope.showQueue();
|
||||
|
@ -123,7 +93,7 @@
|
|||
} else {
|
||||
$scope.album = [];
|
||||
$rootScope.song = [];
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (item.status != "skipped") {
|
||||
$rootScope.song.push(map(item));
|
||||
}
|
||||
|
@ -134,9 +104,9 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/* Launch on Startup */
|
||||
$scope.getPodcasts();
|
||||
/* End Startup */
|
||||
});
|
||||
});
|
|
@ -1,8 +1,8 @@
|
|||
JamStash.controller('QueueCtrl',
|
||||
function QueueCtrl($scope, $rootScope, $routeParams, $location, utils, globals, json, notifications) {
|
||||
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;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,94 +1,71 @@
|
|||
JamStash.controller('SettingsCtrl',
|
||||
function SettingsCtrl($scope, $routeParams, $location, utils, globals, json, notifications) {
|
||||
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.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() {
|
||||
$scope.$watch('settings.HideAZ', function () {
|
||||
if (globals.settings.HideAZ) {
|
||||
$('#AZIndex').hide();
|
||||
} else {
|
||||
$('#AZIndex').show();
|
||||
}
|
||||
});
|
||||
|
||||
$scope.reset = function() {
|
||||
$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) {
|
||||
$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 (globals.settings.NotificationNowPlaying) {
|
||||
if ($scope.settings.NotificationNowPlaying) {
|
||||
notifications.requestPermissionIfRequired();
|
||||
if (!notifications.hasNotificationPermission()) {
|
||||
alert('HTML5 Notifications are not available for your current browser, Sorry :(');
|
||||
}
|
||||
}
|
||||
if (globals.settings.SaveTrackPosition) {
|
||||
//saveTrackPosition();
|
||||
if ($scope.settings.SaveTrackPosition) {
|
||||
player.saveTrackPosition();
|
||||
} else {
|
||||
//deleteCurrentPlaylist();
|
||||
player.deleteCurrentQueue();
|
||||
}
|
||||
if (globals.settings.Theme) {
|
||||
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 !== '') {
|
||||
if (globals.settings.Server != '' && globals.settings.Username != '' && globals.settings.Password != '') {
|
||||
$scope.ping();
|
||||
}
|
||||
};
|
||||
|
||||
json.getChangeLog(function(data) {
|
||||
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.changeLogShowMore = function () {
|
||||
json.getChangeLog(function (data) {
|
||||
$scope.changeLog = data;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.setupDemo = function() {
|
||||
}
|
||||
$scope.setupDemo = function () {
|
||||
var Username = "android-guest";
|
||||
var Password = "guest";
|
||||
var Server = "http://subsonic.org/demo";
|
||||
|
@ -100,8 +77,8 @@
|
|||
//$scope.save();
|
||||
$location.url('/library');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* Load on Startup */
|
||||
/* End Startup */
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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>" }
|
||||
]
|
||||
},
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
||||
<!--
|
||||
|
|
150
js/player.js
150
js/player.js
|
@ -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) {
|
||||
var song;
|
||||
if (globals.settings.Debug) {
|
||||
console.log('Getting Next Song > ' + 'Queue length: ' + $rootScope.queue.length);
|
||||
}
|
||||
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) {
|
||||
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');
|
||||
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));
|
||||
}
|
||||
$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", {
|
||||
|
@ -304,9 +276,7 @@
|
|||
// 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,
|
||||
|
@ -387,35 +352,32 @@
|
|||
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);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
355
js/service.js
355
js/service.js
|
@ -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,24 +126,17 @@ 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
|
||||
|
@ -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,17 +220,49 @@ 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,
|
||||
|
@ -272,7 +273,7 @@ JamStash.directive('fancybox', function($compile) {
|
|||
$.fancybox.open(el);
|
||||
compiled($scope);
|
||||
};
|
||||
$scope.fancyboxOpenUrl = function() {
|
||||
$scope.fancyboxOpenUrl = function () {
|
||||
var el = angular.element(element.html()),
|
||||
compiled = $compile(el);
|
||||
$.fancybox.open(el);
|
||||
|
@ -281,8 +282,7 @@ JamStash.directive('fancybox', function($compile) {
|
|||
}
|
||||
};
|
||||
});
|
||||
|
||||
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,18 +326,13 @@ 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(
|
||||
|
@ -349,7 +342,7 @@ JamStash.directive('ngDownload', function($compile) {
|
|||
'</a>'
|
||||
)(scope));
|
||||
|
||||
scope.$watch(scope.data, function() {
|
||||
scope.$watch(scope.data, function () {
|
||||
elm.children()[0].href = getUrl();
|
||||
});
|
||||
}
|
||||
|
@ -357,45 +350,47 @@ 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
|
||||
return {
|
||||
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);
|
||||
},
|
||||
getSongs: function(callback) {
|
||||
templateUrl = 'js/partials/songs.html';
|
||||
$http.get(templateUrl, {
|
||||
cache: $templateCache
|
||||
}).success(callback);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
JamStash.factory('subsonic', function($http, globals, utils) {
|
||||
JamStash.factory('template', function ($http, $compile, $http, $templateCache) { // Deferred loading
|
||||
return {
|
||||
getSongTemplate: function(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);
|
||||
},
|
||||
getSongs: function (callback) {
|
||||
templateUrl = 'js/partials/songs.html';
|
||||
$http.get(templateUrl, { cache: $templateCache }).success(callback);
|
||||
}
|
||||
}
|
||||
});
|
||||
JamStash.factory('subsonic', function ($http, globals, utils) {
|
||||
return {
|
||||
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) {
|
||||
}
|
||||
});
|
||||
*/
|
||||
$http.get(url).success(function (data) {
|
||||
var items = [];
|
||||
var song = [];
|
||||
if (typeof data["subsonic-response"].directory.child != 'undefined') {
|
||||
|
@ -404,7 +399,7 @@ JamStash.factory('subsonic', function($http, globals, utils) {
|
|||
} else {
|
||||
items[0] = data["subsonic-response"].directory.child;
|
||||
}
|
||||
angular.forEach(items, function(item, key) {
|
||||
angular.forEach(items, function (item, key) {
|
||||
if (!item.isDir) {
|
||||
song.push(utils.mapSong(item));
|
||||
}
|
||||
|
@ -413,54 +408,47 @@ JamStash.factory('subsonic', function($http, globals, utils) {
|
|||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
/* 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();
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
341
js/utils.js
341
js/utils.js
|
@ -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 = ' ';
|
||||
} else {
|
||||
title = song.title.toString();
|
||||
}
|
||||
if (typeof song.track == 'undefined') {
|
||||
track = ' ';
|
||||
} 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 = ' '; } else { title = song.title.toString(); }
|
||||
if (typeof song.track == 'undefined') { track = ' '; } 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(";&#") + ";";
|
||||
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;
|
||||
}
|
||||
});
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue