!7 cmodule ScribbleDemo > DynPrintLog { !include #1029545 // API for Eleu O html(virtual Request request) { S uri = cast get(request, 'uri); SS params = cast get(request, 'params); ret hhtml(hhead(htitle("Scribble") + loadJQuery() + hreconnectingWebSockets() + hcss([[ body { margin: 0 !important; padding: 0 !important; } /*#scribble { width: 100%; height: 100%; }*/ ]])) + hbody( tag canvas("", id := "scribble") + hjssnippet(#1029696) + hjs([[ function resized() { canvas.width = document.body.clientWidth; canvas.height = document.body.clientHeight; } resized(); $(window).bind("resize", resized); // JavaScript WebSocket handling var wsReady = false; var ws = new ReconnectingWebSocket(((window.location.protocol === "https:") ? "wss://" : "ws://") + window.location.host + "/"); ws.onopen = function(event) { wsReady = true; }; ws.onmessage = function(event) { $("#dynamic").html(event.data); document.title = event.data; }; sendStroke = function(data) { console.log(data); if (wsReady) ws.send(JSON.stringify(data)); }; ]]) )); } }