Newer
Older
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div>
Your client ID: <input id="user-id" type="text" value="" readonly="" />
</div>
<div>
Enter peer ID: <input id="peer-id" type="text" value="" />
<button id="peer-connect">Connect</button>
</div>
<div>
Connected peers:
<ul id="connected-peers"></ul>
</div>
<textarea style="width: 100%; height: 500px" id="textfield"></textarea>
<script src="js/app.js"></script>
<svg id="whiteboard" width="100%" height="100%"></svg>
<script>
var whiteboard = document.getElementById("whiteboard")
var painting = false
var path
whiteboard.onmousedown = function(e) {
painting = true
var mouse = {
x: e.offsetX,
}
path = document.createElementNS("http://www.w3.org/2000/svg", "path")
path.setAttribute("d", "M" + mouse.x + " " + mouse.y)
path.setAttribute("stroke", "blue")
path.setAttribute("stroke-width", 3)
path.setAttribute("fill", "none")
path.setAttribute("pointer-events", "none")
whiteboard.appendChild(path)
}
whiteboard.onmouseup = function(e) {
painting = false
}
whiteboard.onmousemove = function(e) {
var mouse = {
x: e.offsetX,
}
if (painting) {
path.setAttribute(
"d",
path.getAttribute("d") + " L" + mouse.x + " " + mouse.y,
)
}
}
</script>
</body>
</html>