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 10 KiB

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