jsnes/index.html

28 lines
753 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;
window.webxdc.sendUpdate({payload: {name: window.webxdc.selfName(), msg: msg}}, 'someone typed "'+msg+'"');
2021-12-31 00:27:45 +00:00
}
function receiveUpdate(update) {
2022-01-02 20:47:10 +00:00
document.getElementById('output').innerHTML += "<strong>&lt;" + update.payload.name + "&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);
2022-01-02 21:19:04 +00:00
window.webxdc.getAllUpdates().forEach(receiveUpdate);
2021-12-31 00:27:45 +00:00
</script>
</body>
</html>