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

20 lines
9.6 KiB
JavaScript
Raw Normal View History

use keyboardevent.key if implemented Beside other stuff the main reason for this change is the circumstance that Firefox triggers the "Toggle RTL mode" shortcut if the user press F11 to switch Firefox into the fullscreen mode. Each browser sends keycodes that are used by different other keys on the keyboard for the function keys. Firefox is the only browser which sends the onkeypress event for the function keys. The used keyboard event properties event.keyCode and event.which are already marked as deprecated and has been removed from the Web standards. The "DOM Level 3 Events" standard specifies event.key as their successor. Right now event.key is only available for Firefox 29+ and Internet Explorer 9+. Webkit based browser have support for the former specified event.keyIdentifier. The implementation of event.keyIdentifier isn't the same across different webkit based browsers and buggy: - the value for the z key is F11 (Chrome - Windows, Linux) - the value for the F11 key is F11 as well on (Chrome - Windows, Linux) - the value for latin keys is always the value of the capital letter (Chrome) - the value for cyrillic keys depends on the shift modifier (Chrome) - the value for the keypress event is always an empty string (Safari - Mac OS) - the value for the keydown event matches the keyboard layout dependent character (Safari - Mac OS) - the value for the keydown event does NOT matches the keyboard layout dependent character (Chrome - Windows, Linux) Instead of workaround the problems, the event.which is used for every browser that doesn't support event.key.
2015-03-07 18:23:36 +01:00
var l=function(){var d=[];return{h:function(c,a){var b=c.querySelector("span.items-count");if(b){var e=c.getAttribute("data-feed-id"),d=c.querySelector("h2:first-of-type");d.className="loading-icon";var p=new XMLHttpRequest;p.onload=function(){d.className="";c.removeAttribute("data-feed-error");var e=c.querySelector(".feed-last-checked");e&&(e.innerHTML=e.getAttribute("data-after-update"));e=JSON.parse(this.responseText);e.result?b.innerHTML=e.items_count.items_unread+"/"+e.items_count.items_total:
c.setAttribute("data-feed-error","1");a?a(e):h.a()};p.open("POST","?action=refresh-feed&feed_id="+e,!0);p.send()}},i:function(){var c=Array.prototype.slice.call(document.querySelectorAll("article:not([data-feed-disabled])")),a=setInterval(function(){for(;0<c.length&&5>d.length;){var b=c.shift();d.push(parseInt(b.getAttribute("data-feed-id"),10));l.h(b,function(b){b=d.indexOf(b.feed_id);0<=b&&d.splice(b,1);0===c.length&&0===d.length&&(clearInterval(a),h.a())})}},100)}}}(),h=function(){function d(f){var a=
document.createEvent("MouseEvents");a.initEvent("mousedown",!0,!0);f.dispatchEvent(a);a=document.createEvent("MouseEvents");a.initEvent("mouseup",!0,!0);f.dispatchEvent(a);f.click()}function c(a){return item_id=a.getAttribute("data-item-id")}function a(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 b(a){"mouse"!==n.c&&u.d();a.parentNode.removeChild(a);q--}function e(){-1<window.location.href.indexOf("nothing_to_read=1")&&
0<m?window.location.href="?action=unread":0===q&&window.location.reload();var a=document.getElementById("page-counter");a&&(a.textContent=q||"");document.getElementById("nav-counter").textContent=m||"";var b=document.querySelector("div.page-header h2:first-of-type");if(b)pageHeading=b.firstChild.nodeValue;else if(b=document.querySelector("article.item h1:first-of-type")){document.title=b.textContent;return}switch(document.querySelector("section.page").getAttribute("data-item-page")){case "unread":document.title=
use keyboardevent.key if implemented Beside other stuff the main reason for this change is the circumstance that Firefox triggers the "Toggle RTL mode" shortcut if the user press F11 to switch Firefox into the fullscreen mode. Each browser sends keycodes that are used by different other keys on the keyboard for the function keys. Firefox is the only browser which sends the onkeypress event for the function keys. The used keyboard event properties event.keyCode and event.which are already marked as deprecated and has been removed from the Web standards. The "DOM Level 3 Events" standard specifies event.key as their successor. Right now event.key is only available for Firefox 29+ and Internet Explorer 9+. Webkit based browser have support for the former specified event.keyIdentifier. The implementation of event.keyIdentifier isn't the same across different webkit based browsers and buggy: - the value for the z key is F11 (Chrome - Windows, Linux) - the value for the F11 key is F11 as well on (Chrome - Windows, Linux) - the value for latin keys is always the value of the capital letter (Chrome) - the value for cyrillic keys depends on the shift modifier (Chrome) - the value for the keypress event is always an empty string (Safari - Mac OS) - the value for the keydown event matches the keyboard layout dependent character (Safari - Mac OS) - the value for the keydown event does NOT matches the keyboard layout dependent character (Chrome - Windows, Linux) Instead of workaround the problems, the event.which is used for every browser that doesn't support event.key.
2015-03-07 18:23:36 +01:00
"Miniflux ("+m+")";break;case "feed-items":document.title="("+q+") "+pageHeading;break;default:document.title=a?pageHeading+" ("+q+")":pageHeading}}function v(f){var g=c(f),k=new XMLHttpRequest;k.onload=function(){if(u.b()){if(f.getAttribute("data-hide"))b(f);else{f.setAttribute("data-item-status","read");var g=f.querySelector("a.mark");a(g);(g=f.querySelector("a.mark"))&&g.setAttribute("data-action","mark-unread")}m--;e()}};k.open("POST","?action=mark-item-read&id="+g,!0);k.send()}function p(f){var g=
c(f),k=new XMLHttpRequest;k.onload=function(){if(u.b()){if(f.getAttribute("data-hide"))b(f);else{f.setAttribute("data-item-status","unread");var g=f.querySelector("a.mark");a(g);(g=f.querySelector("a.mark"))&&g.setAttribute("data-action","mark-read")}m++;e()}};k.open("POST","?action=mark-item-unread&id="+g,!0);k.send()}var t=[],r=!1,m=function(){var a=document.getElementById("nav-counter");if(a)return counter=parseInt(a.textContent,10)||0}(),q=function(){var a=document.getElementById("page-counter");
if(a)return counter=parseInt(a.textContent,10)||0}();return{n:function(a){"read"!==a.getAttribute("data-item-status")&&v(a)},p:p,o:function(a){var g=c(a),k=new XMLHttpRequest;k.onload=function(){u.b()&&(b(a),"unread"===a.getAttribute("data-item-status")&&m--,e())};k.open("POST","?action=mark-item-removed&id="+g,!0);k.send()},g:function(f){var g=c(f),k="1"===f.getAttribute("data-item-bookmark")?"0":"1",d=new XMLHttpRequest;d.onload=function(){var g=document.querySelector("section.page");if(u.b()&&
"bookmarks"===g.getAttribute("data-item-page"))b(f),e();else if(f.setAttribute("data-item-bookmark",k),u.b())g=f.querySelector("a.bookmark"),a(g);else if((g=f.querySelector("a.bookmark-icon"))&&g.hasAttribute("data-reverse-title")){var c=g.getAttribute("title");g.setAttribute("title",g.getAttribute("data-reverse-title"));g.setAttribute("data-reverse-title",c)}};d.open("POST","?action=bookmark&id="+g+"&value="+k,!0);d.send()},B:function(a){var b=a.getAttribute("data-item-status");"read"===b?p(a):"unread"===
b&&v(a)},w:function(a){(a=a.querySelector("a.show"))&&d(a)},t:function(a){(a=a.querySelector("a.original"))&&d(a)},e:function(a){var b=document.getElementById("download-item");if(b){b.innerHTML=" "+b.getAttribute("data-before-message");b.className="loading-icon";var e=new XMLHttpRequest;e.onload=function(){var a=JSON.parse(e.responseText);b.className="";if(a.result){var c=document.getElementById("item-content");c&&(c.innerHTML=a.content);b.innerHTML=b.getAttribute("data-after-message")}else b.innerHTML=
b.getAttribute("data-failure-message")};a=c(a);e.open("POST","?action=download-item&id="+a,!0);e.send()}},r:function(a){for(var b=document.getElementsByTagName("article"),e=[],d=0,m=b.length;d<m;d++)e.push(c(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(e))},q:function(a){var b=new XMLHttpRequest;b.onload=function(){window.location.href="?action=feeds"};b.open("POST","?action=mark-feed-as-read&feed_id="+
a,!0);b.send()},C:function(){for(var a=["#current-item h1","#item-content","#listing #current-item h2","#listing #current-item .preview"],b=0;b<a.length;b++){var e=document.querySelector(a[b]);e&&(e.dir=""==e.dir?"rtl":"")}},D:function(){return r},a:function(){if(!document.hidden||!r){var a=new XMLHttpRequest;a.onload=function(){var a=0===t.length,b=!1,c=JSON.parse(this.responseText),d;for(d in c.feeds){var f=c.feeds[d];if(!t.hasOwnProperty(d)||f.time>t[d])t[d]=f.time,"unread"===f.status&&(b=!0)}document.hidden||
c.nbUnread===m&&!r?document.hidden&&!a&&b&&(r=!0,document.title="\u21bb "+document.title):(r=!1,m=c.nbUnread,e())};a.open("POST","?action=latest-feeds-items",!0);a.send()}}}}(),n=function(){function d(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 c=[];return{c:"",l:function(){document.onclick=function(a){a.target.hasAttribute("data-action")&&"original"!==a.target.className&&
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){n.c="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":l.i();break;case "refresh-feed":c&&l.h(c);break;case "mark-read":c&&h.n(c);break;
use keyboardevent.key if implemented Beside other stuff the main reason for this change is the circumstance that Firefox triggers the "Toggle RTL mode" shortcut if the user press F11 to switch Firefox into the fullscreen mode. Each browser sends keycodes that are used by different other keys on the keyboard for the function keys. Firefox is the only browser which sends the onkeypress event for the function keys. The used keyboard event properties event.keyCode and event.which are already marked as deprecated and has been removed from the Web standards. The "DOM Level 3 Events" standard specifies event.key as their successor. Right now event.key is only available for Firefox 29+ and Internet Explorer 9+. Webkit based browser have support for the former specified event.keyIdentifier. The implementation of event.keyIdentifier isn't the same across different webkit based browsers and buggy: - the value for the z key is F11 (Chrome - Windows, Linux) - the value for the F11 key is F11 as well on (Chrome - Windows, Linux) - the value for latin keys is always the value of the capital letter (Chrome) - the value for cyrillic keys depends on the shift modifier (Chrome) - the value for the keypress event is always an empty string (Safari - Mac OS) - the value for the keydown event matches the keyboard layout dependent character (Safari - Mac OS) - the value for the keydown event does NOT matches the keyboard layout dependent character (Chrome - Windows, Linux) Instead of workaround the problems, the event.which is used for every browser that doesn't support event.key.
2015-03-07 18:23:36 +01:00
case "mark-unread":c&&h.p(c);break;case "mark-removed":c&&h.o(c);break;case "bookmark":c&&h.g(c);break;case "download-item":c&&h.e(c);break;case "mark-all-read":h.r("?action=unread");break;case "mark-feed-read":h.q(a.target.getAttribute("data-feed-id"))}}}}},k:function(){document.onkeypress=function(a){if(!d(a))if(n.c="keyboard",c.push(a.key||a.which),"g"===c[0]||103===c[0])switch(c[1]){case void 0:break;case "u":case 117:window.location.href="?action=unread";c=[];break;case "b":case 98:window.location.href=
"?action=bookmarks";c=[];break;case "h":case 104:window.location.href="?action=history";c=[];break;case "s":case 115:window.location.href="?action=feeds";c=[];break;case "p":case 112:window.location.href="?action=config";c=[];break;default:c=[]}else{c=[];var b=document.getElementById("current-item");switch(a.key||a.which){case "d":case 100:b&&h.e(b);break;case "p":case 112:case "k":case 107:u.f();break;case "n":case 110:case "j":case 106:u.d();break;case "v":case 118:b&&h.t(b);break;case "o":case 111:b&&
h.w(b);break;case "m":case 109:b&&h.B(b);break;case "f":case 102:b&&h.g(b);break;case "h":case 104:u.u();break;case "l":case 108:u.s();break;case "r":case 114:l.i();break;case "?":case 63:u.A();break;case "z":case 122:h.C()}}};document.onkeydown=function(a){if(!d(a))switch(n.c="keyboard",a.key||a.which){case "ArrowLeft":case "Left":case 37:u.f();break;case "ArrowRight":case "Right":case 39:u.d()}}},m:function(){document.addEventListener("visibilitychange",function(){!document.hidden&&h.D()&&h.a()})}}}(),
u=function(){function d(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 c(){return document.getElementById("listing")?!0:!1}return{s:function(){var a=document.getElementById("next-page");a&&a.click()},u:function(){var a=document.getElementById("previous-page");a&&a.click()},d: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 b=0,e=a.length;b<e;b++){if("current-item"===a[b].id){b+1<e&&(a[b].id="item-"+a[b].getAttribute("data-item-id"),a[b+1].id="current-item",d(a[b+1]));break}}else a[0].id="current-item",d(a[0])},f: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 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",d(a[b-1]));break}}else a[a.length-1].id="current-item",d(a[a.length-1])},A:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},b:c}}();
({F:function(){},v:function(){n.k();n.l();n.m();this.j()},j:function(){var d=new XMLHttpRequest;d.onload=function(){var c=JSON.parse(this.responseText);0<c.frontend_updatecheck_interval&&(h.a(),setInterval(function(){h.a()},6E4*c.frontend_updatecheck_interval))};d.open("POST","?action=get-config",!0);d.send(JSON.stringify(["frontend_updatecheck_interval"]))}}).v();