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,11 +75,24 @@ $(function(){
}; };
function render_result(data){ function render_result(data){
var baseUrl = OC.generateUrl('/apps/radio');
$.get(baseUrl + '/stations', function ( fav_stations ) {
$.each(data, function(i, station) { $.each(data, function(i, station) {
var isstarred = ""
for (var fav_station in fav_stations) {
if (fav_stations[fav_station]["stationid"] == station['id']) {
isstarred = "starred";
break;
}
};
$('tbody').append('<tr data-src='+station['url']+' data-id='+station['id']+'>\ $('tbody').append('<tr data-src='+station['url']+' data-id='+station['id']+'>\
<td class="favcolumn">\ <td class="favcolumn">\
<a href="#" class="favpls" onclick="station_fav();">\ <a href="#" class="favpls" onclick="station_fav();">\
<span class="icon-stationfav"></span>\ <span class="icon-stationfav ' + isstarred + '"></span>\
<span class="hidden-visually">Favorite</span>\ <span class="hidden-visually">Favorite</span>\
</a>\ </a>\
</td>\ </td>\
@ -94,6 +106,8 @@ $(function(){
</td>\ </td>\
</tr>'); </tr>');
}); });
});
} }
function action_load_favorites(){ function action_load_favorites(){