nextcloud-app-radio/js/main.js

46 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-11-17 22:07:22 +00:00
$(window).on('load', function(){
$('body').on('click', 'tr', function() {
var sourceUrl = $(this).attr('src');
$("#player").attr("src", sourceUrl);
$('#player').trigger('play');
});
function show_result(data){
$("tbody > tr").remove();
$.each(data, function(i, station) {
2016-11-18 21:45:53 +00:00
$('tbody').append('<tr src='+station['url']+'>\
2017-01-04 17:54:04 +00:00
<td class="filename">\
<a href="#" class="action action-favorite" data-original-title="" title="">\
<span class="icon icon-star"></span>\
<span class="hidden-visually">Favorite</span>\
</a>\
<label for="select-files-3">\
<div class="thumbnail" style="background-image:url('+station['favicon']+'); background-size: 32px;"></div>\
</label>\
<a class="name" href="#">\
<span class="nametext"><span class="innernametext">'+station['name']+'</span></span>\
</a>\
</td>\
2016-11-18 21:45:53 +00:00
</tr>');
2016-11-17 22:07:22 +00:00
});
}
function search(query){
$.ajax({
method: "POST",
2016-11-18 21:45:53 +00:00
url: 'https://www.radio-browser.info/webservice/json/stations/search',
2016-11-17 22:07:22 +00:00
data: {
name: query
},
dataType: 'json',
success: show_result
});
};
2016-11-18 21:45:53 +00:00
$('#radiosearch').submit(function() {
var query = $('#radioquery').val();
2016-11-17 22:07:22 +00:00
search(query);
});
});