Skip to content

Commit 82b60dd

Browse files
committed
Simplified demo TypeScript code by using the HTML element hidden attribute instead of CSS display:none.
1 parent 777682a commit 82b60dd

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

Readme.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ for (int y = 0; y < qr1.size; y++) {
6969
License
7070
-------
7171

72-
Copyright © 2024 Project Nayuki. (MIT License)
72+
Copyright © 2025 Project Nayuki. (MIT License)
7373
[https://www.nayuki.io/page/qr-code-generator-library](https://www.nayuki.io/page/qr-code-generator-library)
7474

7575
Permission is hereby granted, free of charge, to any person obtaining a copy of

typescript-javascript/qrcodegen-input-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h1>QR Code generator input demo (JavaScript)</h1>
7070
<p>(Are the JavaScript files missing?)</p>
7171
<p>(The JavaScript code needs to be compiled from the TypeScript code.)</p>
7272
</div>
73-
<form id="loaded" style="display:none" onsubmit="event.preventDefault();">
73+
<form id="loaded" hidden="hidden" onsubmit="event.preventDefault();">
7474
<table>
7575
<tbody>
7676
<tr>

typescript-javascript/qrcodegen-input-demo.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
namespace app {
2828

2929
function initialize(): void {
30-
getElem("loading").style.display = "none";
31-
getElem("loaded").style.removeProperty("display");
30+
getElem("loading").hidden = true;
31+
getElem("loaded").hidden = false;
3232
let elems = document.querySelectorAll("input[type=number], input[type=text], textarea");
3333
for (let el of elems) {
3434
if (el.id.indexOf("version-") != 0)
@@ -46,19 +46,18 @@ namespace app {
4646
const bitmapOutput: boolean = getInput("output-format-bitmap").checked;
4747
const scaleRow : HTMLElement = getElem("scale-row");
4848
let download = getElem("download") as HTMLAnchorElement;
49+
scaleRow.hidden = !bitmapOutput;
4950
if (bitmapOutput) {
50-
scaleRow.style.removeProperty("display");
5151
download.download = "qr-code.png";
5252
} else {
53-
scaleRow.style.display = "none";
5453
download.download = "qr-code.svg";
5554
}
5655
download.removeAttribute("href");
5756

5857
// Reset output images in case of early termination
5958
const canvas = getElem("qrcode-canvas") as HTMLCanvasElement;
6059
const svg = (document.getElementById("qrcode-svg") as Element) as SVGElement;
61-
canvas.style.display = "none";
60+
canvas.hidden = true;
6261
svg.style.display = "none";
6362

6463
// Returns a QrCode.Ecc object based on the radio buttons in the HTML form.
@@ -94,7 +93,7 @@ namespace app {
9493
if (scale <= 0 || scale > 30)
9594
return;
9695
drawCanvas(qr, scale, border, lightColor, darkColor, canvas);
97-
canvas.style.removeProperty("display");
96+
canvas.hidden = false;
9897
download.href = canvas.toDataURL("image/png");
9998
} else {
10099
const code: string = toSvgString(qr, border, lightColor, darkColor);

0 commit comments

Comments
 (0)