-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqr.js
44 lines (38 loc) · 1.12 KB
/
qr.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
44
class OSQrGenerator{
constructor(name, defaultData, image, textFieldId, canvasId) {
this.name = name;
this.defaultData = defaultData;
this.qrData = document.getElementById(textFieldId);
this.qrCode = new QRCodeStyling({
width: 300,
height: 300,
data: this.defaultData,
image: image,
dotsOptions: {
color: "#000000",
type: "rounded"
},
backgroundOptions: {
color: "#e8ebee",
}
});
this.qrCode.append(document.getElementById(canvasId));
this.update = this.update.bind(this);
this.download = this.download.bind(this);
}
update() {
let newQrData = this.qrData.value;
if (newQrData.length === 0) newQrData = this.defaultData;
this.qrCode.update({
data: newQrData
});
}
download() {
this.qrCode.download({
name: this.name,
extension: "jpeg"
});
}
}
const session = new OSQrGenerator("SessionAddress", "https://getsession.org/", "session_icon.png", 'dataInput', 'canvas');
const oxen = new OSQrGenerator("OxenWallet", "https://oxen.io/", "oxen_icon.png", 'oxenDataInput', 'oxenCanvas');