summaryrefslogtreecommitdiffhomepage
path: root/html/whiteboard.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/whiteboard.js')
-rw-r--r--html/whiteboard.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/html/whiteboard.js b/html/whiteboard.js
index d9f0904..c6fb657 100644
--- a/html/whiteboard.js
+++ b/html/whiteboard.js
@@ -62,6 +62,16 @@ class AdjustingTimer {
var timer = new AdjustingTimer();
+function showQRWindow()
+{
+ document.getElementById("qrwindow").style.display = 'block';
+}
+
+function hideQRWindow()
+{
+ document.getElementById("qrwindow").style.display = 'none';
+}
+
function init_board() {
var xhr = new XMLHttpRequest();
@@ -124,6 +134,16 @@ function init_board() {
xhr.send(xmlDocument);
//set_status("Please wait while server prepares " + filename + " ...");
+
+ document.getElementById("qrwindow").onclick = function() {
+ hideQRWindow();
+ }
+
+ document.onkeydown = function(evt) {
+ if (evt.key == "Escape") {
+ hideQRWindow();
+ }
+ }
}
function get_id()
@@ -300,3 +320,51 @@ function checkupdate() {
//set_status("Please wait while server prepares " + filename + " ...");
}
+function on_qrcode()
+{
+ var xhr = new XMLHttpRequest();
+
+ // run on data received back
+ xhr.onreadystatechange = function() {
+ if (this.readyState == 3) {
+ //set_status("Please wait while downloading " + filename + " ...");
+ return;
+ }
+ if (this.readyState != 4) {
+ return;
+ }
+ if (this.status != 200) {
+ //set_status("Server Error while retrieving " + filename + ", status: " + this.status + " " + this.statusText);
+ return;
+ }
+
+ if (this.getResponseHeader("Content-Type") == "image/png") {
+ var blob = new Blob([this.response], {type: 'image/png'});
+ var url = URL.createObjectURL(blob);
+ var img = document.getElementById("qrcode");
+ img.src = url;
+ showQRWindow();
+ }
+
+ //set_status(""); // OK
+ }
+
+ var parser = new DOMParser();
+ var xmlDocument = parser.parseFromString("<request></request>", "text/xml");
+
+ var requestElement = xmlDocument.getElementsByTagName("request")[0];
+
+ var commandElement = xmlDocument.createElement("command");
+ commandElement.appendChild(document.createTextNode("qrcode"));
+ requestElement.appendChild(commandElement);
+
+ var idElement = xmlDocument.createElement("url");
+ idElement.appendChild(document.createTextNode(document.location));
+ requestElement.appendChild(idElement);
+
+ xhr.open("POST", "whiteboard.fcgi", true);
+ xhr.setRequestHeader("Content-type", "text/xml");
+ xhr.responseType = 'blob';
+ xhr.send(xmlDocument);
+}
+