nimcity.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!doctype html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>nimсity</title>
  7. <style>
  8. body {
  9. background: #000;
  10. margin: 0;
  11. padding: 0;
  12. }
  13. textarea.emscripten { font-family: monospace; width: 80%; }
  14. div.emscripten { text-align: center; }
  15. div.emscripten_border { border: 1px solid black; }
  16. /* the canvas *must not* have any border or padding, or mouse coords will be wrong */
  17. canvas.emscripten {
  18. border: 0px none; background-color: black; margin: 0;
  19. position: absolute;
  20. left: 0;
  21. top: 0;
  22. width: 100%;
  23. height: 100%;
  24. }
  25. .spinner {
  26. height: 50px;
  27. width: 50px;
  28. margin: 0px auto;
  29. -webkit-animation: rotation .8s linear infinite;
  30. -moz-animation: rotation .8s linear infinite;
  31. -o-animation: rotation .8s linear infinite;
  32. animation: rotation 0.8s linear infinite;
  33. border-left: 10px solid rgb(0,150,240);
  34. border-right: 10px solid rgb(0,150,240);
  35. border-bottom: 10px solid rgb(0,150,240);
  36. border-top: 10px solid rgb(100,0,200);
  37. border-radius: 100%;
  38. background-color: rgb(200,100,250);
  39. }
  40. @-webkit-keyframes rotation {
  41. from {-webkit-transform: rotate(0deg);}
  42. to {-webkit-transform: rotate(360deg);}
  43. }
  44. @-moz-keyframes rotation {
  45. from {-moz-transform: rotate(0deg);}
  46. to {-moz-transform: rotate(360deg);}
  47. }
  48. @-o-keyframes rotation {
  49. from {-o-transform: rotate(0deg);}
  50. to {-o-transform: rotate(360deg);}
  51. }
  52. @keyframes rotation {
  53. from {transform: rotate(0deg);}
  54. to {transform: rotate(360deg);}
  55. }
  56. </style>
  57. </head>
  58. <body>
  59. <figure style="overflow:visible;" id="spinner"><div class="spinner"></div><center style="margin-top:0.5em"><strong>emscripten</strong></center></figure>
  60. <div class="emscripten" id="status">Downloading...</div>
  61. <div class="emscripten">
  62. <progress value="0" max="100" id="progress" hidden=1></progress>
  63. </div>
  64. <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" onmouseenter="window.focus()" onclick="window.focus()" tabindex=-1></canvas>
  65. <script type='text/javascript'>
  66. var statusElement = document.getElementById('status');
  67. var progressElement = document.getElementById('progress');
  68. var spinnerElement = document.getElementById('spinner');
  69. var Module = {
  70. preRun: [],
  71. postRun: [],
  72. canvas: (function() {
  73. var canvas = document.getElementById('canvas');
  74. // As a default initial behavior, pop up an alert when webgl context is lost. To make your
  75. // application robust, you may want to override this behavior before shipping!
  76. // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
  77. canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
  78. return canvas;
  79. })(),
  80. setStatus: function(text) {
  81. if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
  82. if (text === Module.setStatus.last.text) return;
  83. var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
  84. var now = Date.now();
  85. if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
  86. Module.setStatus.last.time = now;
  87. Module.setStatus.last.text = text;
  88. if (m) {
  89. text = m[1];
  90. progressElement.value = parseInt(m[2])*100;
  91. progressElement.max = parseInt(m[4])*100;
  92. progressElement.hidden = false;
  93. spinnerElement.hidden = false;
  94. } else {
  95. progressElement.value = null;
  96. progressElement.max = null;
  97. progressElement.hidden = true;
  98. if (!text) spinnerElement.hidden = true;
  99. }
  100. statusElement.innerHTML = text;
  101. },
  102. totalDependencies: 0,
  103. monitorRunDependencies: function(left) {
  104. this.totalDependencies = Math.max(this.totalDependencies, left);
  105. Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
  106. },
  107. 'print': function(text) { console.log('stdout: ' + text) },
  108. 'printErr': function(text) { console.log('stderr: ' + text) }
  109. };
  110. Module.setStatus('Downloading...');
  111. window.onerror = function() {
  112. Module.setStatus('Exception thrown, see JavaScript console');
  113. spinnerElement.style.display = 'none';
  114. Module.setStatus = function(text) {
  115. if (text) Module.printErr('[post-exception status] ' + text);
  116. };
  117. };
  118. </script>
  119. <script async type="text/javascript" src="nimсity.js"></script>
  120. </body>
  121. </html>