3.4.1 archive tab improvements

This commit is contained in:
Trevor Squillario 2014-05-04 13:53:35 -04:00
parent e20c780052
commit 1f8c286a13
8 changed files with 237 additions and 216 deletions

View file

@ -35,7 +35,7 @@ JamStash.service('globals', function (utils) {
Repeat: false, Repeat: false,
Debug: false Debug: false
}; };
this.SavedCollections = []; this.DefaultCollection = [];
this.SavedGenres = []; this.SavedGenres = [];
this.BaseURL = function () { return this.settings.Server + '/rest'; }; 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.BaseParams = function () { return 'u=' + this.settings.Username + '&p=' + this.settings.Password + '&f=' + this.settings.Protocol + '&v=' + this.settings.ApiVersion + '&c=' + this.settings.ApplicationName; };

View file

@ -10,15 +10,23 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.selectedAlbum = null; $scope.selectedAlbum = null;
$scope.selectedSongs = []; $scope.selectedSongs = [];
$scope.SavedCollections = globals.SavedCollections; $scope.SavedCollections = globals.SavedCollections;
$scope.AllCollections = []; $scope.AllArtists = [];
$scope.loadedCollection = false; $scope.loadedCollection = false;
/* /*
json.getCollections(function (data) { $scope.getCollections = function (query) {
$scope.AllCollections = data; json.getCollections(query).then(function (data) {
$scope.loadedCollection = true; $scope.AllCollections = data;
$scope.loadedCollection = true;
});
};
$scope.selectedCollection = globals.DefaultCollection;
$scope.$watch("selectedCollection", function (newValue, oldValue) {
if (newValue !== oldValue) {
utils.setValue('DefaultCollection', newValue, false);
globals.DefaultCollection = newValue;
}
}); });
*/ */
$scope.writeSavedCollection = function () { $scope.writeSavedCollection = function () {
utils.setValue('SavedCollections', $scope.SavedCollections.join(), false); utils.setValue('SavedCollections', $scope.SavedCollections.join(), false);
globals.SavedCollections = $scope.SavedCollections; globals.SavedCollections = $scope.SavedCollections;
@ -33,12 +41,6 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.SavedCollections.splice(index, 1); $scope.SavedCollections.splice(index, 1);
$scope.writeSavedCollection(); $scope.writeSavedCollection();
}; };
$scope.selectedCollection = null;
$scope.$watch("selectedCollection", function (newValue, oldValue) {
if (newValue !== oldValue) {
$scope.addSavedCollection(newValue);
}
});
$scope.setupDemoCollections = function () { $scope.setupDemoCollections = function () {
var demo = ["YonderMountainStringBand", "GreenskyBluegrass"]; var demo = ["YonderMountainStringBand", "GreenskyBluegrass"];
angular.forEach(demo, function (item, key) { angular.forEach(demo, function (item, key) {
@ -50,7 +52,7 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
$scope.archiveUrl = globals.archiveUrl; $scope.archiveUrl = globals.archiveUrl;
/* Filter */ /* Filter */
$scope.selectedArchiveAlbumSort = "date desc"; $scope.selectedArchiveAlbumSort = globals.settings.DefaultArchiveAlbumSort;
$scope.ArchiveAlbumSort = [ $scope.ArchiveAlbumSort = [
'addeddate desc', 'addeddate desc',
'addeddate asc', 'addeddate asc',
@ -73,10 +75,10 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
if (utils.getValue('AlbumSort') != newValue) { if (utils.getValue('AlbumSort') != newValue) {
if (typeof newValue != 'undefined') { if (typeof newValue != 'undefined') {
utils.setValue('AlbumSort', newValue, true); utils.setValue('AlbumSort', newValue, true);
globals.settings.DefaultArchiveAlbumSort = newValue;
} else { } else {
utils.setValue('AlbumSort', null, true); utils.setValue('AlbumSort', null, true);
} }
//alert(newValue);
$scope.getAlbums(''); $scope.getAlbums('');
} }
}); });
@ -101,186 +103,52 @@ function ArchiveCtrl($scope, $rootScope, $location, $routeParams, $http, utils,
}; };
/* End Filter */ /* End Filter */
$scope.getCollections = function (all) { $scope.getArtists = function (all) {
var query = $('#Collections').val(); var query = $('#Artists').val();
var collection = $('#Collections option:selected').text();
if (all || query.length >= 3) { if (all || query.length >= 3) {
archive.getCollections(query).then(function (data) { archive.getArtists(query, collection).then(function (data) {
$scope.AllCollections = data.artist; $scope.AllArtists = data.artist;
$scope.loadedCollection = true; $scope.loadedCollection = true;
}); });
} }
}; };
/* $scope.getAlbums = function (name) {
$scope.getArtists = function (data) { archive.getAlbums(name, $scope.filter).then(function (data) {
var map = function (data) { $scope.song = data.song;
return new model.Artist('', data); $scope.album = data.album;
}; $scope.selectedArtist = data.selectedArtist;
angular.forEach($scope.SavedCollections, function (item, key) {
$scope.artist.push(map(item));
});
};
*/
$scope.getAlbums = function (name, identifier) {
var url = $scope.archiveUrl + 'advancedsearch.php?q=';
if (name !== '') {
$scope.selectedArtist = name;
url += 'collection:(' + name + ') AND format:(MP3)';
} else if ($scope.selectedArtist) {
url += 'collection:(' + $scope.selectedArtist + ') AND format:(MP3)';
} else {
url += 'identifier:(' + identifier + ')';
}
var map = function (data) {
var song = data;
var coverartthumb, coverartfull, starred;
var url = $scope.archiveUrl + 'details/' + song.identifier;
coverartthumb = 'images/albumdefault_50.jpg';
coverartfull = 'images/albumdefault_160.jpg';
if (parseInt(song.avg_rating) == 5) { starred = true; } else { starred = false; }
//var description = '<b>Details</b><br />';
var description = '<b>Source</b>: ' + song.source + '<br />';
description += '<b>Date</b>: ' + song.date + '<br />';
description += typeof song.publisher != 'undefined' ? '<b>Transferer</b>: ' + song.publisher + '<br />' : '';
description += typeof song.avg_rating != 'undefined' ? '<b>Rating</b>: ' + song.avg_rating + '<br />' : '';
description += typeof song.downloads != 'undefined' ? '<b>Downloads</b>: ' + song.downloads + '<br />' : '';
return new model.Album(song.identifier, null, song.title, song.collection[0], '', coverartthumb, coverartfull, $.format.date(new Date(song.publicdate), "yyyy-MM-dd h:mm a"), starred, description, url);
};
if ($scope.filter.Source) {
url += ' AND source:(' + $scope.filter.Source + ')';
}
if ($scope.filter.Year) {
if (parseInt($scope.filter.Year)) {
url += ' AND year:(' + $scope.filter.Year + ')';
}
}
if ($scope.filter.Description) {
url += ' AND description:(' + $scope.filter.Description + ')';
}
if ($scope.selectedArchiveAlbumSort) {
url += '&sort[]=' + $scope.selectedArchiveAlbumSort;
}
url += '&fl[]=avg_rating,collection,date,description,downloads,headerImage,identifier,publisher,publicdate,source,subject,title,year';
url += '&rows=50&page=1&output=json';
$.ajax({
url: url,
method: 'GET',
dataType: $scope.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
var items = [];
if (data.response.docs.length > 0) {
items = data.response.docs;
//alert(JSON.stringify(data["response"]));
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function (item, key) {
$scope.album.push(map(item));
});
$scope.$apply();
notifications.updateMessage($scope.album.length, true);
} else {
notifications.updateMessage("Sorry :(", true);
}
},
error: function () {
alert('Archive.org service down :(');
}
}); });
}; };
$scope.mapSong = function (key, song, server, dir, identifier, coverart) {
var url, time, track, title, rating, starred, contenttype, suffix;
var specs = '';
if (song.format == 'VBR MP3') {
url = 'http://' + server + dir + key;
if (typeof song.bitrate == 'undefined' || typeof song.format == 'undefined') { specs = '&nbsp;'; } else { specs = song.bitrate + 'kbps, ' + song.format.toLowerCase(); }
if (typeof song.track == 'undefined') { track = '&nbsp;'; } else { track = song.track; }
if (typeof song.title == 'undefined') { title = '&nbsp;'; } else { title = song.title; }
if (typeof song.length == 'undefined') { time = '&nbsp;'; } else { time = utils.timeToSeconds(song.length); }
return new model.Song(song.md5, identifier, song.track, title, song.creator, '', song.album, '', coverart, coverart, time, '', '', 'mp3', specs, url, 0, '');
}
};
$scope.getSongs = function (id, action) { $scope.getSongs = function (id, action) {
$scope.selectedAlbum = id; archive.getSongs(id, action).then(function (data) {
var url = $scope.archiveUrl + 'details/' + id + '?output=json'; $scope.song = data.song;
$.ajax({ $scope.album = data.album;
url: url, $scope.selectedAlbum = data.selectedAlbum;
method: 'GET',
dataType: $scope.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
var coverart = '';
var server = data.server;
var dir = data.dir;
var identifier = data.metadata.identifier[0];
if (typeof data.misc.image != 'undefined') {
coverart = data.misc.image;
}
var items = data.files;
if (action == 'add') {
angular.forEach(items, function (item, key) {
var song = $scope.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
});
//$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
$scope.$apply();
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function (item, key) {
var song = $scope.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
});
var next = $rootScope.queue[0];
$scope.$apply(function () {
$rootScope.playSong(false, next);
});
//$rootScope.showQueue();
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
} else {
$scope.album = [];
$rootScope.song = [];
angular.forEach(items, function (item, key) {
var song = $scope.mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.song.push(song);
}
});
$scope.$apply();
}
}
}); });
}; };
$scope.addSongsToQueue = function () {
if ($scope.selectedSongs.length > 0) {
angular.forEach($scope.selectedSongs, function (item, key) {
$scope.queue.push(item);
item.selected = false;
});
//$rootScope.showQueue();
notifications.updateMessage($scope.selectedSongs.length + ' Song(s) Added to Queue', true);
}
};
$scope.scrollToTop = function () { $scope.scrollToTop = function () {
$('#Artists').stop().scrollTo('#auto', 400); $('#Artists').stop().scrollTo('#auto', 400);
}; };
$scope.selectAll = function () { $scope.selectAll = function () {
angular.forEach($rootScope.song, function (item, key) { $rootScope.selectAll($scope.song);
$scope.selectedSongs.push(item);
item.selected = true;
});
}; };
$scope.selectNone = function () { $scope.selectNone = function () {
angular.forEach($rootScope.song, function (item, key) { $rootScope.selectNone($scope.song);
$scope.selectedSongs = []; };
item.selected = false; $scope.playAll = function () {
}); $rootScope.playAll($scope.song);
};
$scope.playFrom = function (index) {
$rootScope.playFrom(index, $scope.song);
};
$scope.removeSong = function (item) {
$rootScope.removeSong(item, $scope.song);
}; };
/* Launch on Startup */ /* Launch on Startup */
//$scope.getArtists();
//$scope.getCollections(); //$scope.getCollections();
if ($routeParams.artist) { if ($routeParams.artist) {
if ($routeParams.album) { if ($routeParams.album) {

View file

@ -1,5 +1,5 @@
JamStash.controller('SubsonicCtrl', JamStash.controller('SubsonicCtrl',
function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, utils, globals, model, map, subsonic, notifications, player) { function SubsonicCtrl($scope, $rootScope, $location, $window, $routeParams, $http, utils, globals, model, map, subsonic, notifications, player) {
//$("#SubsonicAlbums").layout($scope.layoutThreeCol); //$("#SubsonicAlbums").layout($scope.layoutThreeCol);
//subsonic.song = []; //subsonic.song = [];

View file

@ -46,6 +46,7 @@ function AppCtrl($scope, $rootScope, $document, $window, $location, $cookieStore
}); });
} }
if (utils.getValue("SavedCollections")) { globals.SavedCollections = utils.getValue("SavedCollections").split(","); } if (utils.getValue("SavedCollections")) { globals.SavedCollections = utils.getValue("SavedCollections").split(","); }
if (utils.getValue("DefaultCollection")) { globals.DefaultCollection = utils.getValue("DefaultCollection"); }
if (utils.getValue("SavedGenres")) { globals.SavedGenres = utils.getValue("SavedGenres").split(","); } if (utils.getValue("SavedGenres")) { globals.SavedGenres = utils.getValue("SavedGenres").split(","); }
if (globals.settings.Debug) { console.log('Settings: ' + JSON.stringify(globals.settings, null, 2)); } if (globals.settings.Debug) { console.log('Settings: ' + JSON.stringify(globals.settings, null, 2)); }
}; };

View file

@ -1,8 +1,9 @@
[ [
{ {
"date": "5/2/2014", "version": "3.4", "date": "5/4/2014", "version": "3.4.1",
"changes": [ "changes": [
{ "text": "- Tab state saved, consolidated Subsonic artists, playlist and podcasts" } { "text": "- Tab state saved, consolidated Subsonic artists, playlist and podcasts" },
{ "text": "- Archive.org tab, expanded Collection search" }
] ]
}, },
{ {

View file

@ -11,12 +11,9 @@
<div id="LayoutContainer" class="section lgsection split-pane fixed-left" split> <div id="LayoutContainer" class="section lgsection split-pane fixed-left" split>
<div id="left-component" class="split-pane-component smcolumn noselect" tabindex="0"> <div id="left-component" class="split-pane-component smcolumn noselect" tabindex="0">
<!-- Artist --> <!-- Artist -->
<!-- <!--<select class="" id="Collections" ng-disabled="!loadedCollection" ng-model="selectedCollection" title="Select Collection" ng-options="o for o in AllCollections"></select>-->
<select class="large" id="Collections" ng-disabled="!loadedCollection" ng-model="selectedCollection" ng-options="o for o in AllCollections"> <input type="text" id="Artists" name="Artists" class="large" title="Wildcards (*) supported" placeholder="Search..." ng-enter="getArtists()" />
<option value="">Select Collection</option> <a href="" class="button" title="Search" ng-click="getArtists()"><img class="pad" src="images/magnifying_glass_alt_12x12.png" /></a>
</select>-->
<input type="text" id="Collections" name="Collections" class="large" title="" placeholder="Search..." ng-enter="getCollections()" />
<a href="" class="button" title="Search" ng-click="getCollections()"><img class="pad" src="images/magnifying_glass_alt_12x12.png" /></a>
<a href="" title="Load Example Collections?" ng-click="setupDemoCollections()">?</a> <a href="" title="Load Example Collections?" ng-click="setupDemoCollections()">?</a>
<ul class="simplelist mainlist noselect"> <ul class="simplelist mainlist noselect">
<li class="item" ng-repeat="o in SavedCollections" ng-click="getAlbums(o)" ng-class="{ 'selected': selectedArtist == o }"> <li class="item" ng-repeat="o in SavedCollections" ng-click="getAlbums(o)" ng-class="{ 'selected': selectedArtist == o }">
@ -31,7 +28,7 @@
</li> </li>
</ul> </ul>
<ul class="simplelist mainlist noselect"> <ul class="simplelist mainlist noselect">
<li class="item" ng-repeat="o in AllCollections" ng-click="getAlbums(o)" ng-class="{ 'selected': selectedArtist == o }"> <li class="item" ng-repeat="o in AllArtists" ng-click="getAlbums(o)" ng-class="{ 'selected': selectedArtist == o }">
<div class="infolink"> <div class="infolink">
<a href="" class="hover" title="Save Collection" ng-click="addSavedCollection(o)" stop-event="click"> <img src="images/pin_gl_12x12.png" /> </a> <a href="" class="hover" title="Save Collection" ng-click="addSavedCollection(o)" stop-event="click"> <img src="images/pin_gl_12x12.png" /> </a>
</div> </div>
@ -51,35 +48,33 @@
</select> </select>
<input type="text" id="Source" name="Source" class="sm" ng-model="filter.Source" placeholder="Source" title="Source" /> <input type="text" id="Source" name="Source" class="sm" ng-model="filter.Source" placeholder="Source" title="Source" />
<input type="text" id="Description" name="Description" class="m" ng-model="filter.Description" placeholder="Description" title="Description" /> <input type="text" id="Description" name="Description" class="m" ng-model="filter.Description" placeholder="Description" title="Description" />
<a href="" class="button" ng-click="filterSave()">Go</a>&nbsp; <a href="" class="button" ng-click="filterSave()"><img class="pad" src="images/magnifying_glass_alt_12x12.png" /></a>&nbsp;
</form> </form>
</li> </li>
</ul> </ul>
<div class="clear"></div> <div class="clear"></div>
<ul class="simplelist songlist noselect"> <ul class="simplelist songlist noselect">
<div class="" ng-repeat="o in album" ng-switch on="o.type"> <li class="album" ng-repeat="o in album" ng-switch on="o.type" ng-class="{'selected': selectedAlbum == o.id}" ng-click="getSongs(o.id, '')">
<li class="album" id="{{o.id}}" parentid="{{o.parentid}}" ng-class="{'selected': selectedAlbum == o.id}" ng-click="getSongs(o.id, '')"> <div id="{{'AlbumInfo' + $index}}" class="infolink">
<div id="{{'AlbumInfo' + $index}}" class="infolink"> <a href="" class="hover" title="More Info..." ng-click="toggleSubmenu('#submenu_AlbumInfo' + $index, '#AlbumInfo' + $index, 'right', 10)" stop-event="click"><img src="images/info_gl_6x12.png" /></a>
<a href="" class="hover" title="More Info..." ng-click="toggleSubmenu('#submenu_AlbumInfo' + $index, '#AlbumInfo' + $index, 'right', 10)" stop-event="click"><img src="images/info_gl_6x12.png" /></a> </div>
</div> <div id="{{'submenu_AlbumInfo' + $index}}" class="submenu_AlbumInfo submenu shadow" style="display: none;">
<div id="{{'submenu_AlbumInfo' + $index}}" class="submenu_AlbumInfo submenu shadow" style="display: none;"> <a href="" ng-href="{{o.url}}" title="{{o.url}}" target="_blank" stop-event="click">Source</a><br />
<a href="" ng-href="{{o.url}}" title="{{o.url}}" target="_blank" stop-event="click">Source</a><br /> <a href="" ng-href="{{settings.Url + o.artist + '/' + o.id}}" title="{{settings.Url + o.artist + '/' + o.id}}" target="_blank" stop-event="click">PermaStash</a>
<a href="" ng-href="{{settings.Url + o.artist + '/' + o.id}}" title="{{settings.Url + o.artist + '/' + o.id}}" target="_blank" stop-event="click">PermaStash</a> </div>
</div> <div class="itemactions">
<div class="itemactions"> <a class="add" href="" title="Add To Play Queue" ng-click="getSongs(o.id, 'add')" stop-event="click"></a>
<a class="add" href="" title="Add To Play Queue" ng-click="getSongs(o.id, 'add')" stop-event="click"></a> <a class="play" href="" title="Play" ng-click="getSongs(o.id, 'play')" stop-event="click"></a>
<a class="play" href="" title="Play" ng-click="getSongs(o.id, 'play')" stop-event="click"></a> <a class="download" href="" title="Download"></a>
<a class="download" href="" title="Download"></a> <a href="" title="Favorite" ng-class="{'favorite': o.starred, 'rate': !o.starred}" ng-click="updateFavorite(o)" stop-event="click"></a>
<a href="" title="Favorite" ng-class="{'favorite': o.starred, 'rate': !o.starred}" ng-click="updateFavorite(o)" stop-event="click"></a> </div>
</div> <div class="albumart"><img ng-src="{{o.coverart}}" src="images/albumdefault_50.jpg"></div>
<div class="albumart"><img ng-src="{{o.coverart}}" src="images/albumdefault_50.jpg"></div> <div class="title">{{o.name}}</div>
<div class="title">{{o.name}}</div> <div class="artist"><a href="" id="{{o.parentid}}" ng-click="getAlbums(o.artist, o.id)" stop-event="click">{{o.artist}}</a></div>
<div class="artist"><a href="" id="{{o.parentid}}" ng-click="getAlbums(o.artist, o.id)" stop-event="click">{{o.artist}}</a></div> <!--<div class="details">Created: {{o.date}}</div>-->
<!--<div class="details">Created: {{o.date}}</div>--> <div class="description shadow" ng-bind-html="o.description"></div>
<div class="description shadow" ng-show="selectedAlbum == o.id" ng-bind-html="o.description"></div> <div class="clear"></div>
<div class="clear"></div> </li>
</li>
</div>
<div ng-if="song.length > 0" ng-include src="'js/partials/songs.html'"></div> <div ng-if="song.length > 0" ng-include src="'js/partials/songs.html'"></div>
</ul> </ul>
</div> </div>

View file

@ -121,6 +121,7 @@ JamStash.service('globals', function () {
DefaultLibraryLayout: this.Layouts[0], DefaultLibraryLayout: this.Layouts[0],
DefaultSearchType: this.SearchTypes[0], DefaultSearchType: this.SearchTypes[0],
DefaultAlbumSort: this.AlbumSorts[0], DefaultAlbumSort: this.AlbumSorts[0],
DefaultArchiveAlbumSort: "date desc",
AutoPlay: false, AutoPlay: false,
LoopQueue: false, LoopQueue: false,
Repeat: false, Repeat: false,
@ -1254,7 +1255,7 @@ JamStash.factory('subsonic', function ($rootScope, $http, $q, globals, utils, ma
}; };
}); });
JamStash.factory('archive', function ($rootScope, $http, $q, globals, utils, map, notifications) { JamStash.factory('archive', function ($rootScope, $http, $q, $sce, globals, model, utils, map, notifications) {
var index = { shortcuts: [], artists: [] }; var index = { shortcuts: [], artists: [] };
var content = { var content = {
artist: [], artist: [],
@ -1263,19 +1264,58 @@ JamStash.factory('archive', function ($rootScope, $http, $q, globals, utils, map
breadcrumb: [], breadcrumb: [],
selectedArtist: null, selectedArtist: null,
selectedAlbum: null, selectedAlbum: null,
selectedGenre: null selectedGenre: null,
selectedArchiveAlbumSort: "date desc"
}; };
var offset = 0; var offset = 0;
var mapAlbum = function (data) {
var song = data;
var coverartthumb, coverartfull, starred, title, album, publisher, avg_rating, downloads, identifier;
var url = globals.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 (typeof song.title == 'undefined') { title = '&nbsp;'; } else { title = song.title.toString(); }
if (typeof song.identifier == 'undefined') { identifier = '&nbsp;'; } else { identifier = song.identifier.toString(); }
if (typeof song.collection[0] == 'undefined') { album = '&nbsp;'; } else { album = song.collection[0].toString(); }
if (typeof song.source == 'undefined') { source = '&nbsp;'; } else { source = song.source.toString(); }
if (typeof song.date == 'undefined') { date = '&nbsp;'; } else { date = song.date.toString(); }
if (typeof song.publisher == 'undefined') { publisher = '&nbsp;'; } else { publisher = song.publisher.toString(); }
if (typeof song.avg_rating == 'undefined') { avg_rating = '&nbsp;'; } else { avg_rating = song.avg_rating.toString(); }
if (typeof song.downloads == 'undefined') { downloads = '&nbsp;'; } else { downloads = song.downloads.toString(); }
//var description = '<b>Details</b><br />';
var description = '<b>Source</b>: ' + source + '<br />';
description += '<b>Date</b>: ' + date + '<br />';
description += '<b>Transferer</b>: ' + publisher + '<br />';
description += '<b>Rating</b>: ' + avg_rating + '<br />';
description += '<b>Downloads</b>: ' + downloads + '<br />';
return new model.Album(identifier, null, title, album, '', coverartthumb, coverartfull, $.format.date(new Date(song.publicdate), "yyyy-MM-dd h:mm a"), starred, $sce.trustAsHtml(description), url);
};
var mapSong = function (key, song, server, dir, identifier, coverart) {
var url, time, track, title, rating, starred, contenttype, suffix;
var specs = '';
if (song.format == 'VBR MP3') {
url = 'http://' + server + dir + key;
if (typeof song.bitrate == 'undefined' || typeof song.format == 'undefined') { specs = '&nbsp;'; } else { specs = song.bitrate + 'kbps, ' + song.format.toLowerCase(); }
if (typeof song.track == 'undefined') { track = '&nbsp;'; } else { track = song.track; }
if (typeof song.title == 'undefined') { title = '&nbsp;'; } else { title = song.title; }
if (typeof song.length == 'undefined') { time = '&nbsp;'; } else { time = utils.timeToSeconds(song.length); }
return new model.Song(song.md5, identifier, song.track, title, song.creator, '', song.album, '', coverart, coverart, time, '', '', 'mp3', specs, url, 0, '');
}
};
return { return {
getCollections: function (query) { getArtists: function (query) {
var deferred = $q.defer(); var deferred = $q.defer();
if (globals.settings.Debug) { console.log("LOAD ARCHIVE.ORG COLLECTIONS"); } if (globals.settings.Debug) { console.log("LOAD ARCHIVE.ORG COLLECTIONS"); }
var url = globals.archiveUrl + 'advancedsearch.php?q='; var url = globals.archiveUrl + 'advancedsearch.php?q=';
if (query !== '') { if (query !== '') {
url += 'collection:(etree) AND mediatype:(collection) AND identifier:(' + query + ')'; //url += 'collection:(' + collection + ') AND mediatype:(collection) AND identifier:(' + query + ')';
url += 'mediatype:(collection) AND identifier:(' + query + ')';
} else { } else {
url += 'collection:(etree) AND mediatype:(collection)'; url += 'collection:(collection)';
} }
url += '&fl[]=identifier&sort[]=&sort[]=&sort[]=&rows=50&page=1&output=json'; url += '&fl[]=identifier&sort[]=&sort[]=&sort[]=&rows=50&page=1&output=json';
$.ajax({ $.ajax({
@ -1298,14 +1338,126 @@ JamStash.factory('archive', function ($rootScope, $http, $q, globals, utils, map
} }
}); });
return deferred.promise; return deferred.promise;
},
getAlbums: function (name, filter) {
var deferred = $q.defer();
var url = globals.archiveUrl + 'advancedsearch.php?q=';
if (name !== '') {
content.selectedArtist = name;
url += 'collection:(' + name + ') AND format:(MP3)';
} else if (content.selectedArtist) {
name = content.selectedArtist;
url += 'collection:(' + content.selectedArtist + ') AND format:(MP3)';
} else {
url += 'collection:(' + name + ')';
}
if (filter.Source) {
url += ' AND source:(' + filter.Source + ')';
}
if (filter.Year) {
if (parseInt(filter.Year)) {
url += ' AND year:(' + filter.Year + ')';
}
}
if (filter.Description) {
url += ' AND description:(' + filter.Description + ')';
}
if (content.selectedArtist) {
url += '&sort[]=' + globals.settings.DefaultArchiveAlbumSort;
}
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: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
var items = [];
if (data.response.docs.length > 0) {
items = data.response.docs;
//alert(JSON.stringify(data["response"]));
content.album = [];
content.song = [];
angular.forEach(items, function (item, key) {
content.album.push(mapAlbum(item));
});
notifications.updateMessage(content.album.length, true);
} else {
notifications.updateMessage("Sorry :(", true);
}
deferred.resolve(content);
},
error: function () {
notifications.updateMessage('Archive.org service down :(');
}
});
return deferred.promise;
},
getSongs: function (id, action) {
var deferred = $q.defer();
content.selectedAlbum = id;
var url = globals.archiveUrl + 'details/' + id + '?output=json';
$.ajax({
url: url,
method: 'GET',
dataType: globals.settings.Protocol,
timeout: globals.settings.Timeout,
success: function (data) {
var coverart = '';
var server = data.server;
var dir = data.dir;
var identifier = data.metadata.identifier[0];
if (typeof data.misc.image != 'undefined') {
coverart = data.misc.image;
}
var items = data.files;
if (action == 'add') {
angular.forEach(items, function (item, key) {
var song = mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
});
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
} else if (action == 'play') {
$rootScope.queue = [];
angular.forEach(items, function (item, key) {
var song = mapSong(key, item, server, dir, identifier, coverart);
if (song) {
$rootScope.queue.push(song);
}
});
var next = $rootScope.queue[0];
$rootScope.playSong(false, next);
notifications.updateMessage(Object.keys(items).length + ' Song(s) Added to Queue', true);
} else {
content.album = [];
content.song = [];
angular.forEach(items, function (item, key) {
var song = mapSong(key, item, server, dir, identifier, coverart);
if (song) {
content.song.push(song);
}
});
}
deferred.resolve(content);
}
});
return deferred.promise;
} }
}; };
}); });
JamStash.factory('json', function ($http) { // Deferred loading JamStash.factory('json', function ($http, $q) { // Deferred loading
return { return {
getCollections: function (callback) { getCollections: function (callback) {
$http.get('js/json_collections.js').success(callback); //$http.get('js/json_collections.js').success(callback);
var deferred = $q.defer();
var collections = ['etree', 'dnalounge'];
deferred.resolve(collections);
return deferred.promise;
}, },
getChangeLog: function (callback) { getChangeLog: function (callback) {
$http.get('js/json_changelog.js').success(callback); $http.get('js/json_changelog.js').success(callback);

View file

@ -1689,6 +1689,10 @@ select
margin: 5px; margin: 5px;
border: 1px solid #d6d6d6; border: 1px solid #d6d6d6;
} }
select.m
{
width: 100px;
}
select.large select.large
{ {
width: 192px; width: 192px;