aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--roles/webserver/files/www/memzero/pub/.gen.sh81
-rw-r--r--roles/webserver/files/www/memzero/pub/references.html81
2 files changed, 96 insertions, 66 deletions
diff --git a/roles/webserver/files/www/memzero/pub/.gen.sh b/roles/webserver/files/www/memzero/pub/.gen.sh
index 95e4216..36016f3 100644
--- a/roles/webserver/files/www/memzero/pub/.gen.sh
+++ b/roles/webserver/files/www/memzero/pub/.gen.sh
@@ -22,51 +22,66 @@ cat <<EOF > $OUT
<script>
/// Map HTML elements to display kinds.
const elementToDisplay = (E) => {
- switch (E.nodeName) {
- case "LI":
- return "list-item";
- default:
- return "block";
- }
+ switch (E.nodeName) {
+ case "LI":
+ return "list-item";
+ default:
+ return "block";
+ }
}
- /// Display only elements with tag T.
- const showTag = (T) => {
- Array.from(document.getElementsByClassName("content")).forEach(E => {
- E.style.display = "none";
- });
-
- Array.from(document.getElementsByClassName(T)).forEach(E => {
- E.style.display = elementToDisplay(E);
- });
+ /// Display only elements which have all TAGS.
+ const showTag = (TAGS) => {
+ Array.from(document.getElementsByClassName("content")).forEach(E => {
+ // Display the element, iff the element contains every tag T in TAGS.
+ if (TAGS.every(T => Array.from(E.classList).includes(T))) {
+ E.style.display = elementToDisplay(E);
+ } else {
+ E.style.display = "none";
+ }
+ });
};
/// Initialize buttons and callbacks.
window.onload = () => {
- // Handle to the filter placeholder.
- const filter = document.getElementById("filter");
+ // Handle to the filter placeholder.
+ const filter_node = document.getElementById("filter");
+ // Active filter tags.
+ const filter = Array();
+
+ // Create buttons for each tag T.
+ ["arm", "x86", "riscv", "sysv", "clear"].forEach(T => {
+ const btn = document.createElement("button");
+ btn.innerHTML = T;
+ btn.onclick = T === "clear"
+ ? (E) => {
+ // Clear active filter.
+ while (filter.length) { filter.pop(); }
+
+ showTag(["content"]);
+ filter_node.innerHTML = "filter:";
+ }
+ : (E) => {
+ // Toggle tag T in Active filter.
+ if ((idx = filter.indexOf(T)) > -1) {
+ filter.splice(idx, 1);
+ } else {
+ filter.push(T);
+ }
+
+ showTag(filter);
+ out = filter.map(T => \`<mark>\${T}</mark>\`).join(" + ");
+ filter_node.innerHTML = \`filter: \${out}\`;
+ };
- // Create buttons for each tag T.
- ["clear", "sysv", "arm", "x86", "riscv"].forEach(T => {
- const btn = document.createElement("button");
- btn.innerHTML = T;
- btn.onclick = T === "clear"
- ? (E) => {
- showTag("content");
- filter.innerHTML = "filter:";
- }
- : (E) => {
- showTag(T);
- filter.innerHTML = \`filter: <mark>\${T}</mark>\`;
- };
- filter.before(btn);
- });
+ filter_node.insertAdjacentElement("beforebegin", btn);
+ });
}
</script>
</head>
<body>
<p>Self-hosted collection of frequently referenced documents and specifications. This page provides links to the original sources.</p>
- <p id="filter">filter:</p>
+ <p id = "filter">filter:</p>
<ul>
EOF
diff --git a/roles/webserver/files/www/memzero/pub/references.html b/roles/webserver/files/www/memzero/pub/references.html
index dbc7018..28e776f 100644
--- a/roles/webserver/files/www/memzero/pub/references.html
+++ b/roles/webserver/files/www/memzero/pub/references.html
@@ -17,51 +17,66 @@
<script>
/// Map HTML elements to display kinds.
const elementToDisplay = (E) => {
- switch (E.nodeName) {
- case "LI":
- return "list-item";
- default:
- return "block";
- }
+ switch (E.nodeName) {
+ case "LI":
+ return "list-item";
+ default:
+ return "block";
+ }
}
- /// Display only elements with tag T.
- const showTag = (T) => {
- Array.from(document.getElementsByClassName("content")).forEach(E => {
- E.style.display = "none";
- });
-
- Array.from(document.getElementsByClassName(T)).forEach(E => {
- E.style.display = elementToDisplay(E);
- });
+ /// Display only elements which have all TAGS.
+ const showTag = (TAGS) => {
+ Array.from(document.getElementsByClassName("content")).forEach(E => {
+ // Display the element, iff the element contains every tag T in TAGS.
+ if (TAGS.every(T => Array.from(E.classList).includes(T))) {
+ E.style.display = elementToDisplay(E);
+ } else {
+ E.style.display = "none";
+ }
+ });
};
/// Initialize buttons and callbacks.
window.onload = () => {
- // Handle to the filter placeholder.
- const filter = document.getElementById("filter");
+ // Handle to the filter placeholder.
+ const filter_node = document.getElementById("filter");
+ // Active filter tags.
+ const filter = Array();
+
+ // Create buttons for each tag T.
+ ["arm", "x86", "riscv", "sysv", "clear"].forEach(T => {
+ const btn = document.createElement("button");
+ btn.innerHTML = T;
+ btn.onclick = T === "clear"
+ ? (E) => {
+ // Clear active filter.
+ while (filter.length) { filter.pop(); }
+
+ showTag(["content"]);
+ filter_node.innerHTML = "filter:";
+ }
+ : (E) => {
+ // Toggle tag T in Active filter.
+ if ((idx = filter.indexOf(T)) > -1) {
+ filter.splice(idx, 1);
+ } else {
+ filter.push(T);
+ }
+
+ showTag(filter);
+ out = filter.map(T => `<mark>${T}</mark>`).join(" + ");
+ filter_node.innerHTML = `filter: ${out}`;
+ };
- // Create buttons for each tag T.
- ["clear", "sysv", "arm", "x86", "riscv"].forEach(T => {
- const btn = document.createElement("button");
- btn.innerHTML = T;
- btn.onclick = T === "clear"
- ? (E) => {
- showTag("content");
- filter.innerHTML = "filter:";
- }
- : (E) => {
- showTag(T);
- filter.innerHTML = `filter: <mark>${T}</mark>`;
- };
- filter.before(btn);
- });
+ filter_node.insertAdjacentElement("beforebegin", btn);
+ });
}
</script>
</head>
<body>
<p>Self-hosted collection of frequently referenced documents and specifications. This page provides links to the original sources.</p>
- <p id="filter">filter:</p>
+ <p id = "filter">filter:</p>
<ul>
<li class="content sysv">
<a style="color:black;" href="/pub/abi/sysv/sysv-gabi4-2013">abi/sysv/sysv-gabi4-2013</a>