You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

280 lines
8.5 KiB

  1. <DOCTYPE html>
  2. <html>
  3. <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  4. <!--
  5. Copyright (c) 2012 The Native Client Authors. All rights reserved.
  6. Use of this source code is governed by a BSD-style license that can be
  7. found in the LICENSE file.
  8. -->
  9. <head>
  10. <style type="text/css">
  11. body
  12. {
  13. font:12px Consolas;
  14. }
  15. button
  16. {
  17. font:14px Consolas;
  18. }
  19. textarea
  20. {
  21. font:14px Consolas;
  22. }
  23. #id_div_progress_status
  24. {
  25. font:12px Consolas;
  26. }
  27. #id_div_progress
  28. {
  29. position: absolute;
  30. top: 20%;
  31. left: 30%;
  32. right: 30%;
  33. z-index: 3;
  34. background-color:white;
  35. border:1px solid #000000;
  36. visibility: hidden;
  37. }
  38. progress
  39. {
  40. background-color: #f3f3f3;
  41. border: 0;
  42. height: 18px;
  43. width: 200px;
  44. border-radius: 9px;
  45. }
  46. progress::-webkit-progress-bar
  47. {
  48. background-color: #f3f3f3;
  49. border: 1px solid #000000;
  50. padding: 2px 2px;
  51. height: 20px;
  52. border-radius: 0px;
  53. }
  54. progress::-webkit-progress-value
  55. {
  56. background-color: #22BB22;
  57. border: 0px;
  58. height: 14px;
  59. border-radius: 0px;
  60. }
  61. #id_div_listener
  62. {
  63. position: relative;
  64. }
  65. #id_div_frame_embed
  66. {
  67. position: absolute;
  68. top: 2px;
  69. left: 2px;
  70. z-index: -1;
  71. }
  72. #BGCanvas
  73. {
  74. border:1px solid #000000;
  75. }
  76. #id_div_helper_cmd_0
  77. {
  78. margin-left: 5px;
  79. }
  80. </style>
  81. <title>Mesh Viewer Web Edition</title>
  82. </head>
  83. <script type="text/javascript">
  84. //Base data Setup : GLOBAL STYLE
  85. g_div_frame_embed_save = '';
  86. g_div_frame_embed = null;
  87. g_txtarea_code_src = null;
  88. g_div_helper_cmd = [null, null];
  89. g_div_helper_args = null;
  90. g_div_helper_cmnt = null;
  91. g_div_helper_vars = null;
  92. g_div_alphabet = null;
  93. g_div_progress = null;
  94. g_div_progress_status = null;
  95. g_progress_bar = null;
  96. g_var_progress_bar = -1;
  97. g_frame_embed = null;
  98. //This is the module pointer : can be either the NaCl or Em one depending on the context.
  99. g_embed_module = null;
  100. function machinchose() { return 'test machin '; }
  101. function GetTextAreaCodeSrc() { return g_txtarea_code_src; }
  102. function GetDivProgress() { return g_div_progress; }
  103. function GetProgressBar() { return g_progress_bar; }
  104. function GetDivProgressStatus() { return g_div_progress_status; }
  105. function GetDivEmbedData() { return g_div_frame_embed; }
  106. function GetDivEmbedDataSave() { return g_div_frame_embed_save; }
  107. function GetFrameData() { return g_frame_embed; }
  108. //Communication with iframe content.
  109. function InitModuleVar() { g_embed_module = GetiFrameModuleVar(); }
  110. function GetiFrameDivEmbed() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetDivEmbed()); }
  111. function GetiFrameModuleVar() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetEmbedModule()); }
  112. function IsUsingNaCl() { return window.chrome; }
  113. </script>
  114. <script src="./utils.js"></script>
  115. <script src="./progress_status.js"></script>
  116. <script src="./type_dictionnary.js"></script>
  117. <script type="text/javascript">
  118. var EasyMeshDict = new TypeDictionnary("EasyMesh");
  119. function GetCmdDictionnary() { return EasyMeshDict; }
  120. </script>
  121. <script src="./easy_mesh_dictionnary.js"></script>
  122. <script type="text/javascript">
  123. //Base init for all datas
  124. function VarInit()
  125. {
  126. //Init frame variable first.
  127. g_frame_embed = document.getElementById('id_frame_embed');
  128. //This is in an iframe.
  129. g_div_frame_embed = g_frame_embed.contentDocument.getElementById('id_div_frame_embed');
  130. //The rest of these are in this page.
  131. g_txtarea_code_src = document.getElementById('id_txtarea_code_src');
  132. g_div_helper_cmd[0] = document.getElementById('id_div_helper_cmd_0');
  133. g_div_helper_cmd[1] = document.getElementById('id_div_helper_cmd_1');
  134. g_div_helper_args = document.getElementById('id_div_helper_args');
  135. g_div_helper_cmnt = document.getElementById('id_div_helper_cmnt');
  136. g_div_helper_vars = document.getElementById('id_div_helper_vars');
  137. g_div_alphabet = document.getElementById('id_div_alphabet');
  138. g_div_progress = document.getElementById('id_div_progress');
  139. g_div_progress_status = document.getElementById('id_div_progress_status');
  140. g_progress_bar = document.getElementById('id_progress_bar');
  141. }
  142. //Base init
  143. function Init()
  144. {
  145. VarInit();
  146. //Put here any cookie update
  147. if (!g_txtarea_code_src.value)
  148. g_txtarea_code_src.value = "//This is a comment\nsc#f8f afcb 1 1 1 0";
  149. //Fill the TOC
  150. if (!g_div_alphabet.innerHTML)
  151. {
  152. g_div_alphabet.innerHTML = '&nbsp;Table of content<br>&nbsp;[';
  153. var new_toc = BuildTOC(true);
  154. var pattern = new RegExp("^[a-zA-Z\.]");
  155. while (pattern.test(new_toc))
  156. new_toc = new_toc.replace(pattern, "<b>$&");
  157. pattern = new RegExp("[a-zA-Z\.]$");
  158. while (pattern.test(new_toc))
  159. new_toc = new_toc.replace(pattern, "$&</b>");
  160. pattern = new RegExp("([a-zA-Z])([\.])");
  161. while (pattern.test(new_toc))
  162. new_toc = new_toc.replace(pattern, "$1</b>$2");
  163. pattern = new RegExp("([\.])([a-zA-Z])");
  164. while (pattern.test(new_toc))
  165. new_toc = new_toc.replace(pattern, "$1<b>$2");
  166. g_div_alphabet.innerHTML += new_toc + ']&nbsp;<br>&nbsp;';
  167. }
  168. //NaCl Specific
  169. if (IsUsingNaCl())
  170. {
  171. DynLoadFile("nacl_loading.js");
  172. g_frame_embed.src = 'meshviewer_nacl.html';
  173. }
  174. else
  175. g_frame_embed.src = 'meshviewer_em.html';
  176. g_frame_embed.onload = function() { VarInit(); }
  177. //Tick has been done, start Tick
  178. window.setTimeout("Tick()", 200);
  179. }
  180. function Tick()
  181. {
  182. window.setTimeout("Tick()", 100);
  183. var text_src = g_txtarea_code_src;
  184. var div_cmds = g_div_helper_cmd;
  185. var div_args = g_div_helper_args;
  186. var div_cmnt = g_div_helper_cmnt;
  187. var div_vars = g_div_helper_vars;
  188. CmdLookup(div_cmds, div_args, div_cmnt, div_vars, text_src);
  189. }
  190. //Handle message from the NaCl module
  191. function ModuleSentMessage(message)
  192. {
  193. alert('Module sent message: ' + message.data);
  194. }
  195. //Called by the "Send Mesh Command !" button
  196. function SendMessageToModule()
  197. {
  198. if (g_embed_module)
  199. g_embed_module.SendMessage(GetTextAreaCodeSrc().value);
  200. else
  201. alert("Module not loaded !");
  202. }
  203. </script>
  204. <body>
  205. <h1>Mesh Viewer : Web version.</h1>
  206. <p>
  207. <div id="final_div">
  208. <div id="id_div_listener" align="center" style="width:770px;height:200px">
  209. <canvas id="BGCanvas" width="772" height="202"></canvas>
  210. <div id="id_div_progress">
  211. <br>&nbsp;
  212. <progress id="id_progress_bar" align="left"></progress>
  213. <div id="id_div_progress_status">....</div>&nbsp;
  214. </div>
  215. <div id="id_div_frame_embed">
  216. <iframe onload="Init();" id="id_frame_embed" src="empty.html" width=770 height=200 frameborder=0 scrolling=no></iframe>
  217. </div>
  218. </div>
  219. </div>
  220. </p>
  221. <div><button onclick="SendMessageToModule()">Send Mesh Command !</button></div>
  222. <table border="0" cellpadding="0" cellspacing="0">
  223. <tr>
  224. <td height="1%">
  225. <div id="bouton">
  226. <textarea autofocus id="id_txtarea_code_src" rows="6" cols="94" style="font: 14px Consolas; resize: none;"></textarea>
  227. </div>
  228. </td>
  229. <td valign="top" rowspan="3">&nbsp;</td>
  230. <td valign="top" rowspan="3">
  231. <div><b><u>Variable Types usage :</u></b></div>
  232. <div id="id_div_helper_vars"></div>
  233. </td>
  234. </tr>
  235. <tr>
  236. <td height="1%">
  237. <div id="id_div_alphabet"></div>
  238. </td>
  239. </tr>
  240. <tr>
  241. <td valign="top">
  242. <table border="0" cellpadding="0" cellspacing="0">
  243. <tr>
  244. <td valign="top"><div id="id_div_helper_cmd_0"></div></td>
  245. <td valign="top"><div id="id_div_helper_cmd_1"></div></td>
  246. <td valign="top"><div id="id_div_helper_args" ></div></td>
  247. <td valign="top"><div id="id_div_helper_cmnt" ></div></td>
  248. </tr>
  249. </table>
  250. </td>
  251. </tr>
  252. </table>
  253. </body>
  254. </html>