Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<!DOCTYPE html>
<html>
<head>
<title>NaCl Test</title>
<script type="text/javascript">
ApplicationModule = null; // Global application object.
statusText = 'NO-STATUS';
// Indicate load success.
function moduleDidLoad() {
ApplicationModule = document.getElementById('Application');
updateStatus('SUCCESS');
ApplicationModule.postMessage('hello');
}
function handleMessage(message_event) {
appendToEventLog(message_event.data);
}
function pageDidLoad() {
if (ApplicationModule == null) {
updateStatus('LOADING...');
} else {
updateStatus();
}
}
function updateStatus(opt_message) {
if (opt_message)
statusText = opt_message;
var statusField = document.getElementById('status_field');
if (statusField) {
statusField.innerHTML = statusText;
}
}
function appendToEventLog(logMessage) {
var eventLogField = document.getElementById('event_log_field');
if (eventLogField.innerHTML.length == 0) {
eventLogField.innerHTML = logMessage;
} else {
eventLogField.innerHTML = eventLogField.innerHTML +
'<br />' +
logMessage;
}
}
</script>
</head>
<body onload="pageDidLoad()">
<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="Application"
width=1024 height=768
src="boson.nmf"
type="application/x-nacl" />
</div>
</p>
<h2>Status</h2>
<div id="status_field">NO-STATUS</div>
<h2>Event Log</h2>
<div id="event_log_field"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment