openfree commited on
Commit
f872762
β€’
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: