-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqr_list_page.js
77 lines (55 loc) · 2.23 KB
/
qr_list_page.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
document.addEventListener("DOMContentLoaded", function() {
var QRTextDiv = document.getElementById("QRText");
var QRContainerDiv = document.getElementById("qr-container");
json = JSON.parse(new URLSearchParams(location.search).get('data'));
var silent_qrs = json.silent_qrs;
var jsons = json.jsons;
var full_text = "";
if (!silent_qrs) {
var QRFeatureDesc = document.getElementById("qr-feature-desc");
QRFeatureDesc.innerText += ", hover over QRs for their text";
}
for (i = 0; i < jsons.length; i++) {
img_src = jsons[i].src;
var image_box = document.createElement('div');
image_box.classList.add("image-box");
var label = document.createElement('label');
label.innerText = "QR #" + (i + 1);
image_box.appendChild(label);
if (!silent_qrs) {
image_box.title = jsons[i].text;
}
var qr_code_div = document.createElement('div');
qr_code_div.classList.add("qr-code");
var img = document.createElement('img');
img.src = img_src;
img.width = 256;
img.height = 256;
if (silent_qrs) {
qr_code_div.style.cursor = "none";
}
qr_code_div.appendChild(img);
var back_content = document.createElement('div');
back_content.classList.add("back-content");
back_content.innerText = "QR #" + (i + 1) + " is hidden"
qr_code_div.appendChild(back_content);
image_box.appendChild(qr_code_div);
qr_code_div.addEventListener("click", function() {
this.classList.toggle("flipped");
});
QRContainerDiv.appendChild(image_box);
full_text += jsons[i].text;
}
QRTextDiv.innerText = full_text;
var WaitingQRsDiv = document.getElementById("wait-qrs");
WaitingQRsDiv.remove();
var QRContentDiv = document.getElementById("qr-content");
QRContentDiv.style.visibility = "visible";
const flipAllButton = document.querySelector(".flip-all-button");
flipAllButton.addEventListener("click", function() {
const qrCodes = document.querySelectorAll(".qr-code");
qrCodes.forEach((qrCode) => {
qrCode.classList.toggle("flipped");
});
});
});