1 <!DOCTYPE html> 2 <html> 3 <!-- 4 Copyright 2013 Google Inc. 5 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 11 <title>Skia Hello World</title> 12 13 <script type="text/javascript"> 14 "use strict"; 15 16 var SkiaModule = null; // Global application object. 17 18 // Force a re-draw of the given element. 19 function refresh(elem) { 20 var old_display_style = elem.style.display; 21 elem.style.display = "none"; 22 elem.style.display = old_display_style; 23 } 24 25 // When the module loads, begin running the application. 26 function moduleDidLoad() { 27 SkiaModule = document.getElementById("skia_nacl"); 28 run(); 29 } 30 31 function handleMessage(message_event) { 32 var skdebugf_cmd = "SkDebugf:"; 33 if (message_event.data.indexOf(skdebugf_cmd) == 0) { 34 var msg_contents = message_event.data.slice(skdebugf_cmd.length) 35 console.log("Skia: " + msg_contents); 36 } else { 37 alert(message_event.data); 38 } 39 } 40 41 // Run the application. 42 function run() { 43 if (SkiaModule) { 44 var cmd = "init"; 45 SkiaModule.postMessage(cmd); 46 } else { 47 alert("The Skia module has not properly loaded..."); 48 } 49 } 50 </script> 51 </head> 52 <body> 53 54 <h1>Skia Hello World</h1> 55 <p> 56 <div id="listener"> 57 <script type="text/javascript"> 58 var listener = document.getElementById('listener'); 59 listener.addEventListener('load', moduleDidLoad, true); 60 listener.addEventListener('message', handleMessage, true); 61 </script> 62 63 <embed name="nacl_module" 64 id="skia_nacl" 65 width=300 height=300 66 src="skhello.nmf" 67 type="application/x-nacl" /> 68 </div> 69 </p> 70 </body> 71 </html> 72