From e849f8ef1160641268a916596582586344a07459 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 20 Mar 2024 00:23:51 +0000 Subject: deploy: 428fb92cb7e0b566f39fdb61d9ffc03b056d7a7b --- web/html.html | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++- web/src/figure.html | 2 +- web/src/tags2.html | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 web/src/tags2.html (limited to 'web') diff --git a/web/html.html b/web/html.html index c58c523..94a9c76 100644 --- a/web/html.html +++ b/web/html.html @@ -307,6 +307,7 @@ window.onload = () => { </div>

Minimal tags filter

+

Single active filter tag

Rendered html

<script>
 /// Map HTML elements to display kinds.
@@ -365,6 +366,83 @@ window.onload = () => {
     <li class = "content x86 arm">x86 + arm</li>
 </ul>
 
+<div class = "content arm">arm</div>
+<div class = "content arm x86">arm x86</div>
+<div class = "content x86">x86</div>
+
+

Multiple active filter tags

+

Rendered html

+
<script>
+/// Map HTML elements to display kinds.
+const elementToDisplay = (E) => {
+    switch (E.nodeName) {
+        case "LI":
+            return "list-item";
+        default:
+            return "block";
+    }
+}
+
+/// 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_node = document.getElementById("filter");
+    // Active filter tags.
+    const filter = Array();
+
+    // Create buttons for each tag T.
+    ["arm", "x86", "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 = "<p>filter:</p>";
+            }
+            : (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 = `<p>filter: ${out}</p>`;
+            };
+
+        document.body.prepend(btn);
+    });
+}
+</script>
+
+<div id = "filter"><p>filter:</p></div>
+
+<ul>
+    <li class = "content arm">arm 1</li>
+    <li class = "content arm">arm 2</li>
+    <li class = "content arm">arm 3</li>
+    <li class = "content x86">x86 1</li>
+    <li class = "content x86">x86 2</li>
+    <li class = "content x86 arm">x86 + arm</li>
+</ul>
+
 <div class = "content arm">arm</div>
 <div class = "content arm x86">arm x86</div>
 <div class = "content x86">x86</div>
@@ -463,7 +541,7 @@ etiam non quam lacus suspendisse faucibus interdum posuere.
 </figure>
 <code>overflow: auto</code> gives an alternative to <code>clear</code> to
 control placement of the floats. The red boarder visualizes the size of the
-<code>&ltdiv&gt</code> block, you can remove the <code>overflow</code> property
+<code>&ltdiv&gt</code> block. One can remove the <code>overflow</code> property
 and observe how the border changes.
 </div>
 
diff --git a/web/src/figure.html b/web/src/figure.html
index ebcdf58..73502d0 100644
--- a/web/src/figure.html
+++ b/web/src/figure.html
@@ -90,7 +90,7 @@ etiam non quam lacus suspendisse faucibus interdum posuere.
 
 overflow: auto gives an alternative to clear to
 control placement of the floats. The red boarder visualizes the size of the
-<div> block, you can remove the overflow property
+<div> block. One can remove the overflow property
 and observe how the border changes.
 
 
diff --git a/web/src/tags2.html b/web/src/tags2.html
new file mode 100644
index 0000000..a321aeb
--- /dev/null
+++ b/web/src/tags2.html
@@ -0,0 +1,74 @@
+
+
+

filter:

+ +
    +
  • arm 1
  • +
  • arm 2
  • +
  • arm 3
  • +
  • x86 1
  • +
  • x86 2
  • +
  • x86 + arm
  • +
+ +
arm
+
arm x86
+
x86
-- cgit v1.2.3