aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/lib/qr_code.js
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2022-05-13 13:21:13 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2022-05-13 13:21:13 +0000
commit024421a96574dbb6c2a6ffc8fbd7d469140e6643 (patch)
tree6d50ee586c19a1267bcce838a6a245cf104011b2 /resources/assets/javascripts/lib/qr_code.js
parentc6893fd30b8430605978ee4525f577b9fa5a47a2 (diff)
load jquery.qrcode via npm and rework integration into stud.ip
Closes #993 Merge request studip/studip!571
Diffstat (limited to 'resources/assets/javascripts/lib/qr_code.js')
-rw-r--r--resources/assets/javascripts/lib/qr_code.js18
1 files changed, 7 insertions, 11 deletions
diff --git a/resources/assets/javascripts/lib/qr_code.js b/resources/assets/javascripts/lib/qr_code.js
index 914db9b..3db4fd8 100644
--- a/resources/assets/javascripts/lib/qr_code.js
+++ b/resources/assets/javascripts/lib/qr_code.js
@@ -1,4 +1,3 @@
-import QRCodeGenerator from "../vendor/qrcode-04f46c6.js"
import { $gettext } from "./gettext.js";
import Dialog from "./dialog.js";
@@ -28,7 +27,7 @@ const QRCode = {
}
// Actually generate code
- new QRCodeGenerator(code[0], {
+ code.qrcode({
text: text,
width: 1280,
height: 1280,
@@ -69,6 +68,12 @@ const QRCode = {
click () {
var openWindow = window.open("", '_blank');
openWindow.document.write(`<body style="text-align: center;">${content.html()}</body>`);
+ // Copy qrcode canvas itself (as it is not included in .html()
+ openWindow.document.querySelector('canvas').getContext('2d').drawImage(
+ $('canvas', code)[0],
+ 0,
+ 0
+ );
openWindow.document.close();
openWindow.focus();
openWindow.print();
@@ -78,20 +83,11 @@ const QRCode = {
}, buttons);
}
-
Dialog.show(content, {
title: options.title ?? $gettext('QR-Code'),
size: 'big',
buttons
});
- },
- generate: function (element, text, options = {}) {
- options.text = text;
- if (options.correctLevel === undefined) {
- options.correctLevel = 3;
- }
-
- var qrcode = new QRCodeGenerator(element, options);
}
};