Skip to content

Instantly share code, notes, and snippets.

@jeff-hykin
Created July 28, 2024 05:02
Show Gist options
  • Save jeff-hykin/4cdebafd8698298d021f103e22a2b98a to your computer and use it in GitHub Desktop.
Save jeff-hykin/4cdebafd8698298d021f103e22a2b98a to your computer and use it in GitHub Desktop.
var B=BigInt,s=[],u=B(0)
Deno.serve(r=>(!r.url.endsWith("w")&&new Response(`<body><script>d=document
m=Math
c="createElement"
a="appendChild"
o=d[c]("div")
i=d[c]("div")
o.style="height:80vh;overflow:auto"
o[a](i)
d.body[a](o)
B=BigInt
y=14
x=50
i.style="height:"+y*1000000/x+"px;position:relative"
u=B("${u}")
ws=new WebSocket(d.URL+"w")
;(ws.onmessage=o.onscroll=e=>{e?.data&&(u=B(e.data))
t=m.floor((o.scrollTop/y))
b=m.ceil((o.scrollTop+o.clientHeight)/y)
i.innerHTML="";[...Array(m.ceil(x*(b-t)))].map(
(h,k)=>{
l=t*x+k
r=m.floor(l/x)
k=l%x
h=d[c]("input")
h.style=\`position:absolute;top:\${r*y}px;left:\${k*14}px\`
k=l
h.type="checkbox"
h.checked=u&(1n<<B(k))
h.onchange=_=>(_.target.checked?u|=(1n<<B(k)):u&=~(1n<<B(k)),ws.send(\`\${u}\`))
i[a](h)})})()</script>`,{headers:{"content-type":"html"}})||(r=Deno.upgradeWebSocket(r),s.push(r.socket),r.socket.onmessage=e=>(s.map(_=>{try{_.send(e.data)}catch{}}),u=B(e.data)),r.response)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment