Skip to content

Commit 17cc7fe

Browse files
committed
js-wasm: Accept a data URI parameter in the browser demo
1 parent 6919215 commit 17cc7fe

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

docs/demo/example.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@ async function init() {
4242

4343
document.title = "GS1 Syntax Engine HTML demo | Library release: " + gs1encoder.version;
4444

45-
document.getElementById("data").value = "https://example.com/01/12312312312333/10/ABC123?99=TESTING";
45+
var dataParam = new URL(document.location.toString()).searchParams.get('data');
46+
47+
document.getElementById("data").value = dataParam ??
48+
"https://example.com/01/12312312312333/10/ABC123?99=TESTING";
4649

4750
load_data_values();
4851

52+
if (dataParam)
53+
process_clicked();
54+
4955
}
5056

5157

src/js-wasm/example.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@ async function init() {
4242

4343
document.title = "GS1 Syntax Engine HTML demo | Library release: " + gs1encoder.version;
4444

45-
document.getElementById("data").value = "https://example.com/01/12312312312333/10/ABC123?99=TESTING";
45+
var dataParam = new URL(document.location.toString()).searchParams.get('data');
46+
47+
document.getElementById("data").value = dataParam ??
48+
"https://example.com/01/12312312312333/10/ABC123?99=TESTING";
4649

4750
load_data_values();
4851

52+
if (dataParam)
53+
process_clicked();
54+
4955
}
5056

5157

0 commit comments

Comments
 (0)