-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqrcode.js
44 lines (39 loc) · 2.11 KB
/
qrcode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*=====================================================================*/
/* serrano/diffusion/talk/pliss23/qrcode.js */
/* ------------------------------------------------------------- */
/* Author : manuel serrano */
/* Creation : Fri Sep 8 06:45:23 2023 */
/* Last change : Fri Sep 8 06:46:07 2023 (serrano) */
/* Copyright : 2023 manuel serrano */
/* ------------------------------------------------------------- */
/* QRCODE binding */
/*=====================================================================*/
"use strict";
/*---------------------------------------------------------------------*/
/* The module */
/*---------------------------------------------------------------------*/
import { qrcode as Qrcode } from "./qrcode-lib.js";
/*---------------------------------------------------------------------*/
/* QRCODE ... */
/*---------------------------------------------------------------------*/
export function QRCODE(attr, ...nodes) {
const el = DIV(attr);
const lt = ~{ window.addEventListener("load", function() {
document.qrcode(${el.id}, ${attr });
});
};
return [lt, el];
}
/*---------------------------------------------------------------------*/
/* qrcode ... */
/*---------------------------------------------------------------------*/
export function qrcode(el, attr) {
var qr = Qrcode(attr.type || 4, attr.level || 'L' );
qr.addData(attr.data);
qr.make();
document.getElementById(el).innerHTML = qr.createImgTag(attr.pixelSize || 4);
}
/*---------------------------------------------------------------------*/
/* toplevel */
/*---------------------------------------------------------------------*/
if (!hop.isServer) document.qrcode = qrcode;