openfree commited on
Commit
f872762
·
verified ·
1 Parent(s): c8d3bbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -1
app.py CHANGED
@@ -586,9 +586,59 @@ def get_user_spaces():
586
  </div>
587
 
588
  <script>
589
- // ... (기존 스크립트 코드는 동일하게 유지)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
590
  </script>
591
  """
 
 
592
  return html_content
593
 
594
  except Exception as e:
 
586
  </div>
587
 
588
  <script>
589
+ document.addEventListener('DOMContentLoaded', function() {{
590
+ // 좋아요 상태 로드
591
+ function loadLikes() {{
592
+ const cards = document.querySelectorAll('.vercel-card');
593
+ cards.forEach(card => {{
594
+ const cardId = card.id;
595
+ const likes = localStorage.getItem(cardId) || 0;
596
+ card.querySelector('.like-count').textContent = likes;
597
+ card.dataset.likes = likes;
598
+ updateLikeButton(card, likes > 0);
599
+ }});
600
+ sortCards();
601
+ }}
602
+
603
+ // 좋아요 버튼 토글
604
+ window.toggleLike = function(cardId) {{
605
+ const card = document.getElementById(cardId);
606
+ const likeCount = parseInt(localStorage.getItem(cardId) || 0);
607
+ const newCount = likeCount > 0 ? 0 : 1;
608
+
609
+ localStorage.setItem(cardId, newCount);
610
+ card.querySelector('.like-count').textContent = newCount;
611
+ card.dataset.likes = newCount;
612
+ updateLikeButton(card, newCount > 0);
613
+
614
+ sortCards();
615
+ }}
616
+
617
+ // 좋아요 버튼 상태 업데이트
618
+ function updateLikeButton(card, isLiked) {{
619
+ const button = card.querySelector('.like-button');
620
+ button.textContent = isLiked ? '❤️' : '🤍';
621
+ }}
622
+
623
+ // 카드 정렬
624
+ function sortCards() {{
625
+ const container = document.getElementById('vercel-container');
626
+ const cards = Array.from(container.children);
627
+
628
+ cards.sort((a, b) => {{
629
+ return parseInt(b.dataset.likes) - parseInt(a.dataset.likes);
630
+ }});
631
+
632
+ cards.forEach(card => container.appendChild(card));
633
+ }}
634
+
635
+ // 초기 로드
636
+ loadLikes();
637
+ }});
638
  </script>
639
  """
640
+
641
+
642
  return html_content
643
 
644
  except Exception as e: