Download assets/js/admin.js from stat2025/psrc2: direct link, hf CLI and curl.
- Browser
- Download file 3.63 kB
-
https://huggingface.co/spaces/stat2025/psrc2/resolve/main/assets/js/admin.js
- Command line
-
hf download hf://spaces/stat2025/psrc2/assets/js/admin.js
-
curl -L -o admin.js https://huggingface.co/spaces/stat2025/psrc2/resolve/main/assets/js/admin.js
3.63 kB
| (() => { | |
| const rows=document.getElementById("adminRows");if(!rows)return;let filter="all"; | |
| const txt=s=>s==="present"?"حاضر":s==="absent"?"غائب":"انصراف"; | |
| function render(){ | |
| const s=Eefaa360.getState().students,p=s.filter(x=>x.attendance==="present").length,a=s.filter(x=>x.attendance==="absent").length,l=s.filter(x=>x.attendance==="left").length,n=s.filter(x=>x.parentNotified).length,pct=Math.round(p/s.length*100); | |
| document.querySelector("[data-a-total]").textContent=s.length;document.querySelector("[data-a-present]").textContent=p;document.querySelector("[data-a-absent]").textContent=a;document.querySelector("[data-a-left]").textContent=l;document.querySelector("[data-a-notified]").textContent=n;document.querySelector("[data-ring-value]").textContent=pct+"%";document.querySelector(".attendance-ring").style.setProperty("--pct",pct); | |
| const data=filter==="all"?s:s.filter(x=>x.attendance===filter); | |
| rows.innerHTML=data.map(x=>`<div class="admin-row"><div class="person-cell"><div class="avatar sm">${x.name[0]}${x.name.split(" ")[1]?.[0]||""}</div><div><strong>${x.name}</strong><span>${x.program}</span></div></div><span class="status-pill ${x.attendance}">${txt(x.attendance)}</span><span class="row-time">${x.time||"—"}</span><span class="notify-state">${x.parentNotified?"تم الإشعار ✓":"—"}</span></div>`).join(""); | |
| const vals=[82,86,79,91,88,84,pct];document.querySelectorAll(".week-bar").forEach((b,i)=>b.style.height=vals[i]+"%"); | |
| } | |
| document.querySelectorAll("[data-filter]").forEach(btn=>btn.addEventListener("click",()=>{filter=btn.dataset.filter;document.querySelectorAll("[data-filter]").forEach(b=>b.classList.remove("active"));btn.classList.add("active");render()})); | |
| render();window.addEventListener("eefaa:update",render);window.addEventListener("storage",render); | |
| })(); | |
| (()=>{const ranges={today:{b:86,p:74,s:18,c:14,n:11,i:5,r:'86%',bars:[72,82,76,90,86]},week:{b:86,p:79,s:82,c:73,n:47,i:7,r:'91%',bars:[86,89,92,90,91]},month:{b:91,p:84,s:326,c:302,n:181,i:9,r:'92%',bars:[88,91,93,92,94]}};const set=(id,v)=>{const e=document.getElementById(id);if(e)e.textContent=v};document.querySelectorAll('.filter-btn').forEach(btn=>btn.addEventListener('click',()=>{document.querySelectorAll('.filter-btn').forEach(b=>b.classList.remove('active'));btn.classList.add('active');const d=ranges[btn.dataset.range];set('kpi-beneficiaries',d.b);set('kpi-present',d.p);set('kpi-sessions',d.s);set('kpi-completed',d.c);set('kpi-notices',d.n);set('kpi-intervention',d.i);set('attendance-rate',d.r);document.querySelectorAll('#attendance-bars i').forEach((bar,i)=>bar.style.setProperty('--h',d.bars[i]+'%'));}));document.querySelectorAll('.legend-item').forEach(btn=>btn.addEventListener('click',()=>{document.querySelectorAll('.legend-item').forEach(b=>b.classList.remove('active'));btn.classList.add('active');const type=btn.dataset.clinic;document.querySelectorAll('.session-row').forEach(row=>row.style.display=(type==='all'||row.dataset.type===type)?'grid':'none');}));const tog=document.getElementById('toggle-all-sessions');if(tog)tog.addEventListener('click',()=>{const ex=[...document.querySelectorAll('.session-row.extra')];const showing=ex.some(x=>getComputedStyle(x).display!=='none');ex.forEach(x=>x.style.display=showing?'none':'grid');tog.textContent=showing?'عرض الكل':'عرض المختصر';});const s=document.getElementById('beneficiary-search');if(s)s.addEventListener('input',()=>{const q=s.value.trim();document.querySelectorAll('.beneficiary-row').forEach(r=>r.style.display=r.textContent.includes(q)?'grid':'none');});})(); | |