multi
This commit is contained in:
1 parent
f2559bc63e
commit
882aba6004
3 files changed
+169
-3
No files matched your search
@@ -0,0 +1,130 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Queue dump type shit</title>
|
||||
<style>
|
||||
li {
|
||||
width: min-content;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- style="display: flex; justify-content: space-between" -->
|
||||
<form id="c">
|
||||
<label for="n"
|
||||
>how many:
|
||||
<input
|
||||
name="n"
|
||||
id="n"
|
||||
step="1"
|
||||
min="0"
|
||||
type="number"
|
||||
placeholder="how many"
|
||||
value="1"
|
||||
/></label>
|
||||
<div>
|
||||
<button id="s" type="button">send it</button>
|
||||
<button id="all" type="button">send all</button>
|
||||
</div>
|
||||
</form>
|
||||
<div id="gonk"></div>
|
||||
<script>
|
||||
/** @type {HTMLDivElement} */
|
||||
const bij = document.getElementById("gonk");
|
||||
let arrlen = 0;
|
||||
/** @type {HTMLInputElement} */
|
||||
const n = document.getElementById("n");
|
||||
const changeHandler = async () => {
|
||||
const number = parseInt(n.value);
|
||||
if (isNaN(number)) {
|
||||
bij.textContent = "number?";
|
||||
return;
|
||||
}
|
||||
const f = new URL("/api/queue", window.location.href);
|
||||
f.searchParams.append("n", number);
|
||||
console.log("fetching", f);
|
||||
const c = await fetch(f)
|
||||
.then((r) => r.json())
|
||||
.then((n) => {
|
||||
console.log(n);
|
||||
arrlen = n.length;
|
||||
if (n) {
|
||||
const ol = document.createElement("ol");
|
||||
for (const i of n) {
|
||||
const li = document.createElement("li");
|
||||
const a = document.createElement("a");
|
||||
a.href = i;
|
||||
a.textContent = i;
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener noreferrer";
|
||||
li.appendChild(a);
|
||||
ol.appendChild(li);
|
||||
}
|
||||
bij.textContent = `next ${
|
||||
n.length != 1
|
||||
? `${n.length} entries are`
|
||||
: "entry is"
|
||||
} SO gone`;
|
||||
bij.appendChild(ol);
|
||||
} else {
|
||||
bij.textContent = "wym empty";
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
arrlen = 0;
|
||||
bij.textContent = `shit. cant fetch`;
|
||||
});
|
||||
};
|
||||
n.addEventListener("change", changeHandler);
|
||||
/** @type {HTMLFormElement} */
|
||||
const c = document.getElementById("c");
|
||||
c.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
await changeHandler();
|
||||
});
|
||||
changeHandler();
|
||||
const s = document.getElementById("s");
|
||||
s.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
console.log("ts runs");
|
||||
changeHandler();
|
||||
for (const _ of Array(arrlen)) {
|
||||
const w = window.open(
|
||||
"/r",
|
||||
"_blank",
|
||||
"noopener, noreferrer"
|
||||
);
|
||||
console.log(w);
|
||||
}
|
||||
arrlen = 0;
|
||||
bij.textContent = "something idk";
|
||||
});
|
||||
/** @type {HTMLButtonElement} */
|
||||
const all = document.getElementById("all");
|
||||
all.addEventListener(
|
||||
"click",
|
||||
async () =>
|
||||
await fetch("/api/queue/len")
|
||||
.then((d) => d.json())
|
||||
.then((len) => {
|
||||
console.log("ts runs", len);
|
||||
for (const _ of Array(len)) {
|
||||
const w = window.open(
|
||||
"/r",
|
||||
"_blank",
|
||||
"noopener, noreferrer"
|
||||
);
|
||||
console.log(w);
|
||||
}
|
||||
arrlen = 0;
|
||||
bij.textContent = "everything idk";
|
||||
})
|
||||
.catch((e) => console.error(e))
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user