diff --git a/app/ui.js b/app/ui.js index ffbb64f1..8b056170 100644 --- a/app/ui.js +++ b/app/ui.js @@ -766,12 +766,21 @@ const UI = { }); }, + attachDownloadScreenshotButton() { + document.getElementById('noVNC_download_screenshot').addEventListener('click', function() { + let link = document.createElement('a'); + link.download = 'screenshot.png'; + link.href = UI.rfb.canvas.toDataURL("image/png"); + link.click(); + }); + }, + updateInteractionStackUI() { - document.getElementById('noVNC_click_stack').innerHTML = ""; + document.getElementById('noVNC_click_stack').innerHTML = ''; for (var i = 0; i < UI.canvasInteractionEvents.length; i++) { let e = UI.canvasInteractionEvents[i]; let el = document.createElement('li'); - el.innerText = e.name + " at (" + e.x + ", " + e.y + ")"; + el.innerText = e.name + ' at (' + e.x + ', ' + e.y + ')'; document.getElementById('noVNC_click_stack').append(el); } }, @@ -1108,6 +1117,7 @@ const UI = { UI.trackMouse(); UI.trackClicks(); + UI.attachDownloadScreenshotButton(); UI.updateViewOnly(); // requires UI.rfb }, diff --git a/vnc.html b/vnc.html index 578e8647..05977e35 100644 --- a/vnc.html +++ b/vnc.html @@ -16,7 +16,7 @@ noVNC - + @@ -338,6 +338,10 @@ (0, 0) +
+ Screenshot + +
Interaction stack