Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

202 строки
5.9 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright (c) 2012 The Native Client Authors. All rights reserved.
  5. Use of this source code is governed by a BSD-style license that can be
  6. found in the LICENSE file.
  7. -->
  8. <head>
  9. <style type="text/css">
  10. progress {
  11. background-color: #f3f3f3;
  12. border: 0;
  13. height: 18px;
  14. border-radius: 9px;
  15. }
  16. progress::-webkit-progress-bar {
  17. background-color: #f3f3f3;
  18. border: 1px solid #000000;
  19. padding: 2px 2px;
  20. height: 20px;
  21. border-radius: 0px;
  22. }
  23. progress::-webkit-progress-value {
  24. background-color: #22BB22;
  25. border: 0px;
  26. height: 14px;
  27. border-radius: 0px;
  28. }
  29. </style>
  30. <!--
  31. -->
  32. <title>Mesh Viewer NaCl</title>
  33. <script type="text/javascript">
  34. NaClModule = null; // Global application object.
  35. MeshCodeModule = null;
  36. statusText = 'NO-STATUS';
  37. window.setTimeout("Tick()", 100);
  38. document.getElementById('prout').style.top = 0;
  39. function Tick() {
  40. window.setTimeout("Tick()", 100);
  41. var truc = parseInt(document.getElementById('prout').style.top);
  42. //document.getElementById('prout').style.top = truc + 1 + "px";
  43. var statusField = document.getElementById('tick_field');
  44. if (statusField) {
  45. statusField.innerHTML = truc;
  46. }
  47. }
  48. // Indicate load success.
  49. function moduleDidLoad() {
  50. NaClModule = document.getElementById('ID_NaClModule');
  51. MeshCodeModule = document.getElementById('ID_MeshCode');
  52. //document.getElementById('listener').style.visibility = "visible";
  53. //document.getElementById('canvas_loading').style.display = "none";
  54. //document.getElementById('ID_NaClModule').width = 640;
  55. //document.getElementById('ID_NaClModule').height = 480;
  56. updateStatus('Rock n\' Roll !!');
  57. }
  58. // The 'message' event handler. This handler is fired when the NaCl module
  59. // posts a message to the browser by calling PPB_Messaging.PostMessage()
  60. // (in C) or pp::Instance.PostMessage() (in C++). This implementation
  61. // simply displays the content of the message in an alert panel.
  62. function handleMessage(message_event) {
  63. alert(message_event.data);
  64. }
  65. // If the page loads before the Native Client module loads, then set the
  66. // status message indicating that the module is still loading. Otherwise,
  67. // do not change the status message.
  68. function pageDidLoad() {
  69. if (NaClModule == null) {
  70. updateStatus('Please wait, loading ...');
  71. } else {
  72. // It's possible that the Native Client module onload event fired
  73. // before the page's onload event. In this case, the status message
  74. // will reflect 'SUCCESS', but won't be displayed. This call will
  75. // display the current message.
  76. updateStatus();
  77. }
  78. }
  79. // Set the global status message. If the element with id 'statusField'
  80. // exists, then set its HTML to the status message as well.
  81. // opt_message The message test. If this is null or undefined, then
  82. // attempt to set the element with id 'statusField' to the value of
  83. // |statusText|.
  84. function updateStatus(opt_message) {
  85. if (opt_message)
  86. statusText = opt_message;
  87. var statusField = document.getElementById('status_field');
  88. if (statusField) {
  89. statusField.innerHTML = statusText;
  90. }
  91. }
  92. function moduleLoadProgress(event)
  93. {
  94. var progressBar = document.getElementById("p");
  95. var statusField = document.getElementById('status_field');
  96. if (event.lengthComputable) {
  97. progressBar.max = event.total;
  98. progressBar.value = event.loaded;
  99. status_field.innerHTML = 'Loading [' + (event.total / event.max * 100.0) + ']';
  100. }
  101. else {
  102. progressBar.value = -1;
  103. status_field.innerHTML = 'Computing progress ...'
  104. }
  105. }
  106. function SendMeshData()
  107. {
  108. if (NaClModule)
  109. {
  110. NaClModule.postMessage(MeshCodeModule.value);
  111. //NaClModule.postMessage("sc#f8f afcb 1 1 1 0");
  112. alert("Data sent");
  113. }
  114. else
  115. alert("Module not loaded");
  116. }
  117. </script>
  118. </head>
  119. <body onload="pageDidLoad()">
  120. <h1>Mesh Viewer : Native Client version.</h1>
  121. <p>
  122. <div>
  123. <table border="1" cellspacing="0" cellpadding="0" style="width:770px;height:200px">
  124. <tr border="0"> <td border="0" align="center">
  125. <div id="status_field">NO-STATUS</div>
  126. <progress id=p align="left"></progress>
  127. <script type="text/javascript">
  128. var progressBar = document.getElementById("p");
  129. progressBar.max = 100;
  130. progressBar.value = 100;
  131. </script>
  132. <!--
  133. <script>
  134. var progressBar = document.getElementById("p"), client = new XMLHttpRequest()
  135. client.open("GET", "magical-unicorns")
  136. client.onprogress = function (pe) {
  137. if (pe.lengthComputable) {
  138. progressBar.max = pe.total
  139. progressBar.value = pe.loaded
  140. }
  141. }
  142. client.onloadend = function (pe) {
  143. progressBar.value = pe.loaded
  144. }
  145. client.send()
  146. progressBar.max = pe.total;
  147. progressBar.value = pe.loaded;
  148. </script>
  149. -->
  150. </td> </tr>
  151. </table>
  152. </div>
  153. </p>
  154. <h2>Status</h2>
  155. <div id="tick_field"></div>
  156. <div id="bouton">
  157. <textarea id="ID_MeshCode" rows="5" cols="80">
  158. //This is a comment
  159. sc#f8f afcb 1 1 1 0
  160. </textarea>
  161. </div>
  162. <div>
  163. <button onclick="SendMeshData()">Update Mesh</button>
  164. </div>
  165. <div id="listener" >
  166. <script type="text/javascript">
  167. var listener = document.getElementById('listener');
  168. listener.addEventListener('load', moduleDidLoad, true);
  169. listener.addEventListener('progress', moduleLoadProgress, true);
  170. listener.addEventListener('message', handleMessage, true);
  171. </script>
  172. <div id="nacl_div">
  173. <embed name="nacl_module"
  174. id="ID_NaClModule"
  175. width=770 height=200
  176. src="nacl.nmf"
  177. type="application/x-nacl" />
  178. </div>
  179. </div>
  180. </body>
  181. </html>