trail
This commit is contained in:
1 parent
4f10325b3e
commit
c557ca01e7
5 files changed
+84
-10
No files matched your search
+13
-9
@@ -34,9 +34,9 @@
|
||||
<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)) {
|
||||
@@ -46,12 +46,11 @@
|
||||
const f = new URL("/api/queue", window.location.href);
|
||||
f.searchParams.append("n", number);
|
||||
console.log("fetching", f);
|
||||
const c = await fetch(f)
|
||||
return await fetch(f)
|
||||
.then((r) => r.json())
|
||||
.then((n) => {
|
||||
console.log(n);
|
||||
arrlen = n.length;
|
||||
if (n) {
|
||||
if (n.length > 0) {
|
||||
const ol = document.createElement("ol");
|
||||
for (const i of n) {
|
||||
const li = document.createElement("li");
|
||||
@@ -64,7 +63,7 @@
|
||||
ol.appendChild(li);
|
||||
}
|
||||
bij.textContent = `next ${
|
||||
n.length != 1
|
||||
n.length > 1
|
||||
? `${n.length} entries are`
|
||||
: "entry is"
|
||||
} SO gone`;
|
||||
@@ -72,26 +71,31 @@
|
||||
} else {
|
||||
bij.textContent = "wym empty";
|
||||
}
|
||||
return n.length;
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
arrlen = 0;
|
||||
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");
|
||||
changeHandler();
|
||||
const arrlen = changeHandler();
|
||||
for (const _ of Array(arrlen)) {
|
||||
const w = window.open(
|
||||
"/r",
|
||||
@@ -103,11 +107,12 @@
|
||||
arrlen = 0;
|
||||
bij.textContent = "something idk";
|
||||
});
|
||||
|
||||
/** @type {HTMLButtonElement} */
|
||||
const all = document.getElementById("all");
|
||||
all.addEventListener(
|
||||
"click",
|
||||
async () =>
|
||||
async (e) =>
|
||||
await fetch("/api/queue/len")
|
||||
.then((d) => d.json())
|
||||
.then((len) => {
|
||||
@@ -120,7 +125,6 @@
|
||||
);
|
||||
console.log(w);
|
||||
}
|
||||
arrlen = 0;
|
||||
bij.textContent = "everything idk";
|
||||
})
|
||||
.catch((e) => console.error(e))
|
||||
|
||||
Reference in new issue
Block a user