| OLD | NEW |
| (Empty) |
| 1 <!doctype html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <meta charset="UTF-8" /> | |
| 5 <title>Hex!</title> | |
| 6 <script type="text/javascript"> | |
| 7 naclModule = null; // Global application object. | |
| 8 statusText = 'NO-STATUS'; | |
| 9 | |
| 10 // Set the global |field| message. If the element with id |field| | |
| 11 // exists, then set its HTML to the status message as well. | |
| 12 // opt_message The message test. If this is null or undefined, then | |
| 13 // attempt to set the element with id |field| to the value of | |
| 14 // |statusText|. | |
| 15 function updateHtmlField(field, opt_message) { | |
| 16 if (opt_message) | |
| 17 statusText = opt_message; | |
| 18 var statusField = document.getElementById(field); | |
| 19 if (statusField) { | |
| 20 statusField.innerHTML = statusText; | |
| 21 console.log('Updated field {' + field + '}'); | |
| 22 } else { | |
| 23 // alert('Error getting field ' + field); | |
| 24 console.log('Error getting field {' + field + '}'); | |
| 25 console.log('Message for field was ' + opt_message); | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 function moduleDidLoad() { | |
| 30 naclModule = document.getElementById('hex_app'); | |
| 31 console.log('MODULE DID LOAD CALLED') | |
| 32 naclModule.addEventListener('message', handleMessage, false); | |
| 33 updateHtmlField('status_field', 'SUCCESS'); | |
| 34 } | |
| 35 | |
| 36 | |
| 37 // If the page loads before the Native Client module loads, then set the | |
| 38 // status message indicating that the module is still loading. Otherwise, | |
| 39 // do not change the status message. | |
| 40 function pageDidLoad() { | |
| 41 if (naclModule == null) { | |
| 42 updateHtmlField('status_field', 'LOADING...'); | |
| 43 console.log('In pageDidLoad...LOADING'); | |
| 44 } else { | |
| 45 // It's possible that the Native Client module onload event fired | |
| 46 // before the page's onload event. In this case, the status message | |
| 47 // will reflect 'SUCCESS', but won't be displayed. This call will | |
| 48 // display the current message. | |
| 49 updateHtmlField('status_field', 'LOADED'); | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 </script> | |
| 54 </head> | |
| 55 <body onload="pageDidLoad()"> | |
| 56 <div id="listener"> | |
| 57 <script type="text/javascript"> | |
| 58 document.getElementById('listener') | |
| 59 .addEventListener('load', moduleDidLoad, true); | |
| 60 console.log('Added event listener!'); | |
| 61 </script> | |
| 62 | |
| 63 <embed name="nacl_module" | |
| 64 id="hex_app" | |
| 65 width=0 height=0 | |
| 66 src="hex.nmf" | |
| 67 type="application/x-nacl" /> | |
| 68 </div> | |
| 69 | |
| 70 <p> | |
| 71 <p style="margin-bottom: 0px"><a href="http://en.wikipedia.org/wiki/Hex_
(board_game)" | |
| 72 target="about_hex_game">Hex Game</a></p> | |
| 73 <p style="margin-bottom: 0px;"><a href="http://code.google.com/p/nativec
lient-sdk/source/browse/trunk/src/experimental/hex/" | |
| 74 target="about_hex_game">View the source</a></p> | |
| 75 <p style="margin-bottom: 0px;"><a href="about.html" | |
| 76 target="about_hex_game">Acknowledgments</a></p> | |
| 77 | |
| 78 <div> | |
| 79 <canvas id="canvas" | |
| 80 style="z-index:6; | |
| 81 position:absolute; | |
| 82 left:0px; | |
| 83 top:120px;" | |
| 84 width="1800" height="1500"> | |
| 85 This text is displayed if your browser does not support HTML5 Canvas. | |
| 86 </canvas> | |
| 87 <canvas id="canvas2" | |
| 88 style="z-index:4; | |
| 89 position:absolute; | |
| 90 left:0px; | |
| 91 top:120px;" | |
| 92 width="1800" height="1500"> | |
| 93 This text is displayed if your browser does not support HTML5 Canvas. | |
| 94 </canvas> | |
| 95 <canvas id="canvasBk" | |
| 96 style="z-index:2; | |
| 97 position:absolute; | |
| 98 left:0px; | |
| 99 top:120px;" | |
| 100 width="1800" height="1500"> | |
| 101 This text is displayed if your browser does not support HTML5 Canvas. | |
| 102 </canvas> | |
| 103 </div> | |
| 104 | |
| 105 <script type="text/javascript" src="hex.js"></script> | |
| 106 | |
| 107 </section> | |
| 108 <h4>Status</h4> | |
| 109 <div id="TurnNumber">NO-NUMBER</div> | |
| 110 <div id="status_field">NO-STATUS</div> | |
| 111 <div id="Turn">NO-TURN</div> | |
| 112 </body> | |
| 113 </html> | |
| OLD | NEW |