PageSourceSearch

https://gradex.bond/assets/StudentPTest-DOSbH9ZE-v34753.js

js gradex.bond collected 2026-10-02 01:17:59 UTC 6,074 bytes, 2 lines download raw bytes

1import{r as a,j as e}from"./index-C0NzahTm-v34753.js";const i="/api/student-portal",K={maxWidth:520,margin:"0 auto",padding:20,display:"flex",flexDirection:"column",gap:12,fontFamily:"var(--gradex-font-body, system-ui)"},v={width:"100%",padding:"12px 14px",borderRadius:0,border:"1px solid var(--border-color, #333)",background:"var(--card-bg, #111)",color:"var(--text-primary, #f5f5f5)",fontSize:15,boxSizing:"border-box"},p={padding:"12px 16px",borderRadius:0,border:"1px solid #38bdf8",background:"rgba(56,189,248,0.12)",color:"#7dd3fc",fontSize:15,fontWeight:700,cursor:"pointer"},z={...p,border:"1px solid var(--border-color,#333)",background:"transparent",color:"var(--text-secondary,#aaa)"};function H(){var A;const[r,D]=a.useState(""),[u,E]=a.useState(""),[g,S]=a.useState(""),[x,C]=a.useState(""),[w,j]=a.useState(""),[h,f]=a.useState("idle"),[o,l]=a.useState(!1),[P,F]=a.useState([]),[y,$]=a.useState(null),[b,k]=a.useState(!1),[R,L]=a.useState(null),I=a.useRef(null),n=a.useCallback(t=>F(s=>[`${new Date().toLocaleTimeString()} — ${t}`,...s].slice(0,40)),[]),O=a.useCallback(async()=>{l(!0),$(null),f("idle");try{const t=await fetch(`${i}?action=v3-start`).then(s=>s.json());if(!t.success)throw new Error(t.error||"start failed");D(t.stateId),j(`${i}?action=v3-captcha&stateId=${encodeURIComponent(t.stateId)}&t=${Date.now()}`),f("ready"),n("Real browser session started. Solve the captcha below.")}catch(t){n(`ERROR ${t.message}`)}finally{l(!1)}},[n]),T=a.useCallback(async()=>{if(r){l(!0);try{const t=await fetch(`${i}?action=v3-login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stateId:r,username:u,password:g,captcha:x})}).then(s=>s.json());n(`login: ${t.success?"SUCCESS":"FAILED"} — ${t.message||t.portalReason||""}`),t.success?(f("loggedin"),L(Date.now()),S("")):(C(""),j(`${i}?action=v3-captcha&stateId=${encodeURIComponent(r)}&refresh=1&t=${Date.now()}`))}catch(t){n(`ERROR ${t.message}`)}finally{l(!1)}}},[r,u,g,x,n]),m=a.useCallback(async(t=!1)=>{if(r){t||l(!0);try{const s=await fetch(`${i}?action=v3-attendance&stateId=${encodeURIComponent(r)}`).then(N=>N.json());s.success?($(s),n(`attendance OK — ${s.count} courses, reg ${s.regNumber||"?"}, session age ${s.sessionAgeSeconds}s`)):(n(`attendance failed (${s.status||"?"}) — ${s.error}`),s.status===419&&(f("ready"),k(!1)))}catch(s){n(`ERROR ${s.message}`)}finally{t||l(!1)}}},[r,n]);a.useEffect(()=>{if(b&&h==="loggedin")return I.current=setInterval(()=>{n("keep-alive ping…"),m(!0)},5*60*1e3),()=>clearInterval(I.current)},[b,h,m,n]);const U=R?Math.floor((Date.now()-R)/6e4):0;return e.jsx("main",{style:{background:"var(--bg-primary,#000)",color:"var(--text-primary,#f5f5f5)",padding:"24px 0"},children:e.jsxs("div",{style:K,children:[e.jsx("h1",{style:{margin:0,fontSize:24},children:"Student Portal — attendance trial"}),e.jsx("p",{style:{margin:0,color:"var(--text-secondary,#999)",fontSize:13,lineHeight:1.5},children:"Human-in-the-loop login against sp.srmist.edu.in. You solve your own captcha; nothing is auto-solved. After login it holds the session cookie and can refresh attendance in the background."}),h==="idle"&&e.jsx("button",{style:p,onClick:O,disabled:o,children:o?"Loading…":"Start — load login page"}),h==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{style:v,placeholder:"NetID / username",value:u,onChange:t=>E(t.target.value),autoCapitalize:"none"}),e.jsx("input",{style:v,type:"password",placeholder:"Password",value:g,onChange:t=>S(t.target.value)}),w&&e.jsx("img",{src:w,alt:"captcha",style:{alignSelf:"flex-start",border:"1px solid #333"}}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{style:{...v,flex:1},placeholder:"Captcha text",value:x,onChange:t=>C(t.target.value)}),e.jsx("button",{style:z,onClick:()=>j(`${i}?action=v3-captcha&stateId=${encodeURIComponent(r)}&refresh=1&t=${Date.now()}`),children:"↻"})]}),e.jsx("button",{style:p,onClick:T,disabled:o||!u||!g||!x,children:o?"Logging in…":"Log in"})]}),h==="loggedin"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:12,border:"1px solid rgba(74,222,128,0.35)",background:"rgba(74,222,128,0.08)",color:"#4ade80",fontSize:14},children:["Logged in · session age ~",U," min"]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx("button",{style:p,onClick:()=>m(!1),disabled:o,children:o?"Fetching…":"Fetch attendance"}),e.jsx("button",{style:b?p:z,onClick:()=>k(t=>
1!t),children:b?"Keep-alive ON (5 min)":"Keep-alive OFF"})]})]}),((A=y==null?void 0:y.courses)==null?void 0:A.length)>0&&e.jsx("div",{style:{overflowX:"auto",border:"1px solid var(--border-color,#333)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"rgba(255,255,255,0.04)"},children:[e.jsx("th",{style:c,children:"Code"}),e.jsx("th",{style:c,children:"Course"}),e.jsx("th",{style:c,children:"Cond."}),e.jsx("th",{style:c,children:"Att."}),e.jsx("th",{style:c,children:"Abs."}),e.jsx("th",{style:c,children:"%"})]})}),e.jsx("tbody",{children:y.courses.map((t,s)=>e.jsxs("tr",{style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("td",{style:d,children:t.courseCode}),e.jsx("td",{style:d,children:t.courseTitle}),e.jsx("td",{style:d,children:t.hoursConducted}),e.jsx("td",{style:d,children:t.hoursAttended}),e.jsx("td",{style:d,children:t.hoursAbsent}),e.jsxs("td",{style:{...d,fontWeight:700,color:Number(t.attendancePercentage)>=75?"#4ade80":"#f87171"},children:[t.attendancePercentage,"%"]})]},s))})]})}),e.jsxs("details",{open:!0,style:{marginTop:8},children:[e.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary,#999)",fontSize:13},children:"Log"}),e.jsx("pre",{style:{fontSize:11,lineHeight:1.6,color:"var(--text-secondary,#888)",whiteSpace:"pre-wrap",margin:"8px 0 0"},children:P.join(`
2`)})]})]})})}const c={textAlign:"left",padding:"8px 10px",fontSize:11,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-secondary,#999)"},d={padding:"8px 10px"};export{H as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.