-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbqncrate.js
23 lines (23 loc) · 1.08 KB
/
bqncrate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
C=_=>F(history.replaceState({},document.title,location.pathname+(q.value?"?q="+encodeURIComponent(q.value):"")))
F=_=>q.focus()
I=_=>{
var s=new URLSearchParams(location.search)
b.className=0==s.get("w")?"w":0==s.get("b")?"b":""
um.href="quiz?"+b.className
fetch("table.tsv").then(d=>d.text()).then(d=>{
ps=d.replace(/[<>&'"]/g,x=>({'<':'<','>':'>','&':'&',"'":''','"':'"'}[x])).split(/\r?\n/g).slice(1,-1).map(r=>r.split("\t"))
c=ps.map(r=>r[0])
e=ps.map(r=>r[1])
p=d.split(/\r?\n/g).slice(1,-1).map(x=>x.toLowerCase().replace(/http\S+\t/,"(>)").replace(/http\S+$/,"(?)"))
r=""
for(var i=0;i<c.length;i++){r+='<tr><td>'+c[i]+'</td><td>'+e[i]+'</td></tr>'}
t.innerHTML=r
F(Q(q.value=s.get("q")))})}
Q=_=>{
var f,l=q.value.toLowerCase().split(' '),r=t.rows,n=0
for(var i=0;i<r.length;i++){
for(var j=0;j<l.length;j++){f=p[i].indexOf(l[j])>-1;if(!f)break}
n+=!(r[i].hidden=!f)}
z.textContent="Showing "+n+" of "+r.length}
W=x=>{F(b.className=x?x:"wbg"[1+"wb".indexOf(b.className[0])]);um.href="quiz?"+b.className}
X=_=>F(Q(q.value=""))