forked from maebert/themostdangerouswritingapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
2 lines (2 loc) · 3.26 KB
/
main.js
1
2
(function(){var e,t,n,o,l,u,r,c,i,s,d,a,m,y,h,g,p,f,w,I,v,B,b,E,k=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};d=300,p=d,f=0,g=document.getElementById("time"),u=document.getElementById("input"),s=!1,w=null,c=0,b=/Digit.|Key.|Space|Backspace|Bracket.+|Enter|Semicolon|Quote|Backquote|Backslash|Comma|Period|Slash|Numpad.+/,B=[13,32,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,186,187,188,189,190,191,222],r=5,t=3,n=function(e){var t;return t=function(e){var t;return t=""+Math.floor(e),1===t.length?"0"+t:t},t(Math.floor(e/60))+":"+t(e%60)},I=function(){return g.innerHTML=n(p)},v=function(){var e,t,n;return e=u.value.length,t=u.value.split(" ").length,n=Math.floor(60*t/(d-p)),.1>=p%1?c=n:n=c,document.getElementById("stats").innerHTML=e+"c "+t+"w "+n+"wpm"},e=function(){var e,t;return t=u.value.split(" ").length,e=n(d-p),u.value="",u.placeholder="",clearInterval(w),s=!1,document.getElementById("tweet").href="https://twitter.com/intent/tweet?text=I+wrote+"+t+"+words+in+"+e+"+minutes+-+and+then+I+died+using+The+Most+Dangerous+Writing+App+%23MDWA&url=http%3A%2F%2Fwww.themostdangerouswritingapp.com",document.getElementById("tweet").innerHTML="I wrote "+t+" words in "+e+" minutes - and then I died using The Most Dangerous Writing App #MDWA",a("die"),a("logo")},E=function(){return clearInterval(w),s=!1,a("win_button"),l("time")},h=function(){var n;return p-=.1,f+=.1,I(),v(),0>=p?E():f>r?e():f>t?(n=(f-t)/(r-t),u.style.opacity=1-n,document.body.style.boxShadow="inset 0px 0px "+Math.floor(100*n)+"px 0px rgba(242, 77, 77, "+.7*n+")"):void 0},y=function(e){var t;if(!(e.keyCode&&(t=e.keyCode,k.call(B,t)<0))&&(!e.code||e.code.match(b)))return f=0,s?(u.style.opacity=1,document.body.style.boxShadow="none"):(s=!0,w=setInterval(h,100))},u.onkeydown=y,o=function(e){return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():void 0},l=function(e){var t;return t=document.getElementById(e).style.display="none",document.getElementById("status").style.opacity=1},a=function(e){return document.getElementById(e).style.display="block"},m=function(){return u.value="",g.style.display="inline",u.disabled=!1,u.style.opacity=1,document.body.style.boxShadow="none",p=d,I(),u.placeholder="Start typing...",document.getElementById("status").style.opacity=1,document.getElementById("status_lower").style.opacity=1,l("logo"),l("start"),l("win_button"),u.focus()},i=function(){return console.log("qwe"),document.getElementById("stats").innerHTML="",document.body.style.boxShadow="none",l("time"),a("start"),l("die"),u.disabled=!0},document.getElementById("start_button").onclick=function(){var e;return d=parseInt(function(){var t,n,o,l;for(o=document.getElementsByClassName("select_time"),l=[],t=0,n=o.length;n>t;t++)e=o[t],e.checked&&l.push(e);return l}()[0].value),m()},document.getElementById("show_help").onclick=function(){return a("help")},document.getElementById("hide_help").onclick=function(){return l("help")},document.getElementById("retry_button").onclick=i,document.getElementById("win_button").onclick=i}).call(this);
//# sourceMappingURL=./main.js.map