search a service, youtube support, bugfix

- Search: select service to search in
- Youtube icons
- Fixed single quote bug #39
This commit is contained in:
woutervanwijk 2014-09-23 13:08:01 +02:00
parent 99ab2dbfb8
commit 1a39499906
6 changed files with 63 additions and 30 deletions

View File

@ -2,6 +2,7 @@ Webclient
- Wouter van Wijk
- Flat Interface: Ulrich Lichtenegger
- Kingosticks
- Szymon Nowak
Mopidy:
https://github.com/mopidy/mopidy/blob/develop/AUTHORS

View File

@ -54,6 +54,13 @@ Project resources
Changelog
=========
v1.0.2 Dev
-------------------
- Search: select service to search in
- Youtube icons
- Fixed single quote bug #39
v1.0.1 (20-9-2014)
-------------------

View File

@ -5,7 +5,7 @@ import os
from mopidy import config, ext
__version__ = '1.0.1'
__version__ = '1.0.2'
class MusicBoxExtension(ext.Extension):

View File

@ -283,6 +283,9 @@
<div data-role="content" class="pane" id="searchpane">
<div class="">
<form>
<select id="selectSearchService" data-native-menu="false"> <!-- multiple="multiple" data-native-menu="false">
<option data-placeholder="true">Choose services</option> -->
</select>
<input id="searchinput" class="span2" data-clear-btn="true"
onkeypress="return searchPressed(event.keyCode);" id="appendedInputButton" type="text"/>
<button class="btn" type="button" onclick="return initSearch(event.value);">

View File

@ -77,11 +77,14 @@ TRACK_TIMER = 1000;
//check status timer, every 5 or 10 sec
STATUS_TIMER = 10000;
//var uriHumanList = [ ['spotify', 'Spotify'], ['local', 'Local Files'], ['podcast', 'Podcasts'], ['dirble', 'Dirble'],
// ['tunein', 'TuneIn'], ['soundcloud', 'SoundCloud'], ['sc', 'SoundCloud'], ['gmusic', 'Google Music'], ['internetarchive', 'Internet Archive'], ['somafm', 'Soma FM'], ['yt', 'YouTube'], ['youtube', 'YouTube'], ['subsonic', 'Subsonic'] ];
var uriClassList = [ ['spotify', 'fa-spotify'], ['local', 'fa-file-sound-o'], ['podcast', 'fa-rss-square'], ['dirble', 'fa-microphone'],
['tunein', 'fa-headphones'], ['soundcloud', 'fa-soundcloud'], ['gmusic', 'fa-google'], ['internetarchive', 'fa-university'], ['somafm', 'fa-flask'], ['subsonic', 'fa-folder-open'] ];
['tunein', 'fa-headphones'], ['soundcloud', 'fa-soundcloud'], ['sc', 'fa-soundcloud'], ['gmusic', 'fa-google'], ['internetarchive', 'fa-university'], ['somafm', 'fa-flask'], ['youtube', 'fa-youtube'], ['yt', 'fa-youtube'], ['subsonic', 'fa-folder-open'] ];
var uriHumanList = [ ['spotify', 'Spotify'], ['local', 'Local Files'], ['podcast', 'Podcasts'], ['dirble', 'Dirble'],
['tunein', 'TuneIn'], ['soundcloud', 'SoundCloud'], ['gmusic', 'Google Music'], ['internetarchive', 'Internet Archive'], ['somafm', 'Soma FM'], ['subsonic', 'Subsonic'] ];
['tunein', 'TuneIn'], ['soundcloud', 'SoundCloud'], ['gmusic', 'Google Music'], ['internetarchive', 'Internet Archive'], ['somafm', 'Soma FM'], ['youtube', 'YouTube'], ['subsonic', 'Subsonic'] ];
function scrollToTop() {
var divtop = 0;
@ -166,7 +169,6 @@ function renderSongLi(song, liID, uri, playlistType){
}
function resultsToTables(results, target, uri) {
//console.log(results, target, uri);
if (!results) { return }
if (target == '#currenttable') {
playlistType = 'playTrackQueueByUri';
@ -279,7 +281,6 @@ function resultsToTables(results, target, uri) {
} //albums name
}
}
// console.log(html);
tableid = "#" + tableid;
$(target).html(html);
$(target).attr('data', uri);
@ -414,7 +415,6 @@ $.event.special.swipe = $.extend($.event.special.swipe, {
origin: $( event.target ),
offset: $('body').scrollTop()
};
// console.log('start');
},
stop: function( event ) {

View File

@ -15,6 +15,7 @@ function searchPressed(key) {
//init search
function initSearch() {
var value = $('#searchinput').val();
var searchService = $('#selectSearchService').val();
if ((value.length < 100) && (value.length > 0)) {
showLoading(true);
@ -28,6 +29,9 @@ function initSearch() {
delete customTracklists['trackresultscache'];
$("#searchresults").hide();
if (searchService != 'all') {
mopidy.library.search({any:[value]}, [searchService + ':']).then(processSearchResults, console.error);
} else {
mopidy.getUriSchemes().then(function (schemes) {
var query = {},
uris = [];
@ -44,18 +48,16 @@ function initSearch() {
} else {
query = {any: [value]};
}
mopidy.library.search(query, uris).then(processSearchResults, console.error);
// console.log('search sent', value);
});
}
}
}
/********************************************************
* process results of a search
*********************************************************/
function processSearchResults(resultArr) {
// console.log('srch', resultArr);
$(SEARCH_TRACK_TABLE).empty();
$(SEARCH_ARTIST_TABLE).empty();
$(SEARCH_ALBUM_TABLE).empty();
@ -123,7 +125,7 @@ function processSearchResults(resultArr) {
child = '';
pattern = '<li><a href="#" onclick="return showAlbum(this.id)" id="{albumId}">';
pattern += '<h5 data-role="heading"><i class="{class}"></i> {albumName}</h5>';
pattern += '<p data-role="desc">{artistName} ({albumYear})</p>';
pattern += '<p data-role="desc">{artistName}</p>';
pattern += '</a></li>';
for (var i = 0; i < results.albums.length; i++) {
@ -134,13 +136,16 @@ function processSearchResults(resultArr) {
'albumYear': results.albums[i].date,
'class': getMediaClass(results.albums[i].uri)
};
//console.log(i, results.albums[i].artists.length);
if (results.albums[i].artists) {
for (var j = 0; j < results.albums[i].artists.length; j++) {
if (results.albums[i].artists[j].name) {
tokens.artistName += results.albums[i].artists[j].name + ' ';
}
}
}
if (tokens.albumYear) {
tokens.artistName += '(' + tokens.albumYear + ')';
}
// Add 'Show all' item after a certain number of hits.
if (i == 4 && results.albums.length > 5) {
child += theme(showMorePattern, {'count': results.albums.length - i});
@ -150,7 +155,6 @@ function processSearchResults(resultArr) {
child += theme(pattern, tokens);
}
// Inject list items, refresh listview and hide superfluous items.
// console.log(child, results.albums.length);
$(SEARCH_ALBUM_TABLE).html(child).listview('refresh').find('.overflow').hide();
$('#expandsearch').show();
@ -276,3 +280,21 @@ function showAlbum(uri) {
setSongInfo();
return false;
}
function getSearchSchemes() {
mopidy.getUriSchemes().then(
function(schemesArray) {
var humanIndex;
$("#selectSearchService").children().remove().end();
$("#selectSearchService").append(new Option('All services', 'all'));
for (var i = 0; i < schemesArray.length; i++) {
for (var j = 0; j < uriHumanList.length; j++) {
if (uriHumanList[j][0] == schemesArray[i].toLowerCase() ) {
$("#selectSearchService").append(new Option(uriHumanList[j][1], schemesArray[i]));
}
}
}
$("#selectSearchService").selectmenu( "refresh", true );
}, console.error
);
}