aboutsummaryrefslogtreecommitdiff
path: root/http/src/js
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-09-15 09:51:15 +0100
committerJoe Carstairs <me@joeac.net>2026-09-15 09:51:15 +0100
commit12040e85274153ebc159a00f9ee6df85b59e1bb8 (patch)
tree73b0eb89fa6ad75a50fc3c5cdbe9365c3ff557cb /http/src/js
parent721be368f5b1b4d8cbf0d3cd7221908bafa7e508 (diff)
add feed-condense-content.js
Diffstat (limited to 'http/src/js')
-rw-r--r--http/src/js/feed-condense-content.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/http/src/js/feed-condense-content.js b/http/src/js/feed-condense-content.js
new file mode 100644
index 0000000..02361b5
--- /dev/null
+++ b/http/src/js/feed-condense-content.js
@@ -0,0 +1,25 @@
+const expandedClass = "e-content--expanded";
+
+function toggleContentExpanded(id) {
+ const content = document.querySelector(`[data-content-id=${id}`);
+ if (!content) {
+ throw new Error(`No content found with ID: ${id}`);
+ }
+ const classes = content.getAttribute("class").split(" ");
+ if (classes.includes(expandedClass)) {
+ const newClasses = classes.filter((c) => c != expandedClass);
+ content.setAttribute("class", newClasses.join(" "));
+ } else {
+ content.setAttribute("class", [...classes, expandedClass].join(" "));
+ }
+}
+
+function addExpandItemButtons() {
+ for (const content of document.querySelectorAll(".e-content")) {
+ const contentId = crypto.randomUUID();
+ content.setAttribute("data-content-id", contentId);
+ const button = new HTMLButtonElement();
+ button.onclick = `toggleContentExpanded(${contentId})`;
+ content.insertAdjacentElement("afterend", button);
+ }
+}