Browse Source

Add javascript to show/hide the QR code

pull/144/head
Austen Adler 6 years ago
parent
commit
161c973efe
  1. 1
      static/css/linx.css
  2. 20
      static/js/upload.js
  3. 1
      templates/index.html

1
static/css/linx.css

@ -284,6 +284,7 @@ body {
color: #800000; color: #800000;
} }
/* Center the QR code */
.qrcode > canvas, .qrcode > img { .qrcode > canvas, .qrcode > img {
margin: 0 auto; margin: 0 auto;
padding: 10px; padding: 10px;

20
static/js/upload.js

@ -1,5 +1,19 @@
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
var qrCodeCheckbox = document.getElementById("qrcode-show");
if (qrCodeCheckbox !== null) {
qrCodeCheckbox.addEventListener('change', function() {
var qrCodeCheckbox = document.getElementById("qrcode-show");
if (qrCodeCheckbox == null) {
return;
}
var qrCodes = document.getElementsByClassName('qrcode');
for(var i=0; i<qrCodes.length; i++) {
qrCodes[i].style.display = qrCodeCheckbox.checked ? "block" : "none";
}
})
}
Dropzone.options.dropzone = { Dropzone.options.dropzone = {
init: function() { init: function() {
var dzone = document.getElementById("dzone"); var dzone = document.getElementById("dzone");
@ -59,6 +73,12 @@ Dropzone.options.dropzone = {
var qrCode = document.createElement("div"); var qrCode = document.createElement("div");
qrCode.className = "qrcode"; qrCode.className = "qrcode";
file.uploadElement.qrCode = qrCode; file.uploadElement.qrCode = qrCode;
// Determine if the QR code should be shown or not
var qrCodeCheckbox = document.getElementById("qrcode-show");
if (qrCodeCheckbox !== null) {
qrCode.style.display = qrCodeCheckbox.checked ? "block" : "none";
}
file.uploadElement.appendChild(qrCode); file.uploadElement.appendChild(qrCode);
new QRCode(qrCode, resp.url); new QRCode(qrCode, resp.url);

1
templates/index.html

@ -27,6 +27,7 @@
</label> </label>
</div> </div>
<label><input name="randomize" id="randomize" type="checkbox" checked /> Randomize filename</label> <label><input name="randomize" id="randomize" type="checkbox" checked /> Randomize filename</label>
<label><input name="qrcode-show" id="qrcode-show" type="checkbox" /> QR code</label>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</form> </form>

Loading…
Cancel
Save