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