openfree commited on
Commit
1f5398a
Β·
verified Β·
1 Parent(s): ea54d2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -43
app.py CHANGED
@@ -334,53 +334,55 @@ def get_user_spaces():
334
  </div>
335
 
336
  <script>
337
- // μ’‹μ•„μš” μƒνƒœ λ‘œλ“œ
338
- function loadLikes() {
339
- const cards = document.querySelectorAll('.vercel-card');
340
- cards.forEach(card => {
341
- const cardId = card.id;
342
- const likes = localStorage.getItem(cardId) || 0;
343
- card.querySelector('.like-count').textContent = likes;
344
- card.dataset.likes = likes;
345
- updateLikeButton(card, likes > 0);
346
- });
347
- sortCards();
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
- localStorage.setItem(cardId, newCount);
357
- card.querySelector('.like-count').textContent = newCount;
358
- card.dataset.likes = newCount;
359
- updateLikeButton(card, newCount > 0);
 
 
 
 
 
 
 
 
 
360
 
361
- sortCards();
362
- }
363
-
364
- // μ’‹μ•„μš” λ²„νŠΌ μƒνƒœ μ—…λ°μ΄νŠΈ
365
- function updateLikeButton(card, isLiked) {
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
- cards.sort((a, b) => {
376
- return parseInt(b.dataset.likes) - parseInt(a.dataset.likes);
377
- });
 
 
 
 
 
 
 
 
378
 
379
- cards.forEach(card => container.appendChild(card));
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