vendor: 5,704 bytes, lines 1-14
1/* mousetrap v1.6.3 craig.is/killing/mice */ 2(function(q,u,c){function v(a,b,g){a.addEventListener?a.addEventListener(b,g,!1):a.attachEvent("on"+b,g)}function z(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return n[a.which]?n[a.which]:r[a.which]?r[a.which]:String.fromCharCode(a.which).toLowerCase()}function F(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function w(a){return"shift"==a||"ctrl"==a||"alt"==a|| 3 "meta"==a}function A(a,b){var g,d=[];var e=a;"+"===e?e=["+"]:(e=e.replace(/\+{2}/g,"+plus"),e=e.split("+"));for(g=0;g<e.length;++g){var m=e[g];B[m]&&(m=B[m]);b&&"keypress"!=b&&C[m]&&(m=C[m],d.push("shift"));w(m)&&d.push(m)}e=m;g=b;if(!g){if(!p){p={};for(var c in n)95<c&&112>c||n.hasOwnProperty(c)&&(p[n[c]]=c)}g=p[e]?"keydown":"keypress"}"keypress"==g&&d.length&&(g="keydown");return{key:m,modifiers:d,action:g}}function D(a,b){return null===a||a===u?!1:a===b?!0:D(a.parentNode,b)}function d(a){function b(a){a= 4 a||{};var b=!1,l;for(l in p)a[l]?b=!0:p[l]=0;b||(x=!1)}function g(a,b,t,f,g,d){var l,E=[],h=t.type;if(!k._callbacks[a])return[];"keyup"==h&&w(a)&&(b=[a]);for(l=0;l<k._callbacks[a].length;++l){var c=k._callbacks[a][l];if((f||!c.seq||p[c.seq]==c.level)&&h==c.action){var e;(e="keypress"==h&&!t.metaKey&&!t.ctrlKey)||(e=c.modifiers,e=b.sort().join(",")===e.sort().join(","));e&&(e=f&&c.seq==f&&c.level==d,(!f&&c.combo==g||e)&&k._callbacks[a].splice(l,1),E.push(c))}}return E}function c(a,b,c,f){k.stopCallback(b, 5 b.target||b.srcElement,c,f)||!1!==a(b,c)||(b.preventDefault?b.preventDefault():b.returnValue=!1,b.stopPropagation?b.stopPropagation():b.cancelBubble=!0)}function e(a){"number"!==typeof a.which&&(a.which=a.keyCode);var b=z(a);b&&("keyup"==a.type&&y===b?y=!1:k.handleKey(b,F(a),a))}function m(a,g,t,f){function h(c){return function(){x=c;++p[a];clearTimeout(q);q=setTimeout(b,1E3)}}function l(g){c(t,g,a);"keyup"!==f&&(y=z(g));setTimeout(b,10)}for(var d=p[a]=0;d<g.length;++d){var e=d+1===g.length?l:h(f|| 6 A(g[d+1]).action);n(g[d],e,f,a,d)}}function n(a,b,c,f,d){k._directMap[a+":"+c]=b;a=a.replace(/\s+/g," ");var e=a.split(" ");1<e.length?m(a,e,b,c):(c=A(a,c),k._callbacks[c.key]=k._callbacks[c.key]||[],g(c.key,c.modifiers,{type:c.action},f,a,d),k._callbacks[c.key][f?"unshift":"push"]({callback:b,modifiers:c.modifiers,action:c.action,seq:f,level:d,combo:a}))}var k=this;a=a||u;if(!(k instanceof d))return new d(a);k.target=a;k._callbacks={};k._directMap={};var p={},q,y=!1,r=!1,x=!1;k._handleKey=function(a, 7 d,e){var f=g(a,d,e),h;d={};var k=0,l=!1;for(h=0;h<f.length;++h)f[h].seq&&(k=Math.max(k,f[h].level));for(h=0;h<f.length;++h)f[h].seq?f[h].level==k&&(l=!0,d[f[h].seq]=1,c(f[h].callback,e,f[h].combo,f[h].seq)):l||c(f[h].callback,e,f[h].combo);f="keypress"==e.type&&r;e.type!=x||w(a)||f||b(d);r=l&&"keydown"==e.type};k._bindMultiple=function(a,b,c){for(var d=0;d<a.length;++d)n(a[d],b,c)};v(a,"keypress",e);v(a,"keydown",e);v(a,"keyup",e)}if(q){var n={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl", 8 18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},r={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},C={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},B={option:"alt",command:"meta","return":"enter", 9 escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},p;for(c=1;20>c;++c)n[111+c]="f"+c;for(c=0;9>=c;++c)n[c+96]=c.toString();d.prototype.bind=function(a,b,c){a=a instanceof Array?a:[a];this._bindMultiple.call(this,a,b,c);return this};d.prototype.unbind=function(a,b){return this.bind.call(this,a,function(){},b)};d.prototype.trigger=function(a,b){if(this._directMap[a+":"+b])this._directMap[a+":"+b]({},a);return this};d.prototype.reset=function(){this._callbacks={}; 10 this._directMap={};return this};d.prototype.stopCallback=function(a,b){if(-1<(" "+b.className+" ").indexOf(" mousetrap ")||D(b,this.target))return!1;if("composedPath"in a&&"function"===typeof a.composedPath){var c=a.composedPath()[0];c!==a.target&&(b=c)}return"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable};d.prototype.handleKey=function(){return this._handleKey.apply(this,arguments)};d.addKeycodes=function(a){for(var b in a)a.hasOwnProperty(b)&&(n[b]=a[b]);p=null}; 11 d.init=function(){var a=d(u),b;for(b in a)"_"!==b.charAt(0)&&(d[b]=function(b){return function(){return a[b].apply(a,arguments)}}(b))};d.init();q.Mousetrap=d;"undefined"!==typeof module&&module.exports&&(module.exports=d);"function"===typeof define&&define.amd&&define(function(){return d})}})("undefined"!==typeof window?window:null,"undefined"!==typeof window?document:null); 12console.log('%c -> Write "p l a y" on Keyboard or press [ctrl]+[alt]+[h] to play a game :D ', 'background:green; color: white; font-weight: bold;'); 13 14var abmodalisopened = false;
15var canvas, ctx, numLives, gameOver, status, score; 16const LIVES = 3; 17 18const loadingDoneSoStartGame = () => { 19 // these next few lines set up our game logic and render to happen 30 times per second 20 const FRAMES_PER_SECOND = 50; 21 setInterval(mainGame, 1000 / FRAMES_PER_SECOND); 22 for(let i = 0; i < balls.length; i++ ){ 23 setInterval(balls[i].speedIncrement(0.03), 1000) 24 } 25 26 ; 27 28}; 29 30var loadJS = function(url, implementationCode){ 31 //url is URL of external file, implementationCode is the code 32 //to be called from the file, location is the location to 33 //insert the <script> element 34 35 var scriptTag = document.createElement('script'); 36 scriptTag.src = url; 37 38 scriptTag.onload = implementationCode; 39 scriptTag.onreadystatechange = implementationCode; 40 41 document.body.appendChild(scriptTag); 42}; 43 44function loadAB() { 45 canvas = document.getElementById('mainGame'); 46 ctx = canvas.getContext('2d'); 47 48 // Lives 49 numLives = LIVES; 50 gameOver = false; 51 score = 0; 52 53 loadJS('/ab/graphicsCommon.js', function () { 54 loadJS('/ab/imageLoad.js', function () { 55 loadJS('/ab/soundAndMusic.js', function () { 56 loadJS('/ab/levels.js', function () { 57 loadJS('/ab/paddle.js', function () { 58 loadJS('/ab/ball.js', function () { 59 loadJS('/ab/stage.js', function () { 60 loadJS('/ab/bullet.js', function () { 61 loadJS('/ab/input.js', function () { 62 loadJS('/ab/powerup.js', function () { 63 64 65 addHoldKeyListener('ArrowLeft'); 66 addHoldKeyListener('ArrowRight'); 67 addEventListener('mousedown', mouseClickHandle); 68 //debug 69 addEventListener('keydown', (evt) => { 70 if (evt.key == ' ') { 71 mouseClickHandle(); 72 } 73 // if(evt.key == 'n'){ 74 // level++; 75 // if(level >= levels.length){ 76 // level = 0; 77 // } 78 // bricks = levels[level].slice(); 79 // } 80 81 // if(evt.key == 'm'){ 82 // multiBall = !multiBall; 83 // } 84 // if(evt.key == 'c'){ 85 // cannon = !cannon; 86 // } 87 }); 88 loadImages(); 89 90 // $('#sab-ee').on('show.bs.modal', function () { 91 // abmodalisopened = true; 92 // gameOver = false; 93 // }).modal('show'); 94 // $('#sab-ee').on('hide.bs.modal', function () { 95 // abmodalisopened = false; 96 // gameOver = true; 97 // }); 98 }); 99 }); 100 }); 101 }); 102 }); 103 }); 104 }); 105 }); 106 }); 107 }); 108} 109 110window.onload = function(){ 111 var containerIsLoaded = false; 112 Mousetrap.bind(['p l a y', 'mod+alt+h'], function(){ 113 if( !abmodalisopened ) { 114 if (containerIsLoaded) { 115 loadAB(); 116 } else { 117 var xhr = new XMLHttpRequest(); 118 xhr.open('GET', '/ab/content'); 119 xhr.send(null); 120 xhr.onreadystatechange = function () { 121 var DONE = 4; // readyState 4 means the request is done. 122 var OK = 200; // status 200 is a successful return. 123 if (xhr.readyState === DONE) { 124 if (xhr.status === OK) { 125 document.getElementById('sab-container').innerHTML = xhr.responseText; 126 containerIsLoaded = true; 127 loadAB(); 128 } else { 129 console.warn('Error: ' + xhr.status); // An error occurred during the request. 130 } 131 } 132 }; 133 } 134 } 135 }); 136};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.