Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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:
|