diff options
Diffstat (limited to 'html')
-rw-r--r-- | html/index.html | 4 | ||||
-rw-r--r-- | html/whiteboard.css | 41 | ||||
-rw-r--r-- | html/whiteboard.js | 68 |
3 files changed, 113 insertions, 0 deletions
diff --git a/html/index.html b/html/index.html index 04522d7..e8a07be 100644 --- a/html/index.html +++ b/html/index.html @@ -10,12 +10,16 @@ <script src="whiteboard.js"></script> </head> <body onload="init();"> + <div class="qrwindow" id="qrwindow" hidden> + <img class="qrcode" id="qrcode"></img> + </div> <div class="page"> <h1><img class="banner" src="banner256.png" alt="Reichwein.IT"/> Whiteboard</h1> <textarea cols="80" rows="30" id="board" name="board"></textarea> <br/> <br/> <button class="button" onclick="on_new_page();">New page</button> + <button class="button" onclick="on_qrcode();">QR code</button> <br/> <br/> Reichwein.IT Whiteboard by <a href="https://www.reichwein.it">https://www.reichwein.it</a><br/> diff --git a/html/whiteboard.css b/html/whiteboard.css index 5f804c1..2af2a92 100644 --- a/html/whiteboard.css +++ b/html/whiteboard.css @@ -32,6 +32,37 @@ textarea { resize: none; } +.qrwindow { + position: fixed; + top: 50%; + left: 50%; + width: 400px; + height: 400px; + margin-top: -200px; + margin-left: -200px; + background-color: #FFFFFF; + opacity: 1; + z-index: 10; + border-width: 3px; + border-style: solid; + border-color: #FFFFFF; + padding: 10pt; + box-sizing: border-box; +} + +.qrcode { + width: 374px; + height: 374px; + + image-rendering: optimizeSpeed; /* */ + image-rendering: -moz-crisp-edges; /* Firefox */ + image-rendering: -o-crisp-edges; /* Opera */ + image-rendering: -webkit-optimize-contrast; /* Chrome (and Safari) */ + image-rendering: pixelated; /* Chrome as of 2019 */ + image-rendering: optimize-contrast; /* CSS3 Proposed */ + -ms-interpolation-mode: nearest-neighbor; /* IE8+ */ +} + .mobile { width: 300px; border-width: 80px 15px 80px 15px; @@ -67,6 +98,16 @@ img.banner { } @media only screen and (min-width: 1px) and (max-width: 630px) { + +.qrwindow { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + margin: 0; +} + } @media only screen and (min-width: 631px) and (max-width: 950px) { 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); +} + |