OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <!-- | |
4 Copyright (c) 2010 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 This html example is copied from stub.html, from the examples/stub/ directory | |
9 of the NativeClient SDK web site: http://code.google.com/p/nativeclient-sdk/. | |
10 --> | |
11 <head> | |
12 <title>$safeprojectname$</title> | |
13 | |
14 <script type="text/javascript"> | |
15 $safeprojectname$Module = null; // Global application object. | |
16 statusText = 'NO-STATUS'; | |
17 | |
18 function moduleDidLoad() { | |
19 $safeprojectname$Module = document.getElementById('$safeprojectname$'); | |
20 updateStatus('SUCCESS'); | |
21 } | |
22 | |
23 // If the page loads before the Native Client module loads, then set the | |
24 // status message indicating that the module is still loading. Otherwise, | |
25 // do not change the status message. | |
26 function pageDidLoad() { | |
27 if ($safeprojectname$Module == null) { | |
28 updateStatus('LOADING...'); | |
29 } else { | |
30 // It's possible that the Native Client module onload event fired | |
31 // before the page's onload event. In this case, the status message | |
32 // will reflect 'SUCCESS', but won't be displayed. This call will | |
33 // display the current message. | |
34 updateStatus(); | |
35 } | |
36 } | |
37 | |
38 // Set the global status message. If the element with id 'statusField' | |
39 // exists, then set its HTML to the status message as well. | |
40 // opt_message The message test. If this is null or undefined, then | |
41 // attempt to set the element with id 'statusField' to the value of | |
42 // |statusText|. | |
43 function updateStatus(opt_message) { | |
44 if (opt_message) | |
45 statusText = opt_message; | |
46 var statusField = document.getElementById('status_field'); | |
47 if (statusField) { | |
48 statusField.innerHTML = statusText; | |
49 } | |
50 } | |
51 </script> | |
52 </head> | |
53 <body onload="pageDidLoad()"> | |
54 | |
55 <h1>Native Client $safeprojectname$ Module</h1> | |
56 <p> | |
57 <!-- Load the published .nexe. This includes the 'src' attribute which | |
58 shows how to load multi-architecture modules. Each entry in the "nexes" | |
59 object in the .nmf manifest file is a key-value pair: the key is the | |
60 runtime ('x86-32', 'x86-64', etc.); the value is a URL for the desired NaCl | |
61 module. To load the debug versions of your .nexes, set the 'src' | |
62 attribute to the _dbg.nmf version of the manifest file. | |
63 | |
64 Note that the <EMBED> element is wrapped inside a <DIV>, which has a 'load' | |
65 event listener attached. This method is used instead of attaching the | |
66 'load' event listener directly to the <EMBED> element to ensure that the | |
67 listener is active before the NaCl module 'load' event fires. | |
68 --> | |
69 <div id="listener"> | |
70 <script type="text/javascript"> | |
71 document.getElementById('listener') | |
72 .addEventListener('load', moduleDidLoad, true); | |
73 </script> | |
74 <embed name="nacl_module" | |
75 id="$safeprojectname$" | |
76 width=0 height=0 | |
77 src="$safeprojectname$.nmf" | |
78 type="application/x-nacl" | |
79 onload="moduleDidLoad();" /> | |
80 </div> | |
81 </p> | |
82 | |
83 <h2>Status</h2> | |
84 <div id="status_field">NO-STATUS</div> | |
85 </body> | |
86 </html> | |
OLD | NEW |