| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <TITLE>Life Demo</TITLE> | 3 <title>Life Demo</title> |
| 4 <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> | 4 <meta HTTP-EQUIV="Pragma" CONTENT="no-cache"> |
| 5 <META HTTP-EQUIV="Expires" CONTENT="-1"> | 5 <meta HTTP-EQUIV="Expires" CONTENT="-1"> |
| 6 <link href="life.css" rel="stylesheet" type="text/css"> |
| 7 <script type="text/javascript" src="dragger.js"></script> |
| 8 <script type="text/javascript" src="life.js"></script> |
| 9 <script type="text/javascript"> |
| 10 life.application = new life.Application(); |
| 6 | 11 |
| 7 <script type="text/javascript"> | 12 // This function is called when the life NaCl module is loaded. |
| 8 // Set the global status message. If the element with id 'status_field' | 13 function moduleDidLoad() { |
| 9 // exists, then set its HTML to the status message as well. | 14 var module = |
| 10 // opt_message The message test. If this is null or undefined, then | 15 document.getElementById('life'); |
| 11 // attempt to set the element with id 'status_field' to the value of | 16 life.application.moduleDidLoad(module, 'div_event_layer'); |
| 12 // |status_text|. | |
| 13 var life = null; | |
| 14 var updateInterval = null; | |
| 15 function updateStatus(opt_message) { | |
| 16 if (opt_message) | |
| 17 status_text = opt_message; | |
| 18 var status_field = document.getElementById('status_field'); | |
| 19 if (status_field) { | |
| 20 status_field.innerHTML = status_text; | |
| 21 } | 17 } |
| 22 } | |
| 23 | 18 |
| 24 // use a 10ms update interval to drive frame rate | 19 function pageDidUnload() { |
| 25 function moduleDidLoad() { | 20 life.application.moduleDidUnload(); |
| 26 life = document.getElementById('life'); | |
| 27 if (life != null) { | |
| 28 updateStatus('SUCCESS'); | |
| 29 updateInterval = setInterval("life.update()", 10); | |
| 30 } | 21 } |
| 31 } | 22 </script> |
| 32 | |
| 33 function pageDidUnload() { | |
| 34 clearInterval(updateInterval); | |
| 35 } | |
| 36 | |
| 37 </script> | |
| 38 | |
| 39 </head> | 23 </head> |
| 40 <body id="bodyId" onunload="pageDidUnload();" > | 24 <body id="bodyId" onunload="pageDidUnload();" > |
| 41 | 25 |
| 42 <h1>Conway's Life</h1> | 26 <h1>Conway's Life</h1> |
| 43 <p> | 27 <p> |
| 44 Use the mouse to paint extra life into the simulation. | 28 Use the mouse to paint extra life into the simulation. |
| 45 </p> | 29 </p> |
| 46 | 30 |
| 47 <div id="life_content"></div> | 31 <!-- Load the published .nexe. This includes the 'nacl' attribute which |
| 48 <script type="text/javascript"> | 32 shows how to load multi-architecture modules. Each entry in the "nexes" |
| 49 contentDiv = document.getElementById('life_content'); | 33 object in the .nmf manifest file is a key-value pair: the key is the |
| 50 if (window.location.hash == '#develop') { | 34 runtime ('x86-32', 'x86-64', etc.); the value is a URL for the desired NaCl |
| 51 // Load the develop version of the module. | 35 module. To load the debug versions of your .nexes, set the 'nacl' |
| 52 contentDiv.innerHTML = '<embed name="nacl_module" ' | 36 attribute to the _dbg.nmf version of the manifest file. |
| 53 + 'id="life" ' | 37 --> |
| 54 + 'width=200 height=200 ' | 38 <div id="div_background_layer" class="background_layer"> |
| 55 + 'type="pepper-application/life" ' | 39 <div id="div_event_layer" class="event_layer"></div> |
| 56 + 'dimension="2" />' | 40 <embed name="nacl_module" |
| 57 moduleDidLoad(); | 41 id="life" |
| 58 } else { | 42 class="nacl_module_layer" |
| 59 // Load the published .nexe. This includes the 'nexes' attribute which | 43 width=400 height=400 |
| 60 // shows how to load multi-architecture modules. Each entry in the | 44 nacl="life.nmf" |
| 61 // table is a key-value pair: the key is the runtime ('x86-32', | 45 type="application/x-nacl" |
| 62 // 'x86-64', etc.); the value is a URL for the desired NaCl module. | 46 dimensions="2" |
| 63 var nexes = 'x86-32: life_x86_32.nexe\n' | 47 onload="moduleDidLoad();" /> |
| 64 + 'x86-64: life_x86_64.nexe\n' | 48 </div> |
| 65 + 'arm: life_arm.nexe '; | |
| 66 contentDiv.innerHTML = '<embed name="nacl_module" ' | |
| 67 + 'id="life" ' | |
| 68 + 'width=200 height=200 ' | |
| 69 // + 'nexes="' + nexes + '" ' | |
| 70 + 'type="application/x-nacl-srpc" ' | |
| 71 + 'dimensions="2" ' | |
| 72 + 'onload=moduleDidLoad() />'; | |
| 73 // Note: this code is here to work around a bug in Chromium build | |
| 74 // #47357. See also | |
| 75 // http://code.google.com/p/nativeclient/issues/detail?id=500 | |
| 76 document.getElementById('life').nexes = nexes; | |
| 77 } | |
| 78 </script> | |
| 79 <br> | 49 <br> |
| 80 </body> | 50 </body> |
| 81 </html> | 51 </html> |
| OLD | NEW |