|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <!DOCTYPE html>
- <html>
-
- <!--
- Copyright (c) 2012 The Native Client Authors. All rights reserved.
- Use of this source code is governed by a BSD-style license that can be
- found in the LICENSE file.
- -->
-
- <head>
-
- <style type="text/css">
- progress {
- background-color: #f3f3f3;
- border: 0;
- height: 18px;
- border-radius: 9px;
- }
- progress::-webkit-progress-bar {
- background-color: #f3f3f3;
- border: 1px solid #000000;
- padding: 2px 2px;
- height: 20px;
- border-radius: 0px;
- }
- progress::-webkit-progress-value {
- background-color: #22BB22;
- border: 0px;
- height: 14px;
- border-radius: 0px;
- }
- #listener {
- position: relative;
- }
- #progress_bar {
- position: absolute;
- top: 40%;
- left: 40%;
- z-index: 3;
- }
- #nacl_div {
- position: absolute;
- top: 2px;
- left: 2px;
- z-index: -1;
- }
- #BGCanvas {
- border:1px solid #000000;
- }
- </style>
- <!--
- -->
- <title>Mesh Viewer NaCl</title>
-
- <script type="text/javascript">
- NaClModule = null; // Global application object.
- MeshCodeModule = null;
- statusText = 'NO-STATUS';
- window.setTimeout("Tick()", 100);
-
- function Tick() {
- window.setTimeout("Tick()", 100);
- }
-
-
- // Indicate load success.
- function moduleDidLoad() {
- NaClModule = document.getElementById('ID_NaClModule');
- MeshCodeModule = document.getElementById('ID_MeshCode');
- updateStatus('Rock n\' Roll !!');
- var progress_bar = document.getElementById('progress_bar');
- progress_bar.style.visibility="hidden";
- }
-
- // The 'message' event handler. This handler is fired when the NaCl module
- // posts a message to the browser by calling PPB_Messaging.PostMessage()
- // (in C) or pp::Instance.PostMessage() (in C++). This implementation
- // simply displays the content of the message in an alert panel.
- function handleMessage(message_event) {
- alert(message_event.data);
- }
-
- // If the page loads before the Native Client module loads, then set the
- // status message indicating that the module is still loading. Otherwise,
- // do not change the status message.
- function pageDidLoad() {
- if (NaClModule == null) {
- updateStatus('Please wait, loading ...');
- } else {
- // It's possible that the Native Client module onload event fired
- // before the page's onload event. In this case, the status message
- // will reflect 'SUCCESS', but won't be displayed. This call will
- // display the current message.
- updateStatus();
- }
- }
-
- // Set the global status message. If the element with id 'statusField'
- // exists, then set its HTML to the status message as well.
- // opt_message The message test. If this is null or undefined, then
- // attempt to set the element with id 'statusField' to the value of
- // |statusText|.
- function updateStatus(opt_message) {
- if (opt_message)
- statusText = opt_message;
- var statusField = document.getElementById('status_field');
- if (statusField) {
- statusField.innerHTML = statusText;
- }
- }
-
- function moduleLoadProgress(event)
- {
- var progressBar = document.getElementById("p");
- var statusField = document.getElementById('status_field');
- if (event.lengthComputable) {
- progressBar.max = event.total;
- progressBar.value = event.loaded;
- var load_progress = ((event.loaded / event.total) * 100.0);
- status_field.innerHTML = 'Please wait, loading [' + load_progress.toFixed(0) + '%]';
- }
- else {
- progressBar.value = -1;
- status_field.innerHTML = 'Computing progress ...'
- }
- }
-
-
- function SendMeshData()
- {
- if (NaClModule)
- NaClModule.postMessage(MeshCodeModule.value);
- else
- alert("Module not loaded");
- }
- </script>
- </head>
- <body onload="pageDidLoad()">
-
- <h1>Mesh Viewer : Native Client version.</h1>
- <p>
- <div id="final_div">
- <div id="listener" align="center" style="width:770px;height:200px">
- <canvas id="BGCanvas" width="772" height="202">
- test
- </canvas>
- <div id="progress_bar">
- <div id="status_field">NO-STATUS</div>
- <progress id=p align="left"></progress>
- </div>
- <div id="nacl_div">
- <param name="wmode" value="opaque"/>
- <embed name="nacl_module"
- id="ID_NaClModule"
- width=770 height=200
- src="meshviewer_nacl.nmf"
- type="application/x-nacl" />
- </div>
- <script type="text/javascript">
- var listener = document.getElementById('listener');
- listener.addEventListener('load', moduleDidLoad, true);
- listener.addEventListener('progress', moduleLoadProgress, true);
- listener.addEventListener('message', handleMessage, true);
- </script>
- </div>
- </div>
- </p>
- <h2>Status</h2>
- <div id="tick_field"></div>
- <div id="bouton">
- <textarea id="ID_MeshCode" rows="5" cols="80">
- //This is a comment
- sc#f8f afcb 1 1 1 0
- </textarea>
- </div>
- <div>
- <button onclick="SendMeshData()">Update Mesh</button>
- </div>
-
- </body>
- </html>
|