summaryrefslogtreecommitdiffhomepage
path: root/html/whiteboard.js
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-02-10 18:02:40 +0100
committerRoland Reichwein <mail@reichwein.it>2023-02-10 18:02:40 +0100
commit40506bc32efca98b43a72202d0823cdd3c8b2c05 (patch)
tree11f3c81f774362a40a069ad6f9c8d208984b5bd8 /html/whiteboard.js
parent87c11f835502c97b4f54d4d73f55eef496e67103 (diff)
Add download Markdown as PDFv1.7
Diffstat (limited to 'html/whiteboard.js')
-rw-r--r--html/whiteboard.js15
1 files changed, 15 insertions, 0 deletions
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("<request><command>pdf</command><id>" + get_id() + "</id></request>");
+}
+