diff options
author | Case Duckworth | 2022-07-20 23:56:26 -0500 |
---|---|---|
committer | Case Duckworth | 2022-07-20 23:56:26 -0500 |
commit | 8499547f6f7a37a7b0817ab7f609354d0a28fedc (patch) | |
tree | 752d18bfbb32887f7ed404e235382f37398a8e8c | |
parent | Change fresh/stale logic (diff) | |
download | sfeed-8499547f6f7a37a7b0817ab7f609354d0a28fedc.tar.gz sfeed-8499547f6f7a37a7b0817ab7f609354d0a28fedc.zip |
Add javascript to hide/show stale feeds
-rwxr-xr-x | sfeed_html.sh | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/sfeed_html.sh b/sfeed_html.sh index a2f7cc4..3965a87 100755 --- a/sfeed_html.sh +++ b/sfeed_html.sh | |||
@@ -20,6 +20,8 @@ Planet ACDW</h1> | |||
20 | <p class="last-updated">last updated at <time>$(date -R)</time></p> | 20 | <p class="last-updated">last updated at <time>$(date -R)</time></p> |
21 | </header> | 21 | </header> |
22 | <nav> | 22 | <nav> |
23 | <a href="#" id="stalebutton">hide stale</a> | ||
24 | // | ||
23 | <a href="feeds-short.xml">rss</a> | 25 | <a href="feeds-short.xml">rss</a> |
24 | // | 26 | // |
25 | <a href="feeds.html">all</a> | 27 | <a href="feeds.html">all</a> |
@@ -31,13 +33,40 @@ Planet ACDW</h1> | |||
31 | </nav> | 33 | </nav> |
32 | <main> | 34 | <main> |
33 | $(html_main "$@") | 35 | $(html_main "$@") |
34 | <aside><ul>$(cat "$aside")</ul></aside> | 36 | <aside><ul id="feedlist">$(cat "$aside")</ul></aside> |
35 | </main> | 37 | </main> |
36 | <footer> | 38 | <footer> |
37 | Generated by <a href="https://codemadness.org/sfeed-simple-feed-parser.html">sfeed</a> | 39 | Generated by <a href="https://codemadness.org/sfeed-simple-feed-parser.html">sfeed</a> |
38 | using <a href="https://git.acdw.net/sfeed/">this configuration</a>. | 40 | using <a href="https://git.acdw.net/sfeed/">this configuration</a>. |
39 | <a href="mailto:planet@me.acdw.net">suggest a feed!</a> | 41 | <a href="mailto:planet@me.acdw.net">suggest a feed!</a> |
40 | </footer> | 42 | </footer> |
43 | <script> | ||
44 | var staleHidden = false; | ||
45 | var staleItems = new Set(document.getElementsByClassName("stale")); | ||
46 | var staleFeeds = new Set(document.getElementsByClassName("stale_feed")); | ||
47 | var feedlistFeeds = new Set(document.getElementById("feedlist").children); | ||
48 | function hideShowStale(){ | ||
49 | var display; | ||
50 | if (staleHidden) { | ||
51 | display = null; staleHidden = false; | ||
52 | flBG = null; flBB = null; | ||
53 | } else { | ||
54 | display = 'none'; staleHidden = true; | ||
55 | flBG = 'inherit'; flBB = '1px solid'; | ||
56 | } | ||
57 | staleItems.forEach(e => { e.style.display = display; }); | ||
58 | staleFeeds.forEach(e => { e.style.display = display; }); | ||
59 | if (window.innerWidth > 720) { | ||
60 | feedlistFeeds.forEach(e => { e.style.background = flBG; e.style.borderBottom = flBB; }); | ||
61 | } | ||
62 | } | ||
63 | var button = document.getElementById("stalebutton"); | ||
64 | button.addEventListener("click", function() { | ||
65 | hideShowStale(); | ||
66 | if (staleHidden) { button.textContent = "show stale"; } | ||
67 | else { button.textContent = "hide stale"; } | ||
68 | }); | ||
69 | </script> | ||
41 | </body> | 70 | </body> |
42 | </html> | 71 | </html> |
43 | EOF | 72 | EOF |