<!doctype html>
<html lang="en-us">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>SYGTVG-Sam's Apache2 Server</title>
    <style>
      body { font-family: sans-serif; margin: 0; padding: none; color: white; background: black; }
      canvas.emscripten { border: 0px none; width: 320px; height: 240px; max-width: 100%; max-height: 100%; position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }
      #status { font-weight: bold; color: #888888; text-align: center; margin: auto; }
      #controls { text-align: right; } #controls input { border: 1px solid gray; background: black; color: gray; }
      @media all and (min-width: 640px) { canvas.emscripten { width: 640px; height: 480px;
        image-rendering: optimizeSpeed;             /* Older versions of FF          */
        image-rendering: -moz-crisp-edges;          /* FF 6.0+                       */
        image-rendering: -webkit-optimize-contrast; /* Safari                        */
        image-rendering: -o-crisp-edges;            /* OS X & Windows Opera (12.02+) */
        image-rendering: pixelated;                 /* Awesome future-browsers       */
        -ms-interpolation-mode: nearest-neighbor;   /* IE                            */
      } }
      @media all and (max-width: 639px) { canvas.emscripten { width: 320px; height: 240px; } }
    </style>
  </head>
  <body>

    <div id="controls"><input type="button" value="Full screen" onclick="if (Module.requestFullScreen) Module.requestFullScreen()"></div>

    <div id="status">Downloading...</div>

    <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>

    <script type='text/javascript'>
      var statusElement = document.getElementById('status');

      var Module = {
        preRun: [],
        postRun: [],
        print: (function() {
          var element = document.getElementById('output');
          if (element) element.value = ''; // clear browser cache
          return function(text) {
            if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
            console.log(text);
            if (element) {
              element.value += text + "\n";
              element.scrollTop = element.scrollHeight; // focus on bottom
            }
          };
        })(),
        printErr: function(text) {
          if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
          console.error(text);
        },
        canvas: (function() {
          var canvas = document.getElementById('canvas');

          // As a default initial behavior, pop up an alert when webgl context is lost. To make your
          // application robust, you may want to override this behavior before shipping!
          // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
          canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);

          return canvas;
        })(),
        setStatus: function(text) {
          if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
          if (text === Module.setStatus.text) return;
          statusElement.innerHTML = text;
        },
        totalDependencies: 0,
        monitorRunDependencies: function(left) {
          this.totalDependencies = Math.max(this.totalDependencies, left);
          Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'Downloading game data...');
        }
      };
      Module.setStatus('Downloading...');
      window.onerror = function(event) {
        Module.setStatus('Exception thrown, see JavaScript console');
        Module.setStatus = function(text) {
          if (text) Module.printErr('[post-exception status] ' + text);
        };
      };
    </script>
    <script>

          (function() {
            var memoryInitializer = 'index.html.mem';
            if (typeof Module['locateFile'] === 'function') {
              memoryInitializer = Module['locateFile'](memoryInitializer);
            } else if (Module['memoryInitializerPrefixURL']) {
              memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer;
            }
            var meminitXHR = Module['memoryInitializerRequest'] = new XMLHttpRequest();
            meminitXHR.open('GET', memoryInitializer, true);
            meminitXHR.responseType = 'arraybuffer';
            meminitXHR.send(null);
          })();

          var script = document.createElement('script');
          script.src = "index.js";
          document.body.appendChild(script);

</script>
    <script>
      //prevents scrolling on arrow key press
      window.addEventListener("keydown", function(e) {
          // space and arrow keys, from 112 to 123 for function keys (only works in some browsers)
          if([32, 37, 38, 39, 40, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123].indexOf(e.keyCode) > -1) {
              e.preventDefault();
          }
      }, false);
    </script>
  </body>
</html>