Commit 9b2021ed authored by yPhil's avatar yPhil
Browse files

Various woes

- Progress goes to max immediately
- items are mixed up / duplicated
parent dba39c16
......@@ -554,10 +554,6 @@ li.feedItem.error > strong.value {
z-index: 10;
}
.hidden {
display: none;
}
#newTabTab.hidden {
display: none;
}
......@@ -1393,3 +1389,7 @@ button.ui-state-success {
border-radius: 3px;
/* box-shadow: 0 0 1px #333; */
}
.hidden {
display: none;
}
......@@ -731,6 +731,11 @@ PTL.dialog = {
class: "dangerous translate",
click: function() {
$selectedPanel.find('li.feed').each(function(){
localStorage.setItem($(this).find('div.dataStore').attr('data-url'), '');
console.log('deleting (%s) from cache', $(this).find('div.dataStore').attr('data-url'));
});
$selectedTab.remove();
$selectedPanel.remove();
......
......@@ -22,7 +22,7 @@ PTL.feed = {
});
const $newItemsBadge = $('<div>')
.attr('class', 'newItemsBadge');
.attr('class', 'newItemsBadge hidden');
const $feedIcon = $('<i>')
.attr('class', 'feed-control feedIcon translate')
......@@ -397,7 +397,8 @@ PTL.feed = {
const type = (error.statusText) ? error.statusText : PTL.tr('Unknown error');
const status = (error.status) ? error.status : '0';
const errno = (error.errno) ? error.errno : '0';
const message = (error.responseJSON.error.message) ? error.responseJSON.error.message : '';
// const message = (error.responseJSON.error.message) ? error.responseJSON.error.message : '';
const message = 'plop';
const $validateLink = $('<a>')
.attr('href', 'https://validator.w3.org/feed/check.cgi?url=' + feedUrl);
......@@ -525,131 +526,141 @@ PTL.feed = {
} else {
// $.get("/favicon", {
// url: decodeURI(feedHost),
// dataType: "json"
// }).done(function(hash) {
$.get("/favicon", {
url: decodeURI(feedHost),
dataType: "json"
}).done(function(hash) {
// if (hash) {
// $myFeedIcon.attr('src', '/favicons/' + hash + '.favicon');
// $dataStore.data('iconhash', hash);
// PTL.tab.saveTabs();
// }
if (hash) {
$myFeedIcon.attr('src', '/favicons/' + hash + '.favicon');
$dataStore.data('iconhash', hash);
PTL.tab.saveTabs();
}
// }).fail(function(jqXHR, textStatus, errorThrown) {
// // $feedIcon.addClass('icon-rss');
// });
}).fail(function(jqXHR, textStatus, errorThrown) {
// $feedIcon.addClass('icon-rss');
});
}
$feedLink.removeClass('danger');
if ($dataStore.data('status') == 'on') {
$feedIcon.removeClass('fold');
$refreshButton.addClass('spin');
$feedLink.removeClass('danger');
var saved = localStorage.getItem(feedUrl);
if (saved) {
} else {
if ($feedBody.is(':empty')) {
$feedBody.append(saved);
}
$dataStore
.parent()
.parent()
.children('div.feedBody')
.addClass('folded');
PTL.feed.getit(feedUrl, feedLastItem, feedNbItems)
.then(function(data) {
}
if (data.lastItem) {
$dataStore.data('lastitem', data.lastItem);
PTL.tab.saveTabs();
}
var saved = localStorage.getItem(feedUrl);
var $feedBodyUl = PTL.feed.lastItems(data, $dataStore);
if (saved) {
$feedBody.prepend($feedBodyUl[0]);
if ($feedBody.is(':empty')) {
$feedBody.append(saved);
}
const $html = $feedBody.html();
localStorage.setItem(feedUrl, $html);
PTL.feed.getit(feedUrl, feedLastItem, feedNbItems)
.then(function(data) {
$badge.text($feedBodyUl[1]);
if (data.lastItem) {
$dataStore.data('lastitem', data.lastItem);
PTL.tab.saveTabs();
}
$refreshButton
.prop('title', PTL.tr('Refresh this feed (%1 - %2)', feedName || feedUrl, timeStamp) + ' (' + $feedBodyUl[1] + ' new items)' )
.removeClass('spin');
var $feedBodyUl = PTL.feed.lastItems(data, $dataStore);
if (progress) progress.increment();
$feedBody.prepend($feedBodyUl[0]);
})
.catch(function(error) {
console.log('whoops: %s (%s)', error);
$feedBody.empty().append(PTL.feed.errorFeed(error, feedUrl));
$feedBody.css('height', '');
const $html = $feedBody.html();
localStorage.setItem(feedUrl, $html);
$refreshButton.removeClass('spin');
});
$badge.text($feedBodyUl[1]);
} else {
if ($feedBodyUl[1] > 0) {
$badge.fadeIn('slow');
} else {
$badge.fadeOut('slow');
}
PTL.feed.getit(feedUrl, feedLastItem, feedNbItems)
.then(function(data) {
// console.log('YAAA: %s (%s)', JSON.stringify(data));
$refreshButton
.prop('title', PTL.tr('Refresh this feed (%1 - %2)', feedName || feedUrl, timeStamp) + ' (' + $feedBodyUl[1] + ' new items)' )
.removeClass('spin');
if (feedName) {
feedTitle = feedName;
} else if (data.feedTitle) {
feedTitle = data.feedTitle;
$dataStore.data('name', feedTitle);
}
})
.catch(function(error) {
console.log('whoops: %s (%s)', error, feedUrl);
$feedBody.empty().append(PTL.feed.errorFeed(error, feedUrl));
$feedBody.css('height', '');
$feedLink.text(feedTitle)
.attr('href', data.feedLink)
.attr('title', feedTitle + ' (' + feedUrl + ')');
$refreshButton.removeClass('spin');
});
if (data.lastItem) {
// console.log('YEP: %s (%s)', data.lastItem);
$dataStore.attr('data-lastitem', data.lastItem);
}
} else {
var $feedBodyUl = PTL.feed.lastItems(data, $dataStore);
PTL.feed.getit(feedUrl, feedLastItem, feedNbItems)
.then(function(data) {
// console.log('YAAA: %s (%s)', JSON.stringify(data));
$feedBody.append($feedBodyUl[0]);
if (feedName) {
feedTitle = feedName;
} else if (data.feedTitle) {
feedTitle = data.feedTitle;
$dataStore.data('name', feedTitle);
}
if (!$feedBody.is(':empty')) {
$feedLink.text(feedTitle)
.attr('href', data.feedLink)
.attr('title', feedTitle + ' (' + feedUrl + ')');
const $html = $feedBody.html();
localStorage.setItem(feedUrl, $html);
if (data.lastItem) {
// console.log('YEP: %s (%s)', data.lastItem);
$dataStore.attr('data-lastitem', data.lastItem);
}
}
var $feedBodyUl = PTL.feed.lastItems(data, $dataStore);
$badge.text($feedBodyUl[1]);
$feedBody.append($feedBodyUl[0]);
$refreshButton
.prop('title', PTL.tr('Refresh this feed (%1 - %2)', feedName || feedUrl, timeStamp) + ' (' + $feedBodyUl[1] + ' new items)' )
.removeClass('spin');
if (!$feedBody.is(':empty')) {
const $html = $feedBody.html();
localStorage.setItem(feedUrl, $html);
}
if (progress) progress.increment();
$badge.text($feedBodyUl[1]);
})
.catch(function(error) {
console.log('whoops: %s (%s)', error);
$feedBody.empty().append(PTL.feed.errorFeed(error, feedUrl));
$feedBody.css('height', '');
if ($feedBodyUl[1] > 0) {
$badge.fadeIn('slow');
} else {
$badge.fadeOut('slow');
}
$refreshButton.removeClass('spin');
});
$refreshButton
.prop('title', PTL.tr('Refresh this feed (%1 - %2)', feedName || feedUrl, timeStamp) + ' (' + $feedBodyUl[1] + ' new items)' )
.removeClass('spin');
}
})
.catch(function(error) {
console.log('whoops: %s (%s)', error);
$feedBody.empty().append(PTL.feed.errorFeed(error, feedUrl));
$feedBody.css('height', '');
} else {
$badge.fadeOut('fast');
$dataStore
.parent()
.parent()
.children('div.feedBody')
.addClass('folded');
$refreshButton.removeClass('spin');
});
if (progress) progress.increment();
}
if (progress) progress.increment();
}
};
......@@ -239,13 +239,13 @@ PTL.tab = {
feeds.forEach(function(feed) {
// console.log('feed.lastitem: %s (%s)', feed.lastitem, feed.url);
const type = PTL.feedTypes.includes(feed.type) ? feed.type : 'mixed',
nbitems = Number.isInteger(feed.nbitems) ? feed.nbitems : 30,
nbitems = Number.isInteger(feed.nbitems) ? feed.nbitems : 5,
limit = Number.isInteger(feed.limit) ? feed.limit : 260;
PTL.feed.add($column, feed.url, feed.name, type, limit, feed.status, feed.iconhash, nbitems, feed.lastitem, false, false, progress);
});
}
if (nbOfColumnsInTab <2) $column.find('.col-del').addClass('ui-state-disabled');
if (nbOfColumnsInTab < 2) $column.find('.col-del').addClass('ui-state-disabled');
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment