jsnes/index.html

27 lines
688 B
HTML
Raw Normal View History

2021-12-31 00:27:45 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
2022-01-01 17:47:14 +00:00
<script src="webxdc.js"></script>
2021-12-31 00:27:45 +00:00
</head>
<body>
<input id="input" type="text"/>
<a href="" onclick="sendMsg(); return false;">Send</a>
<p id="output"></p>
<script>
function sendMsg() {
msg = document.getElementById("input").value;
2022-01-01 17:47:14 +00:00
window.webxdc.sendUpdate('someone typed "'+msg+'"', {"addr": window.webxdc.selfAddr(), "msg": msg});
2021-12-31 00:27:45 +00:00
}
function receiveUpdate(update) {
document.getElementById('output').innerHTML += "<strong>&lt;" + update.payload.addr + "&gt;</strong> " + update.payload.msg + "<br>";
2021-12-31 00:27:45 +00:00
}
2022-01-01 17:47:14 +00:00
window.webxdc.setUpdateListener(receiveUpdate);
2021-12-31 00:27:45 +00:00
</script>
</body>
</html>