With change in article numbering, need way to tie article
back to HTML element. Use an ID.
This commit is contained in:
parent
ef96c04946
commit
d3f2337fd7
1 changed files with 16 additions and 10 deletions
26
js/App.js
26
js/App.js
|
@ -273,8 +273,10 @@ App.prototype.populateList = function() {
|
||||||
html_str += '<ul id=' + feedid + ' style="display: none;">'
|
html_str += '<ul id=' + feedid + ' style="display: none;">'
|
||||||
for (let artidx of byfeed[f.fid]) {
|
for (let artidx of byfeed[f.fid]) {
|
||||||
const article = ua[artidx];
|
const article = ua[artidx];
|
||||||
html_str += "<li"+ (article.unread ?
|
html_str += '<li' +
|
||||||
" class='unread'" : "") +">";
|
' id="art' + artidx.toString() + '"' +
|
||||||
|
(article.unread ? ' class="unread"' : '') +
|
||||||
|
'>';
|
||||||
html_str += "<a href='#full-" + artidx + "'>";
|
html_str += "<a href='#full-" + artidx + "'>";
|
||||||
html_str += "<h2>" + article.title + "</h2>";
|
html_str += "<h2>" + article.title + "</h2>";
|
||||||
if (article.excerpt) {
|
if (article.excerpt) {
|
||||||
|
@ -292,17 +294,21 @@ App.prototype.populateList = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
App.prototype.updateList = function() {
|
App.prototype.updateList = function() {
|
||||||
var unread = 0, artnum = 0;
|
var unread = 0;
|
||||||
$$("#list ul ul li").forEach(function(o, i) {
|
const ua = this.unread_articles, ual = ua.length;
|
||||||
|
|
||||||
if (!this.unread_articles[artnum++].unread) {
|
// Walk "unread" articles, keep count of those still
|
||||||
o.removeClass("unread");
|
// unread and update display.
|
||||||
}
|
for (let i = 0; i < ual; ++i) {
|
||||||
else {
|
const art = ua[i];
|
||||||
|
const e = document.getElementById("art" + i.toString());
|
||||||
|
if (art.unread) {
|
||||||
|
e.addClass("unread");
|
||||||
unread++;
|
unread++;
|
||||||
o.addClass("unread");
|
} else {
|
||||||
|
e.removeClass("unread");
|
||||||
}
|
}
|
||||||
}, this);
|
}
|
||||||
|
|
||||||
if (unread > 0) {
|
if (unread > 0) {
|
||||||
$("#all-read").addClass('inactive');
|
$("#all-read").addClass('inactive');
|
||||||
|
|
Reference in a new issue