4 <title>News River</title>
6 <link rel="stylesheet" href="style.css">
7 <script src="https://unpkg.com/htmx.org@1.7.0"></script>
10 <div id="feed-pane" valign="top" hx-get="/feeds" hx-trigger="load, newFeed from:body, every 900s" hx-target="#feed-list">
13 <form hx-post="/feeds">
14 <input type="url" name="link" placeholder="Link to RSS Feed">
15 <button type="submit">Add</button>
18 <div id="feed-list"></div>
22 <table><thead><tr><th style="width: 80%">Title</th><th>Publish Date</th></head></table>
24 <ul class="scrollable list" id="feed-item-list"></ul>
26 <div id="reading-pane"></div>
28 A project by <a href="https://xangelo.ca">xangelo</a> that is still in active <a href="https://git.xangelo.ca">development</a>
32 function $(sel, root, opts) {
33 const el = (root || document).querySelectorAll(sel);
34 if(opts && opts.array) {
35 return Array.from(el);
41 return Array.from(el);
45 function activeMarker(e) {
46 // clear sibling active class.
47 if(e.target.parentElement.tagName === 'LI') {
48 const parent = e.target.parentElement.parentElement;
49 $('a.active', parent, {array: true}).forEach(el => {
50 el.classList.remove('active');
54 e.target.classList.add('active');
57 $('body').addEventListener('click', e => {
58 const actions = e.target.getAttribute('data-actions');
59 if(actions && actions.split(' ').includes('activate')) {
62 if (e.target.classList.contains('unread') && e.target.getAttribute('data-feed-item-id') !== null) {
63 e.target.classList.remove('unread');
64 // ok it was unread.. so we should figure out the id that it belongs
65 // to and decr the counter for that!
66 const feedId = e.target.getAttribute('data-feed-id');
67 const el = $(`#feed-list a[data-feed-id="${feedId}"] .unread-count`);
69 if(el.innerHTML.length) {
70 let count = parseInt(el.innerHTML.split('(')[1].split(')')[0]);
74 el.parentElement.classList.remove('unread');
77 el.innerHTML = `(${count})`;