Javascript cleanup
This commit is contained in:
parent
27e43ca908
commit
cd01042f7d
@ -41,9 +41,6 @@ Miniflux.App = (function() {
|
|||||||
})();
|
})();
|
||||||
Miniflux.Feed = (function() {
|
Miniflux.Feed = (function() {
|
||||||
|
|
||||||
// List of subscriptions
|
|
||||||
var feeds = [];
|
|
||||||
|
|
||||||
// List of feeds currently updating
|
// List of feeds currently updating
|
||||||
var queue = [];
|
var queue = [];
|
||||||
|
|
||||||
@ -55,7 +52,7 @@ Miniflux.Feed = (function() {
|
|||||||
var itemsCounter = feed.querySelector("span.items-count");
|
var itemsCounter = feed.querySelector("span.items-count");
|
||||||
if (! itemsCounter) return;
|
if (! itemsCounter) return;
|
||||||
|
|
||||||
var feed_id = feed.getAttribute("data-feed-id")
|
var feed_id = feed.getAttribute("data-feed-id");
|
||||||
|
|
||||||
var heading = feed.querySelector("h2:first-of-type");
|
var heading = feed.querySelector("h2:first-of-type");
|
||||||
heading.className = "loading-icon";
|
heading.className = "loading-icon";
|
||||||
@ -112,7 +109,8 @@ Miniflux.Feed = (function() {
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();Miniflux.Item = (function() {
|
})();
|
||||||
|
Miniflux.Item = (function() {
|
||||||
|
|
||||||
// timestamp of the latest item per feed ever seen
|
// timestamp of the latest item per feed ever seen
|
||||||
var latest_feeds_items = [];
|
var latest_feeds_items = [];
|
||||||
@ -124,8 +122,7 @@ Miniflux.Feed = (function() {
|
|||||||
var navCounterElement = document.getElementById("nav-counter");
|
var navCounterElement = document.getElementById("nav-counter");
|
||||||
|
|
||||||
if (navCounterElement) {
|
if (navCounterElement) {
|
||||||
counter = parseInt(navCounterElement.textContent, 10) || 0;
|
return parseInt(navCounterElement.textContent, 10) || 0;
|
||||||
return counter;
|
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -133,8 +130,7 @@ Miniflux.Feed = (function() {
|
|||||||
var pageCounterElement = document.getElementById("page-counter");
|
var pageCounterElement = document.getElementById("page-counter");
|
||||||
|
|
||||||
if (pageCounterElement) {
|
if (pageCounterElement) {
|
||||||
counter = parseInt(pageCounterElement.textContent, 10) || 0;
|
return parseInt(pageCounterElement.textContent, 10) || 0;
|
||||||
return counter;
|
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -144,7 +140,7 @@ Miniflux.Feed = (function() {
|
|||||||
event.initEvent("mousedown", true, true);
|
event.initEvent("mousedown", true, true);
|
||||||
element.dispatchEvent(event);
|
element.dispatchEvent(event);
|
||||||
|
|
||||||
var event = document.createEvent("MouseEvents");
|
event = document.createEvent("MouseEvents");
|
||||||
event.initEvent("mouseup", true, true);
|
event.initEvent("mouseup", true, true);
|
||||||
element.dispatchEvent(event);
|
element.dispatchEvent(event);
|
||||||
|
|
||||||
@ -153,8 +149,7 @@ Miniflux.Feed = (function() {
|
|||||||
|
|
||||||
function getItemID(item)
|
function getItemID(item)
|
||||||
{
|
{
|
||||||
item_id = item.getAttribute("data-item-id");
|
return item.getAttribute("data-item-id");
|
||||||
return item_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeLabel(link)
|
function changeLabel(link)
|
||||||
@ -239,6 +234,8 @@ Miniflux.Feed = (function() {
|
|||||||
|
|
||||||
function updateCounters()
|
function updateCounters()
|
||||||
{
|
{
|
||||||
|
var pageHeading = null;
|
||||||
|
|
||||||
// redirect to unread if we're on a nothing to read page
|
// redirect to unread if we're on a nothing to read page
|
||||||
if (window.location.href.indexOf('nothing_to_read=1') > -1 && nbUnreadItems > 0) {
|
if (window.location.href.indexOf('nothing_to_read=1') > -1 && nbUnreadItems > 0) {
|
||||||
window.location.href = '?action=unread';
|
window.location.href = '?action=unread';
|
||||||
@ -457,7 +454,6 @@ Miniflux.Feed = (function() {
|
|||||||
|
|
||||||
for (var feed_id in response['feeds']) {
|
for (var feed_id in response['feeds']) {
|
||||||
var current_feed = response['feeds'][feed_id];
|
var current_feed = response['feeds'][feed_id];
|
||||||
var feed_id = parseInt(feed_id, 10);
|
|
||||||
|
|
||||||
if (! latest_feeds_items.hasOwnProperty(feed_id) || current_feed.time > latest_feeds_items[feed_id]) {
|
if (! latest_feeds_items.hasOwnProperty(feed_id) || current_feed.time > latest_feeds_items[feed_id]) {
|
||||||
Miniflux.App.Log('feed ' + feed_id + ': New item(s)');
|
Miniflux.App.Log('feed ' + feed_id + ': New item(s)');
|
||||||
@ -508,11 +504,7 @@ Miniflux.Event = (function() {
|
|||||||
|
|
||||||
// Do not handle events when there is a focus in form fields
|
// Do not handle events when there is a focus in form fields
|
||||||
var target = e.target || e.srcElement;
|
var target = e.target || e.srcElement;
|
||||||
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
|
return !!(target.tagName === 'INPUT' || target.tagName === 'TEXTAREA');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -545,7 +537,7 @@ Miniflux.Event = (function() {
|
|||||||
Miniflux.Event.lastEventType = "mouse";
|
Miniflux.Event.lastEventType = "mouse";
|
||||||
|
|
||||||
var currentItem = function () {
|
var currentItem = function () {
|
||||||
element = e.target;
|
var element = e.target;
|
||||||
|
|
||||||
while (element && element.parentNode) {
|
while (element && element.parentNode) {
|
||||||
element = element.parentNode;
|
element = element.parentNode;
|
||||||
@ -553,8 +545,6 @@ Miniflux.Event = (function() {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}();
|
}();
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@ -754,7 +744,7 @@ Miniflux.Event = (function() {
|
|||||||
"touchend" : false,
|
"touchend" : false,
|
||||||
"direction" : "undetermined",
|
"direction" : "undetermined",
|
||||||
"swipestarted" : false,
|
"swipestarted" : false,
|
||||||
"element" : null,
|
"element" : null
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
var horizontalSwipe = function () {
|
var horizontalSwipe = function () {
|
||||||
@ -784,7 +774,7 @@ Miniflux.Event = (function() {
|
|||||||
if(touches.element === null) {
|
if(touches.element === null) {
|
||||||
touches.element = getTouchElement();
|
touches.element = getTouchElement();
|
||||||
}
|
}
|
||||||
swipedistance = horizontalSwipe();
|
var swipedistance = horizontalSwipe();
|
||||||
|
|
||||||
if(swipedistance > 0) {
|
if(swipedistance > 0) {
|
||||||
var element = getTouchElement();
|
var element = getTouchElement();
|
||||||
@ -916,8 +906,7 @@ Miniflux.Nav = (function() {
|
|||||||
|
|
||||||
function isListing()
|
function isListing()
|
||||||
{
|
{
|
||||||
if (document.getElementById("listing")) return true;
|
return !!document.getElementById("listing");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -10,11 +10,7 @@ Miniflux.Event = (function() {
|
|||||||
|
|
||||||
// Do not handle events when there is a focus in form fields
|
// Do not handle events when there is a focus in form fields
|
||||||
var target = e.target || e.srcElement;
|
var target = e.target || e.srcElement;
|
||||||
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
|
return !!(target.tagName === 'INPUT' || target.tagName === 'TEXTAREA');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -47,7 +43,7 @@ Miniflux.Event = (function() {
|
|||||||
Miniflux.Event.lastEventType = "mouse";
|
Miniflux.Event.lastEventType = "mouse";
|
||||||
|
|
||||||
var currentItem = function () {
|
var currentItem = function () {
|
||||||
element = e.target;
|
var element = e.target;
|
||||||
|
|
||||||
while (element && element.parentNode) {
|
while (element && element.parentNode) {
|
||||||
element = element.parentNode;
|
element = element.parentNode;
|
||||||
@ -55,8 +51,6 @@ Miniflux.Event = (function() {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}();
|
}();
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@ -256,7 +250,7 @@ Miniflux.Event = (function() {
|
|||||||
"touchend" : false,
|
"touchend" : false,
|
||||||
"direction" : "undetermined",
|
"direction" : "undetermined",
|
||||||
"swipestarted" : false,
|
"swipestarted" : false,
|
||||||
"element" : null,
|
"element" : null
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
var horizontalSwipe = function () {
|
var horizontalSwipe = function () {
|
||||||
@ -286,7 +280,7 @@ Miniflux.Event = (function() {
|
|||||||
if(touches.element === null) {
|
if(touches.element === null) {
|
||||||
touches.element = getTouchElement();
|
touches.element = getTouchElement();
|
||||||
}
|
}
|
||||||
swipedistance = horizontalSwipe();
|
var swipedistance = horizontalSwipe();
|
||||||
|
|
||||||
if(swipedistance > 0) {
|
if(swipedistance > 0) {
|
||||||
var element = getTouchElement();
|
var element = getTouchElement();
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
Miniflux.Feed = (function() {
|
Miniflux.Feed = (function() {
|
||||||
|
|
||||||
// List of subscriptions
|
|
||||||
var feeds = [];
|
|
||||||
|
|
||||||
// List of feeds currently updating
|
// List of feeds currently updating
|
||||||
var queue = [];
|
var queue = [];
|
||||||
|
|
||||||
@ -14,7 +11,7 @@ Miniflux.Feed = (function() {
|
|||||||
var itemsCounter = feed.querySelector("span.items-count");
|
var itemsCounter = feed.querySelector("span.items-count");
|
||||||
if (! itemsCounter) return;
|
if (! itemsCounter) return;
|
||||||
|
|
||||||
var feed_id = feed.getAttribute("data-feed-id")
|
var feed_id = feed.getAttribute("data-feed-id");
|
||||||
|
|
||||||
var heading = feed.querySelector("h2:first-of-type");
|
var heading = feed.querySelector("h2:first-of-type");
|
||||||
heading.className = "loading-icon";
|
heading.className = "loading-icon";
|
||||||
@ -71,4 +68,4 @@ Miniflux.Feed = (function() {
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -10,8 +10,7 @@ Miniflux.Item = (function() {
|
|||||||
var navCounterElement = document.getElementById("nav-counter");
|
var navCounterElement = document.getElementById("nav-counter");
|
||||||
|
|
||||||
if (navCounterElement) {
|
if (navCounterElement) {
|
||||||
counter = parseInt(navCounterElement.textContent, 10) || 0;
|
return parseInt(navCounterElement.textContent, 10) || 0;
|
||||||
return counter;
|
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -19,8 +18,7 @@ Miniflux.Item = (function() {
|
|||||||
var pageCounterElement = document.getElementById("page-counter");
|
var pageCounterElement = document.getElementById("page-counter");
|
||||||
|
|
||||||
if (pageCounterElement) {
|
if (pageCounterElement) {
|
||||||
counter = parseInt(pageCounterElement.textContent, 10) || 0;
|
return parseInt(pageCounterElement.textContent, 10) || 0;
|
||||||
return counter;
|
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -30,7 +28,7 @@ Miniflux.Item = (function() {
|
|||||||
event.initEvent("mousedown", true, true);
|
event.initEvent("mousedown", true, true);
|
||||||
element.dispatchEvent(event);
|
element.dispatchEvent(event);
|
||||||
|
|
||||||
var event = document.createEvent("MouseEvents");
|
event = document.createEvent("MouseEvents");
|
||||||
event.initEvent("mouseup", true, true);
|
event.initEvent("mouseup", true, true);
|
||||||
element.dispatchEvent(event);
|
element.dispatchEvent(event);
|
||||||
|
|
||||||
@ -39,8 +37,7 @@ Miniflux.Item = (function() {
|
|||||||
|
|
||||||
function getItemID(item)
|
function getItemID(item)
|
||||||
{
|
{
|
||||||
item_id = item.getAttribute("data-item-id");
|
return item.getAttribute("data-item-id");
|
||||||
return item_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeLabel(link)
|
function changeLabel(link)
|
||||||
@ -125,6 +122,8 @@ Miniflux.Item = (function() {
|
|||||||
|
|
||||||
function updateCounters()
|
function updateCounters()
|
||||||
{
|
{
|
||||||
|
var pageHeading = null;
|
||||||
|
|
||||||
// redirect to unread if we're on a nothing to read page
|
// redirect to unread if we're on a nothing to read page
|
||||||
if (window.location.href.indexOf('nothing_to_read=1') > -1 && nbUnreadItems > 0) {
|
if (window.location.href.indexOf('nothing_to_read=1') > -1 && nbUnreadItems > 0) {
|
||||||
window.location.href = '?action=unread';
|
window.location.href = '?action=unread';
|
||||||
@ -343,7 +342,6 @@ Miniflux.Item = (function() {
|
|||||||
|
|
||||||
for (var feed_id in response['feeds']) {
|
for (var feed_id in response['feeds']) {
|
||||||
var current_feed = response['feeds'][feed_id];
|
var current_feed = response['feeds'][feed_id];
|
||||||
var feed_id = parseInt(feed_id, 10);
|
|
||||||
|
|
||||||
if (! latest_feeds_items.hasOwnProperty(feed_id) || current_feed.time > latest_feeds_items[feed_id]) {
|
if (! latest_feeds_items.hasOwnProperty(feed_id) || current_feed.time > latest_feeds_items[feed_id]) {
|
||||||
Miniflux.App.Log('feed ' + feed_id + ': New item(s)');
|
Miniflux.App.Log('feed ' + feed_id + ': New item(s)');
|
||||||
|
@ -67,8 +67,7 @@ Miniflux.Nav = (function() {
|
|||||||
|
|
||||||
function isListing()
|
function isListing()
|
||||||
{
|
{
|
||||||
if (document.getElementById("listing")) return true;
|
return !!document.getElementById("listing");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user