-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.js
More file actions
1 lines (1 loc) · 2.02 KB
/
index.js
File metadata and controls
1 lines (1 loc) · 2.02 KB
1
(()=>{var U="https://ifct2017.deno.dev";var _=ifct2017.columns,I=ifct2017.hierarchy,P=ifct2017.intakes,L=ifct2017.methods,O=ifct2017.nutrients,j=ifct2017.representations;function b(t){return location.href=location.origin+t+location.hash}function C(){console.log("setupForms()");for(var t=document.querySelectorAll("form [type=submit]"),e=0,r=t.length;e<r;e++)t[e].onclick=function(){this.form.submitted=this.name}}function f(){$(this).text()||$(this).triggerHandler(jQuery.Event("keyup",{keyCode:65,which:65}))}function w(t=!1){console.log("setupQueryAutocomplete()"),$("#text").on("keydown",function(e){e.keyCode===13&&(e.preventDefault(),$("form").submit())}),$("#text").easyAutocomplete({url:function(e){return U+"/api/query/search?text="+encodeURIComponent(e)},getValue:function(e){return e.text},list:{onClickEvent:function(){$("form").submit()}}}).click(f).change(f),t&&f.call(document.querySelector("#text"))}function E(){let t=document.createElement("canvas");document.body.appendChild(t);let e=t.getContext("2d"),r,s,l,p,d=0,h=0,m=20,i=0,v=()=>{r=t.width=window.innerWidth,s=t.height=window.innerHeight,l=r/2,p=s/2},x=n=>{let a=n.touches?n.touches[0].clientX:n.clientX,o=n.touches?n.touches[0].clientY:n.clientY;d=a,h=o};window.addEventListener("resize",v),window.addEventListener("mousemove",x),window.addEventListener("touchmove",x),v();let g=()=>{i+=.005,e.fillStyle="white",e.fillRect(0,0,r,s);let n=.1*l+(d-l)*.1,a=.1*p+(h-p)*.1,o=60+5*Math.sin(i*2);e.beginPath(),e.arc(n,a,o,0,Math.PI*2),e.fillStyle="yellow",e.fill();for(let u=0;u<m;u++){let c=u/m*Math.PI*2+i,y=90+10*Math.sin(i*4+u),S=n+Math.cos(c)*(o+5),M=a+Math.sin(c)*(o+5),T=n+Math.cos(c)*(o+y),A=a+Math.sin(c)*(o+y);e.strokeStyle="rgba(255, 215, 0, 0.6)",e.lineWidth=3,e.beginPath(),e.moveTo(S,M),e.lineTo(T,A),e.stroke()}requestAnimationFrame(g)};g()}function R(t){var e=t.target.submitted;console.log("onSubmit()",e);var r=document.getElementById("text").value;return b("/data/query?text="+r),!1}function N(){console.log("setup()"),$("form").submit(R),w(!1),C(),E()}$(document).ready(N);})();