-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
7 lines (5 loc) · 7.72 KB
/
test.js
1
2
3
4
5
var mod_pagespeed__aEbQF6rZl = "var gamepadSupport={TYPICAL_BUTTON_COUNT:16,TYPICAL_AXIS_COUNT:4,ticking:false,gamepads:[],prevRawGamepadTypes:[],prevTimestamps:[],init:function(){var gamepadSupportAvailable=!!navigator.webkitGetGamepads||!!navigator.webkitGamepads||(navigator.userAgent.indexOf('Firefox/')!=-1);if(!gamepadSupportAvailable){tester.showNotSupported();}else{window.addEventListener('MozGamepadConnected',gamepadSupport.onGamepadConnect,false);window.addEventListener('MozGamepadDisconnected',gamepadSupport.onGamepadDisconnect,false);if(!!navigator.webkitGamepads||!!navigator.webkitGetGamepads){gamepadSupport.startPolling();}}},onGamepadConnect:function(event){gamepadSupport.gamepads.push(event.gamepad);tester.updateGamepads(gamepadSupport.gamepads);gamepadSupport.startPolling();},onGamepadDisconnect:function(event){for(var i in gamepadSupport.gamepads){if(gamepadSupport.gamepads[i].index==event.gamepad.index){gamepadSupport.gamepads.splice(i,1);break;}}\nif(gamepadSupport.gamepads.length==0){gamepadSupport.stopPolling();}\ntester.updateGamepads(gamepadSupport.gamepads);},startPolling:function(){if(!gamepadSupport.ticking){gamepadSupport.ticking=true;gamepadSupport.tick();}},stopPolling:function(){gamepadSupport.ticking=false;},tick:function(){gamepadSupport.pollStatus();gamepadSupport.scheduleNextTick();},scheduleNextTick:function(){if(gamepadSupport.ticking){if(window.requestAnimationFrame){window.requestAnimationFrame(gamepadSupport.tick);}else if(window.mozRequestAnimationFrame){window.mozRequestAnimationFrame(gamepadSupport.tick);}else if(window.webkitRequestAnimationFrame){window.webkitRequestAnimationFrame(gamepadSupport.tick);}}},pollStatus:function(){gamepadSupport.pollGamepads();for(var i in gamepadSupport.gamepads){var gamepad=gamepadSupport.gamepads[i];if(gamepad.timestamp&&(gamepad.timestamp==gamepadSupport.prevTimestamps[i])){continue;}\ngamepadSupport.prevTimestamps[i]=gamepad.timestamp;gamepadSupport.updateDisplay(i);}},pollGamepads:function(){var rawGamepads=(navigator.webkitGetGamepads&&navigator.webkitGetGamepads())||navigator.webkitGamepads;if(rawGamepads){gamepadSupport.gamepads=[];var gamepadsChanged=false;for(var i=0;i<rawGamepads.length;i++){if(typeof rawGamepads[i]!=gamepadSupport.prevRawGamepadTypes[i]){gamepadsChanged=true;gamepadSupport.prevRawGamepadTypes[i]=typeof rawGamepads[i];}\nif(rawGamepads[i]){gamepadSupport.gamepads.push(rawGamepads[i]);}}\nif(gamepadsChanged){tester.updateGamepads(gamepadSupport.gamepads);}}},updateDisplay:function(gamepadId){var gamepad=gamepadSupport.gamepads[gamepadId];tester.updateButton(gamepad.buttons[0],gamepadId,'button-1');tester.updateButton(gamepad.buttons[1],gamepadId,'button-2');tester.updateButton(gamepad.buttons[2],gamepadId,'button-3');tester.updateButton(gamepad.buttons[3],gamepadId,'button-4');tester.updateButton(gamepad.buttons[4],gamepadId,'button-left-shoulder-top');tester.updateButton(gamepad.buttons[6],gamepadId,'button-left-shoulder-bottom');tester.updateButton(gamepad.buttons[5],gamepadId,'button-right-shoulder-top');tester.updateButton(gamepad.buttons[7],gamepadId,'button-right-shoulder-bottom');tester.updateButton(gamepad.buttons[8],gamepadId,'button-select');tester.updateButton(gamepad.buttons[9],gamepadId,'button-start');tester.updateButton(gamepad.buttons[10],gamepadId,'stick-1');tester.updateButton(gamepad.buttons[11],gamepadId,'stick-2');tester.updateButton(gamepad.buttons[12],gamepadId,'button-dpad-top');tester.updateButton(gamepad.buttons[13],gamepadId,'button-dpad-bottom');tester.updateButton(gamepad.buttons[14],gamepadId,'button-dpad-left');tester.updateButton(gamepad.buttons[15],gamepadId,'button-dpad-right');tester.updateAxis(gamepad.axes[0],gamepadId,'stick-1-axis-x','stick-1',true);tester.updateAxis(gamepad.axes[1],gamepadId,'stick-1-axis-y','stick-1',false);tester.updateAxis(gamepad.axes[2],gamepadId,'stick-2-axis-x','stick-2',true);tester.updateAxis(gamepad.axes[3],gamepadId,'stick-2-axis-y','stick-2',false);var extraButtonId=gamepadSupport.TYPICAL_BUTTON_COUNT;while(typeof gamepad.buttons[extraButtonId]!='undefined'){tester.updateButton(gamepad.buttons[extraButtonId],gamepadId,'extra-button-'+extraButtonId);extraButtonId++;}\nvar extraAxisId=gamepadSupport.TYPICAL_AXIS_COUNT;while(typeof gamepad.axes[extraAxisId]!='undefined'){tester.updateAxis(gamepad.axes[extraAxisId],gamepadId,'extra-axis-'+extraAxisId);extraAxisId++;}}};";
var mod_pagespeed_49knjTv_8y = "var tester={VISIBLE_THRESHOLD:0.1,STICK_OFFSET:25,ANALOGUE_BUTTON_THRESHOLD:.5,init:function(){tester.updateMode();tester.updateGamepads();},showNotSupported:function(){document.querySelector('#no-gamepad-support').classList.add('visible');},updateMode:function(){if(document.querySelector('#mode-raw').checked){document.querySelector('#gamepads').classList.add('raw');}else{document.querySelector('#gamepads').classList.remove('raw');}},updateGamepads:function(gamepads){var els=document.querySelectorAll('#gamepads > :not(.template)');for(var i=0,el;el=els[i];i++){el.parentNode.removeChild(el);}\nvar padsConnected=false;if(gamepads){for(var i in gamepads){var gamepad=gamepads[i];if(gamepad){var el=document.createElement('li');el.innerHTML=document.querySelector('#gamepads > .template').innerHTML;el.id='gamepad-'+i;el.querySelector('.name').innerHTML=gamepad.id;el.querySelector('.index').innerHTML=gamepad.index;document.querySelector('#gamepads').appendChild(el);var extraButtonId=gamepadSupport.TYPICAL_BUTTON_COUNT;while(typeof gamepad.buttons[extraButtonId]!='undefined'){var labelEl=document.createElement('label');labelEl.setAttribute('for','extra-button-'+extraButtonId);labelEl.setAttribute('description','Extra button');labelEl.setAttribute('access','buttons['+extraButtonId+']');el.querySelector('.extra-inputs').appendChild(labelEl);extraButtonId++;}\nvar extraAxisId=gamepadSupport.TYPICAL_AXIS_COUNT;while(typeof gamepad.axes[extraAxisId]!='undefined'){var labelEl=document.createElement('label');labelEl.setAttribute('for','extra-axis-'+extraAxisId);labelEl.setAttribute('description','Extra axis');labelEl.setAttribute('access','axes['+extraAxisId+']');el.querySelector('.extra-inputs').appendChild(labelEl);extraAxisId++;}\npadsConnected=true;}}}\nif(padsConnected){document.querySelector('#no-gamepads-connected').classList.remove('visible');}else{document.querySelector('#no-gamepads-connected').classList.add('visible');}},updateButton:function(value,gamepadId,id){var gamepadEl=document.querySelector('#gamepad-'+gamepadId);var buttonEl=gamepadEl.querySelector('[name=\"'+id+'\"]');if(buttonEl){if(value>tester.ANALOGUE_BUTTON_THRESHOLD){buttonEl.classList.add('pressed');}else{buttonEl.classList.remove('pressed');}}\nvar labelEl=gamepadEl.querySelector('label[for=\"'+id+'\"]');if(typeof value=='undefined'){labelEl.innerHTML='?';}else{labelEl.innerHTML=value.toFixed(2);if(value>tester.VISIBLE_THRESHOLD){labelEl.classList.add('visible');}else{labelEl.classList.remove('visible');}}},updateAxis:function(value,gamepadId,labelId,stickId,horizontal){var gamepadEl=document.querySelector('#gamepad-'+gamepadId);var stickEl=gamepadEl.querySelector('[name=\"'+stickId+'\"]');if(stickEl){var offsetVal=value*tester.STICK_OFFSET;if(horizontal){stickEl.style.marginLeft=offsetVal+'px';}else{stickEl.style.marginTop=offsetVal+'px';}}\nvar labelEl=gamepadEl.querySelector('label[for=\"'+labelId+'\"]');if(typeof value=='undefined'){labelEl.innerHTML='?';}else{labelEl.innerHTML=value.toFixed(2);if((value<-tester.VISIBLE_THRESHOLD)||(value>tester.VISIBLE_THRESHOLD)){labelEl.classList.add('visible');if(value>tester.VISIBLE_THRESHOLD){labelEl.classList.add('positive');}else{labelEl.classList.add('negative');}}else{labelEl.classList.remove('visible');labelEl.classList.remove('positive');labelEl.classList.remove('negative');}}}};";/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/