remove multiple definition of item id

The item id exists as data attribute or as element.id postfix on multiple
elements in an article.

The basic idea is to traverse the DOM tree - starting from the event firing
element - in reverse order till an article element is found.

This article element is passed to the JavaScript functions. These JavaScript
functions are getting the elements which they want to manipulate starting from
the article utilizing the JavaScript querySelector function.

The bootstrap themes had a conflicting and unused class style definied, which is
removed by now.
This commit is contained in:
Mathias Kresin 2014-09-16 20:42:15 +02:00
parent e9762e7ea0
commit 3dae99ac27
15 changed files with 137 additions and 212 deletions

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

@ -1,21 +1,19 @@
var Miniflux={};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()}}}();
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 l=b[d].getAttribute("data-feed-id");l&&a.push(parseInt(l))}}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 d=JSON.parse(this.responseText);if(d.result){var e=d.items_count,f=document.getElementById("items-count-"+a);f&&(f.innerHTML="("+e.items_unread+"/"+e.items_total+")")}b&&b(d)}catch(g){}};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&&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){c=document.getElementById("status-"+c);b(c)}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,d=document.getElementsByTagName("article");if(0===b||0===d.length)window.location=location.href;a.textContent=b;switch(c){case "unread":document.title="Miniflux ("+b+")";document.getElementById("nav-counter").textContent=b;break;case "feed-items":document.title="("+b+") "+a.parentNode.firstChild.nodeValue;break;default:document.title=a.parentNode.firstChild.nodeValue+" ("+b+")"}}}
function f(c){var b=new XMLHttpRequest;b.onload=function(){if(Miniflux.Nav.IsListing()){var b=e(c);b&&(b.getAttribute("data-hide")?d(b):(b.setAttribute("data-item-status","read"),a(c),(link=document.getElementById("status-"+c))&&link.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);b&&(b.getAttribute("data-hide")?d(b):(b.setAttribute("data-item-status",
"unread"),a(c),(link=document.getElementById("status-"+c))&&link.setAttribute("data-action","mark-read")))}};b.open("POST","?action=mark-item-unread&id="+c,!0);b.send()}function k(c,a){var d=c.getAttribute("data-item-id"),e=new XMLHttpRequest;e.onload=function(){try{if(JSON.parse(this.responseText).result&&(c.setAttribute("data-item-bookmark",a),Miniflux.Nav.IsListing())){var e=document.getElementById("bookmark-"+d);b(e)}}catch(f){}};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")?k(c,0):k(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)},Show:function(a){(a=document.getElementById("show-"+a))&&a.click()},OpenOriginal:function(a){var b=
document.getElementById("original-"+a);b&&("unread"==e(a).getAttribute("data-item-status")&&f(a),b.removeAttribute("data-action"),b.click())},DownloadContent:function(){var a=document.getElementById("download-item");if(a){var b=a.getAttribute("data-item-id"),d=a.getAttribute("data-before-message"),e=document.createElement("span");e.appendChild(document.createTextNode("\u2600"));e.className="loading-icon";a.innerHTML="";a.className="downloading";a.appendChild(e);a.appendChild(document.createTextNode(" "+
d));var f=setInterval(Miniflux.App.BlinkIcon,250),g=new XMLHttpRequest;g.onload=function(){var b=JSON.parse(g.responseText);clearInterval(f);if(b.result){var d=document.getElementById("item-content");d&&(d.innerHTML=b.content);a&&(b=a.getAttribute("data-after-message"),a.innerHTML="",a.appendChild(document.createTextNode(" "+b)))}else a&&(b=a.getAttribute("data-failure-message"),a.innerHTML="",a.appendChild(document.createTextNode(" "+b)))};g.open("POST","?action=download-item&id="+b,!0);g.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"))}}},ListenKeyboardEvents:function(){document.onkeypress=function(b){if(!(b.ctrlKey||b.shiftKey||b.altKey||b.metaKey)){var a=b.target||b.srcElement;if("INPUT"!=a.tagName&&"TEXTAREA"!=a.tagName)if(Miniflux.Event.lastEventType="keyboard",e.push(b.keyCode||b.which),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();
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()}}}();
Miniflux.Feed=function(){function e(d){if(d=document.getElementById("loading-feed-"+d))d.appendChild(document.createTextNode("\u2600")),d.classList.add("loading-icon-blink");g||(g=setInterval(Miniflux.App.BlinkIcon,500))}function c(){for(var d=document.getElementsByTagName("a"),h=0,a=d.length;h<a;h++){var c=d[h].getAttribute("data-feed-id");c&&b.push(parseInt(c))}}var b=[],a=[],g;return{Update:function(d,b){e(d);var a=new XMLHttpRequest;a.onload=function(){var a=document.getElementById("loading-feed-"+
d);a&&(a.innerHTML="");if(a=document.getElementById("last-checked-feed-"+d))a.innerHTML=a.getAttribute("data-after-update");try{var c=JSON.parse(this.responseText);if(c.result){var f=c.items_count,e=document.getElementById("items-count-"+d);e&&(e.innerHTML="("+f.items_unread+"/"+f.items_total+")")}b&&b(c)}catch(g){}};a.open("POST","?action=refresh-feed&feed_id="+d,!0);a.send()},UpdateAll:function(){c();var d=setInterval(function(){for(;0<b.length&&5>a.length;){var h=b.shift();a.push(h);Miniflux.Feed.Update(h,
function(h){h=a.indexOf(h.feed_id);0<=h&&a.splice(h,1);0==b.length&&0==a.length&&(clearInterval(d),clearInterval(g),window.location.href="?action=unread")})}},100)}}}();
Miniflux.Item=function(){function e(d){return item_id=d.getAttribute("data-item-id")}function c(d){if(d&&d.hasAttribute("data-reverse-label")){var b=d.innerHTML;d.innerHTML=d.getAttribute("data-reverse-label");d.setAttribute("data-reverse-label",b)}}function b(d){"mouse"!==Miniflux.Event.lastEventType&&Miniflux.Nav.SelectNextItem();d.parentNode.removeChild(d);var b=document.getElementById("page-counter");if(b){d=d.getAttribute("data-item-page");var a=parseInt(b.textContent,10)-1,c=document.getElementsByTagName("article");
if(0===a||0===c.length)window.location=location.href;b.textContent=a;switch(d){case "unread":document.title="Miniflux ("+a+")";document.getElementById("nav-counter").textContent=a;break;case "feed-items":document.title="("+a+") "+b.parentNode.firstChild.nodeValue;break;default:document.title=b.parentNode.firstChild.nodeValue+" ("+a+")"}}}function a(d){var a=e(d),f=new XMLHttpRequest;f.onload=function(){if(Miniflux.Nav.IsListing())if(d.getAttribute("data-hide"))b(d);else{d.setAttribute("data-item-status",
"read");var a=d.querySelector("a.mark");c(a);(a=d.querySelector("a.mark"))&&a.setAttribute("data-action","mark-unread")}};f.open("POST","?action=mark-item-read&id="+a,!0);f.send()}function g(d){var a=e(d),f=new XMLHttpRequest;f.onload=function(){if(Miniflux.Nav.IsListing())if(d.getAttribute("data-hide"))b(d);else{d.setAttribute("data-item-status","unread");var a=d.querySelector("a.mark");c(a);(a=d.querySelector("a.mark"))&&a.setAttribute("data-action","mark-read")}};f.open("POST","?action=mark-item-unread&id="+
a,!0);f.send()}return{MarkAsRead:a,MarkAsUnread:g,MarkAsRemoved:function(a){var c=e(a),f=new XMLHttpRequest;f.onload=function(){Miniflux.Nav.IsListing()&&b(a)};f.open("POST","?action=mark-item-removed&id="+c,!0);f.send()},SwitchBookmark:function(a){var b=e(a),f="1"===a.getAttribute("data-item-bookmark")?"0":"1",k=new XMLHttpRequest;k.onload=function(){a.setAttribute("data-item-bookmark",f);if(Miniflux.Nav.IsListing()){var b=a.querySelector("a.bookmark");c(b)}};k.open("POST","?action=bookmark&id="+
b+"&value="+f,!0);k.send()},SwitchStatus:function(b){var c=b.getAttribute("data-item-status");"read"===c?g(b):"unread"===c&&a(b)},Show:function(a){(a=a.querySelector("a.show"))&&a.click()},OpenOriginal:function(b){var c=b.querySelector("a.original");c&&("unread"===b.getAttribute("data-item-status")&&a(b),c.removeAttribute("data-action"),c.click())},DownloadContent:function(a){var b=document.getElementById("download-item");if(b){a=e(a);var c=b.getAttribute("data-before-message"),k=document.createElement("span");
k.appendChild(document.createTextNode("\u2600"));k.className="loading-icon";b.innerHTML="";b.className="downloading";b.appendChild(k);b.appendChild(document.createTextNode(" "+c));var g=setInterval(Miniflux.App.BlinkIcon,250),l=new XMLHttpRequest;l.onload=function(){var a=JSON.parse(l.responseText);clearInterval(g);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)))};l.open("POST","?action=download-item&id="+a,!0);l.send()}},MarkListingAsRead:function(b){for(var a=document.getElementsByTagName("article"),c=[],g=0,m=a.length;g<m;g++)c.push(e(a[g]));a=new XMLHttpRequest;a.onload=function(){window.location.href=b};a.open("POST","?action=mark-items-as-read",!0);a.send(JSON.stringify(c))}}}();
Miniflux.Event=function(){var e=[];return{lastEventType:"",ListenMouseEvents:function(){document.onclick=function(c){var b=c.target.getAttribute("data-action");if(b){Miniflux.Event.lastEventType="mouse";var a;a:{for(element=c.target;element&&element.parentNode;)if(element=element.parentNode,element.tagName&&"article"===element.tagName.toLowerCase()){a=element;break a}a=null}switch(b){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(a);break;case "mark-unread":c.preventDefault();Miniflux.Item.MarkAsUnread(a);break;case "mark-removed":c.preventDefault();Miniflux.Item.MarkAsRemoved(a);break;case "bookmark":c.preventDefault();Miniflux.Item.SwitchBookmark(a);break;case "download-item":c.preventDefault();Miniflux.Item.DownloadContent(a);break;case "original-link":c.preventDefault();Miniflux.Item.OpenOriginal(a);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"))}}}},ListenKeyboardEvents:function(){document.onkeypress=function(c){if(!(c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)){var b=c.target||c.srcElement;if("INPUT"!=b.tagName&&"TEXTAREA"!=b.tagName)if(Miniflux.Event.lastEventType="keyboard",e.push(c.keyCode||c.which),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=document.getElementById("current-item"),c.keyCode||c.which){case 100:Miniflux.Item.DownloadContent(b);break;case 112:case 107:Miniflux.Nav.SelectPreviousItem();break;case 110:case 106:Miniflux.Nav.SelectNextItem();break;case 118:Miniflux.Item.OpenOriginal(b);
break;case 111:Miniflux.Item.Show(b);break;case 109:Miniflux.Item.SwitchStatus(b);break;case 102:Miniflux.Item.SwitchBookmark(b);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(b){var a=pageYOffset+document.documentElement.clientHeight;(0>a-(b.offsetTop+b.offsetHeight)||a-b.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,b.offsetTop-10)}function c(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var b=document.getElementById("next-page");b&&b.click()},OpenPreviousPage:function(){var b=document.getElementById("previous-page");b&&b.click()},SelectNextItem:function(){var b=document.getElementById("next-item");
if(b)b.click();else if(c())if(b=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var a=0,g=b.length;a<g;a++){if("current-item"==b[a].id){b[a].id="item-"+b[a].getAttribute("data-item-id");a+1<g&&(b[a+1].id="current-item",e(b[a+1]));break}}else b[0].id="current-item",e(b[0])},SelectPreviousItem:function(){var b=document.getElementById("previous-item");if(b)b.click();else if(c())if(b=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var a=
b.length-1;0<=a;a--){if("current-item"==b[a].id){b[a].id="item-"+b[a].getAttribute("data-item-id");0<=a-1&&(b[a-1].id="current-item",e(b[a-1]));break}}else b[b.length-1].id="current-item",e(b[b.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.Run();

View File

@ -14,6 +14,19 @@ Miniflux.Event = (function() {
Miniflux.Event.lastEventType = "mouse";
var currentItem = function () {
element = e.target;
while (element && element.parentNode) {
element = element.parentNode;
if (element.tagName && element.tagName.toLowerCase() === 'article') {
return element;
}
}
return null;
}();
switch (action) {
case 'refresh-all':
e.preventDefault();
@ -25,27 +38,27 @@ Miniflux.Event = (function() {
break;
case 'mark-read':
e.preventDefault();
Miniflux.Item.MarkAsRead(e.target.getAttribute("data-item-id"));
Miniflux.Item.MarkAsRead(currentItem);
break;
case 'mark-unread':
e.preventDefault();
Miniflux.Item.MarkAsUnread(e.target.getAttribute("data-item-id"));
Miniflux.Item.MarkAsUnread(currentItem);
break;
case 'mark-removed':
e.preventDefault();
Miniflux.Item.MarkAsRemoved(e.target.getAttribute("data-item-id"));
Miniflux.Item.MarkAsRemoved(currentItem);
break;
case 'bookmark':
e.preventDefault();
Miniflux.Item.SwitchBookmark(Miniflux.Item.Get(e.target.getAttribute("data-item-id")));
Miniflux.Item.SwitchBookmark(currentItem);
break;
case 'download-item':
e.preventDefault();
Miniflux.Item.DownloadContent();
Miniflux.Item.DownloadContent(currentItem);
break;
case 'original-link':
e.preventDefault();
Miniflux.Item.OpenOriginal(e.target.getAttribute("data-item-id"));
Miniflux.Item.OpenOriginal(currentItem);
break;
case 'mark-all-read':
e.preventDefault();
@ -77,7 +90,7 @@ Miniflux.Event = (function() {
queue.push(e.keyCode || e.which);
if (queue[0] == 103) { // g
if (queue[0] === 103) { // g
switch (queue[1]) {
case undefined:
@ -111,9 +124,13 @@ Miniflux.Event = (function() {
queue = [];
var currentItem = function () {
return document.getElementById("current-item");
}();
switch (e.keyCode || e.which) {
case 100: // d
Miniflux.Item.DownloadContent(Miniflux.Nav.GetCurrentItemId());
Miniflux.Item.DownloadContent(currentItem);
break;
case 112: // p
case 107: // k
@ -124,16 +141,16 @@ Miniflux.Event = (function() {
Miniflux.Nav.SelectNextItem();
break;
case 118: // v
Miniflux.Item.OpenOriginal(Miniflux.Nav.GetCurrentItemId());
Miniflux.Item.OpenOriginal(currentItem);
break;
case 111: // o
Miniflux.Item.Show(Miniflux.Nav.GetCurrentItemId());
Miniflux.Item.Show(currentItem);
break;
case 109: // m
Miniflux.Item.SwitchStatus(Miniflux.Nav.GetCurrentItem());
Miniflux.Item.SwitchStatus(currentItem);
break;
case 102: // f
Miniflux.Item.SwitchBookmark(Miniflux.Nav.GetCurrentItem());
Miniflux.Item.SwitchBookmark(currentItem);
break;
case 104: // h
Miniflux.Nav.OpenPreviousPage();
@ -142,8 +159,8 @@ Miniflux.Event = (function() {
Miniflux.Nav.OpenNextPage();
break;
case 114: // r
Miniflux.Feed.UpdateAll();
break;
Miniflux.Feed.UpdateAll();
break;
case 63: // ?
Miniflux.Nav.ShowHelp();
break;

View File

@ -1,95 +1,65 @@
Miniflux.Item = (function() {
function getItem(item_id)
function getItemID(item)
{
var item = document.getElementById("item-" + item_id);
if (! item) {
item = document.getElementById("current-item");
if (item.getAttribute("data-item-id") != item_id) item = false;
}
return item;
item_id = item.getAttribute("data-item-id");
return item_id;
}
function changeLabel(link)
{
if (link && link.getAttribute("data-reverse-label")) {
if (link && link.hasAttribute("data-reverse-label")) {
var content = link.innerHTML;
link.innerHTML = link.getAttribute("data-reverse-label");
link.setAttribute("data-reverse-label", content);
}
}
function changeBookmarkLabel(item_id)
function changeBookmarkLabel(item)
{
var link = document.getElementById("bookmark-" + item_id);
var link = item.querySelector("a.bookmark");
changeLabel(link);
}
function showItemBookmarked(item_id)
function changeStatusLabel(item)
{
if (Miniflux.Nav.IsListing()) {
changeBookmarkLabel(item_id);
}
}
function showItemNotBookmarked(item_id)
{
if (Miniflux.Nav.IsListing()) {
changeBookmarkLabel(item_id);
}
}
function changeStatusLabel(item_id)
{
var link = document.getElementById("status-" + item_id);
var link = item.querySelector("a.mark");
changeLabel(link);
}
function showItemAsRead(item_id)
function showItemAsRead(item)
{
var item = getItem(item_id);
if (item.getAttribute("data-hide")) {
hideItem(item);
}
else {
item.setAttribute("data-item-status", "read");
changeStatusLabel(item);
if (item) {
if (item.getAttribute("data-hide")) {
hideItem(item);
}
else {
item.setAttribute("data-item-status", "read");
changeStatusLabel(item_id);
// Change action
link = document.getElementById("status-" + item_id);
if (link) link.setAttribute("data-action", "mark-unread");
}
// Change action
var link = item.querySelector("a.mark");
if (link) link.setAttribute("data-action", "mark-unread");
}
}
function showItemAsUnread(item_id)
function showItemAsUnread(item)
{
var item = getItem(item_id);
if (item.getAttribute("data-hide")) {
hideItem(item);
}
else {
item.setAttribute("data-item-status", "unread");
changeStatusLabel(item);
if (item) {
if (item.getAttribute("data-hide")) {
hideItem(item);
}
else {
item.setAttribute("data-item-status", "unread");
changeStatusLabel(item_id);
// Change action
link = document.getElementById("status-" + item_id);
if (link) link.setAttribute("data-action", "mark-read");
}
// Change action
var link = item.querySelector("a.mark");
if (link) link.setAttribute("data-action", "mark-read");
}
}
function hideItem(item)
{
if (Miniflux.Event.lastEventType != "mouse") {
if (Miniflux.Event.lastEventType !== "mouse") {
Miniflux.Nav.SelectNextItem();
}
@ -121,114 +91,87 @@ Miniflux.Item = (function() {
}
}
function markAsRead(item_id)
function markAsRead(item)
{
var item_id = getItemID(item);
var request = new XMLHttpRequest();
request.onload = function() {
if (Miniflux.Nav.IsListing()) showItemAsRead(item_id);
if (Miniflux.Nav.IsListing()) showItemAsRead(item);
};
request.open("POST", "?action=mark-item-read&id=" + item_id, true);
request.send();
}
function markAsUnread(item_id)
function markAsUnread(item)
{
var item_id = getItemID(item);
var request = new XMLHttpRequest();
request.onload = function() {
if (Miniflux.Nav.IsListing()) showItemAsUnread(item_id);
if (Miniflux.Nav.IsListing()) showItemAsUnread(item);
};
request.open("POST", "?action=mark-item-unread&id=" + item_id, true);
request.send();
}
function markAsRemoved(item_id)
function markAsRemoved(item)
{
var item_id = getItemID(item);
var request = new XMLHttpRequest();
request.onload = function() {
if (Miniflux.Nav.IsListing()) hideItem(getItem(item_id));
if (Miniflux.Nav.IsListing()) hideItem(item);
};
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");
var request = new XMLHttpRequest();
request.onload = function() {
try {
var response = JSON.parse(this.responseText);
if (response.result) {
item.setAttribute("data-item-bookmark", value);
if (value) {
showItemBookmarked(item_id);
}
else {
showItemNotBookmarked(item_id);
}
}
}
catch (e) {}
};
request.open("POST", "?action=bookmark&id=" + item_id + "&value=" + value, true);
request.send();
}
return {
Get: getItem,
MarkAsRead: markAsRead,
MarkAsUnread: markAsUnread,
MarkAsRemoved: markAsRemoved,
SwitchBookmark: function(item) {
var item_id = getItemID(item);
var value = item.getAttribute("data-item-bookmark") === "1" ? "0" : "1";
var request = new XMLHttpRequest();
request.onload = function() {
item.setAttribute("data-item-bookmark", value);
if (Miniflux.Nav.IsListing()) changeBookmarkLabel(item);
};
var bookmarked = item.getAttribute("data-item-bookmark");
if (bookmarked == "1") {
bookmark(item, 0);
}
else {
bookmark(item, 1);
}
request.open("POST", "?action=bookmark&id=" + item_id + "&value=" + value, true);
request.send();
},
SwitchStatus: function(item) {
var item_id = item.getAttribute("data-item-id");
var status = item.getAttribute("data-item-status");
if (status == "read") {
markAsUnread(item_id);
if (status === "read") {
markAsUnread(item);
}
else if (status == "unread") {
markAsRead(item_id);
else if (status === "unread") {
markAsRead(item);
}
},
Show: function(item_id) {
var link = document.getElementById("show-" + item_id);
Show: function(item) {
var link = item.querySelector("a.show");
if (link) link.click();
},
OpenOriginal: function(item_id) {
var link = document.getElementById("original-" + item_id);
OpenOriginal: function(item) {
var link = item.querySelector("a.original");
if (link) {
if (getItem(item_id).getAttribute("data-item-status") == "unread") markAsRead(item_id);
if (item.getAttribute("data-item-status") === "unread") markAsRead(item);
link.removeAttribute("data-action");
link.click();
}
},
DownloadContent: function() {
DownloadContent: function(item) {
var container = document.getElementById("download-item");
if (! container) return;
var item_id = container.getAttribute("data-item-id");
var item_id = getItemID(item);
var message = container.getAttribute("data-before-message");
var span = document.createElement("span");
@ -278,7 +221,7 @@ Miniflux.Item = (function() {
var listing = [];
for (var i = 0, ilen = articles.length; i < ilen; i++) {
listing.push(articles[i].getAttribute("data-item-id"));
listing.push(getItemID(articles[i]));
}
var request = new XMLHttpRequest();

View File

@ -73,14 +73,6 @@ Miniflux.Nav = (function() {
}
return {
GetCurrentItem: function() {
return document.getElementById("current-item");
},
GetCurrentItemId: function() {
var item = Miniflux.Nav.GetCurrentItem();
if (item) return item.getAttribute("data-item-id");
return null;
},
OpenNextPage: function() {
var link = document.getElementById("next-page");
if (link) link.click();

View File

@ -1,19 +1,16 @@
<li class="hide-mobile">
<?php if ($item['bookmark']): ?>
<a
id="bookmark-<?= $item['id'] ?>"
class="bookmark"
href="?action=bookmark&amp;value=0&amp;id=<?= $item['id'] ?>&amp;menu=<?= $menu ?>&amp;offset=<?= $offset ?>&amp;source=<?= $source ?>"
data-action="bookmark"
data-item-id="<?= $item['id'] ?>"
data-reverse-label="<?= t('bookmark') ?>"
><?= t('remove bookmark') ?></a>
<?php else: ?>
<a
id="bookmark-<?= $item['id'] ?>"
class="item-bookmark"
class="bookmark"
href="?action=bookmark&amp;value=1&amp;id=<?= $item['id'] ?>&amp;menu=<?= $menu ?>&amp;offset=<?= $offset ?>&amp;source=<?= $source ?>"
data-action="bookmark"
data-item-id="<?= $item['id'] ?>"
data-reverse-label="<?= t('remove bookmark') ?>"
><?= t('bookmark') ?></a>
<?php endif ?>

View File

@ -12,8 +12,7 @@
<span class="read-icon"></span>
<a
href="?action=show&amp;menu=<?= $menu ?>&amp;id=<?= $item['id'] ?>"
data-item-id="<?= $item['id'] ?>"
id="show-<?= $item['id'] ?>"
class="show"
><?= Helper\escape($item['title']) ?></a>
</h2>
<?php if($display_mode === 'full'): ?>
@ -37,7 +36,7 @@
<span title="<?= dt('%e %B %Y %k:%M', $item['updated']) ?>"><?= Helper\relative_time($item['updated']) ?></span>
</li>
<li class="hide-mobile">
<a href="<?= $item['url'] ?>" id="original-<?= $item['id'] ?>" rel="noreferrer" target="_blank" data-item-id="<?= $item['id'] ?>" data-action="original-link"><?= t('original link') ?></a>
<a href="<?= $item['url'] ?>" class="original" rel="noreferrer" target="_blank" data-action="original-link"><?= t('original link') ?></a>
</li>
<?php if ($item['enclosure']): ?>
<li>

View File

@ -31,28 +31,24 @@
<?php endif ?>
<h1 <?= Helper\isRTL($item + array('rtl' => $feed['rtl'])) ? 'dir="rtl"' : '' ?>>
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" id="original-<?= $item['id'] ?>"><?= Helper\escape($item['title']) ?></a>
<a href="<?= $item['url'] ?>" rel="noreferrer" target="_blank" class="original"><?= Helper\escape($item['title']) ?></a>
</h1>
<ul class="item-infos">
<li>
<?php if ($item['bookmark']): ?>
<a
id="bookmark-<?=$item['id'] ?>"
class="bookmark-icon"
href="?action=bookmark&amp;value=0&amp;id=<?= $item['id'] ?>&amp;source=show&amp;menu=<?= $menu ?>"
title="<?= t('remove bookmark') ?>"
class="bookmark-icon"
data-action="bookmark"
data-item-id="<?= $item['id'] ?>"
></a>
<?php else: ?>
<a
id="bookmark-<?=$item['id'] ?>"
class="bookmark-icon"
href="?action=bookmark&amp;value=1&amp;id=<?= $item['id'] ?>&amp;source=show&amp;menu=<?= $menu ?>"
title="<?= t('bookmark') ?>"
class="bookmark-icon"
data-action="bookmark"
data-item-id="<?= $item['id'] ?>"
></a>
<?php endif ?>
</li>
@ -74,7 +70,6 @@
</li>
<li class="hide-mobile">
<span id="download-item"
data-item-id="<?= $item['id'] ?>"
data-failure-message="<?= t('unable to fetch content') ?>"
data-before-message="<?= t('in progress...') ?>"
data-after-message="<?= t('content downloaded') ?>">

View File

@ -2,26 +2,22 @@
<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"
class="delete"
><?= t('remove') ?></a>
</li>
<li>
<?php if ($item['status'] == 'unread'): ?>
<a
id="status-<?= $item['id'] ?>"
class="item-mark"
class="mark"
href="?action=mark-item-read&amp;id=<?= $item['id'] ?>&amp;offset=<?= $offset ?>&amp;redirect=<?= $redirect ?>&amp;feed_id=<?= $item['feed_id'] ?>"
data-action="mark-read"
data-item-id="<?= $item['id'] ?>"
data-reverse-label="<?= t('mark as unread') ?>"
><?= t('mark as read') ?></a>
<?php else: ?>
<a
id="status-<?= $item['id'] ?>"
class="mark"
href="?action=mark-item-unread&amp;id=<?= $item['id'] ?>&amp;offset=<?= $offset ?>&amp;redirect=<?= $redirect ?>&amp;feed_id=<?= $item['feed_id'] ?>"
data-action="mark-unread"
data-item-id="<?= $item['id'] ?>"
data-reverse-label="<?= t('mark as read') ?>"
><?= t('mark as unread') ?></a>
<?php endif ?>

View File

@ -4532,9 +4532,6 @@ article.item > .panel-footer + .panel-collapse .panel-body,
.hide {
display: none !important;
}
.show {
display: block !important;
}
.invisible {
visibility: hidden;
}

View File

@ -23,9 +23,6 @@
.hide {
display: none !important;
}
.show {
display: block !important;
}
.invisible {
visibility: hidden;
}

View File

@ -4532,9 +4532,6 @@ article.item > .panel-footer + .panel-collapse .panel-body,
.hide {
display: none !important;
}
.show {
display: block !important;
}
.invisible {
visibility: hidden;
}

View File

@ -23,9 +23,6 @@
.hide {
display: none !important;
}
.show {
display: block !important;
}
.invisible {
visibility: hidden;
}

View File

@ -159,9 +159,9 @@ nav .active a {
color: #929292;
}
.items .item-menu .item-bookmark,
.items .item-menu .item-delete,
.items .item-menu .item-mark{
.items .item-menu .bookmark,
.items .item-menu .delete,
.items .item-menu .mark{
color: transparent;
text-indent: -9999px;
background-repeat: no-repeat;
@ -171,15 +171,15 @@ nav .active a {
height: 15px;
}
.items .item-menu .item-bookmark{
.items .item-menu .bookmark{
background-image: url("../img/star.png");
}
.items .item-menu .item-delete{
.items .item-menu .delete{
background-image: url("../img/cross.png");
}
.items .item-menu .item-mark{
.items .item-menu .mark{
background-image: url("../img/tick.png");
}

View File

@ -313,9 +313,9 @@ article[data-item-bookmark="0"] .bookmark-icon:before {
background-color: rgba(153, 153, 153, 0.7); }
.items article[data-item-status="read"] .read-icon:before {
content: "✔"; }
.items article[data-item-bookmark="1"] .item-menu a[id*="bookmark-"]:before {
.items article[data-item-bookmark="1"] .item-menu a.bookmark:before {
content: "\f088"; }
.items article[data-item-bookmark="0"] .item-menu a[id*="bookmark-"]:before {
.items article[data-item-bookmark="0"] .item-menu a.bookmark:before {
content: "\f087"; }
.items article h2 {
display: block;
@ -350,7 +350,7 @@ article[data-item-bookmark="0"] .bookmark-icon:before {
margin-right: 2px; }
.items .item-menu li a:first-child:before {
content: "\f0b0"; }
.items .item-menu li a[id*="original-"]:before {
.items .item-menu li a.original:before {
content: "\f08e"; }
.items .item-menu li a[href*="action=confirm-remove-feed"]:before {
content: "\f014"; }
@ -361,7 +361,7 @@ article[data-item-bookmark="0"] .bookmark-icon:before {
.items .item-menu li a[href*="action=mark-item-removed"]:before {
content: "\f014";
margin-right: 2px; }
.items .item-menu li a[id*="status-"]:before {
.items .item-menu li a.mark:before {
content: "\f058"; }
.items .item-menu li a[href*="action=disable-grabber-feed"]:before {
content: "\f057"; }

View File

@ -33,7 +33,7 @@ article {
&[data-item-bookmark="1"] {
.item-menu {
a {
&[id*="bookmark-"] {
&.bookmark {
&:before {
content: "\f088";
}
@ -45,7 +45,7 @@ article {
&[data-item-bookmark="0"] {
.item-menu {
a {
&[id*="bookmark-"] {
&.bookmark {
&:before {
content: "\f087";
}
@ -107,7 +107,7 @@ article {
content: "\f0b0";
}
}
&[id*="original-"] {
&.original {
&:before {
content: "\f08e";
}
@ -135,7 +135,7 @@ article {
}
}
&[id*="status-"] {
&.mark {
&:before {
content: "\f058";
}