@@ -1550,49 +1550,36 @@ card.appendChild(badge);
15501550 e . stopPropagation ( ) ;
15511551 var favs = JSON . parse ( localStorage . getItem ( "favorites" ) || "[]" ) ;
15521552 var idx = favs . indexOf ( name ) ;
1553+
15531554 if ( idx === - 1 ) {
1555+ // Add to favorites
15541556 favs . push ( name ) ;
15551557 favBtn . classList . add ( "active" ) ;
15561558 favBtn . innerHTML = '<i class="fas fa-star"></i>' ;
1559+ favBtn . style . color = "#f5a623" ; // Yellow
1560+ console . log ( "⭐ Added " + name + " to favorites" ) ;
15571561 } else {
1562+ // Remove from favorites
15581563 favs . splice ( idx , 1 ) ;
15591564 favBtn . classList . remove ( "active" ) ;
15601565 favBtn . innerHTML = '<i class="far fa-star"></i>' ;
1566+ favBtn . style . color = "" ; // Reset to default
1567+ console . log ( "☆ Removed " + name + " from favorites" ) ;
15611568 if ( currentCategory === "favorites" ) {
15621569 card . style . display = "none" ;
15631570 }
15641571 }
1572+
15651573 localStorage . setItem ( "favorites" , JSON . stringify ( favs ) ) ;
1566- updateSidebarCategoryCounts ( ) ;
1574+
1575+ // Update badge and counts
1576+ if ( typeof updateSidebarCategoryCounts === 'function' ) {
1577+ updateSidebarCategoryCounts ( ) ;
1578+ }
1579+ if ( typeof updateFavoritesCountBadge === 'function' ) {
1580+ updateFavoritesCountBadge ( ) ;
1581+ }
15671582 } ) ;
1568- e . stopPropagation ( ) ;
1569- var favs = JSON . parse ( localStorage . getItem ( "favorites" ) || "[]" ) ;
1570- var idx = favs . indexOf ( name ) ;
1571-
1572- if ( idx === - 1 ) {
1573- // Add to favorites
1574- favs . push ( name ) ;
1575- favBtn . classList . add ( "active" ) ;
1576- favBtn . innerHTML = '<i class="fas fa-star"></i>' ;
1577- favBtn . style . color = "#f5a623" ; // Yellow
1578- console . log ( "⭐ Added " + name + " to favorites" ) ;
1579- } else {
1580- // Remove from favorites
1581- favs . splice ( idx , 1 ) ;
1582- favBtn . classList . remove ( "active" ) ;
1583- favBtn . innerHTML = '<i class="far fa-star"></i>' ;
1584- favBtn . style . color = "" ; // Reset to default
1585- console . log ( "☆ Removed " + name + " from favorites" ) ;
1586- if ( currentCategory === "favorites" ) {
1587- card . style . display = "none" ;
1588- }
1589- }
1590-
1591- localStorage . setItem ( "favorites" , JSON . stringify ( favs ) ) ;
1592-
1593- // Update badge
1594- updateFavoritesCountBadge ( ) ;
1595- } ) ;
15961583
15971584 var cardActions = card . querySelector ( ".card-actions" ) ;
15981585 if ( cardActions ) cardActions . appendChild ( favBtn ) ;
0 commit comments