indicate favorite stations

This commit is contained in:
Jonas Heinrich 2017-08-05 19:41:29 +02:00
parent 15e95e0e60
commit ff27e5ba4c
2 changed files with 40 additions and 21 deletions

View File

@ -35,6 +35,11 @@
opacity: 0.3; opacity: 0.3;
} }
.starred {
background-image: url('../img/starred.svg');
opacity: 1;
}
.icon-stationfav:hover { .icon-stationfav:hover {
background-image: url('../img/starred.svg'); background-image: url('../img/starred.svg');
opacity: 1; opacity: 1;

View File

@ -36,10 +36,7 @@ $(function(){
url: baseUrl + '/stations/' + data[station]["id"], url: baseUrl + '/stations/' + data[station]["id"],
method: 'DELETE' method: 'DELETE'
}).done(function(){ }).done(function(){
if ($('li.nav-favorites').hasClass('active')){ $( "tr[data-id='"+data[station]["stationid"]+"']" ).find('.icon-stationfav').removeClass('starred');
$( "tr[data-id='"+data[station]["stationid"]+"']" ).slideUp();
$( "tr[data-id='"+data[station]["stationid"]+"']" ).remove();
};
}); });
}; };
}; };
@ -55,6 +52,8 @@ $(function(){
method: 'POST', method: 'POST',
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify(station) data: JSON.stringify(station)
}).done(function(){
$( "tr[data-id='"+stationid+"']" ).find('.icon-stationfav').addClass('starred');
}); });
}; };
}); });
@ -76,23 +75,38 @@ $(function(){
}; };
function render_result(data){ function render_result(data){
$.each(data, function(i, station) {
$('tbody').append('<tr data-src='+station['url']+' data-id='+station['id']+'>\ var baseUrl = OC.generateUrl('/apps/radio');
<td class="favcolumn">\ $.get(baseUrl + '/stations', function ( fav_stations ) {
<a href="#" class="favpls" onclick="station_fav();">\
<span class="icon-stationfav"></span>\ $.each(data, function(i, station) {
<span class="hidden-visually">Favorite</span>\
</a>\ var isstarred = ""
</td>\ for (var fav_station in fav_stations) {
<td class="filename">\ if (fav_stations[fav_station]["stationid"] == station['id']) {
<label for="select-files-3">\ isstarred = "starred";
<div class="thumbnail" style="background-image:url('+station['favicon']+'); background-size: 32px;"></div>\ break;
</label>\ }
<a class="name" href="#">\ };
<span class="nametext"><span class="innernametext">'+station['name']+'</span></span>\
</a>\ $('tbody').append('<tr data-src='+station['url']+' data-id='+station['id']+'>\
</td>\ <td class="favcolumn">\
</tr>'); <a href="#" class="favpls" onclick="station_fav();">\
<span class="icon-stationfav ' + isstarred + '"></span>\
<span class="hidden-visually">Favorite</span>\
</a>\
</td>\
<td class="filename">\
<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>\
</tr>');
});
}); });
} }