Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

336 rindas
10 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. var g_code_addin = ['custom setmesh "#CODE#"', '#CODE#'];
  101. var g_code_base = [];
  102. var CodeDictionnary = [];
  103. g_code_id = 0;
  104. g_code_base[0] = "//This is a comment\nsc#f8f afcb 1 1 1 0";
  105. g_code_base[1] = "//This is a comment\naddlight 0.0 position (4 -1 -4) color (.0 .2 .5 1)\naddlight 0.0 position (8 2 6) color #ffff";
  106. function machinchose() { return 'test machin '; }
  107. function GetTextAreaCodeSrc() { return g_txtarea_code_src; }
  108. function GetDivProgress() { return g_div_progress; }
  109. function GetProgressBar() { return g_progress_bar; }
  110. function GetDivProgressStatus() { return g_div_progress_status; }
  111. function GetDivEmbedData() { return g_div_frame_embed; }
  112. function GetDivEmbedDataSave() { return g_div_frame_embed_save; }
  113. function GetFrameData() { return g_frame_embed; }
  114. //Communication with iframe content.
  115. function InitModuleVar() { g_embed_module = GetiFrameModuleVar(); }
  116. function GetiFrameDivEmbed() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetDivEmbed()); }
  117. function GetiFrameModuleVar() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetEmbedModule()); }
  118. function IsUsingNaCl() { return window.chrome; }
  119. </script>
  120. <script src="../javascript/utils.js"></script>
  121. <script src="../javascript/progressstatus.js"></script>
  122. <script type="text/javascript">
  123. //Used by typedictionnary.js
  124. function GetCmdDictionnary() { return CodeDictionnary[g_code_id]; }
  125. g_code_id = 1;
  126. </script>
  127. <script src="../javascript/typedictionnary.js"></script>
  128. <!-- Init Scene setup dictionnary -->
  129. <script type="text/javascript">
  130. CodeDictionnary[g_code_id] = new TypeDictionnary("SceneSetup");
  131. </script>
  132. <script src="./scenesetupdictionnary.js"></script>
  133. <!-- Init Easy mesh dictionnary -->
  134. <script type="text/javascript">
  135. g_code_id--;
  136. CodeDictionnary[g_code_id] = new TypeDictionnary("EasyMesh");
  137. </script>
  138. <script src="./easymeshdictionnary.js"></script>
  139. <!-- Revert datas to normal -->
  140. <script type="text/javascript">
  141. g_code_id = 0;
  142. </script>
  143. <script type="text/javascript">
  144. //Base init for all datas
  145. function VarInit()
  146. {
  147. //Init frame variable first.
  148. g_frame_embed = document.getElementById('id_frame_embed');
  149. //This is in an iframe.
  150. g_div_frame_embed = g_frame_embed.contentDocument.getElementById('id_div_frame_embed');
  151. //The rest of these are in this page.
  152. g_txtarea_code_src = document.getElementById('id_txtarea_code_src');
  153. g_div_helper_cmd[0] = document.getElementById('id_div_helper_cmd_0');
  154. g_div_helper_cmd[1] = document.getElementById('id_div_helper_cmd_1');
  155. g_div_helper_args = document.getElementById('id_div_helper_args');
  156. g_div_helper_cmnt = document.getElementById('id_div_helper_cmnt');
  157. g_div_helper_vars = document.getElementById('id_div_helper_vars');
  158. g_div_alphabet = document.getElementById('id_div_alphabet');
  159. g_div_progress = document.getElementById('id_div_progress');
  160. g_div_progress_status = document.getElementById('id_div_progress_status');
  161. g_progress_bar = document.getElementById('id_progress_bar');
  162. }
  163. //Base init
  164. function Init()
  165. {
  166. VarInit();
  167. //Put here any cookie update
  168. if (!g_txtarea_code_src.value)
  169. g_txtarea_code_src.value = g_code_base[g_code_id];
  170. //Fill the TOC
  171. if (!g_div_alphabet.innerHTML)
  172. {
  173. for (var i = 0; i < CodeDictionnary.length; i++)
  174. {
  175. g_code_id = i;
  176. var new_toc = BuildTOC(true);
  177. var pattern = new RegExp("^[a-zA-Z\.]");
  178. while (pattern.test(new_toc))
  179. new_toc = new_toc.replace(pattern, "<b>$&");
  180. pattern = new RegExp("[a-zA-Z\.]$");
  181. while (pattern.test(new_toc))
  182. new_toc = new_toc.replace(pattern, "$&</b>");
  183. pattern = new RegExp("([a-zA-Z])([\.])");
  184. while (pattern.test(new_toc))
  185. new_toc = new_toc.replace(pattern, "$1</b>$2");
  186. pattern = new RegExp("([\.])([a-zA-Z])");
  187. while (pattern.test(new_toc))
  188. new_toc = new_toc.replace(pattern, "$1<b>$2");
  189. CodeDictionnary[i].m_alphabet = new_toc;
  190. }
  191. g_code_id = 0;
  192. InitEditValues();
  193. }
  194. //NaCl Specific
  195. if (IsUsingNaCl())
  196. {
  197. DynLoadFile("../javascript/naclloading.js");
  198. g_frame_embed.src = 'meshviewer.nacl.html';
  199. }
  200. else
  201. g_frame_embed.src = 'meshviewer.em.html';
  202. g_frame_embed.onload = function() { VarInit(); }
  203. //Tick has been done, start Tick
  204. window.setTimeout("Tick()", 200);
  205. }
  206. function Tick()
  207. {
  208. window.setTimeout("Tick()", 100);
  209. var text_src = g_txtarea_code_src;
  210. var div_cmds = g_div_helper_cmd;
  211. var div_args = g_div_helper_args;
  212. var div_cmnt = g_div_helper_cmnt;
  213. var div_vars = g_div_helper_vars;
  214. CmdLookup(div_cmds, div_args, div_cmnt, div_vars, text_src);
  215. }
  216. function StoreTextAreaValue()
  217. {
  218. g_code_base[g_code_id] = GetTextAreaCodeSrc().value;
  219. }
  220. function ExchangeSetup()
  221. {
  222. StoreTextAreaValue();
  223. g_code_id = (g_code_id + 1) % 2;
  224. InitEditValues();
  225. }
  226. function InitEditValues()
  227. {
  228. GetTextAreaCodeSrc().value = g_code_base[g_code_id];
  229. g_div_alphabet.innerHTML = '&nbsp;Table of content<br>&nbsp;[' + CodeDictionnary[g_code_id].m_alphabet + ']&nbsp;<br>&nbsp;';
  230. }
  231. //Handle message from the NaCl module
  232. function ModuleSentMessage(message)
  233. {
  234. alert('Module sent message: ' + message.data);
  235. }
  236. //Called by the "Send Mesh Command !" button
  237. function SendMessageToModule()
  238. {
  239. StoreTextAreaValue();
  240. if (g_embed_module)
  241. g_embed_module.SendMessage(g_code_addin[g_code_id].replace('#CODE#', g_code_base[g_code_id]));
  242. else
  243. alert("Module not loaded !");
  244. }
  245. </script>
  246. <body>
  247. <h1>Mesh Viewer : Web version.</h1>
  248. <p>
  249. <div id="final_div">
  250. <div id="id_div_listener" align="center" style="width:770px;height:200px">
  251. <canvas id="BGCanvas" width="772" height="202"></canvas>
  252. <div id="id_div_progress">
  253. <br>&nbsp;
  254. <progress id="id_progress_bar" align="left"></progress>
  255. <div id="id_div_progress_status">....</div>&nbsp;
  256. </div>
  257. <div id="id_div_frame_embed">
  258. <iframe onload="Init();" id="id_frame_embed" src="empty.html" width=770 height=200 frameborder=0 scrolling=no></iframe>
  259. </div>
  260. </div>
  261. </div>
  262. </p>
  263. <table border="0" cellpadding="0" cellspacing="0" width="772">
  264. <tr>
  265. <td align="left">
  266. <div><button onclick="SendMessageToModule()">Update program</button></div>
  267. </td>
  268. <td align="right">
  269. <div><button onclick="ExchangeSetup()">Change edit data</button></div>
  270. </td>
  271. </tr>
  272. </table>
  273. <table border="0" cellpadding="0" cellspacing="0">
  274. <tr>
  275. <td height="1%">
  276. <div id="bouton">
  277. <textarea autofocus id="id_txtarea_code_src" rows="6" cols="94" style="font: 14px Consolas; resize: none;"></textarea>
  278. </div>
  279. </td>
  280. <td valign="top" rowspan="3">&nbsp;</td>
  281. <td valign="top" rowspan="3">
  282. <div><b><u>Variable Types usage :</u></b></div>
  283. <div id="id_div_helper_vars"></div>
  284. </td>
  285. </tr>
  286. <tr>
  287. <td height="1%">
  288. <div id="id_div_alphabet"></div>
  289. </td>
  290. </tr>
  291. <tr>
  292. <td valign="top">
  293. <table border="0" cellpadding="0" cellspacing="0">
  294. <tr>
  295. <td valign="top"><div id="id_div_helper_cmd_0"></div></td>
  296. <td valign="top"><div id="id_div_helper_cmd_1"></div></td>
  297. <td valign="top"><div id="id_div_helper_args" ></div></td>
  298. <td valign="top"><div id="id_div_helper_cmnt" ></div></td>
  299. </tr>
  300. </table>
  301. </td>
  302. </tr>
  303. </table>
  304. </body>
  305. </html>