Created
October 28, 2015 23:16
-
-
Save kayru/f8a9e9a0f65378db8907 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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