Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

meshviewer_index.html 5.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. #listener {
  30. position: relative;
  31. }
  32. #progress_bar {
  33. position: absolute;
  34. top: 40%;
  35. left: 40%;
  36. z-index: 3;
  37. }
  38. #nacl_div {
  39. position: absolute;
  40. top: 2px;
  41. left: 2px;
  42. z-index: -1;
  43. }
  44. #BGCanvas {
  45. border:1px solid #000000;
  46. }
  47. </style>
  48. <!--
  49. -->
  50. <title>Mesh Viewer NaCl</title>
  51. <script type="text/javascript">
  52. NaClModule = null; // Global application object.
  53. MeshCodeModule = null;
  54. statusText = 'NO-STATUS';
  55. window.setTimeout("Tick()", 100);
  56. function Tick() {
  57. window.setTimeout("Tick()", 100);
  58. }
  59. // Indicate load success.
  60. function moduleDidLoad() {
  61. NaClModule = document.getElementById('ID_NaClModule');
  62. MeshCodeModule = document.getElementById('ID_MeshCode');
  63. updateStatus('Rock n\' Roll !!');
  64. var progress_bar = document.getElementById('progress_bar');
  65. progress_bar.style.visibility="hidden";
  66. }
  67. // The 'message' event handler. This handler is fired when the NaCl module
  68. // posts a message to the browser by calling PPB_Messaging.PostMessage()
  69. // (in C) or pp::Instance.PostMessage() (in C++). This implementation
  70. // simply displays the content of the message in an alert panel.
  71. function handleMessage(message_event) {
  72. alert(message_event.data);
  73. }
  74. // If the page loads before the Native Client module loads, then set the
  75. // status message indicating that the module is still loading. Otherwise,
  76. // do not change the status message.
  77. function pageDidLoad() {
  78. if (NaClModule == null) {
  79. updateStatus('Please wait, loading ...');
  80. } else {
  81. // It's possible that the Native Client module onload event fired
  82. // before the page's onload event. In this case, the status message
  83. // will reflect 'SUCCESS', but won't be displayed. This call will
  84. // display the current message.
  85. updateStatus();
  86. }
  87. }
  88. // Set the global status message. If the element with id 'statusField'
  89. // exists, then set its HTML to the status message as well.
  90. // opt_message The message test. If this is null or undefined, then
  91. // attempt to set the element with id 'statusField' to the value of
  92. // |statusText|.
  93. function updateStatus(opt_message) {
  94. if (opt_message)
  95. statusText = opt_message;
  96. var statusField = document.getElementById('status_field');
  97. if (statusField) {
  98. statusField.innerHTML = statusText;
  99. }
  100. }
  101. function moduleLoadProgress(event)
  102. {
  103. var progressBar = document.getElementById("p");
  104. var statusField = document.getElementById('status_field');
  105. if (event.lengthComputable) {
  106. progressBar.max = event.total;
  107. progressBar.value = event.loaded;
  108. var load_progress = ((event.loaded / event.total) * 100.0);
  109. status_field.innerHTML = 'Please wait, loading [' + load_progress.toFixed(0) + '%]';
  110. }
  111. else {
  112. progressBar.value = -1;
  113. status_field.innerHTML = 'Computing progress ...'
  114. }
  115. }
  116. function SendMeshData()
  117. {
  118. if (NaClModule)
  119. NaClModule.postMessage(MeshCodeModule.value);
  120. else
  121. alert("Module not loaded");
  122. }
  123. </script>
  124. </head>
  125. <body onload="pageDidLoad()">
  126. <h1>Mesh Viewer : Native Client version.</h1>
  127. <p>
  128. <div id="final_div">
  129. <div id="listener" align="center" style="width:770px;height:200px">
  130. <canvas id="BGCanvas" width="772" height="202">
  131. test
  132. </canvas>
  133. <div id="progress_bar">
  134. <div id="status_field">NO-STATUS</div>
  135. <progress id=p align="left"></progress>
  136. </div>
  137. <div id="nacl_div">
  138. <param name="wmode" value="opaque"/>
  139. <embed name="nacl_module"
  140. id="ID_NaClModule"
  141. width=770 height=200
  142. src="meshviewer_nacl.nmf"
  143. type="application/x-nacl" />
  144. </div>
  145. <script type="text/javascript">
  146. var listener = document.getElementById('listener');
  147. listener.addEventListener('load', moduleDidLoad, true);
  148. listener.addEventListener('progress', moduleLoadProgress, true);
  149. listener.addEventListener('message', handleMessage, true);
  150. </script>
  151. </div>
  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. </body>
  166. </html>