Remove items via ajax requests (merge pull-request #227)

This commit is contained in:
Frédéric Guillot 2014-07-26 08:01:25 -04:00
parent 8b9e95d25f
commit 8d93fbc48c
16 changed files with 85 additions and 43 deletions

46
assets/js/all.min.js vendored
View File

@ -1,24 +1,26 @@
var Miniflux={};
Miniflux.App=function(){return{BlinkIcon:function(){var e=document.querySelectorAll(".loading-icon");[].forEach.call(e,function(c){c.classList.toggle("loading-icon-blink")})},Run:function(){Miniflux.Event.ListenKeyboardEvents();Miniflux.Event.ListenMouseEvents()},MozillaAuth:function(e){navigator.id.watch({onlogin:function(c){var a=new XMLHttpRequest;a.open("POST","?action="+e+"&token="+c,!0);a.setRequestHeader("Connection","close");a.onload=function(){window.location.href=this.responseText};a.send("token="+
c)},onlogout:function(){}});navigator.id.request()}}}();
Miniflux.Feed=function(){function e(a){if(a=document.getElementById("loading-feed-"+a))a.appendChild(document.createTextNode("\u2600")),a.classList.add("loading-icon-blink");f||(f=setInterval(Miniflux.App.BlinkIcon,500))}function c(){for(var c=document.getElementsByTagName("a"),d=0,b=c.length;d<b;d++){var g=c[d].getAttribute("data-feed-id");g&&a.push(parseInt(g))}}var a=[],d=[],f;return{Update:function(a,c){e(a);var b=new XMLHttpRequest;b.onload=function(){var b=document.getElementById("loading-feed-"+
a);b&&(b.innerHTML="");if(b=document.getElementById("last-checked-feed-"+a))b.innerHTML=b.getAttribute("data-after-update");try{var k=JSON.parse(this.responseText);if(k.result){var d=k.items_count,e=document.getElementById("items-count-"+a);e&&(e.innerHTML="("+d.items_unread+"/"+d.items_total+")")}c&&c(k)}catch(f){}};b.open("POST","?action=refresh-feed&feed_id="+a,!0);b.send()},UpdateAll:function(){c();var e=setInterval(function(){for(;0<a.length&&5>d.length;){var c=a.shift();d.push(c);Miniflux.Feed.Update(c,
function(b){b=d.indexOf(b.feed_id);0<=b&&d.splice(b,1);0==a.length&&0==d.length&&(clearInterval(e),clearInterval(f),window.location.href="?action=unread")})}},100)}}}();
Miniflux.Item=function(){function e(b){var a=document.getElementById("item-"+b);a||(a=document.getElementById("current-item"),a.getAttribute("data-item-id")!=b&&(a=!1));return a}function c(b){if((b=document.getElementById("bookmark-"+b))&&b.getAttribute("data-reverse-label")){var a=b.innerHTML;b.innerHTML=b.getAttribute("data-reverse-label");b.setAttribute("data-reverse-label",a)}}function a(b){if(b=document.getElementById("status-"+b)){var a=b.innerHTML;b.innerHTML=b.getAttribute("data-reverse-label");
b.setAttribute("data-reverse-label",a)}}function d(b){"mouse"!=Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();b.parentNode.removeChild(b);if(b=document.getElementById("page-counter"))counter=parseInt(b.textContent.trim(),10)-1,0==counter?window.location="?action=unread":(b.textContent=counter+" ",document.title="miniflux ("+counter+")",document.getElementById("nav-counter").textContent="("+counter+")")}function f(b){var c=new XMLHttpRequest;c.onload=function(){if(Miniflux.Nav.IsListing()){var c=
e(b);if(c)if(c.getAttribute("data-hide"))d(c);else{c.setAttribute("data-item-status","read");a(b);if(c=document.getElementById("show-"+b)){c.className="read";var g=document.createElement("span");g.id="read-icon-"+b;g.appendChild(document.createTextNode("\u2714 "));c.parentNode.insertBefore(g,c)}(c=document.getElementById("status-"+b))&&c.setAttribute("data-action","mark-unread")}}};c.open("POST","?action=mark-item-read&id="+b,!0);c.send()}function h(b){var c=new XMLHttpRequest;c.onload=function(){if(Miniflux.Nav.IsListing()){var c=
e(b);if(c)if(c.getAttribute("data-hide"))d(c);else{c.setAttribute("data-item-status","unread");a(b);if(c=document.getElementById("show-"+b))c.className="";(c=document.getElementById("read-icon-"+b))&&c.parentNode.removeChild(c);(c=document.getElementById("status-"+b))&&c.setAttribute("data-action","mark-read")}}};c.open("POST","?action=mark-item-unread&id="+b,!0);c.send()}function m(b,a){var d=b.getAttribute("data-item-id"),e=new XMLHttpRequest;e.onload=function(){try{if(JSON.parse(this.responseText).result)if(b.setAttribute("data-item-bookmark",
a),a)if(Miniflux.Nav.IsListing()){if(f=document.getElementById("show-"+d)){var e=document.createElement("span");e.id="bookmark-icon-"+d;e.appendChild(document.createTextNode("\u2605 "));f.parentNode.insertBefore(e,f)}c(d)}else{var f=document.getElementById("bookmark-"+d);f&&(f.innerHTML="\u2605")}else if(Miniflux.Nav.IsListing()){var l=document.getElementById("bookmark-icon-"+d);l&&l.parentNode.removeChild(l);c(d)}else{var n=document.getElementById("bookmark-"+d);n&&(n.innerHTML="\u2606")}}catch(h){}};
e.open("POST","?action=bookmark&id="+d+"&value="+a,!0);e.send()}return{Get:e,MarkAsRead:f,MarkAsUnread:h,SwitchBookmark:function(b){"1"==b.getAttribute("data-item-bookmark")?m(b,0):m(b,1)},SwitchStatus:function(b){var a=b.getAttribute("data-item-id");b=b.getAttribute("data-item-status");"read"==b?h(a):"unread"==b&&f(a)},ChangeStatus:function(b,a){switch(a){case "read":f(b);break;case "unread":h(b)}},Show:function(b){(b=document.getElementById("show-"+b))&&b.click()},OpenOriginal:function(b){var a=
document.getElementById("original-"+b);a&&("unread"==e(b).getAttribute("data-item-status")&&f(b),a.removeAttribute("data-action"),a.click())},DownloadContent:function(){var b=document.getElementById("download-item");if(b){var a=b.getAttribute("data-item-id"),c=b.getAttribute("data-before-message"),d=document.createElement("span");d.appendChild(document.createTextNode("\u2600"));d.className="loading-icon";b.innerHTML="";b.className="downloading";b.appendChild(d);b.appendChild(document.createTextNode(" "+
c));var e=setInterval(Miniflux.App.BlinkIcon,250),f=new XMLHttpRequest;f.onload=function(){var a=JSON.parse(f.responseText);clearInterval(e);if(a.result){var c=document.getElementById("item-content");c&&(c.innerHTML=a.content);b&&(a=b.getAttribute("data-after-message"),b.innerHTML="",b.appendChild(document.createTextNode(" "+a)))}else b&&(a=b.getAttribute("data-failure-message"),b.innerHTML="",b.appendChild(document.createTextNode(" "+a)))};f.open("POST","?action=download-item&id="+a,!0);f.send()}},
MarkListingAsRead:function(a){for(var c=document.getElementsByTagName("article"),d=[],e=0,f=c.length;e<f;e++)d.push(c[e].getAttribute("data-item-id"));c=new XMLHttpRequest;c.onload=function(){window.location.href=a};c.open("POST","?action=mark-items-as-read",!0);c.send(JSON.stringify(d))}}}();
Miniflux.Event=function(){var e=[];return{lastEventType:"",ListenMouseEvents:function(){document.onclick=function(c){var a=c.target.getAttribute("data-action");if(a)switch(Miniflux.Event.lastEventType="mouse",a){case "refresh-all":c.preventDefault();Miniflux.Feed.UpdateAll();break;case "refresh-feed":c.preventDefault();Miniflux.Feed.Update(c.target.getAttribute("data-feed-id"));break;case "mark-read":c.preventDefault();Miniflux.Item.MarkAsRead(c.target.getAttribute("data-item-id"));break;case "mark-unread":c.preventDefault();
Miniflux.Item.MarkAsUnread(c.target.getAttribute("data-item-id"));break;case "bookmark":c.preventDefault();Miniflux.Item.SwitchBookmark(Miniflux.Item.Get(c.target.getAttribute("data-item-id")));break;case "download-item":c.preventDefault();Miniflux.Item.DownloadContent();break;case "original-link":c.preventDefault();Miniflux.Item.OpenOriginal(c.target.getAttribute("data-item-id"));break;case "mark-all-read":c.preventDefault();Miniflux.Item.MarkListingAsRead("?action=unread");break;case "mark-feed-read":c.preventDefault();
Miniflux.Item.MarkListingAsRead("?action=feed-items&feed_id="+c.target.getAttribute("data-feed-id"));break;case "mozilla-login":c.preventDefault();Miniflux.App.MozillaAuth("mozilla-auth");break;case "mozilla-link":c.preventDefault(),Miniflux.App.MozillaAuth("mozilla-link")}}},ListenKeyboardEvents:function(){document.onkeypress=function(c){Miniflux.Event.lastEventType="keyboard";e.push(c.keyCode||c.which);if(103==e[0])switch(e[1]){case void 0:break;case 117:window.location.href="?action=unread";e=
[];break;case 98:window.location.href="?action=bookmarks";e=[];break;case 104:window.location.href="?action=history";e=[];break;case 115:window.location.href="?action=feeds";e=[];break;case 112:window.location.href="?action=config";e=[];break;default:e=[]}else switch(e=[],c.keyCode||c.which){case 100:Miniflux.Item.DownloadContent(Miniflux.Nav.GetCurrentItemId());break;case 112:case 107:Miniflux.Nav.SelectPreviousItem();break;case 110:case 106:Miniflux.Nav.SelectNextItem();break;case 118:Miniflux.Item.OpenOriginal(Miniflux.Nav.GetCurrentItemId());
break;case 111:Miniflux.Item.Show(Miniflux.Nav.GetCurrentItemId());break;case 109:Miniflux.Item.SwitchStatus(Miniflux.Nav.GetCurrentItem());break;case 102:Miniflux.Item.SwitchBookmark(Miniflux.Nav.GetCurrentItem());break;case 104:Miniflux.Nav.OpenPreviousPage();break;case 108:Miniflux.Nav.OpenNextPage();break;case 114:Miniflux.Feed.UpdateAll();break;case 63:Miniflux.Nav.ShowHelp()}}}}}();
Miniflux.Nav=function(){function e(a){var c=pageYOffset+document.documentElement.clientHeight;(0>c-(a.offsetTop+a.offsetHeight)||c-a.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,a.offsetTop-10)}function c(){return document.getElementById("listing")?!0:!1}return{GetCurrentItem:function(){return document.getElementById("current-item")},GetCurrentItemId:function(){var a=Miniflux.Nav.GetCurrentItem();return a?a.getAttribute("data-item-id"):null},OpenNextPage:function(){var a=document.getElementById("next-page");
a&&a.click()},OpenPreviousPage:function(){var a=document.getElementById("previous-page");a&&a.click()},SelectNextItem:function(){var a=document.getElementById("next-item");if(a)a.click();else if(c())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var d=0,f=a.length;d<f;d++){if("current-item"==a[d].id){a[d].id="item-"+a[d].getAttribute("data-item-id");d+1<f&&(a[d+1].id="current-item",e(a[d+1]));break}}else a[0].id="current-item",e(a[0])},SelectPreviousItem:function(){var a=
document.getElementById("previous-item");if(a)a.click();else if(c())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var d=a.length-1;0<=d;d--){if("current-item"==a[d].id){a[d].id="item-"+a[d].getAttribute("data-item-id");0<=d-1&&(a[d-1].id="current-item",e(a[d-1]));break}}else a[a.length-1].id="current-item",e(a[a.length-1])},ShowHelp:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},IsListing:c}}();
Miniflux.App=function(){return{BlinkIcon:function(){var e=document.querySelectorAll(".loading-icon");[].forEach.call(e,function(b){b.classList.toggle("loading-icon-blink")})},Run:function(){Miniflux.Event.ListenKeyboardEvents();Miniflux.Event.ListenMouseEvents()},MozillaAuth:function(e){navigator.id.watch({onlogin:function(b){var a=new XMLHttpRequest;a.open("POST","?action="+e+"&token="+b,!0);a.setRequestHeader("Connection","close");a.onload=function(){window.location.href=this.responseText};a.send("token="+
b)},onlogout:function(){}});navigator.id.request()}}}();
Miniflux.Feed=function(){function e(a){if(a=document.getElementById("loading-feed-"+a))a.appendChild(document.createTextNode("\u2600")),a.classList.add("loading-icon-blink");f||(f=setInterval(Miniflux.App.BlinkIcon,500))}function b(){for(var b=document.getElementsByTagName("a"),d=0,c=b.length;d<c;d++){var g=b[d].getAttribute("data-feed-id");g&&a.push(parseInt(g))}}var a=[],d=[],f;return{Update:function(a,b){e(a);var c=new XMLHttpRequest;c.onload=function(){var c=document.getElementById("loading-feed-"+
a);c&&(c.innerHTML="");if(c=document.getElementById("last-checked-feed-"+a))c.innerHTML=c.getAttribute("data-after-update");try{var k=JSON.parse(this.responseText);if(k.result){var d=k.items_count,e=document.getElementById("items-count-"+a);e&&(e.innerHTML="("+d.items_unread+"/"+d.items_total+")")}b&&b(k)}catch(f){}};c.open("POST","?action=refresh-feed&feed_id="+a,!0);c.send()},UpdateAll:function(){b();var e=setInterval(function(){for(;0<a.length&&5>d.length;){var b=a.shift();d.push(b);Miniflux.Feed.Update(b,
function(c){c=d.indexOf(c.feed_id);0<=c&&d.splice(c,1);0==a.length&&0==d.length&&(clearInterval(e),clearInterval(f),window.location.href="?action=unread")})}},100)}}}();
Miniflux.Item=function(){function e(c){var a=document.getElementById("item-"+c);a||(a=document.getElementById("current-item"),a.getAttribute("data-item-id")!=c&&(a=!1));return a}function b(c){if((c=document.getElementById("bookmark-"+c))&&c.getAttribute("data-reverse-label")){var a=c.innerHTML;c.innerHTML=c.getAttribute("data-reverse-label");c.setAttribute("data-reverse-label",a)}}function a(c){if(c=document.getElementById("status-"+c)){var a=c.innerHTML;c.innerHTML=c.getAttribute("data-reverse-label");
c.setAttribute("data-reverse-label",a)}}function d(c){"mouse"!=Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();c.parentNode.removeChild(c);var a=document.getElementById("page-counter");if(a){c=c.getAttribute("data-item-page");var b=parseInt(a.textContent,10)-1;if(0===b)switch(c){case "unread":window.location="?action=unread";break;case "history":window.location="?action=history"}a.textContent=b;"unread"===c?(document.title="Miniflux ("+b+")",document.getElementById("nav-counter").textContent=
"("+b+")"):document.title=a.parentNode.innerText}}function f(c){var b=new XMLHttpRequest;b.onload=function(){if(Miniflux.Nav.IsListing()){var b=e(c);if(b)if(b.getAttribute("data-hide"))d(b);else{b.setAttribute("data-item-status","read");a(c);if(b=document.getElementById("show-"+c)){b.className="read";var g=document.createElement("span");g.id="read-icon-"+c;g.appendChild(document.createTextNode("\u2714 "));b.parentNode.insertBefore(g,b)}(b=document.getElementById("status-"+c))&&b.setAttribute("data-action",
"mark-unread")}}};b.open("POST","?action=mark-item-read&id="+c,!0);b.send()}function h(c){var b=new XMLHttpRequest;b.onload=function(){if(Miniflux.Nav.IsListing()){var b=e(c);if(b)if(b.getAttribute("data-hide"))d(b);else{b.setAttribute("data-item-status","unread");a(c);if(b=document.getElementById("show-"+c))b.className="";(b=document.getElementById("read-icon-"+c))&&b.parentNode.removeChild(b);(b=document.getElementById("status-"+c))&&b.setAttribute("data-action","mark-read")}}};b.open("POST","?action=mark-item-unread&id="+
c,!0);b.send()}function m(c,a){var d=c.getAttribute("data-item-id"),e=new XMLHttpRequest;e.onload=function(){try{if(JSON.parse(this.responseText).result)if(c.setAttribute("data-item-bookmark",a),a)if(Miniflux.Nav.IsListing()){if(f=document.getElementById("show-"+d)){var e=document.createElement("span");e.id="bookmark-icon-"+d;e.appendChild(document.createTextNode("\u2605 "));f.parentNode.insertBefore(e,f)}b(d)}else{var f=document.getElementById("bookmark-"+d);f&&(f.innerHTML="\u2605")}else if(Miniflux.Nav.IsListing()){var l=
document.getElementById("bookmark-icon-"+d);l&&l.parentNode.removeChild(l);b(d)}else{var n=document.getElementById("bookmark-"+d);n&&(n.innerHTML="\u2606")}}catch(h){}};e.open("POST","?action=bookmark&id="+d+"&value="+a,!0);e.send()}return{Get:e,MarkAsRead:f,MarkAsUnread:h,MarkAsRemoved:function(c){var a=new XMLHttpRequest;a.onload=function(){Miniflux.Nav.IsListing()&&d(e(c))};a.open("POST","?action=mark-item-removed&id="+c,!0);a.send()},SwitchBookmark:function(c){"1"==c.getAttribute("data-item-bookmark")?
m(c,0):m(c,1)},SwitchStatus:function(c){var a=c.getAttribute("data-item-id");c=c.getAttribute("data-item-status");"read"==c?h(a):"unread"==c&&f(a)},ChangeStatus:function(c,a){switch(a){case "read":f(c);break;case "unread":h(c)}},Show:function(c){(c=document.getElementById("show-"+c))&&c.click()},OpenOriginal:function(c){var a=document.getElementById("original-"+c);a&&("unread"==e(c).getAttribute("data-item-status")&&f(c),a.removeAttribute("data-action"),a.click())},DownloadContent:function(){var c=
document.getElementById("download-item");if(c){var a=c.getAttribute("data-item-id"),b=c.getAttribute("data-before-message"),d=document.createElement("span");d.appendChild(document.createTextNode("\u2600"));d.className="loading-icon";c.innerHTML="";c.className="downloading";c.appendChild(d);c.appendChild(document.createTextNode(" "+b));var e=setInterval(Miniflux.App.BlinkIcon,250),f=new XMLHttpRequest;f.onload=function(){var a=JSON.parse(f.responseText);clearInterval(e);if(a.result){var b=document.getElementById("item-content");
b&&(b.innerHTML=a.content);c&&(a=c.getAttribute("data-after-message"),c.innerHTML="",c.appendChild(document.createTextNode(" "+a)))}else c&&(a=c.getAttribute("data-failure-message"),c.innerHTML="",c.appendChild(document.createTextNode(" "+a)))};f.open("POST","?action=download-item&id="+a,!0);f.send()}},MarkListingAsRead:function(a){for(var b=document.getElementsByTagName("article"),d=[],e=0,f=b.length;e<f;e++)d.push(b[e].getAttribute("data-item-id"));b=new XMLHttpRequest;b.onload=function(){window.location.href=
a};b.open("POST","?action=mark-items-as-read",!0);b.send(JSON.stringify(d))}}}();
Miniflux.Event=function(){var e=[];return{lastEventType:"",ListenMouseEvents:function(){document.onclick=function(b){var a=b.target.getAttribute("data-action");if(a)switch(Miniflux.Event.lastEventType="mouse",a){case "refresh-all":b.preventDefault();Miniflux.Feed.UpdateAll();break;case "refresh-feed":b.preventDefault();Miniflux.Feed.Update(b.target.getAttribute("data-feed-id"));break;case "mark-read":b.preventDefault();Miniflux.Item.MarkAsRead(b.target.getAttribute("data-item-id"));break;case "mark-unread":b.preventDefault();
Miniflux.Item.MarkAsUnread(b.target.getAttribute("data-item-id"));break;case "mark-removed":b.preventDefault();Miniflux.Item.MarkAsRemoved(b.target.getAttribute("data-item-id"));break;case "bookmark":b.preventDefault();Miniflux.Item.SwitchBookmark(Miniflux.Item.Get(b.target.getAttribute("data-item-id")));break;case "download-item":b.preventDefault();Miniflux.Item.DownloadContent();break;case "original-link":b.preventDefault();Miniflux.Item.OpenOriginal(b.target.getAttribute("data-item-id"));break;
case "mark-all-read":b.preventDefault();Miniflux.Item.MarkListingAsRead("?action=unread");break;case "mark-feed-read":b.preventDefault();Miniflux.Item.MarkListingAsRead("?action=feed-items&feed_id="+b.target.getAttribute("data-feed-id"));break;case "mozilla-login":b.preventDefault();Miniflux.App.MozillaAuth("mozilla-auth");break;case "mozilla-link":b.preventDefault(),Miniflux.App.MozillaAuth("mozilla-link")}}},ListenKeyboardEvents:function(){document.onkeypress=function(b){Miniflux.Event.lastEventType=
"keyboard";e.push(b.keyCode||b.which);if(103==e[0])switch(e[1]){case void 0:break;case 117:window.location.href="?action=unread";e=[];break;case 98:window.location.href="?action=bookmarks";e=[];break;case 104:window.location.href="?action=history";e=[];break;case 115:window.location.href="?action=feeds";e=[];break;case 112:window.location.href="?action=config";e=[];break;default:e=[]}else switch(e=[],b.keyCode||b.which){case 100:Miniflux.Item.DownloadContent(Miniflux.Nav.GetCurrentItemId());break;
case 112:case 107:Miniflux.Nav.SelectPreviousItem();break;case 110:case 106:Miniflux.Nav.SelectNextItem();break;case 118:Miniflux.Item.OpenOriginal(Miniflux.Nav.GetCurrentItemId());break;case 111:Miniflux.Item.Show(Miniflux.Nav.GetCurrentItemId());break;case 109:Miniflux.Item.SwitchStatus(Miniflux.Nav.GetCurrentItem());break;case 102:Miniflux.Item.SwitchBookmark(Miniflux.Nav.GetCurrentItem());break;case 104:Miniflux.Nav.OpenPreviousPage();break;case 108:Miniflux.Nav.OpenNextPage();break;case 114:Miniflux.Feed.UpdateAll();
break;case 63:Miniflux.Nav.ShowHelp()}}}}}();
Miniflux.Nav=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 b(){return document.getElementById("listing")?!0:!1}return{GetCurrentItem:function(){return document.getElementById("current-item")},GetCurrentItemId:function(){var a=Miniflux.Nav.GetCurrentItem();return a?a.getAttribute("data-item-id"):null},OpenNextPage:function(){var a=document.getElementById("next-page");
a&&a.click()},OpenPreviousPage:function(){var a=document.getElementById("previous-page");a&&a.click()},SelectNextItem:function(){var a=document.getElementById("next-item");if(a)a.click();else if(b())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var d=0,f=a.length;d<f;d++){if("current-item"==a[d].id){a[d].id="item-"+a[d].getAttribute("data-item-id");d+1<f&&(a[d+1].id="current-item",e(a[d+1]));break}}else a[0].id="current-item",e(a[0])},SelectPreviousItem:function(){var a=
document.getElementById("previous-item");if(a)a.click();else if(b())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var d=a.length-1;0<=d;d--){if("current-item"==a[d].id){a[d].id="item-"+a[d].getAttribute("data-item-id");0<=d-1&&(a[d-1].id="current-item",e(a[d-1]));break}}else a[a.length-1].id="current-item",e(a[a.length-1])},ShowHelp:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},IsListing:b}}();
Miniflux.App.Run();

View File

@ -31,6 +31,10 @@ Miniflux.Event = (function() {
e.preventDefault();
Miniflux.Item.MarkAsUnread(e.target.getAttribute("data-item-id"));
break;
case 'mark-removed':
e.preventDefault();
Miniflux.Item.MarkAsRemoved(e.target.getAttribute("data-item-id"));
break;
case 'bookmark':
e.preventDefault();
Miniflux.Item.SwitchBookmark(Miniflux.Item.Get(e.target.getAttribute("data-item-id")));

View File

@ -138,19 +138,30 @@ Miniflux.Item = (function() {
}
item.parentNode.removeChild(item);
var container = document.getElementById("page-counter");
var pageCounter = document.getElementById("page-counter");
if (container) {
if (pageCounter) {
var page = item.getAttribute("data-item-page");
var counter = parseInt(pageCounter.textContent, 10) - 1;
counter = parseInt(container.textContent.trim(), 10) - 1;
if (counter == 0) {
window.location = "?action=unread";
if (counter === 0) {
switch (page) {
case "unread":
window.location = "?action=unread";
break;
case "history":
window.location = "?action=history";
break;
}
}
else {
container.textContent = counter + " ";
document.title = "miniflux (" + counter + ")";
pageCounter.textContent = counter;
if (page === "unread") {
document.title = "Miniflux (" + counter + ")";
document.getElementById("nav-counter").textContent = "(" + counter + ")";
} else {
document.title = pageCounter.parentNode.innerText;
}
}
}
@ -175,6 +186,16 @@ Miniflux.Item = (function() {
request.send();
}
function markAsRemoved(item_id)
{
var request = new XMLHttpRequest();
request.onload = function() {
if (Miniflux.Nav.IsListing()) hideItem(getItem(item_id));
};
request.open("POST", "?action=mark-item-removed&id=" + item_id, true);
request.send();
}
function bookmark(item, value)
{
var item_id = item.getAttribute("data-item-id");
@ -209,6 +230,7 @@ Miniflux.Item = (function() {
Get: getItem,
MarkAsRead: markAsRead,
MarkAsUnread: markAsUnread,
MarkAsRemoved: markAsRemoved,
SwitchBookmark: function(item) {
var bookmarked = item.getAttribute("data-item-bookmark");

View File

@ -122,6 +122,13 @@ Router\post_action('mark-item-read', function() {
Response\json(array('Ok'));
});
// Ajax call to mark item as removed
Router\post_action('mark-item-removed', function() {
Model\Item\set_removed(Request\param('id'));
Response\json(array('Ok'));
});
// Ajax call to mark item unread
Router\post_action('mark-item-unread', function() {

View File

@ -138,7 +138,7 @@ return array(
'About' => 'O aplikaci',
'Miniflux version:' => 'Verze Miniflux:',
'Nothing to read' => 'Nic ke čtení',
'<span id="page-counter">%s</span>unread items' => '<span id="page-counter">%s</span>nepřečtené články',
'unread items' => 'nepřečtené články',
'mark all as read' => 'označit vše jako přečtené',
'original link' => 'původní odkaz',
'mark as read' => 'označit jako přečtené',

View File

@ -138,7 +138,7 @@ return array(
'About' => 'Über',
'Miniflux version:' => 'Miniflux-Version:',
'Nothing to read' => 'Nichts zu lesen',
'<span id="page-counter">%s</span>unread items' => '<span id="page-counter">%s</span>ungelesene einträge',
'unread items' => 'ungelesene einträge',
'mark all as read' => 'alle als gelesen markieren',
'original link' => 'original-link',
'mark as read' => 'als gelesen markieren',

View File

@ -138,7 +138,7 @@ return array(
'About' => 'Acerca',
'Miniflux version:' => 'Versión de Miniflux:',
'Nothing to read' => 'No hay nada que leer',
'<span id="page-counter">%s</span>unread items' => '<span id="page-counter">%s</span>ítems no leídos',
'unread items' => 'ítems no leídos',
'mark all as read' => 'marcar todo como leído',
'original link' => 'enlace original',
'mark as read' => 'marcar como leído',

View File

@ -138,7 +138,7 @@ return array(
'About' => 'A propos',
'Miniflux version:' => 'Version de Miniflux :',
'Nothing to read' => 'Rien à lire',
'<span id="page-counter">%s</span>unread items' => '<span id="page-counter">%s</span>éléments non lus',
'unread items' => 'éléments non lus',
'mark all as read' => 'tout marquer comme lu',
'original link' => 'lien original',
'mark as read' => 'marquer comme lu',

View File

@ -138,7 +138,7 @@ return array(
'About' => 'Informazioni sul software',
'Miniflux version:' => 'Versione Miniflux:',
'Nothing to read' => 'Niente da leggere',
'<span id="page-counter">%s</span>unread items' => '<span id="page-counter">%s</span>articoli non letti',
'unread items' => 'articoli non letti',
'mark all as read' => 'segna tutti come già letti',
'original link' => 'link originale',
'mark as read' => 'segna come già letto',

View File

@ -138,7 +138,7 @@ return array(
'About' => 'Sobre',
'Miniflux version:' => 'Miniflux versão:',
'Nothing to read' => 'Nada para ler',
'<span id="page-counter">%s</span>unread items' => '<span id="page-counter">%s</span>Item não lido',
'unread items' => 'Item não lido',
'mark all as read' => 'Marcar tudo como lido',
'original link' => ' Link original',
'mark as read' => 'Marcar como lido',

View File

@ -138,7 +138,7 @@ return array(
'About' => '关于',
'Miniflux version:' => 'Miniflux 版本:',
'Nothing to read' => '没有未读条目',
'<span id="page-counter">%s</span>unread items' => '<span id="page-counter">%s</span>个未读条目',
'unread items' => '个未读条目',
'mark all as read' => '全部标记为已读',
'original link' => '来源链接',
'mark as read' => '标记为已读',

View File

@ -3,7 +3,7 @@
<?php else: ?>
<div class="page-header">
<h2><?= t('Bookmarks') ?> (<?= $nb_items ?>)</h2>
<h2><?= t('Bookmarks') ?> (<span id="page-counter"><?= $nb_items ?></span>)</h2>
</div>
<?php if ($nothing_to_read): ?>

View File

@ -5,7 +5,7 @@
<?php else: ?>
<div class="page-header">
<h2><?= Helper\escape($feed['title']) ?> (<?= $nb_items ?>)</h2>
<h2><?= Helper\escape($feed['title']) ?> (<span id="page-counter"><?= $nb_items ?></span>)</h2>
<ul>
<li>
<a href="?action=feed-items&amp;feed_id=<?= $feed['id'] ?>&amp;order=updated&amp;direction=<?= $direction == 'asc' ? 'desc' : 'asc' ?>"><?= tne('sort by date<span class="hide-mobile"> (%s)</span>', $direction == 'desc' ? t('older first') : t('most recent first')) ?></a>

View File

@ -3,7 +3,7 @@
<?php else: ?>
<div class="page-header">
<h2><?= t('History') ?> (<?= $nb_items ?>)</h2>
<h2><?= t('History') ?> (<span id="page-counter"><?= $nb_items ?></span>)</h2>
<ul>
<li><a href="?action=confirm-flush-history"><?= t('flush all items') ?></a></li>
</ul>

View File

@ -1,5 +1,12 @@
<li class="hide-mobile">
<a class="item-delete" href="?action=mark-item-removed&amp;id=<?= $item['id'] ?>&amp;offset=<?= $offset ?>&amp;redirect=<?= $redirect ?>&amp;feed_id=<?= $item['feed_id'] ?>"><?= t('remove') ?></a>
<a
href="?action=mark-item-removed&amp;id=<?= $item['id'] ?>&amp;offset=<?= $offset ?>&amp;redirect=<?= $redirect ?>&amp;feed_id=<?= $item['feed_id'] ?>"
data-action="mark-removed"
data-item-id="<?= $item['id'] ?>"
class="item-delete"
>
<?= t('remove') ?>
</a>
</li>
<li>
<?php if ($item['status'] == 'unread'): ?>

View File

@ -3,7 +3,7 @@
<?php else: ?>
<div class="page-header">
<h2><?= tne('<span id="page-counter">%s</span>unread items', isset($nb_items) ? $nb_items.' ' : '') ?></h2>
<h2><span id="page-counter"><?= isset($nb_items) ? $nb_items : '' ?></span> <?= t('unread items') ?></h2>
<ul>
<li>
<a href="?action=unread&amp;order=updated&amp;direction=<?= $direction == 'asc' ? 'desc' : 'asc' ?>"><?= tne('sort by date<span class="hide-mobile"> (%s)</span>', $direction == 'desc' ? t('older first') : t('most recent first')) ?></a>