moves
This commit is contained in:
1 parent
107e880cf8
commit
1030e9d739
5 files changed
No files matched your search
@@ -0,0 +1,60 @@
|
||||
<!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>
|
||||
Reference in new issue
Block a user