miniflux-legacy/assets/js/all.min.js

16 lines
8.0 KiB
JavaScript

var g=function(){var e=[];return{i:function(d,a){var b=d.querySelector("span.items-count");if(b){var c=d.getAttribute("data-feed-id"),e=d.querySelector("h2:first-of-type");e.className="loading-icon";var l=new XMLHttpRequest;l.onload=function(){e.className="";d.removeAttribute("data-feed-error");var c=d.querySelector(".feed-last-checked");c&&(c.innerHTML=c.getAttribute("data-after-update"));c=JSON.parse(this.responseText);c.result?b.innerHTML=c.items_count.items_unread+"/"+c.items_count.items_total:
d.setAttribute("data-feed-error","1");a&&a(c)};l.open("POST","?action=refresh-feed&feed_id="+c,!0);l.send()}},j:function(){var d=Array.prototype.slice.call(document.querySelectorAll("article:not([data-feed-disabled])")),a=setInterval(function(){for(;0<d.length&&5>e.length;){var b=d.shift();e.push(parseInt(b.getAttribute("data-feed-id"),10));g.i(b,function(b){b=e.indexOf(b.feed_id);0<=b&&e.splice(b,1);0===d.length&&0===e.length&&(clearInterval(a),window.location.href="?action=unread")})}},100)}}}(),
q=function(){function e(a){return item_id=a.getAttribute("data-item-id")}function d(a){if(a&&a.hasAttribute("data-reverse-label")){var b=a.innerHTML;a.innerHTML=a.getAttribute("data-reverse-label");a.setAttribute("data-reverse-label",b)}}function a(a){"mouse"!==k.b&&m.c();a.parentNode.removeChild(a);p--}function b(){0===p&&window.location.reload();var a=document.getElementById("page-counter");a.textContent=p||"";document.getElementById("nav-counter").textContent=l||"";switch(document.querySelector("section.page").getAttribute("data-item-page")){case "unread":document.title=
"Miniflux ("+l+")";break;case "feed-items":document.title="("+p+") "+a.parentNode.firstChild.nodeValue;break;default:document.title=a.parentNode.firstChild.nodeValue+" ("+p+")"}}function c(h){var f=e(h),c=new XMLHttpRequest;c.onload=function(){if(m.a()){if(h.getAttribute("data-hide"))a(h);else{h.setAttribute("data-item-status","read");var c=h.querySelector("a.mark");d(c);(c=h.querySelector("a.mark"))&&c.setAttribute("data-action","mark-unread")}l--;b()}};c.open("POST","?action=mark-item-read&id="+
f,!0);c.send()}function t(h){var c=e(h),n=new XMLHttpRequest;n.onload=function(){if(m.a()){if(h.getAttribute("data-hide"))a(h);else{h.setAttribute("data-item-status","unread");var c=h.querySelector("a.mark");d(c);(c=h.querySelector("a.mark"))&&c.setAttribute("data-action","mark-read")}l++;b()}};n.open("POST","?action=mark-item-unread&id="+c,!0);n.send()}var l=function(){var a=document.getElementById("nav-counter");if(a)return counter=parseInt(a.textContent,10)||0}(),p=function(){var a=document.getElementById("page-counter");
if(a)return counter=parseInt(a.textContent,10)||0}();return{m:c,o:t,n:function(c){var f=e(c),d=new XMLHttpRequest;d.onload=function(){m.a()&&(a(c),"unread"===c.getAttribute("data-item-status")&&l--,b())};d.open("POST","?action=mark-item-removed&id="+f,!0);d.send()},h:function(c){var f=e(c),n="1"===c.getAttribute("data-item-bookmark")?"0":"1",r=new XMLHttpRequest;r.onload=function(){var f=document.querySelector("section.page");if(m.a()&&"bookmarks"===f.getAttribute("data-item-page"))a(c),b();else if(c.setAttribute("data-item-bookmark",
n),m.a())f=c.querySelector("a.bookmark"),d(f);else if((f=c.querySelector("a.bookmark-icon"))&&f.hasAttribute("data-reverse-title")){var e=f.getAttribute("title");f.setAttribute("title",f.getAttribute("data-reverse-title"));f.setAttribute("data-reverse-title",e)}};r.open("POST","?action=bookmark&id="+f+"&value="+n,!0);r.send()},t:function(a){var b=a.getAttribute("data-item-status");"read"===b?t(a):"unread"===b&&c(a)},r:function(a){(a=a.querySelector("a.show"))&&a.click()},f:function(a){var b=a.querySelector("a.original");
b&&("unread"===a.getAttribute("data-item-status")&&c(a),b.removeAttribute("data-action"),"mouse"!==k.b&&b.click())},d:function(a){var b=document.getElementById("download-item");if(b){b.innerHTML=" "+b.getAttribute("data-before-message");b.className="loading-icon";var c=new XMLHttpRequest;c.onload=function(){var a=JSON.parse(c.responseText);b.className="";if(a.result){var d=document.getElementById("item-content");d&&(d.innerHTML=a.content);b.innerHTML=b.getAttribute("data-after-message")}else b.innerHTML=
b.getAttribute("data-failure-message")};a=e(a);c.open("POST","?action=download-item&id="+a,!0);c.send()}},e:function(a){for(var b=document.getElementsByTagName("article"),c=[],d=0,l=b.length;d<l;d++)c.push(e(b[d]));b=new XMLHttpRequest;b.onload=function(){window.location.href=a};b.open("POST","?action=mark-items-as-read",!0);b.send(JSON.stringify(c))},u:function(){for(var a=["#current-item h1","#item-content","#listing #current-item h2","#listing #current-item .preview"],b=0;b<a.length;b++){var c=
document.querySelector(a[b]);c&&(c.dir=""==c.dir?"rtl":"")}}}}(),k=function(){function e(a){if(63!==a.keyCode&&63!==a.which&&(a.ctrlKey||a.shiftKey||a.altKey||a.metaKey))return!0;a=a.target||a.srcElement;return"INPUT"===a.tagName||"TEXTAREA"===a.tagName?!0:!1}var d=[];return{b:"",l:function(){document.onclick=function(a){var b=a.target.getAttribute("data-action");b&&"original-link"!==b&&a.preventDefault()};document.onmouseup=function(a){if(2!==a.button)if("INPUT"===a.target.nodeName&&"auto-select"===
a.target.className)a.target.select();else{var b=a.target.getAttribute("data-action");if(b){k.b="mouse";var c;a:{for(element=a.target;element&&element.parentNode;)if(element=element.parentNode,element.tagName&&"article"===element.tagName.toLowerCase()){c=element;break a}c=void 0}switch(b){case "refresh-all":g.j();break;case "refresh-feed":c&&g.i(c);break;case "mark-read":c&&q.m(c);break;case "mark-unread":c&&q.o(c);break;case "mark-removed":c&&q.n(c);break;case "bookmark":c&&q.h(c);break;case "download-item":c&&
q.d(c);break;case "original-link":c&&q.f(c);break;case "mark-all-read":q.e("?action=unread");break;case "mark-feed-read":q.e("?action=feed-items&feed_id="+a.target.getAttribute("data-feed-id"))}}}}},k:function(){document.onkeypress=function(a){if(!e(a))if(k.b="keyboard",d.push(a.keyCode||a.which),103===d[0])switch(d[1]){case void 0:break;case 117:window.location.href="?action=unread";d=[];break;case 98:window.location.href="?action=bookmarks";d=[];break;case 104:window.location.href="?action=history";
d=[];break;case 115:window.location.href="?action=feeds";d=[];break;case 112:window.location.href="?action=config";d=[];break;default:d=[]}else{d=[];var b=document.getElementById("current-item");switch(a.keyCode||a.which){case 100:b&&q.d(b);break;case 112:case 107:m.g();break;case 110:case 106:m.c();break;case 118:b&&q.f(b);break;case 111:b&&q.r(b);break;case 109:b&&q.t(b);break;case 102:b&&q.h(b);break;case 104:m.q();break;case 108:m.p();break;case 114:g.j();break;case 63:m.s();break;case 122:q.u()}}};
document.onkeydown=function(a){if(!e(a))switch(k.b="keyboard",a.keyCode||a.which){case 37:m.g();break;case 39:m.c()}}}}}(),m=function(){function e(a){var b=pageYOffset+document.documentElement.clientHeight;(0>b-(a.offsetTop+a.offsetHeight)||b-a.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,a.offsetTop-10)}function d(){return document.getElementById("listing")?!0:!1}return{p:function(){var a=document.getElementById("next-page");a&&a.click()},q:function(){var a=document.getElementById("previous-page");
a&&a.click()},c:function(){var a=document.getElementById("next-item");if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var b=0,c=a.length;b<c;b++){if("current-item"===a[b].id){b+1<c&&(a[b].id="item-"+a[b].getAttribute("data-item-id"),a[b+1].id="current-item",e(a[b+1]));break}}else a[0].id="current-item",e(a[0])},g:function(){var a=document.getElementById("previous-item");if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),
document.getElementById("current-item"))for(var b=a.length-1;0<=b;b--){if("current-item"===a[b].id){0<=b-1&&(a[b].id="item-"+a[b].getAttribute("data-item-id"),a[b-1].id="current-item",e(a[b-1]));break}}else a[a.length-1].id="current-item",e(a[a.length-1])},s:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},a:d}}();k.k();k.l();