-
Notifications
You must be signed in to change notification settings - Fork 0
/
wjs.min.js
1 lines (1 loc) · 34.4 KB
/
wjs.min.js
1
var _ajax=function(e,t,n,i){var r,a,o,s,c,d,u,l,m;if("object"==typeof e){var f=e;for(r in f)switch(r){case"uri":case"url":e=f[r];break;case"data":t=f[r];break;case"method":n=f[r];break;case"after":i=f[r];break;case"success":s=f[r];break;case"error":o=f[r];break;case"progress":a=f[r];break;case"opened":c=f[r];break;case"headers_received":f[r];break;case"loading":d=f[r];break;case"before":f[r];break;case"upload":u=f[r];break;case"timeout":l=f[r];break;case"header":m=f[r]}}void 0===m&&(m={"Content-type":"application/x-www-form-urlencoded"});var h=function(){var e=null;try{window.ActiveXObject?e=new ActiveXObject("Microsoft.XMLHTTP"):window.XMLHttpRequest&&(e=new XMLHttpRequest)}catch(e){return err.log(e.message),null}return e}();if("object"==typeof t){var p="";for(r in t)""!==p&&(p+="&"),p+=r+"="+encodeURI(t[r]);t=p}for(r in"function"==typeof t?(i=t,n="GET",t=""):"function"==typeof n&&(i=n,n="POST"),void 0===e&&(e=e.href()),void 0===n&&void 0!==t&&(n="POST"),void 0===n&&void 0===t&&(n="GET"),h.open(n,e,!0),m)h.setRequestHeader(r,m[r]);void 0!==l&&(h.timeout=function(e){l.bind(h,e)()}),void 0!==u&&(h.upload=function(e){u.bind(h,e)()}),void 0!==a&&(h instanceof window.XMLHttpRequest&&(h.onprogress=function(e){a.bind(h,e)()}),h.upload&&(h.upload.onprogress=function(e){a.bind(h,e)()})),h.onreadystatechange=function(e){4==h.readyState&&200==h.status?void 0!==s?s.bind(h,e)():void 0!==i&&i.bind(h,e)():4==h.readyState?void 0!==o?o.bind(h,e)():void 0!==i&&i.bind(h,e)():3==h.readyState?void 0!==d&&d.bind(h,e)():2==h.readyState?void 0!==c&&c.bind(h,e)():1==h.readyState&&void 0!==c&&c.bind(h,e)()},void 0===t||"GET"==n?h.send():h.send(t)},_array=function(e){return new function(e){this.object=e,this.dump=function(){var e="";for(var t in this.object)e+=t+": "+this.object[t]+"\n";return e},this.each=function(e){this.object.forEach(function(t){e.bind(t)()})},this.indexOf=function(t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1},this.unique=function(){for(var t=e.concat(),n=0;n<t.length;++n)for(var i=n+1;i<t.length;++i)t[n]===t[i]&&t.splice(i--,1);return t}}(e)},_clipboard={mode:null,available:{api:!1,clipboardData:!1,execCommand:!1},init:function(){if(window.clipboardData&&window.clipboardData.setData?_clipboard.available.clipboardData=!0:document.queryCommandSupported("copy")&&(_clipboard.available.execCommand=!0),_clipboard.setMode(),"clipboardData"!=_clipboard.mode)try{void 0!==typeof navigator.clipboard.readText&&navigator.permissions.query({name:"clipboard-read"}).then(function(e){"granted"==e.state?_clipboard.available.api=!0:"denied"==e.state&&(_clipboard.available.api=!1),_clipboard.setMode(),e.onchange=function(){"granted"==e.state?_clipboard.available.api=!0:"denied"==e.state&&(_clipboard.available.api=!1),_clipboard.setMode()}})}catch(e){}},setMode:function(e){void 0===e?_clipboard.available.api?_clipboard.mode="api":_clipboard.available.clipboardData?_clipboard.mode="clipboardData":_clipboard.available.execCommand?_clipboard.mode="execCommand":_clipboard.mode="prompt":this.mode=e},text:function(e){if(void 0===e){switch(this.mode){case"api":err.log("_clipboard.text in mode api is available only async, use _clipboard.read(func) instead");break;case"clipboardData":e=clipboardData.getData("Text");break;case"execCommand":(t=document.createElement("textarea")).style.position="fixed",document.body.appendChild(t),t.focus();try{document.execCommand("paste"),e=t.value}catch(e){prompt("_clipboard.text failed, ctrl+v now for paste manually","")}finally{document.body.removeChild(t)}break;case"prompt":prompt("ctrl+v now for paste manually","")}return e}switch(this.mode){case"api":navigator.clipboard.writeText(e);break;case"clipboardData":clipboardData.setData("Text",e);break;case"execCommand":var t;(t=document.createElement("textarea")).textContent=e,document.body.appendChild(t),t.select();try{document.execCommand("copy")}catch(t){prompt("clipboard.text failed, ctrl+c or ctrl+x now for copy manually",e)}finally{document.body.removeChild(t)}break;case"prompt":prompt("ctrl+c or ctrl+x now for copy manually",e)}},read:function(e){if("api"==this.mode)navigator.clipboard.readText().then(function(t){e(t)});else{var t=_clipboard.text();e(t)}},write:function(e){_clipboard.text(e)}};_clipboard.init();var _dom=function(e,t,n){return new function e(t,n,i){void 0===n&&(n=!1),void 0===i&&(i=0),!1===t||null==t?this.elems=[]:"object"==typeof t?Array.isArray(t)?this.elems=t:(this.elems=[],this.elems.push(t)):this.elems=_dom.querySelectorAllWithEq(t,document),this.length=this.elems.length,this.delegate=function(n,i){return _dom.onFunctions[_dom(document).path+".on:delegate"+n]=function(n){for(var r=n.target;r&&r!=this;r=r.parentNode)if(r.matches(t)){i.call(new e(r),n);break}},document.addEventListener(n,_dom.onFunctions[_dom(document).path+".on:delegate"+n],!1),this},this.delegateOff=function(e){return document.removeEventListener(e,_dom.onFunctions[_dom(document).path+".on:delegate"+e],!1),this},0!==this.length?(this.elem=this.elems[i],this.index=i,this.each=function(n){var i=this;if(void 0===n)return new e(t,!0);this.elems.forEach(function(e){n.bind(i)()})},this.path=function(){for(var e=this.elem.nodeName,t=this.elem,n=this.elem.parentNode;n;){for(var i in n.children)n.children[i]==t&&(e=n.nodeName+"["+i+"]/"+e);t=n,n=n.parentNode}return e},this.is=function(e){if(n){var t=!0;return this.elems.forEach(function(n){(n.matches||n.matchesSelector||n.msMatchesSelector||n.mozMatchesSelector||n.webkitMatchesSelector||n.oMatchesSelector).call(n,e)||(t=!1)}),t}return(this.elem.matches||this.elem.matchesSelector||this.elem.msMatchesSelector||this.elem.mozMatchesSelector||this.elem.webkitMatchesSelector||this.elem.oMatchesSelector).call(this.elem,e)},this.filter=function(t,n){var i=[];for(var r in this.elems)"function"==typeof t?t.bind(new e(this.elems[r]),r)()&&i.push(this.elems[r]):_dom(this.elems[r]).is(t)&&i.push(this.elems[r]);return new e(i,n)},this.siblings=function(t){var n=Array.prototype.filter.call(this.elem.parentNode.children,function(e){return e!==this.elem});return n=new e(n,!0),void 0!==t&&(n=n.filter(t)),n},this.first=function(){return new e(this.elem)},this.last=function(){return new e(this.elems[this.elems.length-1])},this.eq=function(t){return new e(this.elems[t])},this.parent=function(){return new e(this.elem.parentNode)},this.prev=function(){return new e(this.elem.previousElementSibling)},this.next=function(){return new e(this.elem.nextElementSibling)},this.children=function(t){if(n){var i=[];return this.elems.forEach(function(e){i=i.concat([].slice.call(e.children))}),new e(i,!0)}return void 0===t&&(t=0),t<0&&(t=this.elem.children.length+t),!0===t?new e([].slice.call(this.elem.children),!1,t):new e([].slice.call(this.elem.children),!0)},this.find=function(t,i){if(n){var r=[];return this.elems.forEach(function(e){r=r.concat(_dom.querySelectorAllWithEq(t,e))}),new e(r,i)}return new e(_dom.querySelectorAllWithEq(t,this.elem),i)},this.clone=function(){return this.elem.cloneNode(!0)},this.before=function(e){return this.elem.insertAdjacentElement("beforebegin",e),this},this.after=function(e){return this.elem.insertAdjacentElement("afterend",e),this},this.remove=function(){return n?this.elems.forEach(function(e){e.parentNode.removeChild(e)}):this.elem.parentNode.removeChild(this.elem),_dom()},this.empty=function(){if(n)this.elems.forEach(function(e){for(;e.firstChild;)e.removeChild(e.firstChild)});else for(;this.elem.firstChild;)this.elem.removeChild(this.elem.firstChild);return this},this.append=function(e){return n?this.elems.forEach(function(t){t.innerHTML+=e}):this.elem.innerHTML+=e,this},this.prepend=function(e){return n?this.elems.forEach(function(t){t.innerHTML=e+t.innerHTML}):this.elem.innerHTML=e+this.elem.innerHTML,this},this.html=function(e){if(n)this.elems.forEach(function(t){t.innerHTML=e});else{if(void 0===e)return this.elem.innerHTML;this.elem.innerHTML=e}return this},this.text=function(e){if(n)this.elems.forEach(function(t){t.textContent=e});else{if(void 0===e)return this.elem.textContent;this.elem.textContent=e}return this},this.outer=function(e){if(n)this.elems.forEach(function(t){t.outerHTML=e});else{if(void 0===e)return this.elem.outerHTML;this.elem.outerHTML=e}return this},this.attr=function(e,t){if(n)this.elems.forEach(function(n){n.setAttribute(e,t)});else{if(void 0===t)return this.elem.getAttribute(e);this.elem.setAttribute(e,t)}return this},this.data=function(e,t){if(n)this.elems.forEach(function(n){n.setAttribute("data-"+e,t)});else{if(void 0===t)return this.elem.getAttribute("data-"+e);this.elem.setAttribute("data-"+e,t)}return this},this.removeAttr=function(e){return n?this.elems.forEach(function(t){t.removeAttr(e)}):this.elem.removeAttr(e),this},this.css=function(e,t){function i(e,t,n){if(void 0===n&&"string"==typeof t)return window.getComputedStyle(e)[t];if("string"==typeof t)e.style[t]=n;else if("object"==typeof t)for(var i in t)e.style[i]=t[i]}return n?this.elems.forEach(function(n){i(n,e,t)}):i(this.elem,e,t),this},this.offset=function(){return this.elem.getBoundingClientRect()},this.height=function(e){if(n)this.elems.forEach(function(t){t.style.height=e+"px"});else{if(void 0===e)return parseFloat(window.getComputedStyle(this.elem,null).height.replace("px",""));this.elem.style.height=e+"px"}return this},this.width=function(e){if(n)this.elems.forEach(function(t){t.style.width=e+"px"});else{if(void 0===e)return parseFloat(window.getComputedStyle(this.elem,null).width.replace("px",""));this.elem.style.width=e+"px"}return this},this.on=function(t,i){function r(t,n,i){void 0!==_dom.onFunctions[_dom(t).path+".on"+n]&&_dom(t).off(n),_dom.onFunctions[_dom(t).path+".on"+n]=i.bind(new e(t)),t.addEventListener?t.addEventListener(n,_dom.onFunctions[_dom(t).path+".on"+n],!1):t.attachEvent&&t.attachEvent("on"+n,_dom.onFunctions[_dom(t).path+".on"+n])}return n?this.elems.forEach(function(e){r(e,t,i)}):r(this.elem,t,i),this},this.off=function(e){function t(e,t){void 0!==_dom.onFunctions[_dom(e).path+".on"+t]&&(e.removeEventListener?e.removeEventListener(t,_dom.onFunctions[_dom(e).path+".on"+t],!1):e.detachEvent&&e.detachEvent("on"+t,_dom.onFunctions[_dom(e).path+".on"+t]),_dom.onFunctions[_dom(e).path+".on"+t]=void 0)}return n?this.elems.forEach(function(n){t(n,e)}):t(this.elem,e),this},this.trigger=function(e){var t;function i(e,t,n){document.createEvent?e.dispatchEvent(n):e.fireEvent("on"+n.eventType,n)}return document.createEvent?((t=document.createEvent("HTMLEvents")).initEvent(e,!0,!0),t.eventName=e):((t=document.createEventObject()).eventName=e,t.eventType=e),n?this.elems.forEach(function(e){i(e,0,t)}):i(this.elem,0,t),this},this.className=function(e){if(n)this.elems.forEach(function(t){t.className=e});else{if(void 0===e)return this.elem.className;this.elem.className=e}return this},this.hasClass=function(e){if(n){var t=!0;return this.elems.forEach(function(n){n.classList.contains(e)||(t=!1)}),t}return this.elem.classList.contains(e)},this.toggleClass=function(e){return n?this.elems.forEach(function(t){t.classList.toggle(e)}):this.elem.classList.toggle(e),this},this.addClass=function(e){return n?this.elems.forEach(function(t){t.classList.add(e)}):this.elem.classList.add(e),this},this.removeClass=function(e){return n?this.elems.forEach(function(t){t.classList.remove(e)}):this.elem.classList.remove(e),this},this.hide=function(){return n?this.elems.forEach(function(e){e.style.display="none"}):this.elem.style.display="none",this},this.show=function(){return n?this.elems.forEach(function(e){e.style.display=""}):this.elem.style.display="",this},"function"==typeof _ajax&&(this.load=function(e,t,i){var r=this.elem,a=this.elems;return _ajax(e,t,i,function(){var e=this.responseText;n?a.forEach(function(t){t.innerHTML=e}):r.innerHTML=e}),this})):(this.elem=void 0,this.index=null,this.each=function(e){return this},this.path=function(){return this},this.is=function(e){return this},this.filter=function(e){return this},this.siblings=function(e){return this},this.first=function(){return this},this.last=function(){return this},this.eq=function(e){return this},this.parent=function(){return this},this.prev=function(){return this},this.next=function(){return this},this.children=function(e){return this},this.find=function(e,t){return this},this.clone=function(){return this},this.before=function(e){return this},this.after=function(e){return this},this.remove=function(){return this},this.empty=function(){return this},this.append=function(e){return this},this.prepend=function(e){return this},this.html=function(e){return this},this.text=function(e){return this},this.outer=function(e){return this},this.attr=function(e,t){return this},this.data=function(e,t){return this},this.removeAttr=function(e){return this},this.css=function(e,t){return this},this.offset=function(){return this},this.height=function(e){return this},this.width=function(e){return this},this.on=function(e,t){return this},this.off=function(e){return this},this.trigger=function(e){return this},this.className=function(e){return this},this.hasClass=function(e){return this},this.toggleClass=function(e){return this},this.addClass=function(e){return this},this.removeClass=function(e){return this},this.hide=function(){return this},this.show=function(){return this},"function"==typeof _ajax&&(this.load=function(e,t,n){return this}))}(e,t,n)};_dom.querySelectorAllWithEq=function(e,t){void 0===t&&(t=document);for(var n=e,i=n.indexOf(":eq(");-1!==i;){var r=n.substring(0,i),a=n.indexOf(")",i),o=n.substring(i+4,a);o=parseInt(o,10);var s=t.querySelectorAll(r);if(o>=0){if(o>=s.length)return[];t=s[o]}else{if((o=s.length+o)>=s.length)return[];t=s[o]}">"===(n=n.substring(a+1).trim()).charAt(0)&&(n=n.substring(1).trim()),i=n.indexOf(":eq(")}return""!==n?Array.from(t.querySelectorAll(n)):[t]},_dom.start=[],_dom.visibilityChange=[],_dom.onFunctions=[],_dom.isVisible=!0,_dom.isLoaded=!1,_dom.onLoad=function(){for(var e=0;e<_dom.start.length;e++)_dom.start[e]();_dom.isLoaded=!0,_dom.isPrivateProc(function(e){_dom.isPrivate=e})},_dom.onVisibilityChange=function(e){var t=!0;if(!e)throw new Error("no callback given");function n(){t||e(t=!0)}function i(){t&&e(t=!1)}"hidden"in document&&document.addEventListener("visibilitychange",function(){(document.hidden?i:n)()}),"mozHidden"in document&&document.addEventListener("mozvisibilitychange",function(){(document.mozHidden?i:n)()}),"webkitHidden"in document&&document.addEventListener("webkitvisibilitychange",function(){(document.webkitHidden?i:n)()}),"msHidden"in document&&document.addEventListener("msvisibilitychange",function(){(document.msHidden?i:n)()}),"onfocusin"in document&&(document.onfocusin=n,document.onfocusout=i),window.onpageshow=window.onfocus=n,window.onpagehide=window.onblur=i},_dom.isPrivateProc=function(e){var t,n=e.bind(null,!0),i=e.bind(null,!1);window.webkitRequestFileSystem?webkitRequestFileSystem(0,0,i,n):"MozAppearance"in document.documentElement.style?((t=indexedDB.open("test")).onerror=n,t.onsuccess=i):/constructor/i.test(window.HTMLElement)||window.safari?function(){try{localStorage.length?i():(localStorage.x=1,localStorage.removeItem("x"),i())}catch(e){navigator.cookieEnabled?n():i()}}():window.indexedDB||!window.PointerEvent&&!window.MSPointerEvent?i():n()},_dom.isPrivate=!1,_dom.isMobile=/Mobi/.test(navigator.userAgent),_dom.framed=!1,_dom.ready=function(e){return _dom.isLoaded?e():_dom.start.push(e),_dom},_dom.visibility=function(e){return _dom.visibilityChange.push(e),_dom},_dom.on=function(e,t){switch(e.toUpperCase()){case"READY":_dom.ready(t);break;case"VISIBILITY":_dom.visibility(t)}return _dom},_dom.addScript=function(e,t){if("object"==typeof e)return e.forEach(function(e){_dom.addScript(e)}),_dom;var n=document.createElement("script");return n.src=e,void 0!==t&&(n.onload=t,n.onreadystatechange=t),document.head.appendChild(n),_dom},_dom.addCss=function(e){if("object"==typeof e)return e.forEach(function(e){_dom.addCss(e)}),_dom;var t=document.createElement("link");return t.rel="stylesheet",t.href=e,document.head.appendChild(t),_dom},_dom.removeCss=function(e){return"object"==typeof e?(e.forEach(function(e){_dom.removeCss(e)}),_dom):(_dom('link[rel="stylesheet"]').each(function(){-1===this.href.indexOf(identifier)||this.parentNode.removeChild(el)}),_dom)},_dom.replaceCss=function(e,t){return _dom('link[rel="stylesheet"]').each(function(){-1===this.href.indexOf(e)||(this.href=t)}),_dom},_dom.reloadCss=function(e){return"object"==typeof url?(url.forEach(function(e){_dom.reloadCss(e)}),_dom):(_dom('link[rel="stylesheet"]').each(function(){if(void 0!==e){if(-1!==this.href.indexOf(e))return void(this.href=this.href)}else this.href=this.href}),_dom)},_dom.parse=function(e){var t=document.implementation.createHTMLDocument();return t.body.innerHTML=e,t.body.children};try{_dom.framed=window.self!==window.top}catch(e){_dom.framed=!0}if(_dom.onVisibilityChange(function(e){_dom.isVisible=e;for(var t=0;t<_dom.visibilityChange.length;t++)_dom.visibilityChange[t](e)}),window.attachEvent)window.attachEvent("onload",dom.onLoad);else if(window.onload){var curronload=window.onload,newonload=function(e){curronload(e),_dom.onLoad(e)};window.onload=newonload}else window.onload=_dom.onLoad;var _drop=function(e,t,n){return new function(e,t,n){"function"==typeof e&&(t=e,e=document),this.elem=void 0===e?document:e,this.files,this.index=0,this.proc=t,this.params=n;var i=this;_dom(this.elem).on("dragover",function(e){return void 0!==i.proc.dragover&&i.proc.dragover.bind(i,e)(),e.preventDefault(),e.stopPropagation(),!1}),_dom(this.elem).on("dragenter",function(e){return void 0!==i.proc.dragenter&&i.proc.dragenter.bind(i,e)(),e.preventDefault(),e.stopPropagation(),!1}),_dom(this.elem).on("dragleave",function(e){return void 0!==i.proc.dragleave&&i.proc.dragleave.bind(i,e)(),e.preventDefault(),e.stopPropagation(),!1}),_dom(this.elem).on("drop",function(e){return void 0!==i.proc.drop&&i.proc.drop.bind(i,e)(),e.preventDefault(),e.stopPropagation(),e.dataTransfer&&e.dataTransfer.files.length&&(e.preventDefault(),e.stopPropagation(),i.files=e.dataTransfer.files,i.load()),!1}),this.load=function(e){void 0===e&&(e=0);var n=this.files[e],r=new FileReader;r.readAsDataURL(n),r.onerror=function(e){void 0!==i.proc.error?i.proc.error.bind(i,e)():i.next()},r.onprogress=function(e){void 0!==i.proc.progress&&i.proc.progress.bind(i,e)()},r.onload=function(e){e.strfile=e.target.result.split(",")[1],void 0!==i.proc.load?i.proc.load.bind(i,e)():"function"==typeof t&&i.proc.bind(i,e)()}},this.next=function(){this.files.length>this.index+1?(this.index++,this.load(this.index)):(this.index=0,this.files=void 0,void 0!==i.proc.end&&i.proc.end.bind(i)())}}(e,t,n)};_drop.onFunctions=[];var _gamepad={controllers:[],axis_margin:.4,activated:!1,players:[],addplayer:function(e,t,n){return"object"==typeof e&&(void 0!==e.axis_margin&&(n=e.axis_margin,delete e.axis_margin),void 0!==e.index&&(t=e.index,delete e.index)),void 0===t&&(t=-1),void 0===n&&(n=_gamepad.axis_margin),_gamepad.activate(),_gamepad.scangamepads(),_gamepad.players.push({index:t,connected:!1,proc:e,buttons:[],axes:[],axis_margin:n}),_gamepad.players.length-1},haveEvents:"GamepadEvent"in window,activate:function(){_gamepad.activated||(_gamepad.haveEvents?(window.addEventListener("gamepadconnected",_gamepad.connecthandler),window.addEventListener("gamepaddisconnected",_gamepad.disconnecthandler)):setInterval(_gamepad.scangamepads,500),window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,window.requestAnimationFrame(_gamepad.updateStatus),_gamepad.scangamepads(),_gamepad.activated=!0)},scangamepads:function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t<e.length;t++)e[t]&&(e[t].index in _gamepad.controllers?_gamepad.controllers[e[t].index]=e[t]:_gamepad.addgamepad(e[t]))},addgamepad:function(e){_gamepad.controllers[e.index]=e,window.requestAnimationFrame(_gamepad.updateStatus)},connecthandler:function(e){_gamepad.addgamepad(e.gamepad)},disconnecthandler:function(e){delete _gamepad.controllers[e.gamepad.index]},associateGamepad:function(e,t,n){_gamepad.players[e].index=t;var i=_gamepad.formatController(n);_gamepad.players[e].connected=!0,"object"==typeof _gamepad.players[e].proc&&("function"==typeof _gamepad.players[e].proc.connected&&_gamepad.players[e].proc.connected.bind(i)(),void 0===_gamepad.players[e].proc.buttonDown&&(_gamepad.players[e].proc.buttonDown=[]),void 0===_gamepad.players[e].proc.buttonRepeat&&(_gamepad.players[e].proc.buttonRepeat=[]),void 0===_gamepad.players[e].proc.buttonUp&&(_gamepad.players[e].proc.buttonUp=[]))},formatController:function(e){for(var t={id:e.id,index:e.index,axes:[],buttons:[]},n=0;n<e.axes.length;n++)t.axes.push(e.axes[n]);for(n=0;n<e.buttons.length;n++){var i=e.buttons[n],r=1==i;"object"==typeof i&&(r=i.pressed),t.buttons.push(r)}return t},updateStatus:function(){for(var e in _gamepad.scangamepads(),_gamepad.players){var t;if(-1==_gamepad.players[e].index){for(var n in _gamepad.players)if(_gamepad.players.index==e)return;for(var i in _gamepad.controllers){t=_gamepad.controllers[i];for(var r=0;r<t.axes.length;r++)if(t.axes[r]>_gamepad.players[e].axis_margin||t.axes[r]<-_gamepad.players[e].axis_margin)return _gamepad.associateGamepad(e,i,t),void window.requestAnimationFrame(_gamepad.updateStatus);for(r=0;r<t.buttons.length;r++){var a=t.buttons[r],o=1==a;if("object"==typeof a&&(o=a.pressed),o)return _gamepad.associateGamepad(e,i,t),void window.requestAnimationFrame(_gamepad.updateStatus)}}}else if(void 0===_gamepad.controllers[_gamepad.players[e].index])_gamepad.players[e].connected&&(_gamepad.players[e].connected=!1,"function"==typeof _gamepad.players[e].proc.disconnected&&_gamepad.players[e].proc.disconnected.bind(null,e)());else{t=_gamepad.controllers[_gamepad.players[e].index];var s=_gamepad.formatController(t);if(_gamepad.players[e].connected||(_gamepad.players[e].connected=!0,"function"==typeof _gamepad.players[e].proc.connected&&_gamepad.players[e].proc.connected.bind(s)()),"function"==typeof _gamepad.players[e].proc)_gamepad.players[e].proc.bind(s)();else if("function"==typeof _gamepad.players[e].proc.updateStatus)_gamepad.players[e].proc.updateStatus.bind(s)();else{for(r=0;r<t.axes.length;r++)void 0===_gamepad.players[e].axes[r]&&_gamepad.players[e].axes.push(!1),t.axes[r]>_gamepad.players[e].axis_margin||t.axes[r]<-_gamepad.players[e].axis_margin?_gamepad.players[e].axes[r]?void 0!==_gamepad.players[e].proc.axeMove&&"function"==typeof _gamepad.players[e].proc.axeMove[r]&&_gamepad.players[e].proc.axeMove[r].bind(s,t.axes[r])():(void 0!==_gamepad.players[e].proc.axeEnter&&"function"==typeof _gamepad.players[e].proc.axeEnter[r]&&_gamepad.players[e].proc.axeEnter[r].bind(s,t.axes[r])(),void 0!==_gamepad.players[e].proc.waitForAxe&&(_gamepad.players[e].proc.waitForAxe.bind(null,e,r)(),delete _gamepad.players[e].proc.waitForAxe),_gamepad.players[e].axes[r]=!0):_gamepad.players[e].axes[r]&&(void 0!==_gamepad.players[e].proc.axeLeave&&"function"==typeof _gamepad.players[e].proc.axeLeave[r]&&_gamepad.players[e].proc.axeLeave[r].bind(s)(),_gamepad.players[e].axes[r]=!1);for(r=0;r<s.buttons.length;r++)void 0===_gamepad.players[e].buttons[r]&&_gamepad.players[e].buttons.push(!1),!_gamepad.players[e].buttons[r]&&s.buttons[r]?(void 0!==_gamepad.players[e].proc.buttonDown&&"function"==typeof _gamepad.players[e].proc.buttonDown[r]&&_gamepad.players[e].proc.buttonDown[r].bind(s)(),void 0!==_gamepad.players[e].proc.waitForButton&&(console.log("return Button"),_gamepad.players[e].proc.waitForButton.bind(null,e,r)(),delete _gamepad.players[e].proc.waitForButton),_gamepad.players[e].buttons[r]=!0):_gamepad.players[e].buttons[r]&&s.buttons[r]?void 0!==_gamepad.players[e].proc.buttonRepeat&&"function"==typeof _gamepad.players[e].proc.buttonRepeat[r]&&_gamepad.players[e].proc.buttonRepeat[r].bind(s)():_gamepad.players[e].buttons[r]&&!s.buttons[r]&&(void 0!==_gamepad.players[e].proc.buttonUp&&"function"==typeof _gamepad.players[e].proc.buttonUp[r]&&_gamepad.players[e].proc.buttonUp[r].bind(s)(),_gamepad.players[e].buttons[r]=!1)}}}window.requestAnimationFrame(_gamepad.updateStatus)}},_keys={funcHnd:[],disabled:!1,initDown:!1,initUp:!1,fnDown:[],fnUp:[],history:"",mapFromKey:function(e,t){switch(t){case 8:case 46:case 9:case 13:case 16:case 17:case 18:case 20:case 27:case 45:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 91:case 92:return t}var n={32:" ",191:"§",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",48:"0",219:"'",221:"^",186:"è",192:"¨",222:"é",220:"à",223:"$",226:"<",188:",",190:".",189:"-",111:"/",106:"*",109:"-",107:"+",110:"."},i={32:" ",191:"°",49:"+",50:'"',51:"*",52:"ç",53:"%",54:"&",55:"/",56:"(",57:")",48:"=",219:"?",221:"`",186:"ü",192:"!",222:"ö",220:"ä",223:"£",226:">",188:";",190:":",189:"_"},r={191:"",49:"¦",50:"@",51:"#",52:"°",53:"§",54:"¬",55:"|",56:"¢",57:"",48:"",219:"´",221:"~",186:"[",192:"]",222:"",220:"{",223:"}",226:"\\",188:"",190:"",189:""};return 0==e?t>=65&&t<=90?String.fromCharCode(t).toLowerCase():t>=96&&t<=105?t-96+"":void 0!==n[t]?n[t]:String.fromCharCode(t):2==e?t>=65&&t<=90?String.fromCharCode(t).toUpperCase():void 0!==i[t]?i[t]:t:5==e?t>=65&&t<=90?"":void 0!==r[t]?r[t]:t:t},modifier:function(e){switch(e.toUpperCase()){case"CTRL":case"CONTROL":return 1;case"SHIFT":return 2;case"CTRLSHIFT":case"CONTROLSHIFT":case"SHIFTCONTROL":case"SHIFTCONTROL":return 3;case"ALT":return 4;case"CTRLALT":case"CONTROLSALT":case"ALTCONTROL":case"ALTCONTROL":return 5;case"SHIFTALT":case"ALTSHIFT":return 6;case"CTRLSHIFTALT":case"CTRLALTSHIFT":case"SHIFTCTRLALT":case"SHIFTALTCTRL":case"ALTCTRLSHIFT":case"ALTSHIFTCTRL":case"CONTROLSHIFTALT":case"CONTROLALTSHIFT":case"SHIFTCONTROLALT":case"SHIFTALTCONTROL":case"ALTCONTROLSHIFT":case"ALTSHIFTCONTROL":return 7}},code:function(e){switch(e.toUpperCase()){case"BACKSPACE":return 8;case"TAB":return 9;case"ENTER":return 13;case"SHIFT":return 16;case"CONTROL":case"CTRL":return 17;case"ALT":return 18;case"PAUSE":case"BREAK":return 19;case"SHIFTLOCK":return 20;case"ESC":return 27;case"SPACE":return 32;case"PAGEUP":return 33;case"PAGEDOWN":return 34;case"END":return 35;case"HOME":return 36;case"LEFT":return 37;case"UP":return 38;case"RIGHT":return 39;case"DOWN":return 40;case"INSERT":return 45;case"DEL":return 46;case"0":return 48;case"1":return 49;case"2":return 50;case"3":return 51;case"4":return 52;case"5":return 53;case"6":return 54;case"7":return 55;case"8":return 56;case"9":return 57;case"A":return 65;case"B":return 66;case"C":return 67;case"D":return 68;case"E":return 69;case"F":return 70;case"G":return 71;case"H":return 72;case"I":return 73;case"J":return 74;case"K":return 75;case"L":return 76;case"M":return 77;case"N":return 78;case"O":return 79;case"P":return 80;case"Q":return 81;case"R":return 82;case"S":return 83;case"T":return 84;case"U":return 85;case"V":return 86;case"W":return 87;case"X":return 88;case"Y":return 89;case"Z":return 90;case"WINDOWS":return 91;case"MENU":return 93;case"NUMPAD0":return 96;case"NUMPAD1":return 97;case"NUMPAD2":return 98;case"NUMPAD3":return 99;case"NUMPAD4":return 100;case"NUMPAD5":return 101;case"NUMPAD6":return 102;case"NUMPAD7":return 103;case"NUMPAD8":return 104;case"NUMPAD9":return 105;case"NUMPAD*":return 106;case"NUMPAD+":return 107;case"NUMPAD-":return 109;case"NUMPAD.":return 110;case"NUMPAD/":return 111;case"F1":return 112;case"F2":return 113;case"F3":return 114;case"F4":return 115;case"F5":return 116;case"F6":return 117;case"F7":return 118;case"F8":return 119;case"F9":return 120;case"F10":return 121;case"F11":return 122;case"F12":return 123;case"NUMLOCK":return 144;case"SCROLLLOCK":return 145;case"È":return 186;case",":return 188;case"-":return 189;case".":return 190;case"¨":return 192;case"\\":return 191;case"'":return 219;case"À":return 220;case"^":return 221;case"É":return 222;case"$":return 223;default:return-1}},enable:function(){if(!_keys.disabled)return!1;_keys.initDown&&(_keys.addEvent("keydown",function(e){_keys.eventProc(e,"down")}),_keys.initDown=!0),_keys.initUp&&(_keys.addEvent("keyup",function(e){_keys.eventProc(e,"up")}),_keys.initUp=!0),_keys.disabled=!1},disable:function(){for(var e in _keys.funcHnd)_keys.removeEvent(e,_keys.funcHnd[e]);_keys.funcHnd=[],_keys.disabled=!0},add:function(e,t){"string"==typeof e&&(e={keycode:e}),void 0===e.modifier&&(e.modifier=0),void 0===e.block&&(e.block=!1),void 0===e.bubble&&(e.bubble=!1),void 0===e.on&&(e.on="down"),void 0===e.callback&&(e.callback=t),isNaN(e.modifier)&&(e.modifier=_keys.modifier(e.modifier));var n="";isNaN(e.keycode)?-1!==e.keycode.indexOf(",")?e.keycode.split(",").forEach(function(t){n+=_keys.code(t)+"x"+e.modifier+","}):(e.keycode=_keys.code(e.keycode),n=e.keycode+"x"+e.modifier):n=e.keycode+"x"+e.modifier;"down"===e.on?(_keys.initDown||(_keys.addEvent("keydown",function(e){_keys.eventProc(e,"down")}),_keys.initDown=!0),_keys.fnDown[n]=e):"up"===e.on&&(_keys.initUp||(_keys.addEvent("keyup",function(e){_keys.eventProc(e,"up")}),_keys.initUp=!0),_keys.fnUp[n]=e,e.block&&_keys.add({keycode:e.keycode,modifier:e.modifier,block:!0}))},addEvent:function(e,t){var n=document.body;_keys.funcHnd[e]=t.bind(n),n.addEventListener?n.addEventListener(e,_keys.funcHnd[e],!1):n.attachEvent&&n.attachEvent("on"+e,_keys.funcHnd[e])},removeEvent:function(e,t){var n=document.body;n.addEventListener?n.removeEventListener(e,_keys.funcHnd[e],!1):n.attachEvent&&n.detachEvent("on"+e,_keys.funcHnd[e])},eventProc:function(e,t){var n=document.activeElement,i="none";if(n&&("input"==n.tagName.toLowerCase()&&"text"==n.type||"textarea"==n.tagName.toLowerCase())&&(i=n.tagName.toLowerCase()),"none"==i){var r="charCode"in e?e.charCode:e.keyCode;if(r=e.which?e.which:e.keyCode?e.keyCode:0,e.chCode=r,e.modifier=0,e.ctrlKey&&(e.modifier+=1),e.altKey&&(e.modifier+=2),e.shiftKey&&(e.modifier+=4),_keys.history.split(",").length<=16){var a=void 0;"down"===t?(_keys.history+=e.chCode+"x"+e.modifier+",",a=_keys.fnDown[_keys.history]):"up"===t&&(a=_keys.fnUp[_keys.history]),void 0!==a&&"function"==typeof a.callback&&a.callback(e)}_keys.resetHistory();var o=void 0;if("down"===t?o=_keys.fnDown[e.chCode+"x"+e.modifier]:"up"===t&&(o=_keys.fnUp[e.chCode+"x"+e.modifier]),void 0!==o)return"function"==typeof o.callback&&o.callback(e),o.bubble&&(e.cancelBubble=!0,e.stopPropagation&&e.stopPropagation()),!o.block||(e.preventDefault(),!1)}},resetHistoryHnd:null,resetHistory(){null!==_keys.resetHistoryHnd&&clearTimeout(_keys.resetHistoryHnd),_keys.resetHistoryHnd=setInterval(function(){_keys.history=""},1500)}},_notif={internalVar:[],vars:function(e,t){return void 0===e?"undefined"!=typeof localStorage?localStorage:_notif.internalVar:void 0===t?"undefined"!=typeof localStorage?localStorage.getItem(e):void 0!==_notif.internalVar[e]?_notif.internalVar[e]:null:"undefined"!=typeof localStorage?localStorage.setItem(e,t):void(_notif.internalVar[e]=t)},show:function(e){if("Notification"in window){var t,n;if("object"==typeof e?t=e.title:(t=e,e={}),n=void 0===e.name?t:e.name,void 0!==e.counter){if(null===_notif.vars("_notify_Last_"+n)&&_notif.vars("_notify_Last_"+n,0),null===_notif.vars("_notify_"+n)&&_notif.vars("_notify_"+n,0),_notif.vars("_notify_Last_"+n)==e.counter)return;if(_notif.vars("_notify_Last_"+n,e.counter),_notif.vars("_notify_"+n)<e.counter)localStorage.setItem("_notify_"+n,e.counter);else if(_notif.vars("_notify_"+n)>e.counter)return _notif.vars("_notify_Last_"+n,e.counter),void _notif.vars("_notify_"+n,e.counter)}if("granted"===Notification.permission)new Notification(t,e).onclick=function(){window.focus(),this.close()};else Notification.requestPermission()}}},_object=function(e){return new function(e){this.obj=e,this.extend=function(){for(var t=e||{},n=1;n<arguments.length;n++)if(arguments[n])for(var i in arguments[n])arguments[n].hasOwnProperty(i)&&(t[i]=arguments[n][i]);return t},this.deepExtend=function(){for(var e=n||{},t=0;t<arguments.length;t++){var n=arguments[t];if(n)for(var i in n)n.hasOwnProperty(i)&&("object"==typeof n[i]?n[i]instanceof Array==1?e[i]=n[i].slice(0):e[i]=deepExtend(e[i],n[i]):e[i]=n[i])}return e},this.type=Object.prototype.toString.call(e).replace(/^\[object (.+)\]$/,"$1").toLowerCase()}(e)},_string=function(e){return new function(e){this.iLeftLast=_string.iLeftLast,this.iRightLast=_string.iRightLast,this.capitalize=function(){return e.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})},this.count=function(t){return e.split(t).length-1},this.find=function(t){return-1!==e.indexOf(t)},this.iLeft=function(t){var n=0===e.indexOf(t);return _string.iLeftLast=n?e.substr(t.lenght):null,n},this.iRight=function(t){var n=-1!==e.indexOf(t,e.length-t.length);return _string.iRightLast=n?e.substr(0,e.lenght-t.lenght):null,n},this.basename=function(t){void 0===t&&(t=!0);var n=e.substring(e.lastIndexOf("/")+1);return t||-1==n.lastIndexOf(".")||(n=n.substring(0,n.lastIndexOf("."))),n},this.trim=function(){return e.replace(/^\s+|\s+$/g,"")},this.getContrast=function(){var t=e.replace("#","");return(299*parseInt(t.substr(0,2),16)+587*parseInt(t.substr(2,2),16)+114*parseInt(t.substr(4,2),16))/1e3>=128?"black":"white"}}(e)};_string.iLeftLast=null,_string.iRightLast=null;var _timer=function(e){return void 0===e&&(_timer.autoID++,e="auto"+_timer.autoID),new function e(t){this.name=t,this.delay=function(t,n){return void 0===n&&(n=1e3),void 0!==_timer.dataBase[this.name]&&clearTimeout(_timer.dataBase[this.name]),_timer.dataBase[this.name]=setTimeout(t.bind(e(this.name)),n),this},this.interval=function(t,n){return void 0===n&&(n=1e3),void 0!==_timer.dataBase[this.name]&&clearTimeout(_timer.dataBase[this.name]),_timer.dataBase[this.name]=setInterval(t.bind(e(this.name)),n),this},this.stop=function(){return clearTimeout(_timer.dataBase[this.name]),_timer.dataBase[this.name]=void 0,this}}(e)};_timer.dataBase=[],_timer.autoID=-1,_timer.delay=function(e,t){return _timer().delay(e,t)},_timer.interval=function(e,t){return _timer().interval(e,t)},_timer.sleep=function(e){void 0===e&&(e=10);for(var t=(new Date).getTime();(new Date).getTime()<t+e;);return this},_timer.stop=function(){for(var e in _timer.dataBase)clearTimeout(_timer.dataBase[e]),_timer.dataBase[e]=void 0},_timer.now=function(){return(new Date).getTime()};var _url={root:window.location.protocol+"//"+window.location.hostname+window.location.pathname,host:window.location.hostname,href:function(e,t){if(void 0===e)return document.location.href;"/"==e&&(e=""),null!==t&&t&&(document.title=this.domain.substring(0,1)+"/"+e);try{window.history&&history.pushState("data","",this.root+e)}catch(e){}},GET:function(e,t){void 0===t&&(t=document.location.href),e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(t);return null===n?null:n[1]}},_vars=function(e,t){return void 0===e?"undefined"!=typeof localStorage?localStorage:_vars.internalVar:void 0===t?"undefined"!=typeof localStorage?localStorage.getItem(e):void 0!==_vars.internalVar[e]?_vars.internalVar[e]:null:"undefined"!=typeof localStorage?localStorage.setItem(e,t):void(_vars.internalVar[e]=t)};_vars.internalVar=[];