diff --git a/css/main.css b/css/main.css index 7d80648..31b6d82 100644 --- a/css/main.css +++ b/css/main.css @@ -35,6 +35,11 @@ opacity: 0.3; } +.starred { + background-image: url('../img/starred.svg'); + opacity: 1; +} + .icon-stationfav:hover { background-image: url('../img/starred.svg'); opacity: 1; diff --git a/js/main.js b/js/main.js index f1275f4..dc8d498 100644 --- a/js/main.js +++ b/js/main.js @@ -36,10 +36,7 @@ $(function(){ url: baseUrl + '/stations/' + data[station]["id"], method: 'DELETE' }).done(function(){ - if ($('li.nav-favorites').hasClass('active')){ - $( "tr[data-id='"+data[station]["stationid"]+"']" ).slideUp(); - $( "tr[data-id='"+data[station]["stationid"]+"']" ).remove(); - }; + $( "tr[data-id='"+data[station]["stationid"]+"']" ).find('.icon-stationfav').removeClass('starred'); }); }; }; @@ -55,6 +52,8 @@ $(function(){ method: 'POST', contentType: 'application/json', data: JSON.stringify(station) + }).done(function(){ + $( "tr[data-id='"+stationid+"']" ).find('.icon-stationfav').addClass('starred'); }); }; }); @@ -76,23 +75,38 @@ $(function(){ }; function render_result(data){ - $.each(data, function(i, station) { - $('tbody').append('