From 40506bc32efca98b43a72202d0823cdd3c8b2c05 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 10 Feb 2023 18:02:40 +0100 Subject: Add download Markdown as PDF --- html/index.html | 1 + html/whiteboard.css | 14 ++++++++++++++ html/whiteboard.js | 15 +++++++++++++++ 3 files changed, 30 insertions(+) (limited to 'html') diff --git a/html/index.html b/html/index.html index decc540..b72e23b 100644 --- a/html/index.html +++ b/html/index.html @@ -23,6 +23,7 @@ Starting up... +

Reichwein.IT Whiteboard by https://www.reichwein.it
diff --git a/html/whiteboard.css b/html/whiteboard.css index 4de9b46..2d222d5 100644 --- a/html/whiteboard.css +++ b/html/whiteboard.css @@ -20,6 +20,20 @@ div.status { color: #FF0000; } +span.helper { + display: inline-block; + height: 100%; + vertical-align: middle; +} + +img.center-img { + vertical-align: middle; +} + +.clickable { + cursor: pointer; +} + textarea { /* height: 30vh; diff --git a/html/whiteboard.js b/html/whiteboard.js index 38f972f..379c757 100644 --- a/html/whiteboard.js +++ b/html/whiteboard.js @@ -94,6 +94,14 @@ function on_version(version) document.getElementById("version").textContent = version; } +function on_pdf(pdf) +{ + var a = document.getElementById("download-a"); + a.href = "data:application/pdf;base64," + pdf; + a.download = get_id() + ".pdf" + a.click(); +} + function on_modify_ack(rev) { if (rev != revision + 1) @@ -128,6 +136,8 @@ function on_message(e) { on_qrcode(xmlDocument.getElementsByTagName("png")[0].textContent); } else if (type == "version") { on_version(xmlDocument.getElementsByTagName("version")[0].textContent); + } else if (type == "pdf") { + on_pdf(xmlDocument.getElementsByTagName("pdf")[0].textContent); } else if (type == "error") { alert(xmlDocument.getElementsByTagName("message")[0].textContent); } else { @@ -334,3 +344,8 @@ function on_qrcode_click() websocket.send(new XMLSerializer().serializeToString(xmlDocument)); } +function on_pdf_click() +{ + websocket.send("pdf" + get_id() + ""); +} + -- cgit v1.2.3