diff --git a/docs/plugins/issue.js b/docs/plugins/issue.js
deleted file mode 100644
index 1ae5162..0000000
--- a/docs/plugins/issue.js
+++ /dev/null
@@ -1,143 +0,0 @@
-import { DOM, Fmt, style } from "./html.js";
-
-let div = DOM("div");
-let blockquote = DOM("blockquote");
-let paragraph = DOM("p");
-let h2 = DOM("h2");
-
-let css = style(/*css*/ `
- .flag {
- border: 2px solid;
- padding: 10px;
- margin-bottom: 40px;
- max-width: 90%;
- }
- .row {
- border-bottom: 1px solid;
- }
-
- `);
-
-(async () => {
- if (window.location.pathname == "/") {
- let docs = await getAll();
- console.log(docs);
-
- let anchors = document.querySelectorAll("li a");
- for (let i = 0; i < anchors.length; i++) {
- const element = anchors[i];
-
- let flags = getFlags(docs[element.getAttribute("href")]);
- inject(element, flags, true);
- }
- } else {
- let flags = getFlags(document);
- inject(document.querySelector("h1"), flags);
- }
-})();
-
-function getFlags(doc) {
- return [...doc.querySelectorAll("pre code")]
- .map((el) => {
- return el.innerText
- .split("\n")
- .filter((e) => e.trim() != "")
- .filter((e) => parseInt(e).toString() != e)
- .map((e, i, a) => {
- let s = [];
- console.log(e);
- if (e.indexOf("// !ISSUE:") != -1) {
- s.push(
- e
- .trim()
- .slice(e.indexOf("// !ISSUE:") + 10)
- .trim()
- );
- for (let k = i + 1; k < a.length; k++) {
- if (a[k].indexOf("// +") != -1) {
- s.push(
- a[k]
- .trim()
- .slice(a[k].indexOf("// +") + 4)
- .trim()
- );
- } else {
- s.push(a[k].trim());
- break;
- }
- }
- }
- return {
- comment: s.slice(0, -1).join("\n"),
- line: s.slice(-1)[0],
- };
- })
- .filter((e) => e.comment != "");
- })
- .flat();
-}
-
-function inject(el, flags, home = false) {
- if (flags.length > 0) {
- let html = div`class="${css.flag}"`;
- html.add(h2`innerText="ISSUES"`);
-
- for (let i = 0; i < flags.length; i++) {
- const flag = flags[i];
- if (home) {
- html.add(Fmt`${div`class="${css.row}"`}
- ${div`innerText="${flag.comment.replace(
- /\"/g,
- ""
- )}"`}
- `);
- } else {
- html.add(Fmt`${div`class="${css.row}"`}
- ${blockquote`id="${generateUniqueString(flag.line)}"`}
- ${paragraph`innerText="${flag.line}"`}
- ${div`innerText="${flag.comment.replace(/\"/g, "")}"`}
- `);
- }
- }
-
- el.insertAdjacentElement("afterend", html);
- }
-}
-
-function generateUniqueString(inputString) {
- // Generate a hash code from the input string
- let hash = 0;
- for (let i = 0; i < inputString.length; i++) {
- hash = (hash << 5) - hash + inputString.charCodeAt(i);
- hash &= hash; // Convert to 32bit integer
- }
- const hashCode = Math.abs(hash).toString(36);
-
- // Take the first 5 characters of the hash code to ensure consistency
- const uniqueString = hashCode.slice(0, 5);
-
- return uniqueString;
-}
-
-async function getAll() {
- let homepage = await fetch("/").then((e) => e.text());
- let html = document.createElement("div");
- html.innerHTML = homepage;
-
- let pages = html.querySelectorAll("li a");
-
- let documents = {};
-
- for (let i = 0; i < pages.length; i++) {
- let url = new URL(pages[i].getAttribute("href"), window.location.origin)
- .href;
- let text = await fetch(url).then((e) => e.text());
- let frag = document.createElement("div");
-
- frag.innerHTML = text;
-
- documents[pages[i].getAttribute("href")] = frag;
- }
-
- return documents;
-}
import { DOM, Fmt, style } from "./html.js";
let div = DOM("div");
let blockquote = DOM("blockquote");
let paragraph = DOM("p");
let h2 = DOM("h2");
let css = style(/*css*/ `
.flag {
border: 2px solid;
padding: 10px;
margin-bottom: 40px;
max-width: 90%;
}
.row {
border-bottom: 1px solid;
}
`);
(async () => {
if (window.location.pathname == "/") {
let docs = await getAll();
console.log(docs);
let anchors = document.querySelectorAll("li a");
for (let i = 0; i < anchors.length; i++) {
const element = anchors[i];
let flags = getFlags(docs[element.getAttribute("href")]);
inject(element, flags, true);
}
} else {
let flags = getFlags(document);
inject(document.querySelector("h1"), flags);
}
})();
function getFlags(doc) {
return [...doc.querySelectorAll("pre code")]
.map((el) => {
return el.innerText
.split("\n")
.filter((e) => e.trim() != "")
.filter((e) => parseInt(e).toString() != e)
.map((e, i, a) => {
let s = [];
console.log(e);
if (e.indexOf("// !ISSUE:") != -1) {
s.push(
e
.trim()
.slice(e.indexOf("// !ISSUE:") + 10)
.trim()
);
for (let k = i + 1; k < a.length; k++) {
if (a[k].indexOf("// +") != -1) {
s.push(
a[k]
.trim()
.slice(a[k].indexOf("// +") + 4)
.trim()
);
} else {
s.push(a[k].trim());
break;
}
}
}
return {
comment: s.slice(0, -1).join("\n"),
line: s.slice(-1)[0],
};
})
.filter((e) => e.comment != "");
})
.flat();
}
function inject(el, flags, home = false) {
if (flags.length > 0) {
let html = div`class="${css.flag}"`;
html.add(h2`innerText="ISSUES"`);
for (let i = 0; i < flags.length; i++) {
const flag = flags[i];
if (home) {
html.add(Fmt`${div`class="${css.row}"`}
${div`innerText="${flag.comment.replace(
/\"/g,
""
)}"`}
`);
} else {
html.add(Fmt`${div`class="${css.row}"`}
${blockquote`id="${generateUniqueString(flag.line)}"`}
${paragraph`innerText="${flag.line}"`}
${div`innerText="${flag.comment.replace(/\"/g, "")}"`}
`);
}
}
el.insertAdjacentElement("afterend", html);
}
}
function generateUniqueString(inputString) {
// Generate a hash code from the input string
let hash = 0;
for (let i = 0; i < inputString.length; i++) {
hash = (hash << 5) - hash + inputString.charCodeAt(i);
hash &= hash; // Convert to 32bit integer
}
const hashCode = Math.abs(hash).toString(36);
// Take the first 5 characters of the hash code to ensure consistency
const uniqueString = hashCode.slice(0, 5);
return uniqueString;
}
async function getAll() {
let homepage = await fetch("/").then((e) => e.text());
let html = document.createElement("div");
html.innerHTML = homepage;
let pages = html.querySelectorAll("li a");
let documents = {};
for (let i = 0; i < pages.length; i++) {
let url = new URL(pages[i].getAttribute("href"), window.location.origin)
.href;
let text = await fetch(url).then((e) => e.text());
let frag = document.createElement("div");
frag.innerHTML = text;
documents[pages[i].getAttribute("href")] = frag;
}
return documents;
}