-
Notifications
You must be signed in to change notification settings - Fork 8
/
app.js
53 lines (50 loc) · 1.51 KB
/
app.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
$("button").click(() => {
const qrText = $("#Qrtext").val();
const dimension = $("#dimension").val();
const qrImg = $("#qrImg");
const download = $("#download");
const errorContainer = $("#errorContainer");
// Reset error messages
errorContainer.text("");
errorContainer.hide();
if (!qrText.trim() && !dimension.trim()) {
// Display error for both QR text and dimension missing
errorContainer.text("Both QR text and dimension are required fields.");
errorContainer.show();
} else if (!qrText.trim()) {
// Display error for missing QR text
errorContainer.text("QR text is required.");
errorContainer.show();
} else if (!dimension.trim()) {
// Display error for missing dimensions
errorContainer.text("Dimension is required.");
errorContainer.show();
} else if (dimension.trim() && dimension > 547) {
// Display error for invalid dimension
errorContainer.text("Invalid dimension. Max dimension is 547px.");
errorContainer.show();
} else {
// Generate the QR code and download link
qrImg.attr(
"src",
"http://chart.apis.google.com/chart?cht=qr&chl=" +
qrText +
"&chs=" +
dimension +
"x" +
dimension
);
download.attr(
"href",
"http://chart.apis.google.com/chart?cht=qr&chl=" +
qrText +
"&chs=" +
dimension +
"x" +
dimension
);
// Show the QR code and download link
qrImg.show();
download.show();
}
});