130 lines
4.7 KiB
HTML
130 lines
4.7 KiB
HTML
<!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>
|
|
</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");
|
|
/** @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);
|
|
return await fetch(f)
|
|
.then((r) => r.json())
|
|
.then((n) => {
|
|
console.log(n);
|
|
if (n.length > 0) {
|
|
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";
|
|
}
|
|
return n.length;
|
|
})
|
|
.catch((e) => {
|
|
console.error(e);
|
|
bij.textContent = `shit. cant fetch`;
|
|
return 0;
|
|
});
|
|
};
|
|
|
|
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");
|
|
const arrlen = 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 (e) =>
|
|
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);
|
|
}
|
|
bij.textContent = "everything idk";
|
|
})
|
|
.catch((e) => console.error(e))
|
|
);
|
|
</script>
|
|
</body>
|
|
</html>
|