Spaces:
Running
Running
ชื่อโปรเจกต์: Strava Activity Feed & Stats Mockupเป้าหมาย: สร้างไฟล์ HTML5 เดี่ยว (.html) ที่ประกอบด้วย HTML, CSS, และ JavaScript ทั้งหมด เพื่อจำลองหน้า Activity Feed (ฟีดกิจกรรม) และส่วนแสดง Weekly/Monthly Totals (สถิติรวมรายสัปดาห์/รายเดือน) ของแอป Strava ซึ่งเน้นการแสดงผลเชิงสังคม (Social) และข้อมูลการฝึกซ้อม (Performance Data)📝 รายละเอียด Prompt1. โครงสร้างไฟล์ (File Structure)ต้องเป็น ไฟล์ HTML5 เดี่ยว (index.html หรือชื่ออื่นตามสะดวก)HTML, CSS, และ JavaScript ทั้งหมดต้องอยู่ในไฟล์เดียวCSS ต้องอยู่ในแท็ก <style> (ใช้ Dark Mode และโทนสีส้ม/เทาของ Strava)JavaScript ต้องอยู่ในแท็ก <script> (ใช้ Vanilla JS ในการจัดการ DOM เพื่อสร้างฟีดกิจกรรม)ห้ามใช้ Library/Framework ภายนอก (เช่น React, Vue, jQuery, หรือ Library แผนที่/ชาร์ต)2. ข้อมูลจำลอง (Mock Data)สร้างโครงสร้างข้อมูล JavaScript เพื่อจำลอง Activity Feed (อย่างน้อย 5 กิจกรรม) และ Weekly/Monthly Totals ดังนี้:A. Activity Feed Data (อาร์เรย์ของกิจกรรม)FieldDescriptionTypeExampleidรหัสกิจกรรมNumber101athleteNameชื่อนักกีฬาString"Chris Froome"avatarUrlURL รูปโปรไฟล์Stringhttps://via.placeholder.com/40/FF5500activityTypeประเภทกิจกรรมString"Run" หรือ "Ride"activityTitleชื่อกิจกรรมString"Morning Interval Training"distanceระยะทาง (กม.)Number15.2timeเวลา (ชั่วโมง:นาที:วินาที)String"0:58:30"elevationความสูงที่สะสม (เมตร)Number250kudosจำนวน Kudos (Likes)Number58commentsจำนวน CommentsNumber5mapImageUrlURL รูปแผนที่จำลองStringhttps://via.placeholder.com/600x200/444444/FFFFFF?text=Route+Map+MockupB. Totals Data (สถิติรวม)FieldDescriptionTypeExampleweeklyDistanceระยะรวมสัปดาห์นี้Number85.5weeklyTimeเวลารวมสัปดาห์นี้String"5h 45m"monthlyDistanceระยะรวมเดือนนี้Number320.1monthlyActivitiesจำนวนกิจกรรมรวมเดือนนี้Number153. องค์ประกอบของ Dashboard (Dashboard Components)Dashboard ต้องเน้นองค์ประกอบหลัก 3 ส่วนของ Strava:A. Sidebar/Weekly Totals (สถิติรวมรายสัปดาห์)แสดง Weekly Totals (weeklyDistance, weeklyTime)Goals Mockup: แสดง Progress Bar จำลองความคืบหน้าของเป้าหมายรายสัปดาห์ (เช่น 85.5/100 km).B. Activity Feed (ส่วนกลาง)ต้องใช้ JavaScript ในการวนซ้ำ (Loop) ข้อมูล Activity Feed Data เพื่อสร้าง Card กิจกรรมแต่ละรายการActivity Card Layout: แต่ละ Card ต้องแสดง:รูป Avatar และชื่อนักกีฬาประเภทกิจกรรม (พร้อม Icon ที่เหมาะสม เช่น 🏃♂️ หรือ 🚴♀️)ชื่อกิจกรรมที่โดดเด่นสถิติหลัก 3 ตัว: ระยะทาง (distance), เวลา (time), ความสูง (elevation)Map Mockup: แสดงรูป mapImageUrl (ให้ดูเหมือนเส้นทาง GPS)Social Bar: แสดงจำนวน Kudos, Comments, และปุ่มจำลอง "Give Kudos" (ต้องมีฟังก์ชัน JS ง่ายๆ ในการเพิ่ม Kudos เมื่อคลิก)C. Challenges/Clubs Mockup (การแข่งขันและคลับ)แสดง Card เล็กๆ จำลองการเข้าร่วม Challenge (เช่น "November Running Challenge") และ Club (เช่น "Local Runners Club") พร้อมตัวเลขจำนวนสมาชิก/ความคืบหน้า4. คุณสมบัติการโต้ตอบ (Interactive Features)Kudos Counter: เมื่อผู้ใช้คลิกปุ่ม "Give Kudos" บน Activity Card ใดๆ JavaScript ต้อง เพิ่มจำนวน Kudos ของกิจกรรมนั้นๆ บนหน้าจอทันทีInfinite Scroll Mockup: เพิ่มปุ่ม/ข้อความที่ส่วนท้ายของฟีด เช่น "Load More Activities" (แสดงให้เห็นถึงแนวคิดการโหลดข้อมูลเพิ่ม)Filter Mockup: มีปุ่ม/แถบด้านบนสำหรับ "Following" และ "Yours" (แสดงให้เห็นถึงแนวคิดการเปลี่ยนฟีด)5. ข้อจำกัดด้านการออกแบบ (Design Constraints)โทนสี Strava: ใช้สีเทา/ดำ (Dark Mode) เป็นพื้นหลัง และสีส้ม (#FC4C02 หรือใกล้เคียง) สำหรับ Accent Color, ปุ่ม, และกราฟTypography: ใช้ฟอนต์ที่อ่านง่ายและสะอาด (เช่น System Font หรือ Sans-serif)🚀 สิ่งที่ต้องการจากการตอบกลับโค้ด HTML5 ที่ทำงานได้เต็มรูปแบบ (Full working HTML5 file) พร้อมข้อมูลจำลองและฟังก์ชัน JavaScript ข้างต้น เพื่อเป็น Mockup Dashboard ของ Strava ที่จำลอง Activity Feed และ Social Component ได้อย่างครบถ้วน
4d29c3f verified Download index.html from CSNET/strava-social-dash: direct link, hf CLI and curl.
- Browser
- Download file 24 kB
-
https://huggingface.co/spaces/CSNET/strava-social-dash/resolve/main/index.html
- Command line
-
hf download hf://spaces/CSNET/strava-social-dash/index.html
-
curl -L -o index.html https://huggingface.co/spaces/CSNET/strava-social-dash/resolve/main/index.html
24 kB
| <html lang="th"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Strava Activity Feed Mockup</title> | |
| <style> | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| :root { | |
| --strava-orange: #FC4C02; | |
| --dark-bg: #0d1117; | |
| --card-bg: #161b22; | |
| --text-primary: #c9d1d9; | |
| --text-secondary: #8b949e; | |
| --border-color: #30363d; | |
| --success-green: #3fb950; | |
| } | |
| body { | |
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; | |
| background-color: var(--dark-bg); | |
| color: var(--text-primary); | |
| line-height: 1.6; | |
| } | |
| .container { | |
| max-width: 1400px; | |
| margin: 0 auto; | |
| padding: 20px; | |
| display: grid; | |
| grid-template-columns: 320px 1fr; | |
| gap: 24px; | |
| } | |
| /* Header */ | |
| .header { | |
| grid-column: 1 / -1; | |
| background-color: var(--card-bg); | |
| border-radius: 12px; | |
| padding: 16px 24px; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| border: 1px solid var(--border-color); | |
| margin-bottom: 10px; | |
| } | |
| .logo { | |
| font-size: 24px; | |
| font-weight: 800; | |
| color: var(--strava-orange); | |
| display: flex; | |
| align-items: center; | |
| gap: 8px; | |
| } | |
| .filter-buttons { | |
| display: flex; | |
| gap: 8px; | |
| } | |
| .filter-btn { | |
| padding: 8px 16px; | |
| border: 1px solid var(--border-color); | |
| background-color: var(--dark-bg); | |
| color: var(--text-secondary); | |
| border-radius: 20px; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| font-size: 14px; | |
| } | |
| .filter-btn:hover { | |
| border-color: var(--strava-orange); | |
| color: var(--strava-orange); | |
| } | |
| .filter-btn.active { | |
| background-color: var(--strava-orange); | |
| border-color: var(--strava-orange); | |
| color: white; | |
| } | |
| /* Sidebar */ | |
| .sidebar { | |
| display: flex; | |
| flex-direction: column; | |
| gap: 20px; | |
| height: fit-content; | |
| position: sticky; | |
| top: 20px; | |
| } | |
| .stats-card, .challenge-card, .club-card { | |
| background-color: var(--card-bg); | |
| border-radius: 12px; | |
| padding: 20px; | |
| border: 1px solid var(--border-color); | |
| } | |
| .card-title { | |
| font-size: 16px; | |
| font-weight: 600; | |
| margin-bottom: 16px; | |
| color: var(--text-primary); | |
| } | |
| .stat-item { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| padding: 8px 0; | |
| border-bottom: 1px solid var(--border-color); | |
| } | |
| .stat-item:last-child { | |
| border-bottom: none; | |
| } | |
| .stat-label { | |
| color: var(--text-secondary); | |
| font-size: 14px; | |
| } | |
| .stat-value { | |
| font-weight: 700; | |
| color: var(--text-primary); | |
| } | |
| .progress-bar { | |
| margin-top: 16px; | |
| } | |
| .progress-label { | |
| display: flex; | |
| justify-content: space-between; | |
| font-size: 12px; | |
| color: var(--text-secondary); | |
| margin-bottom: 6px; | |
| } | |
| .progress-track { | |
| width: 100%; | |
| height: 8px; | |
| background-color: var(--dark-bg); | |
| border-radius: 4px; | |
| overflow: hidden; | |
| } | |
| .progress-fill { | |
| height: 100%; | |
| background-color: var(--strava-orange); | |
| transition: width 0.5s ease; | |
| } | |
| /* Activity Feed */ | |
| .activity-feed { | |
| display: flex; | |
| flex-direction: column; | |
| gap: 20px; | |
| } | |
| .activity-card { | |
| background-color: var(--card-bg); | |
| border-radius: 12px; | |
| padding: 20px; | |
| border: 1px solid var(--border-color); | |
| transition: transform 0.2s ease, box-shadow 0.2s ease; | |
| } | |
| .activity-card:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 4px 12px rgba(252, 76, 2, 0.1); | |
| } | |
| .athlete-header { | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| margin-bottom: 16px; | |
| } | |
| .avatar { | |
| width: 40px; | |
| height: 40px; | |
| border-radius: 50%; | |
| object-fit: cover; | |
| border: 2px solid var(--strava-orange); | |
| } | |
| .athlete-info { | |
| flex: 1; | |
| } | |
| .athlete-name { | |
| font-weight: 600; | |
| color: var(--text-primary); | |
| font-size: 14px; | |
| } | |
| .activity-type { | |
| display: flex; | |
| align-items: center; | |
| gap: 4px; | |
| font-size: 12px; | |
| color: var(--text-secondary); | |
| margin-top: 2px; | |
| } | |
| .activity-title { | |
| font-size: 18px; | |
| font-weight: 700; | |
| margin-bottom: 16px; | |
| color: var(--text-primary); | |
| } | |
| .stats-grid { | |
| display: grid; | |
| grid-template-columns: repeat(3, 1fr); | |
| gap: 16px; | |
| margin-bottom: 16px; | |
| } | |
| .stat-box { | |
| text-align: center; | |
| padding: 12px; | |
| background-color: var(--dark-bg); | |
| border-radius: 8px; | |
| } | |
| .stat-box-value { | |
| font-size: 20px; | |
| font-weight: 800; | |
| color: var(--strava-orange); | |
| } | |
| .stat-box-label { | |
| font-size: 12px; | |
| color: var(--text-secondary); | |
| margin-top: 4px; | |
| } | |
| .map-mock { | |
| width: 100%; | |
| height: 200px; | |
| background-color: var(--dark-bg); | |
| border-radius: 8px; | |
| margin-bottom: 16px; | |
| overflow: hidden; | |
| position: relative; | |
| } | |
| .map-mock img { | |
| width: 100%; | |
| height: 100%; | |
| object-fit: cover; | |
| } | |
| .map-placeholder { | |
| position: absolute; | |
| top: 50%; | |
| left: 50%; | |
| transform: translate(-50%, -50%); | |
| color: var(--text-secondary); | |
| font-size: 14px; | |
| } | |
| .social-bar { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| padding-top: 16px; | |
| border-top: 1px solid var(--border-color); | |
| } | |
| .social-stats { | |
| display: flex; | |
| gap: 20px; | |
| } | |
| .social-stat { | |
| display: flex; | |
| align-items: center; | |
| gap: 6px; | |
| color: var(--text-secondary); | |
| font-size: 14px; | |
| } | |
| .kudos-btn { | |
| display: flex; | |
| align-items: center; | |
| gap: 8px; | |
| padding: 8px 16px; | |
| background-color: var(--dark-bg); | |
| border: 1px solid var(--border-color); | |
| color: var(--text-secondary); | |
| border-radius: 20px; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| font-size: 14px; | |
| } | |
| .kudos-btn:hover { | |
| border-color: var(--strava-orange); | |
| color: var(--strava-orange); | |
| transform: scale(1.05); | |
| } | |
| .kudos-btn.given { | |
| background-color: var(--strava-orange); | |
| color: white; | |
| border-color: var(--strava-orange); | |
| } | |
| .challenge-card small, .club-card small { | |
| display: block; | |
| color: var(--text-secondary); | |
| font-size: 12px; | |
| margin-top: 8px; | |
| } | |
| .challenge-progress { | |
| margin-top: 12px; | |
| } | |
| .load-more { | |
| text-align: center; | |
| padding: 20px; | |
| } | |
| .load-more-btn { | |
| padding: 10px 24px; | |
| background-color: var(--card-bg); | |
| border: 1px solid var(--border-color); | |
| color: var(--text-secondary); | |
| border-radius: 20px; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| font-size: 14px; | |
| } | |
| .load-more-btn:hover { | |
| border-color: var(--strava-orange); | |
| color: var(--strava-orange); | |
| } | |
| /* Icons */ | |
| .icon { | |
| display: inline-block; | |
| width: 16px; | |
| height: 16px; | |
| } | |
| @media (max-width: 1024px) { | |
| .container { | |
| grid-template-columns: 1fr; | |
| } | |
| .sidebar { | |
| position: static; | |
| display: grid; | |
| grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); | |
| } | |
| } | |
| @media (max-width: 640px) { | |
| .stats-grid { | |
| grid-template-columns: 1fr; | |
| } | |
| .social-bar { | |
| flex-direction: column; | |
| gap: 12px; | |
| } | |
| .filter-buttons { | |
| flex-wrap: wrap; | |
| } | |
| .header { | |
| flex-direction: column; | |
| gap: 12px; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <!-- Header --> | |
| <header class="header"> | |
| <div class="logo"> | |
| 🏃♂️ Strava Social Dash | |
| </div> | |
| <div class="filter-buttons"> | |
| <button class="filter-btn active" data-filter="following">กำลังติดตาม</button> | |
| <button class="filter-btn" data-filter="yours">ของคุณ</button> | |
| </div> | |
| </header> | |
| <!-- Sidebar --> | |
| <aside class="sidebar"> | |
| <!-- Weekly Stats --> | |
| <div class="stats-card"> | |
| <h3 class="card-title">📊 สถิติประจำสัปดาห์</h3> | |
| <div class="stat-item"> | |
| <span class="stat-label">ระยะทาง</span> | |
| <span class="stat-value" id="weeklyDistance">85.5 กม.</span> | |
| </div> | |
| <div class="stat-item"> | |
| <span class="stat-label">เวลา</span> | |
| <span class="stat-value" id="weeklyTime">5h 45m</span> | |
| </div> | |
| <div class="progress-bar"> | |
| <div class="progress-label"> | |
| <span>ความคืบหน้าเป้าหมาย</span> | |
| <span>85.5 / 100 กม.</span> | |
| </div> | |
| <div class="progress-track"> | |
| <div class="progress-fill" style="width: 85.5%"></div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Monthly Stats --> | |
| <div class="stats-card"> | |
| <h3 class="card-title">📈 สถิติประจำเดือน</h3> | |
| <div class="stat-item"> | |
| <span class="stat-label">ระยะทางรวม</span> | |
| <span class="stat-value" id="monthlyDistance">320.1 กม.</span> | |
| </div> | |
| <div class="stat-item"> | |
| <span class="stat-label">กิจกรรมทั้งหมด</span> | |
| <span class="stat-value" id="monthlyActivities">15 ครั้ง</span> | |
| </div> | |
| </div> | |
| <!-- Challenge --> | |
| <div class="challenge-card"> | |
| <h3 class="card-title">🏆 ความท้าทาย</h3> | |
| <div> | |
| <strong>November Running Challenge</strong> | |
| <small>ความคืบหน้า: 85.5 / 100 กม.</small> | |
| </div> | |
| <div class="challenge-progress"> | |
| <div class="progress-track"> | |
| <div class="progress-fill" style="width: 85.5%"></div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Club --> | |
| <div class="club-card"> | |
| <h3 class="card-title">👥 คลับ</h3> | |
| <div> | |
| <strong>Local Runners Club</strong> | |
| <small>สมาชิก 1,234 คน</small> | |
| </div> | |
| </div> | |
| </aside> | |
| <!-- Activity Feed --> | |
| <main class="activity-feed" id="activityFeed"> | |
| <!-- Activities will be inserted here by JavaScript --> | |
| </main> | |
| <!-- Load More --> | |
| <div class="load-more" style="grid-column: 1 / -1;"> | |
| <button class="load-more-btn" id="loadMoreBtn">โหลดกิจกรรมเพิ่มเติม</button> | |
| </div> | |
| </div> | |
| <script> | |
| // Mock Data | |
| const mockActivities = [ | |
| { | |
| id: 101, | |
| athleteName: "Chris Froome", | |
| avatarUrl: "https://static.photos/people/200x200/42", | |
| activityType: "Ride", | |
| activityTitle: "Morning Interval Training", | |
| distance: 15.2, | |
| time: "0:58:30", | |
| elevation: 250, | |
| kudos: 58, | |
| comments: 5, | |
| mapImageUrl: "https://static.photos/technology/600x200/99" | |
| }, | |
| { | |
| id: 102, | |
| athleteName: "เอมม่า โรเดส", | |
| avatarUrl: "https://static.photos/people/200x200/88", | |
| activityType: "Run", | |
| activityTitle: "พักจบรอบสวนจุฬา", | |
| distance: 8.5, | |
| time: "0:45:12", | |
| elevation: 45, | |
| kudos: 32, | |
| comments: 3, | |
| mapImageUrl: "https://static.photos/nature/600x200/77" | |
| }, | |
| { | |
| id: 103, | |
| athleteName: "Arsène Wenger", | |
| avatarUrl: "https://static.photos/people/200x200/15", | |
| activityType: "Ride", | |
| activityTitle: "ออกปั่นรอบเขาใหญ่", | |
| distance: 45.8, | |
| time: "2:15:45", | |
| elevation: 890, | |
| kudos: 89, | |
| comments: 12, | |
| mapImageUrl: "https://static.photos/outdoor/600x200/55" | |
| }, | |
| { | |
| id: 104, | |
| athleteName: "จารุวรรณ สมใจ", | |
| avatarUrl: "https://static.photos/people/200x200/33", | |
| activityType: "Run", | |
| activityTitle: "วิ่งเช้า 5 โมงเช้า", | |
| distance: 12.3, | |
| time: "1:08:15", | |
| elevation: 120, | |
| kudos: 45, | |
| comments: 8, | |
| mapImageUrl: "https://static.photos/cityscape/600x200/11" | |
| }, | |
| { | |
| id: 105, | |
| athleteName: "Robert Lewandowski", | |
| avatarUrl: "https://static.photos/people/200x200/99", | |
| activityType: "Ride", | |
| activityTitle: "Recovery Ride หลังแข่ง", | |
| distance: 25.5, | |
| time: "1:30:00", | |
| elevation: 180, | |
| kudos: 67, | |
| comments: 7, | |
| mapImageUrl: "https://static.photos/blurred/600x200/22" | |
| } | |
| ]; | |
| const activityIcons = { | |
| 'Run': '🏃♂️', | |
| 'Ride': '🚴♀️', | |
| 'Swim': '🏊♂️', | |
| 'Hike': '🥾' | |
| }; | |
| // State to track kudos given | |
| const kudosGiven = new Set(); | |
| // Render Activities | |
| function renderActivities(activities) { | |
| const feedContainer = document.getElementById('activityFeed'); | |
| activities.forEach(activity => { | |
| const activityCard = document.createElement('div'); | |
| activityCard.className = 'activity-card'; | |
| activityCard.innerHTML = ` | |
| <div class="athlete-header"> | |
| <img src="${activity.avatarUrl}" alt="${activity.athleteName}" class="avatar"> | |
| <div class="athlete-info"> | |
| <div class="athlete-name">${activity.athleteName}</div> | |
| <div class="activity-type"> | |
| <span class="icon">${activityIcons[activity.activityType] || '🏃♂️'}</span> | |
| ${activity.activityType} | |
| </div> | |
| </div> | |
| </div> | |
| <h2 class="activity-title">${activity.activityTitle}</h2> | |
| <div class="stats-grid"> | |
| <div class="stat-box"> | |
| <div class="stat-box-value">${activity.distance}</div> | |
| <div class="stat-box-label">กิโลเมตร</div> | |
| </div> | |
| <div class="stat-box"> | |
| <div class="stat-box-value">${activity.time}</div> | |
| <div class="stat-box-label">เวลา</div> | |
| </div> | |
| <div class="stat-box"> | |
| <div class="stat-box-value">${activity.elevation}</div> | |
| <div class="stat-box-label">เมตร</div> | |
| </div> | |
| </div> | |
| <div class="map-mock"> | |
| <img src="${activity.mapImageUrl}" alt="Map"> | |
| <div class="map-placeholder">🗺️ เส้นทาง ${activity.distance} กม.</div> | |
| </div> | |
| <div class="social-bar"> | |
| <div class="social-stats"> | |
| <div class="social-stat"> | |
| <span class="icon">👏</span> | |
| <span id="kudos-${activity.id}">${activity.kudos}</span> | |
| </div> | |
| <div class="social-stat"> | |
| <span class="icon">💬</span> | |
| <span>${activity.comments}</span> | |
| </div> | |
| </div> | |
| <button class="kudos-btn ${kudosGiven.has(activity.id) ? 'given' : ''}" | |
| onclick="giveKudos(${activity.id})" | |
| id="kudos-btn-${activity.id}"> | |
| <span class="icon">👏</span> | |
| ${kudosGiven.has(activity.id) ? 'ให้ Kudos แล้ว' : 'ให้ Kudos'} | |
| </button> | |
| </div> | |
| `; | |
| feedContainer.appendChild(activityCard); | |
| }); | |
| } | |
| // Give Kudos Function | |
| function giveKudos(activityId) { | |
| const kudosElement = document.getElementById(`kudos-${activityId}`); | |
| const button = document.getElementById(`kudos-btn-${activityId}`); | |
| if (!kudosGiven.has(activityId)) { | |
| // Find activity and increment kudos | |
| const activity = mockActivities.find(a => a.id === activityId); | |
| if (activity) { | |
| activity.kudos++; | |
| kudosElement.textContent = activity.kudos; | |
| button.classList.add('given'); | |
| button.innerHTML = '<span class="icon">👏</span> ให้ Kudos แล้ว'; | |
| kudosGiven.add(activityId); | |
| // Animation effect | |
| button.style.transform = 'scale(1.1)'; | |
| setTimeout(() => { | |
| button.style.transform = 'scale(1)'; | |
| }, 200); | |
| } | |
| } | |
| } | |
| // Filter Functions | |
| function setupFilters() { | |
| const filterButtons = document.querySelectorAll('.filter-btn'); | |
| filterButtons.forEach(button => { | |
| button.addEventListener('click', function() { | |
| // Remove active class from all buttons | |
| filterButtons.forEach(btn => btn.classList.remove('active')); | |
| // Add active class to clicked button | |
| this.classList.add('active'); | |
| const filter = this.dataset.filter; | |
| // Clear current feed | |
| const feedContainer = document.getElementById('activityFeed'); | |
| feedContainer.innerHTML = ''; | |
| // Filter logic (mock) | |
| if (filter === 'yours') { | |
| // Show only activities from "คุณ" (mock) | |
| const yourActivities = mockActivities.filter(a => | |
| a.athleteName.includes('จารุวรรณ') || a.athleteName.includes('เอมม่า') | |
| ); | |
| if (yourActivities.length === 0) { | |
| feedContainer.innerHTML = '<p style="text-align: center; color: var(--text-secondary); padding: 40px;">คุณยังไม่มีกิจกรรมในสัปดาห์นี้</p>'; | |
| } else { | |
| renderActivities(yourActivities); | |
| } | |
| } else { | |
| // Show all activities | |
| renderActivities(mockActivities); | |
| } | |
| }); | |
| }); | |
| } | |
| // Load More Function | |
| function setupLoadMore() { | |
| const loadMoreBtn = document.getElementById('loadMoreBtn'); | |
| let loadCount = 0; | |
| loadMoreBtn.addEventListener('click', function() { | |
| loadCount++; | |
| // Create duplicate activities with new IDs | |
| const moreActivities = mockActivities.map(activity => ({ | |
| ...activity, | |
| id: activity.id + (loadCount * 1000), | |
| kudos: Math.floor(Math.random() * 100) + 20 | |
| })); | |
| renderActivities(moreActivities); | |
| // Scroll to new content | |
| const newCards = document.querySelectorAll('.activity-card'); | |
| const lastNewCard = newCards[newCards.length - mockActivities.length]; | |
| lastNewCard.scrollIntoView({ behavior: 'smooth', block: 'start' }); | |
| // Add loading animation | |
| this.style.opacity = '0.5'; | |
| setTimeout(() => { | |
| this.style.opacity = '1'; | |
| }, 300); | |
| }); | |
| } | |
| // Initialize | |
| document.addEventListener('DOMContentLoaded', function() { | |
| renderActivities(mockActivities); | |
| setupFilters(); | |
| setupLoadMore(); | |
| }); | |
| </script> | |
| <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script> | |
| </body> | |
| </html> |