diff options
Diffstat (limited to 'web/dist/v3')
| -rw-r--r-- | web/dist/v3/assets/index-CijeHHiU.js (renamed from web/dist/v3/assets/index-C5ln65P2.js) | 2 | ||||
| -rw-r--r-- | web/dist/v3/index.html | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/web/dist/v3/assets/index-C5ln65P2.js b/web/dist/v3/assets/index-CijeHHiU.js index b54669f..3e6e0fc 100644 --- a/web/dist/v3/assets/index-C5ln65P2.js +++ b/web/dist/v3/assets/index-CijeHHiU.js @@ -181,4 +181,4 @@ </ul> </section> </div> - `,document.getElementById("theme-options")?.addEventListener("click",i=>{const n=i.target.closest("button");n&&(a.setTheme(n.getAttribute("data-theme")),v())}),document.getElementById("style-theme-options")?.addEventListener("click",i=>{const n=i.target.closest("button");n&&a.setStyleTheme(n.getAttribute("data-style-theme"))}),document.getElementById("heading-font-selector")?.addEventListener("change",i=>{a.setHeadingFontTheme(i.target.value)}),document.getElementById("font-selector")?.addEventListener("change",i=>{a.setFontTheme(i.target.value)}),document.getElementById("add-feed-btn")?.addEventListener("click",async()=>{const i=document.getElementById("new-feed-url"),n=i.value.trim();n&&(await j(n)?(i.value="",alert("Feed added successfully!"),T()):alert("Failed to add feed."))});let t="opml";const s=document.getElementById("import-file");document.querySelectorAll(".import-btn").forEach(i=>{i.addEventListener("click",n=>{t=n.currentTarget.getAttribute("data-format")||"opml",s.click()})}),s?.addEventListener("change",async i=>{const n=i.target.files?.[0];n&&(await Q(n,t)?(alert(`Import (${t}) started! check logs.`),T()):alert("Failed to import.")),s.value=""}),document.querySelectorAll(".delete-feed-btn").forEach(i=>{i.addEventListener("click",async n=>{const o=parseInt(n.target.getAttribute("data-id"));confirm("Delete this feed?")&&(await U(o),await T(),v())})})}async function j(e){try{return(await f("/api/feed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).ok}catch(t){return console.error("Failed to add feed",t),!1}}async function Q(e,t){try{const s=new FormData;s.append("file",e),s.append("format",t);const i=document.cookie.split("; ").find(o=>o.startsWith("csrf_token="))?.split("=")[1];return(await fetch("/api/import",{method:"POST",headers:{"X-CSRF-Token":i||""},body:s})).ok}catch(s){return console.error("Failed to import",s),!1}}async function U(e){try{return(await f(`/api/feed/${e}`,{method:"DELETE"})).ok}catch(t){return console.error("Failed to delete feed",t),!1}}async function V(e){const t=a.items.find(s=>s._id===e);t&&p(e,{starred:!t.starred})}async function X(e){if(a.items.find(s=>s._id===e))try{const s=await f(`/api/item/${e}/content`);if(s.ok){const i=await s.json();i.full_content&&p(e,{full_content:i.full_content})}}catch(s){console.error("Failed to fetch full content",s)}}async function p(e,t){try{if((await f(`/api/item/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok){const i=a.items.find(n=>n._id===e);if(i){Object.assign(i,t);const n=document.querySelector(`.feed-item[data-id="${e}"]`);if(n){if(t.read!==void 0&&n.classList.toggle("read",t.read),t.starred!==void 0){const o=n.querySelector(".star-btn");o&&(o.classList.toggle("is-starred",t.starred),o.classList.toggle("is-unstarred",!t.starred),o.setAttribute("title",t.starred?"Unstar":"Star"))}t.full_content&&I()}}}}catch(s){console.error("Failed to update item",s)}}async function T(){const e=await f("/api/feed/");if(e.ok){const t=await e.json();a.setFeeds(t)}}async function J(){const e=await f("/api/tag");if(e.ok){const t=await e.json();a.setTags(t)}}async function E(e,t,s=!1){a.setLoading(!0);try{const i=new URLSearchParams;e&&i.append("feed_id",e),t&&i.append("tag",t),a.searchQuery&&i.append("q",a.searchQuery),(a.filter==="starred"||a.filter==="all")&&i.append("read_filter","all"),a.filter==="starred"&&i.append("starred","true"),s&&a.items.length>0&&i.append("max_id",String(a.items[a.items.length-1]._id));const n=await f(`/api/stream?${i.toString()}`);if(n.ok){const o=await n.json();a.setHasMore(o.length>0),a.setItems(o,s)}}finally{a.setLoading(!1)}}async function S(){const e=r.getCurrentRoute();E(e.params.feedId,e.params.tagName,!0)}async function W(){await f("/api/logout",{method:"POST"}),window.location.href="/login/"}function k(){const e=r.getCurrentRoute(),t=e.query.get("filter");a.setFilter(t||"unread");const s=e.query.get("q");if(s!==null&&a.setSearchQuery(s),e.path==="/settings"){v();return}if(e.path==="/feed"&&e.params.feedId){const i=parseInt(e.params.feedId);a.setActiveFeed(i),E(e.params.feedId),document.getElementById("section-feeds")?.classList.remove("collapsed")}else e.path==="/tag"&&e.params.tagName?(a.setActiveTag(e.params.tagName),E(void 0,e.params.tagName),document.getElementById("section-tags")?.classList.remove("collapsed")):(a.setActiveFeed(null),a.setActiveTag(null),E())}window.addEventListener("keydown",e=>{if(!["INPUT","TEXTAREA"].includes(e.target.tagName))switch(e.key){case"j":w(1);break;case"k":w(-1);break;case"r":if(c){const t=a.items.find(s=>s._id===c);t&&p(t._id,{read:!t.read})}break;case"s":if(c){const t=a.items.find(s=>s._id===c);t&&p(t._id,{starred:!t.starred})}break;case"/":e.preventDefault(),document.getElementById("search-input")?.focus();break}});function w(e){if(a.items.length===0)return;const t=a.items.findIndex(i=>i._id===c);let s;if(t===-1?s=e>0?0:a.items.length-1:s=t+e,s>=0&&s<a.items.length){c=a.items[s]._id,document.querySelectorAll(".feed-item").forEach(n=>{const o=parseInt(n.getAttribute("data-id")||"0");n.classList.toggle("selected",o===c)});const i=document.querySelector(`.feed-item[data-id="${c}"]`);i&&i.scrollIntoView({block:"start",behavior:"smooth"}),a.items[s].read||p(c,{read:!0})}}a.on("feeds-updated",$);a.on("tags-updated",F);a.on("active-feed-updated",$);a.on("active-tag-updated",F);a.on("filter-updated",R);a.on("search-updated",()=>{const e=document.getElementById("search-input");e&&e.value!==a.searchQuery&&(e.value=a.searchQuery),k()});a.on("theme-updated",()=>{h||(h=document.querySelector("#app")),h&&(h.className=`theme-${a.theme} font-${a.fontTheme} heading-font-${a.headingFontTheme}`);const e=document.getElementById("sidebar-theme-toggle");e&&(e.textContent=a.theme==="light"?"☽":"☀",e.title=a.theme==="light"?"Switch to dark mode":"Switch to light mode"),r.getCurrentRoute().path==="/settings"&&v()});a.on("sidebar-toggle",()=>{const e=document.querySelector(".layout");e&&(a.sidebarVisible?(e.classList.remove("sidebar-hidden"),e.classList.add("sidebar-visible")):(e.classList.remove("sidebar-visible"),e.classList.add("sidebar-hidden")))});a.on("style-theme-updated",()=>{L(a.styleTheme),document.querySelectorAll(".sidebar-style-btn").forEach(e=>{e.classList.toggle("active",e.getAttribute("data-style-theme")===a.styleTheme)}),r.getCurrentRoute().path==="/settings"&&v()});a.on("items-updated",I);a.on("loading-state-changed",I);r.addEventListener("route-changed",k);window.app={navigate:e=>r.navigate(e)};async function G(){const e=await f("/api/auth");if(!e||e.status===401){window.location.href="/login/";return}D(),L(a.styleTheme),R();try{await Promise.all([T(),J()])}catch(t){console.error("Initial fetch failed",t)}k()}typeof window<"u"&&!window.__VITEST__&&G(); + `,document.getElementById("theme-options")?.addEventListener("click",i=>{const n=i.target.closest("button");n&&(a.setTheme(n.getAttribute("data-theme")),v())}),document.getElementById("style-theme-options")?.addEventListener("click",i=>{const n=i.target.closest("button");n&&a.setStyleTheme(n.getAttribute("data-style-theme"))}),document.getElementById("heading-font-selector")?.addEventListener("change",i=>{a.setHeadingFontTheme(i.target.value)}),document.getElementById("font-selector")?.addEventListener("change",i=>{a.setFontTheme(i.target.value)}),document.getElementById("add-feed-btn")?.addEventListener("click",async()=>{const i=document.getElementById("new-feed-url"),n=i.value.trim();n&&(await j(n)?(i.value="",alert("Feed added successfully!"),T()):alert("Failed to add feed."))});let t="opml";const s=document.getElementById("import-file");document.querySelectorAll(".import-btn").forEach(i=>{i.addEventListener("click",n=>{t=n.currentTarget.getAttribute("data-format")||"opml",s.click()})}),s?.addEventListener("change",async i=>{const n=i.target.files?.[0];n&&(await Q(n,t)?(alert(`Import (${t}) started! check logs.`),T()):alert("Failed to import.")),s.value=""}),document.querySelectorAll(".delete-feed-btn").forEach(i=>{i.addEventListener("click",async n=>{const o=parseInt(n.target.getAttribute("data-id"));confirm("Delete this feed?")&&(await U(o),await T(),v())})})}async function j(e){try{return(await f("/api/feed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).ok}catch(t){return console.error("Failed to add feed",t),!1}}async function Q(e,t){try{const s=new FormData;s.append("file",e),s.append("format",t);const i=document.cookie.split("; ").find(o=>o.startsWith("csrf_token="))?.split("=")[1];return(await fetch("/api/import",{method:"POST",headers:{"X-CSRF-Token":i||""},body:s})).ok}catch(s){return console.error("Failed to import",s),!1}}async function U(e){try{return(await f(`/api/feed/${e}`,{method:"DELETE"})).ok}catch(t){return console.error("Failed to delete feed",t),!1}}async function V(e){const t=a.items.find(s=>s._id===e);t&&p(e,{starred:!t.starred})}async function X(e){if(a.items.find(s=>s._id===e))try{const s=await f(`/api/item/${e}/content`);if(s.ok){const i=await s.json();i.full_content&&p(e,{full_content:i.full_content})}}catch(s){console.error("Failed to fetch full content",s)}}async function p(e,t){try{if((await f(`/api/item/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok){const i=a.items.find(n=>n._id===e);if(i){Object.assign(i,t);const n=document.querySelector(`.feed-item[data-id="${e}"]`);if(n){if(t.read!==void 0&&n.classList.toggle("read",t.read),t.starred!==void 0){const o=n.querySelector(".star-btn");o&&(o.classList.toggle("is-starred",t.starred),o.classList.toggle("is-unstarred",!t.starred),o.setAttribute("title",t.starred?"Unstar":"Star"))}t.full_content&&I()}}}}catch(s){console.error("Failed to update item",s)}}async function T(){const e=await f("/api/feed/");if(e.ok){const t=await e.json();a.setFeeds(t)}}async function J(){const e=await f("/api/tag");if(e.ok){const t=await e.json();a.setTags(t)}}async function E(e,t,s=!1){a.setLoading(!0);try{const i=new URLSearchParams;e&&i.append("feed_id",e),t&&i.append("tag",t),a.searchQuery&&i.append("q",a.searchQuery),(a.filter==="starred"||a.filter==="all")&&i.append("read_filter","all"),a.filter==="starred"&&i.append("starred","true"),s&&a.items.length>0&&i.append("max_id",String(a.items[a.items.length-1]._id));const n=await f(`/api/stream?${i.toString()}`);if(n.ok){const o=await n.json();a.setHasMore(o.length>0),a.setItems(o,s)}}finally{a.setLoading(!1)}}async function S(){const e=r.getCurrentRoute();E(e.params.feedId,e.params.tagName,!0)}async function W(){await f("/api/logout",{method:"POST"}),window.location.href="/login/"}function k(){const e=r.getCurrentRoute(),t=e.query.get("filter");a.setFilter(t||"unread");const s=e.query.get("q");if(s!==null&&a.setSearchQuery(s),e.path==="/settings"){v();return}if(e.path==="/feed"&&e.params.feedId){const i=parseInt(e.params.feedId);a.setActiveFeed(i),E(e.params.feedId),document.getElementById("section-feeds")?.classList.remove("collapsed")}else e.path==="/tag"&&e.params.tagName?(a.setActiveTag(e.params.tagName),E(void 0,e.params.tagName),document.getElementById("section-tags")?.classList.remove("collapsed")):(a.setActiveFeed(null),a.setActiveTag(null),E())}window.addEventListener("keydown",e=>{if(!["INPUT","TEXTAREA"].includes(e.target.tagName))switch(e.key){case"j":w(1);break;case"k":w(-1);break;case"r":if(c){const t=a.items.find(s=>s._id===c);t&&p(t._id,{read:!t.read})}break;case"s":if(c){const t=a.items.find(s=>s._id===c);t&&p(t._id,{starred:!t.starred})}break;case"/":e.preventDefault(),document.getElementById("search-input")?.focus();break}});function w(e){if(a.items.length===0)return;const t=a.items.findIndex(i=>i._id===c);let s;if(t===-1?s=e>0?0:a.items.length-1:s=t+e,s>=0&&s<a.items.length){c=a.items[s]._id,document.querySelectorAll(".feed-item").forEach(n=>{const o=parseInt(n.getAttribute("data-id")||"0");n.classList.toggle("selected",o===c)});const i=document.querySelector(`.feed-item[data-id="${c}"]`);i&&i.scrollIntoView({block:"start",behavior:"instant"}),a.items[s].read||p(c,{read:!0})}}a.on("feeds-updated",$);a.on("tags-updated",F);a.on("active-feed-updated",$);a.on("active-tag-updated",F);a.on("filter-updated",R);a.on("search-updated",()=>{const e=document.getElementById("search-input");e&&e.value!==a.searchQuery&&(e.value=a.searchQuery),k()});a.on("theme-updated",()=>{h||(h=document.querySelector("#app")),h&&(h.className=`theme-${a.theme} font-${a.fontTheme} heading-font-${a.headingFontTheme}`);const e=document.getElementById("sidebar-theme-toggle");e&&(e.textContent=a.theme==="light"?"☽":"☀",e.title=a.theme==="light"?"Switch to dark mode":"Switch to light mode"),r.getCurrentRoute().path==="/settings"&&v()});a.on("sidebar-toggle",()=>{const e=document.querySelector(".layout");e&&(a.sidebarVisible?(e.classList.remove("sidebar-hidden"),e.classList.add("sidebar-visible")):(e.classList.remove("sidebar-visible"),e.classList.add("sidebar-hidden")))});a.on("style-theme-updated",()=>{L(a.styleTheme),document.querySelectorAll(".sidebar-style-btn").forEach(e=>{e.classList.toggle("active",e.getAttribute("data-style-theme")===a.styleTheme)}),r.getCurrentRoute().path==="/settings"&&v()});a.on("items-updated",I);a.on("loading-state-changed",I);r.addEventListener("route-changed",k);window.app={navigate:e=>r.navigate(e)};async function G(){const e=await f("/api/auth");if(!e||e.status===401){window.location.href="/login/";return}D(),L(a.styleTheme),R();try{await Promise.all([T(),J()])}catch(t){console.error("Initial fetch failed",t)}k()}typeof window<"u"&&!window.__VITEST__&&G(); diff --git a/web/dist/v3/index.html b/web/dist/v3/index.html index e0f57ef..de98996 100644 --- a/web/dist/v3/index.html +++ b/web/dist/v3/index.html @@ -5,7 +5,7 @@ <link rel="icon" type="image/svg+xml" href="/vite.svg" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>neko</title> - <script type="module" crossorigin src="/v3/assets/index-C5ln65P2.js"></script> + <script type="module" crossorigin src="/v3/assets/index-CijeHHiU.js"></script> <link rel="stylesheet" crossorigin href="/v3/assets/index-DPslwYc8.css"> </head> <body> |
