Files
qrcode-from-onetab/past/oh.html
T
2025-12-19 00:50:50 +07:00

61 lines
2.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/qrcode.js"></script>
</head>
<body>
<textarea
name="what"
id="wow"
rows="20"
cols="100"
style="min-width: 20%; min-height: 20dvh"
></textarea>
<button type="button" id="cuh">cuh</button>
<div id="qrcode"></div>
<script>
/** @type { HTMLTextAreaElement } */
const wow = document.getElementById("wow");
/** @type { HTMLDivElement } */
const qrcode = document.getElementById("qrcode");
const cuh = () => {
for (const i of wow.value.split(/\r?\n/)) {
const l = i.split("|", 1)[0].trim();
const d = document.createElement("div");
const h = document.createElement("a");
h.href = l;
h.textContent = l;
console.log(l);
const a = document.createElement("div");
try {
new QRCode(a, {
text: l,
correctLevel: QRCode.CorrectLevel.L,
});
} catch (e) {
console.error(e);
}
d.appendChild(h);
d.appendChild(a);
qrcode.appendChild(d);
}
};
window.addEventListener("load", (_) => {
wow.value = decodeURI(
new URLSearchParams(window.location.search).get("data") ??
""
);
document.getElementById("cuh").addEventListener("click", cuh);
wow.addEventListener("input", (_) => {
const f = new URL(window.location.href);
f.searchParams.set("data", wow.value);
history.replaceState(null, "", f.href);
});
});
</script>
</body>
</html>