Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -334,53 +334,55 @@ def get_user_spaces():
|
|
334 |
</div>
|
335 |
|
336 |
<script>
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
// μ’μμ λ²νΌ ν κΈ
|
351 |
-
function toggleLike(cardId) {
|
352 |
-
const card = document.getElementById(cardId);
|
353 |
-
const likeCount = parseInt(localStorage.getItem(cardId) || 0);
|
354 |
-
const newCount = likeCount > 0 ? 0 : 1;
|
355 |
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
const button = card.querySelector('.like-button');
|
367 |
-
button.textContent = isLiked ? 'β€οΈ' : 'π€';
|
368 |
-
}
|
369 |
-
|
370 |
-
// μΉ΄λ μ λ ¬
|
371 |
-
function sortCards() {
|
372 |
-
const container = document.getElementById('vercel-container');
|
373 |
-
const cards = Array.from(container.children);
|
374 |
|
375 |
-
|
376 |
-
|
377 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
// νμ΄μ§ λ‘λ μ μ€ν
|
383 |
-
document.addEventListener('DOMContentLoaded', loadLikes);
|
384 |
</script>
|
385 |
"""
|
386 |
|
|
|
334 |
</div>
|
335 |
|
336 |
<script>
|
337 |
+
document.addEventListener('DOMContentLoaded', function() {{
|
338 |
+
// μ’μμ μν λ‘λ
|
339 |
+
function loadLikes() {{
|
340 |
+
const cards = document.querySelectorAll('.vercel-card');
|
341 |
+
cards.forEach(card => {{
|
342 |
+
const cardId = card.id;
|
343 |
+
const likes = localStorage.getItem(cardId) || 0;
|
344 |
+
card.querySelector('.like-count').textContent = likes;
|
345 |
+
card.dataset.likes = likes;
|
346 |
+
updateLikeButton(card, likes > 0);
|
347 |
+
}});
|
348 |
+
sortCards();
|
349 |
+
}}
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
+
// μ’μμ λ²νΌ ν κΈ
|
352 |
+
window.toggleLike = function(cardId) {{
|
353 |
+
const card = document.getElementById(cardId);
|
354 |
+
const likeCount = parseInt(localStorage.getItem(cardId) || 0);
|
355 |
+
const newCount = likeCount > 0 ? 0 : 1;
|
356 |
+
|
357 |
+
localStorage.setItem(cardId, newCount);
|
358 |
+
card.querySelector('.like-count').textContent = newCount;
|
359 |
+
card.dataset.likes = newCount;
|
360 |
+
updateLikeButton(card, newCount > 0);
|
361 |
+
|
362 |
+
sortCards();
|
363 |
+
}}
|
364 |
|
365 |
+
// μ’μμ λ²νΌ μν μ
λ°μ΄νΈ
|
366 |
+
function updateLikeButton(card, isLiked) {{
|
367 |
+
const button = card.querySelector('.like-button');
|
368 |
+
button.textContent = isLiked ? 'β€οΈ' : 'π€';
|
369 |
+
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
|
371 |
+
// μΉ΄λ μ λ ¬
|
372 |
+
function sortCards() {{
|
373 |
+
const container = document.getElementById('vercel-container');
|
374 |
+
const cards = Array.from(container.children);
|
375 |
+
|
376 |
+
cards.sort((a, b) => {{
|
377 |
+
return parseInt(b.dataset.likes) - parseInt(a.dataset.likes);
|
378 |
+
}});
|
379 |
+
|
380 |
+
cards.forEach(card => container.appendChild(card));
|
381 |
+
}}
|
382 |
|
383 |
+
// μ΄κΈ° λ‘λ
|
384 |
+
loadLikes();
|
385 |
+
}});
|
|
|
|
|
386 |
</script>
|
387 |
"""
|
388 |
|