Download public/index.html from citedd/cuaca: direct link, hf CLI and curl.
- Browser
- Download file 18.5 kB
-
https://huggingface.co/spaces/citedd/cuaca/resolve/main/public/index.html
- Command line
-
hf download hf://spaces/citedd/cuaca/public/index.html
-
curl -L -o index.html https://huggingface.co/spaces/citedd/cuaca/resolve/main/public/index.html
18.5 kB
| <html lang="id"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Weather Dashboard</title> | |
| <style> | |
| * { margin: 0; padding: 0; box-sizing: border-box; } | |
| body { | |
| font-family: -apple-system, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif; | |
| min-height: 100vh; | |
| color: #fff; | |
| } | |
| .bg-photo { | |
| position: fixed; inset: 0; z-index: -2; | |
| background: url('https://images.unsplash.com/photo-1519681393784-d120267933ba?w=1920&q=80') center/cover no-repeat; | |
| } | |
| .bg-overlay { | |
| position: fixed; inset: 0; z-index: -1; | |
| background: linear-gradient(180deg, rgba(10,10,26,0.55) 0%, rgba(10,10,26,0.75) 100%); | |
| } | |
| .container { | |
| position: relative; z-index: 1; | |
| max-width: 800px; margin: 0 auto; | |
| padding: 2rem 1rem 3rem; | |
| } | |
| .glass { | |
| position: relative; | |
| background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.06) 40%, rgba(255,255,255,0.04) 60%, rgba(255,255,255,0.08) 100%); | |
| backdrop-filter: blur(40px) saturate(180%); | |
| -webkit-backdrop-filter: blur(40px) saturate(180%); | |
| border: 1px solid rgba(255,255,255,0.18); | |
| border-radius: 20px; | |
| box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.15), inset 0 -1px 0 rgba(255,255,255,0.05); | |
| overflow: hidden; | |
| } | |
| .glass::before { | |
| content: ''; position: absolute; inset: 0; border-radius: 20px; | |
| background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 50%, rgba(255,255,255,0.03) 100%); | |
| pointer-events: none; | |
| } | |
| .search-section { margin-bottom: 1.5rem; text-align: center; } | |
| .search-box { position: relative; max-width: 400px; margin: 0 auto; } | |
| .search-box input { | |
| width: 100%; padding: 0.85rem 1.2rem 0.85rem 2.8rem; | |
| background: rgba(255,255,255,0.1); backdrop-filter: blur(20px); | |
| -webkit-backdrop-filter: blur(20px); | |
| border: 1px solid rgba(255,255,255,0.2); border-radius: 16px; | |
| color: #fff; font-size: 0.95rem; outline: none; | |
| transition: border-color 0.3s, background 0.3s; | |
| } | |
| .search-box input::placeholder { color: rgba(255,255,255,0.4); } | |
| .search-box input:focus { border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.15); } | |
| .search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); opacity: 0.5; pointer-events: none; } | |
| .search-results { | |
| position: absolute; top: calc(100% + 4px); left: 0; right: 0; | |
| background: rgba(15,15,30,0.92); backdrop-filter: blur(20px); | |
| -webkit-backdrop-filter: blur(20px); | |
| border: 1px solid rgba(255,255,255,0.15); border-radius: 14px; overflow: hidden; z-index: 10; display: none; | |
| } | |
| .search-results.active { display: block; } | |
| .search-result { | |
| padding: 0.75rem 1.2rem; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.06); | |
| font-size: 0.85rem; color: rgba(255,255,255,0.7); transition: background 0.2s; | |
| } | |
| .search-result:hover { background: rgba(255,255,255,0.08); color: #fff; } | |
| .search-result:last-child { border-bottom: none; } | |
| .search-result .country { color: rgba(255,255,255,0.35); font-size: 0.75rem; } | |
| .weather-header { text-align: center; padding: 2rem 1.5rem; margin-bottom: 1.2rem; border-radius: 24px; } | |
| .city-name { font-size: 1.6rem; font-weight: 700; margin-bottom: 0.25rem; } | |
| .weather-desc { font-size: 0.9rem; color: rgba(255,255,255,0.5); margin-bottom: 1rem; } | |
| .weather-icon { font-size: 4rem; margin-bottom: 0.5rem; } | |
| .current-temp { | |
| font-size: 4.5rem; font-weight: 700; | |
| background: linear-gradient(135deg, #fff 30%, rgba(255,255,255,0.7)); | |
| -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; | |
| } | |
| .feels-like { font-size: 0.8rem; color: rgba(255,255,255,0.4); margin-top: 0.25rem; } | |
| .details { | |
| display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); | |
| gap: 0.75rem; margin-bottom: 1.2rem; | |
| } | |
| .detail-card { padding: 1rem 0.9rem; text-align: center; } | |
| .detail-icon-val { font-size: 1.5rem; margin-bottom: 0.3rem; } | |
| .detail-value { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.15rem; } | |
| .detail-label { font-size: 0.63rem; color: rgba(255,255,255,0.35); text-transform: uppercase; letter-spacing: 0.06em; } | |
| .section-title { font-size: 0.85rem; color: rgba(255,255,255,0.5); margin-bottom: 0.6rem; padding-left: 0.2rem; } | |
| .forecast-grid { | |
| display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); | |
| gap: 0.6rem; padding: 1.2rem 1rem; | |
| } | |
| .forecast-day { | |
| text-align: center; padding: 0.8rem 0.4rem; border-radius: 14px; | |
| background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.06); | |
| transition: background 0.2s; | |
| } | |
| .forecast-day:hover { background: rgba(255,255,255,0.1); } | |
| .forecast-name { font-size: 0.75rem; color: rgba(255,255,255,0.5); margin-bottom: 0.3rem; } | |
| .forecast-icon { font-size: 1.8rem; margin-bottom: 0.25rem; } | |
| .forecast-temp { font-size: 0.9rem; font-weight: 600; } | |
| .forecast-temp-low { color: rgba(255,255,255,0.35); font-size: 0.75rem; font-weight: 400; } | |
| .loading, .error { text-align: center; padding: 4rem 1rem; font-size: 1rem; color: rgba(255,255,255,0.5); } | |
| .error { color: #f87171; } | |
| .spinner { | |
| display: inline-block; width: 24px; height: 24px; | |
| border: 2px solid rgba(255,255,255,0.2); border-top-color: #a78bfa; | |
| border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 0.5rem; | |
| } | |
| @keyframes spin { to { transform: rotate(360deg); } } | |
| .footer { text-align: center; margin-top: 2.5rem; color: rgba(255,255,255,0.18); font-size: 0.68rem; } | |
| .footer a { color: rgba(167,139,250,0.4); text-decoration: none; } | |
| @media (max-width: 600px) { | |
| .container { padding: 1.25rem 0.7rem 2rem; } | |
| .current-temp { font-size: 3.5rem; } | |
| .weather-icon { font-size: 3rem; } | |
| .details { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; } | |
| .forecast-grid { grid-template-columns: repeat(3, 1fr); } | |
| .weather-header { padding: 1.5rem 1rem; } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="bg-photo"></div> | |
| <div class="bg-overlay"></div> | |
| <div class="container"> | |
| <!-- Logo --> | |
| <div style="text-align:center; margin-bottom:1.5rem;"> | |
| <div style="font-size:2.2rem; margin-bottom:0.2rem;">π€οΈ</div> | |
| <div style="font-size:1.1rem; font-weight:700; color:rgba(255,255,255,0.85);">Weather Dashboard</div> | |
| <div style="font-size:0.7rem; color:rgba(255,255,255,0.35); margin-top:0.15rem;">Cuaca real-time & ramalan 6 hari</div> | |
| </div> | |
| <div class="search-section"> | |
| <div class="search-box"> | |
| <span class="search-icon">π</span> | |
| <input type="text" id="searchInput" placeholder="Cari kota... (Jakarta, Tokyo, London)" autocomplete="off"> | |
| <div class="search-results" id="searchResults"></div> | |
| </div> | |
| </div> | |
| <div id="app"> | |
| <div class="loading"><div class="spinner"></div><div>Loading weather...</div></div> | |
| </div> | |
| <div class="footer"> | |
| Weather by <a href="https://open-meteo.com" target="_blank">Open-Meteo</a> Β· Liquid Glass Dashboard by Hedd | |
| </div> | |
| </div> | |
| <script> | |
| const WMO = { | |
| 0: { desc: 'Cerah', icon: 'βοΈ' }, 1: { desc: 'Cerah Berawan', icon: 'π€οΈ' }, | |
| 2: { desc: 'Berawan', icon: 'β ' }, 3: { desc: 'Mendung', icon: 'βοΈ' }, | |
| 45: { desc: 'Kabut', icon: 'π«οΈ' }, 48: { desc: 'Kabut Tebal', icon: 'π«οΈ' }, | |
| 51: { desc: 'Gerimis Ringan', icon: 'π¦οΈ' }, 53: { desc: 'Gerimis', icon: 'π¦οΈ' }, | |
| 55: { desc: 'Gerimis Lebat', icon: 'π§οΈ' }, | |
| 61: { desc: 'Hujan Ringan', icon: 'π§οΈ' }, 63: { desc: 'Hujan', icon: 'π§οΈ' }, | |
| 65: { desc: 'Hujan Lebat', icon: 'βοΈ' }, | |
| 71: { desc: 'Salju Ringan', icon: 'π¨οΈ' }, 73: { desc: 'Salju', icon: 'βοΈ' }, | |
| 75: { desc: 'Salju Lebat', icon: 'βοΈ' }, | |
| 80: { desc: 'Hujan Lokal', icon: 'π¦οΈ' }, 81: { desc: 'Hujan Sedang', icon: 'π§οΈ' }, | |
| 82: { desc: 'Hujan Deras', icon: 'βοΈ' }, | |
| 95: { desc: 'Badai Petir', icon: 'βοΈ' }, | |
| 96: { desc: 'Badai + Hujan Es', icon: 'π©οΈ' }, 99: { desc: 'Badai + Hujan Es', icon: 'π©οΈ' }, | |
| }; | |
| const DAYS = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu']; | |
| let searchTimeout; | |
| const searchInput = document.getElementById('searchInput'); | |
| const searchResults = document.getElementById('searchResults'); | |
| const app = document.getElementById('app'); | |
| searchInput.addEventListener('input', () => { | |
| clearTimeout(searchTimeout); | |
| const q = searchInput.value.trim(); | |
| if (q.length < 2) { searchResults.classList.remove('active'); return; } | |
| searchTimeout = setTimeout(() => searchCity(q), 400); | |
| }); | |
| searchInput.addEventListener('keydown', (e) => { | |
| if (e.key === 'Enter') { clearTimeout(searchTimeout); const q = searchInput.value.trim(); if (q.length >= 2) searchCity(q); } | |
| }); | |
| document.addEventListener('click', (e) => { if (!e.target.closest('.search-box')) searchResults.classList.remove('active'); }); | |
| async function searchCity(query) { | |
| try { | |
| const res = await fetch('/api/search?q=' + encodeURIComponent(query)); | |
| const data = await res.json(); | |
| if (data.results && data.results.length > 0) { | |
| searchResults.innerHTML = data.results.slice(0, 5).map(r => | |
| '<div class="search-result" data-lat="' + r.latitude + '" data-lon="' + r.longitude + '" data-name="' + r.name + '" data-country="' + (r.admin1 || r.country || '') + '">' + | |
| '<div>' + r.name + '</div><div class="country">' + (r.admin1 ? r.admin1 + ', ' : '') + (r.country || '') + '</div></div>' | |
| ).join(''); | |
| searchResults.classList.add('active'); | |
| searchResults.querySelectorAll('.search-result').forEach(el => { | |
| el.addEventListener('click', () => { | |
| const { lat, lon, name, country } = el.dataset; | |
| searchResults.classList.remove('active'); | |
| searchInput.value = name; | |
| loadWeather(parseFloat(lat), parseFloat(lon), name + ', ' + country); | |
| }); | |
| }); | |
| } else { | |
| searchResults.innerHTML = '<div class="search-result" style="opacity:0.5">Tidak ditemukan</div>'; | |
| searchResults.classList.add('active'); | |
| } | |
| } catch(e) { console.error(e); } | |
| } | |
| function getWmo(code) { return WMO[code] || { desc: 'Tidak diketahui', icon: 'β' }; } | |
| function getVerdict(data) { | |
| const cur = data.current; | |
| const code = cur.weather_code; | |
| const temp = cur.temperature_2m; | |
| const hum = cur.relative_humidity_2m; | |
| const wind = cur.wind_speed_10m; | |
| const uv = cur.uv_index; | |
| // Bad weather | |
| if (code >= 95) return { rating: 'π°', label: 'Cuaca Buruk!', text: 'Badai petir terdeteksi hari ini β disarankan tetap di dalam rumah. Bawa payung dan hindari area terbuka.' }; | |
| if (code >= 80 && code <= 82) return { rating: 'π§οΈ', label: 'Hujan Deras', text: 'Curah hujan cukup tinggi hari ini. Pastikan bawa jas hujan atau payung sebelum bepergian.' }; | |
| if (code >= 61 && code <= 65) return { rating: 'βοΈ', label: 'Hujan', text: 'Cuaca hujan hari ini β jangan lupa bawa payung! Suhu cukup nyaman meskipun berawan.' }; | |
| if (code >= 51 && code <= 55) return { rating: 'π¦οΈ', label: 'Gerimis', text: 'Gerimis ringan hari ini. Hujan nggak deras, tapi payung kecil tetep berguna.' }; | |
| // Great weather | |
| if (code === 0 && temp >= 20 && temp <= 32 && hum < 70 && wind < 20) return { rating: 'βοΈ', label: 'Cuaca Sempurna!', text: 'Langit cerah, suhu nyaman, angin sepoi-sepoi β cuaca ideal buat jalan-jalan atau aktivitas outdoor hari ini!' }; | |
| if (code === 1 && temp >= 18 && temp <= 33) return { rating: 'π€οΈ', label: 'Cuaca Cerah!', text: 'Cuaca bagus hari ini! Langit agak berawan tapi tetap hangat β cocok buat ngopi di luar atau olahraga ringan.' }; | |
| // Okay weather | |
| if (code <= 1) return { rating: 'π', label: 'Cuaca Bagus', text: 'Cuaca cerah dan cukup hangat. Cocok buat aktivitas di luar rumah. Jangan lupa minum air!' }; | |
| if (code === 2) return { rating: 'β ', label: 'Cukup Cerah', text: 'Agak berawan hari ini tapi masih cukup terang buat aktivitas outdoor. Suhu masih nyaman.' }; | |
| if (code === 3) return { rating: 'βοΈ', label: 'Mendung', text: 'Langit mendung hari ini β matahari agak tertutup. Mungkin hujan nanti, siap-siap aja.' }; | |
| if (code >= 45 && code <= 48) return { rating: 'π«οΈ', label: 'Kabut', text: 'Visibilitas rendah karena kabut hari ini. Hati-hati di jalan dan kurangi kecepatan berkendara.' }; | |
| // Hot | |
| if (temp >= 35) return { rating: 'π₯΅', label: 'Sangat Panas!', text: 'Suhu sangat tinggi β hindari aktivitas di luar jam 10-14 dan minum banyak air. Panas ekstrem hari ini!' }; | |
| // Cold | |
| if (temp <= 15) return { rating: 'π₯Ά', label: 'Dingin!', text: 'Cuaca cukup dingin hari ini β pakai jaket dan jangan minum es. Suhu di bawah rata-rata!' }; | |
| // High wind | |
| if (wind >= 40) return { rating: 'π¨', label: 'Angin Kencang', text: 'Angin cukup kencang hari ini β hati-hati benda mudah terbang dan hindari tempat tinggi.' }; | |
| // Default | |
| return { rating: 'π', label: 'Cuaca Normal', text: 'Cuaca hari ini cukup normal β tidak terlalu panas, tidak terlalu dingin. Cocok untuk aktivitas sehari-hari.' }; | |
| } | |
| function formatDay(dateStr) { | |
| const d = new Date(dateStr + 'T00:00:00'); | |
| return DAYS[d.getDay()]; | |
| } | |
| function loadWeather(lat, lon, name) { | |
| app.innerHTML = '<div class="loading"><div class="spinner"></div><div>Loading weather...</div></div>'; | |
| fetch('/api/weather?lat=' + lat + '&lon=' + lon + '&name=' + encodeURIComponent(name)) | |
| .then(r => r.json()) | |
| .then(data => { | |
| if (data.error) throw new Error(data.message || data.error); | |
| renderWeather(data); | |
| }) | |
| .catch(e => { | |
| app.innerHTML = '<div class="error">Gagal memuat data cuaca.<br><small>' + e.message + '</small></div>'; | |
| }); | |
| } | |
| function renderWeather(data) { | |
| const cur = data.current; | |
| const daily = data.daily; | |
| const wmo = getWmo(cur.weather_code); | |
| const name = data.location_name || ''; | |
| const sunrise = daily.sunrise && daily.sunrise[0] ? new Date(daily.sunrise[0]).toLocaleTimeString('id-ID', { hour: '2-digit', minute: '2-digit' }) : 'β'; | |
| const sunset = daily.sunset && daily.sunset[0] ? new Date(daily.sunset[0]).toLocaleTimeString('id-ID', { hour: '2-digit', minute: '2-digit' }) : 'β'; | |
| // OpenMeteo: daily arrays (time, weather_code, etc) β NOT .days | |
| const days = daily.time; | |
| if (!days || days.length === 0) throw new Error('No forecast data'); | |
| app.innerHTML = | |
| '<div class="weather-header glass">' + | |
| '<div class="city-name">' + name + '</div>' + | |
| '<div class="weather-icon">' + wmo.icon + '</div>' + | |
| '<div class="weather-desc">' + wmo.desc + '</div>' + | |
| '<div class="current-temp">' + Math.round(cur.temperature_2m) + 'Β°</div>' + | |
| '<div class="feels-like">Terasa seperti ' + Math.round(cur.apparent_temperature) + 'Β°C</div>' + | |
| '</div>' + | |
| (function() { | |
| var v = getVerdict(data); | |
| return '<div class="glass" style="padding:1.2rem 1.3rem; margin-bottom:1.2rem; text-align:center;">' + | |
| '<div style="font-size:2rem; margin-bottom:0.3rem;">' + v.rating + '</div>' + | |
| '<div style="font-size:1rem; font-weight:700; margin-bottom:0.35rem;">' + v.label + '</div>' + | |
| '<div style="font-size:0.82rem; color:rgba(255,255,255,0.55); line-height:1.5;">' + v.text + '</div>' + | |
| '</div>'; | |
| })() + | |
| '<div class="section-title">Detail</div>' + | |
| '<div class="details">' + | |
| '<div class="detail-card glass"><div class="detail-icon-val">π§</div><div class="detail-value">' + cur.relative_humidity_2m + '%</div><div class="detail-label">Kelembapan</div></div>' + | |
| '<div class="detail-card glass"><div class="detail-icon-val">π¨</div><div class="detail-value">' + Math.round(cur.wind_speed_10m) + '</div><div class="detail-label">Angin (km/h)</div></div>' + | |
| '<div class="detail-card glass"><div class="detail-icon-val">π‘οΈ</div><div class="detail-value">' + Math.round(cur.pressure_msl) + '</div><div class="detail-label">Tekanan (hPa)</div></div>' + | |
| '<div class="detail-card glass"><div class="detail-icon-val">βοΈ</div><div class="detail-value">' + (cur.uv_index ?? 'β') + '</div><div class="detail-label">UV Index</div></div>' + | |
| '<div class="detail-card glass"><div class="detail-icon-val">π </div><div class="detail-value">' + sunrise + '</div><div class="detail-label">Sunrise</div></div>' + | |
| '<div class="detail-card glass"><div class="detail-icon-val">π</div><div class="detail-value">' + sunset + '</div><div class="detail-label">Sunset</div></div>' + | |
| '</div>' + | |
| '<div class="section-title">Ramalan ' + days.length + ' Hari</div>' + | |
| '<div class="glass" style="padding: 0; margin-bottom: 1rem;">' + | |
| '<div class="forecast-grid">' + | |
| days.map(function(day, i) { | |
| var dw = getWmo(daily.weather_code[i]); | |
| var isToday = i === 0; | |
| var style = isToday ? 'background: rgba(167,139,250,0.15); border-color: rgba(167,139,250,0.3);' : ''; | |
| return '<div class="forecast-day" style="' + style + '">' + | |
| '<div class="forecast-name">' + (isToday ? 'Hari ini' : formatDay(day)) + '</div>' + | |
| '<div class="forecast-icon">' + dw.icon + '</div>' + | |
| '<div class="forecast-temp"><span style="color:#f87171;">β' + Math.round(daily.temperature_2m_max[i]) + 'Β°</span></div>' + | |
| '<div class="forecast-temp-low"><span style="color:#60a5fa;">β' + Math.round(daily.temperature_2m_min[i]) + 'Β°</span></div>' + | |
| '</div>'; | |
| }).join('') + | |
| '</div>' + | |
| '</div>'; | |
| } | |
| // Load Jakarta default | |
| loadWeather(-6.2, 106.85, 'Jakarta, Indonesia'); | |
| </script> | |
| </body> | |
| </html> | |