search a service, youtube support, bugfix
- Search: select service to search in - Youtube icons - Fixed single quote bug #39
This commit is contained in:
parent
99ab2dbfb8
commit
1a39499906
1
AUTHORS
1
AUTHORS
@ -2,6 +2,7 @@ Webclient
|
|||||||
- Wouter van Wijk
|
- Wouter van Wijk
|
||||||
- Flat Interface: Ulrich Lichtenegger
|
- Flat Interface: Ulrich Lichtenegger
|
||||||
- Kingosticks
|
- Kingosticks
|
||||||
|
- Szymon Nowak
|
||||||
|
|
||||||
Mopidy:
|
Mopidy:
|
||||||
https://github.com/mopidy/mopidy/blob/develop/AUTHORS
|
https://github.com/mopidy/mopidy/blob/develop/AUTHORS
|
||||||
|
|||||||
@ -54,6 +54,13 @@ Project resources
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
v1.0.2 Dev
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Search: select service to search in
|
||||||
|
- Youtube icons
|
||||||
|
- Fixed single quote bug #39
|
||||||
|
|
||||||
v1.0.1 (20-9-2014)
|
v1.0.1 (20-9-2014)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import os
|
|||||||
from mopidy import config, ext
|
from mopidy import config, ext
|
||||||
|
|
||||||
|
|
||||||
__version__ = '1.0.1'
|
__version__ = '1.0.2'
|
||||||
|
|
||||||
|
|
||||||
class MusicBoxExtension(ext.Extension):
|
class MusicBoxExtension(ext.Extension):
|
||||||
|
|||||||
@ -283,6 +283,9 @@
|
|||||||
<div data-role="content" class="pane" id="searchpane">
|
<div data-role="content" class="pane" id="searchpane">
|
||||||
<div class="">
|
<div class="">
|
||||||
<form>
|
<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"
|
<input id="searchinput" class="span2" data-clear-btn="true"
|
||||||
onkeypress="return searchPressed(event.keyCode);" id="appendedInputButton" type="text"/>
|
onkeypress="return searchPressed(event.keyCode);" id="appendedInputButton" type="text"/>
|
||||||
<button class="btn" type="button" onclick="return initSearch(event.value);">
|
<button class="btn" type="button" onclick="return initSearch(event.value);">
|
||||||
|
|||||||
@ -77,11 +77,14 @@ TRACK_TIMER = 1000;
|
|||||||
//check status timer, every 5 or 10 sec
|
//check status timer, every 5 or 10 sec
|
||||||
STATUS_TIMER = 10000;
|
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'],
|
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'],
|
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() {
|
function scrollToTop() {
|
||||||
var divtop = 0;
|
var divtop = 0;
|
||||||
@ -166,7 +169,6 @@ function renderSongLi(song, liID, uri, playlistType){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resultsToTables(results, target, uri) {
|
function resultsToTables(results, target, uri) {
|
||||||
//console.log(results, target, uri);
|
|
||||||
if (!results) { return }
|
if (!results) { return }
|
||||||
if (target == '#currenttable') {
|
if (target == '#currenttable') {
|
||||||
playlistType = 'playTrackQueueByUri';
|
playlistType = 'playTrackQueueByUri';
|
||||||
@ -279,7 +281,6 @@ function resultsToTables(results, target, uri) {
|
|||||||
} //albums name
|
} //albums name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log(html);
|
|
||||||
tableid = "#" + tableid;
|
tableid = "#" + tableid;
|
||||||
$(target).html(html);
|
$(target).html(html);
|
||||||
$(target).attr('data', uri);
|
$(target).attr('data', uri);
|
||||||
@ -414,7 +415,6 @@ $.event.special.swipe = $.extend($.event.special.swipe, {
|
|||||||
origin: $( event.target ),
|
origin: $( event.target ),
|
||||||
offset: $('body').scrollTop()
|
offset: $('body').scrollTop()
|
||||||
};
|
};
|
||||||
// console.log('start');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
stop: function( event ) {
|
stop: function( event ) {
|
||||||
|
|||||||
@ -15,6 +15,7 @@ function searchPressed(key) {
|
|||||||
//init search
|
//init search
|
||||||
function initSearch() {
|
function initSearch() {
|
||||||
var value = $('#searchinput').val();
|
var value = $('#searchinput').val();
|
||||||
|
var searchService = $('#selectSearchService').val();
|
||||||
|
|
||||||
if ((value.length < 100) && (value.length > 0)) {
|
if ((value.length < 100) && (value.length > 0)) {
|
||||||
showLoading(true);
|
showLoading(true);
|
||||||
@ -28,26 +29,28 @@ function initSearch() {
|
|||||||
delete customTracklists['trackresultscache'];
|
delete customTracklists['trackresultscache'];
|
||||||
$("#searchresults").hide();
|
$("#searchresults").hide();
|
||||||
|
|
||||||
mopidy.getUriSchemes().then(function (schemes) {
|
if (searchService != 'all') {
|
||||||
var query = {},
|
mopidy.library.search({any:[value]}, [searchService + ':']).then(processSearchResults, console.error);
|
||||||
uris = [];
|
} else {
|
||||||
|
mopidy.getUriSchemes().then(function (schemes) {
|
||||||
|
var query = {},
|
||||||
|
uris = [];
|
||||||
|
|
||||||
var regexp = $.map(schemes, function (scheme) {
|
var regexp = $.map(schemes, function (scheme) {
|
||||||
return '^' + scheme + ':';
|
return '^' + scheme + ':';
|
||||||
}).join('|');
|
}).join('|');
|
||||||
|
|
||||||
var match = value.match(regexp);
|
var match = value.match(regexp);
|
||||||
if (match) {
|
if (match) {
|
||||||
var scheme = match[0];
|
var scheme = match[0];
|
||||||
query = {uri: [value]};
|
query = {uri: [value]};
|
||||||
uris = [scheme];
|
uris = [scheme];
|
||||||
} else {
|
} else {
|
||||||
query = {any: [value]};
|
query = {any: [value]};
|
||||||
}
|
}
|
||||||
|
mopidy.library.search(query, uris).then(processSearchResults, console.error);
|
||||||
mopidy.library.search(query, uris).then(processSearchResults, console.error);
|
});
|
||||||
// console.log('search sent', value);
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +58,6 @@ function initSearch() {
|
|||||||
* process results of a search
|
* process results of a search
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
function processSearchResults(resultArr) {
|
function processSearchResults(resultArr) {
|
||||||
// console.log('srch', resultArr);
|
|
||||||
$(SEARCH_TRACK_TABLE).empty();
|
$(SEARCH_TRACK_TABLE).empty();
|
||||||
$(SEARCH_ARTIST_TABLE).empty();
|
$(SEARCH_ARTIST_TABLE).empty();
|
||||||
$(SEARCH_ALBUM_TABLE).empty();
|
$(SEARCH_ALBUM_TABLE).empty();
|
||||||
@ -123,7 +125,7 @@ function processSearchResults(resultArr) {
|
|||||||
child = '';
|
child = '';
|
||||||
pattern = '<li><a href="#" onclick="return showAlbum(this.id)" id="{albumId}">';
|
pattern = '<li><a href="#" onclick="return showAlbum(this.id)" id="{albumId}">';
|
||||||
pattern += '<h5 data-role="heading"><i class="{class}"></i> {albumName}</h5>';
|
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>';
|
pattern += '</a></li>';
|
||||||
|
|
||||||
for (var i = 0; i < results.albums.length; i++) {
|
for (var i = 0; i < results.albums.length; i++) {
|
||||||
@ -134,13 +136,16 @@ function processSearchResults(resultArr) {
|
|||||||
'albumYear': results.albums[i].date,
|
'albumYear': results.albums[i].date,
|
||||||
'class': getMediaClass(results.albums[i].uri)
|
'class': getMediaClass(results.albums[i].uri)
|
||||||
};
|
};
|
||||||
|
|
||||||
//console.log(i, results.albums[i].artists.length);
|
|
||||||
if (results.albums[i].artists) {
|
if (results.albums[i].artists) {
|
||||||
for (var j = 0; j < results.albums[i].artists.length; j++) {
|
for (var j = 0; j < results.albums[i].artists.length; j++) {
|
||||||
tokens.artistName += results.albums[i].artists[j].name + ' ';
|
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.
|
// Add 'Show all' item after a certain number of hits.
|
||||||
if (i == 4 && results.albums.length > 5) {
|
if (i == 4 && results.albums.length > 5) {
|
||||||
child += theme(showMorePattern, {'count': results.albums.length - i});
|
child += theme(showMorePattern, {'count': results.albums.length - i});
|
||||||
@ -150,7 +155,6 @@ function processSearchResults(resultArr) {
|
|||||||
child += theme(pattern, tokens);
|
child += theme(pattern, tokens);
|
||||||
}
|
}
|
||||||
// Inject list items, refresh listview and hide superfluous items.
|
// 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();
|
$(SEARCH_ALBUM_TABLE).html(child).listview('refresh').find('.overflow').hide();
|
||||||
|
|
||||||
$('#expandsearch').show();
|
$('#expandsearch').show();
|
||||||
@ -276,3 +280,21 @@ function showAlbum(uri) {
|
|||||||
setSongInfo();
|
setSongInfo();
|
||||||
return false;
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user