FeedMonkey HTML5 RSS Feed Reader

Check-in [b91e2dbdd2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Allow for successive growing of "unread_articles". Move helper function adjacent to method which uses it.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/clean | trunk | master
Files: files | file ages | folders
SHA3-256:b91e2dbdd2e12262f88898f37f2438125356f96a3091ecf7fa6b81136461b818
User & Date: ajv-899-334-8894@vsta.org 2017-01-29 17:03:51
Context
2017-01-29
19:15
With change in article numbering, need way to tie article back to HTML element. Use an ID. check-in: 8687d19ebd user: ajv-899-334-8894@vsta.org tags: origin/clean, trunk, master
17:03
Allow for successive growing of "unread_articles". Move helper function adjacent to method which uses it. check-in: b91e2dbdd2 user: ajv-899-334-8894@vsta.org tags: origin/clean, trunk, master
05:13
Make collapsing feed article lists check-in: d9dcf7e0ea user: ajv-899-334-8894@vsta.org tags: origin/clean, trunk, master
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to js/App.js.

222
223
224
225
226
227
228
229










230
231
232




233
234
235


236
237
238


239
240
241
242
243
244





245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261



262
263
264
265
266
267
268

269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286

	for (var i = 0; i < articles.length; i++) {
		if(typeof articles[i].title != "undefined") return true;
	}

	return false;
};











App.prototype.populateList = function() {

	// First pull all articles together from each distinct feed




	var ua = this.unread_articles;
	var newarts = [], byfeed = [];
	while (ua.length > 0) {


	    article = ua[0];

	    // Next feed ID


	    var fid = article.feed_id;
	    // Here's all the articles under that ID
	    var feeds =
		ua.filter( function(a) { return a.feed_id == fid; } );
	    // Keep a list of them so it's easy to tabulate
	    byfeed.push(feeds);






	    // Add them on to the new unread_articles, so they're
	    //  in order.
	    newarts = newarts.concat(feeds);

	    // Trim them off the old, unsorted article list
	    ua = ua.filter( function(a) { return a.feed_id != fid; } );
	}

	// Make the reordered article list the "official" one
	ua = this.unread_articles = newarts;

	// Now build the article list; it's a <ul> of feeds,
	//  then sub-<ul> of articles in that feed
	var html_str = "";
	var artidx = 0;
	for (i = 0; i < byfeed.length; ++i) {



	    var feed = byfeed[i];
	    html_str += '<li><span' +
		' onclick="return(toggleFeed(' + i.toString() + '));"' +
		'>' + feed[0].feed_title + '</span>';
	    var feedid = '"feed' + i.toString() + '"';
	    html_str += '<ul id=' + feedid + ' style="display: none;">'
	    for (var j = 0; j < feed.length; ++j) {

		article = ua[artidx];
		html_str += "<li"+ (article.unread ?
		    " class='unread'" : "") +">";
		html_str += "<a href='#full-" + artidx + "'>";
		html_str += "<h2>" + article.title + "</h2>";
		if (article.excerpt) {
		    html_str += "<p class='excerpt'>" +
			article.excerpt + "</p>";
		}
		html_str += "</a></li>";
		artidx += 1;
	    }
	    html_str += "</ul></li>";
	}
	
	$("#list ul").innerHTML = html_str;

	this.updatePieChart();








>
>
>
>
>
>
>
>
>
>


<
>
>
>
>
|
<
<
>
>
|

<
>
>
|
<
<
<
<
<
>
>
>
>
>
|
<
<
<
|
<
<
|
<
<
<
<


|
<
<
>
>
>
|

|
|
|

<
>
|









<







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

242
243
244
245
246


247
248
249
250

251
252
253





254
255
256
257
258
259



260


261




262
263
264


265
266
267
268
269
270
271
272
273

274
275
276
277
278
279
280
281
282
283
284

285
286
287
288
289
290
291

	for (var i = 0; i < articles.length; i++) {
		if(typeof articles[i].title != "undefined") return true;
	}

	return false;
};

// Utility function to toggle feed content visibility
function toggleFeed(feedid) {
    var e = document.getElementById("feed" + feedid.toString());
    if (e.style.display == "none") {
	e.style.display = "";
    } else {
	e.style.display = "none";
    }
}

App.prototype.populateList = function() {


	// Tabulate all articles, grouped by feed.
	// Note that this.unread_articles[] can be growing even
	//  as our user reads, so we have to leave it alone and
	//  just point to the appropriate articles in situ.
	const ua = this.unread_articles, ual = ua.length;


	const byfeed = {}, feeds = [];
	for (let x = 0; x < ual; ++x) {
	    const article = ua[x];


	    // Add this article to an existing feed list, or
	    //  or start one for this feed ID.
	    const fid = article.feed_id;





	    if (fid in byfeed) {
		byfeed[fid].push(x);
	    } else {
		byfeed[fid] = [x];
		feeds.push( {"fid": fid, "name": article.feed_title} );
	    }



	}







	// Now build the article list; it's a <ul> of feeds,
	//  then sub-<ul> of articles in that feed
	let html_str = "";


	for (let x = 0; x < feeds.length; ++x) {
	    const xs = x.toString();
	    const f = feeds[x];
	    const feed = byfeed[f.fid];
	    html_str += '<li><span' +
		' onclick="return(toggleFeed(' + xs + '));"' +
		'>' + f.name + '</span>';
	    const feedid = '"feed' + xs + '"';
	    html_str += '<ul id=' + feedid + ' style="display: none;">'

	    for (let artidx of byfeed[f.fid]) {
		const article = ua[artidx];
		html_str += "<li"+ (article.unread ?
		    " class='unread'" : "") +">";
		html_str += "<a href='#full-" + artidx + "'>";
		html_str += "<h2>" + article.title + "</h2>";
		if (article.excerpt) {
		    html_str += "<p class='excerpt'>" +
			article.excerpt + "</p>";
		}
		html_str += "</a></li>";

	    }
	    html_str += "</ul></li>";
	}
	
	$("#list ul").innerHTML = html_str;

	this.updatePieChart();

Changes to js/application.js.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
	else {
		obj = arguments.join(' ')
	}
	
	alert(obj)
}

function toggleFeed(feedid) {
    var e = document.getElementById("feed" + feedid.toString());
    if (e.style.display == "none") {
	e.style.display = "";
    } else {
	e.style.display = "none";
    }
}

function $(obj) {
	if(typeof obj == "string") return document.querySelector(obj);
	else return obj;
}

function $$(obj) {
	if(typeof obj == "string") return document.querySelectorAll(obj);







<
<
<
<
<
<
<
<
<







4
5
6
7
8
9
10









11
12
13
14
15
16
17
	else {
		obj = arguments.join(' ')
	}
	
	alert(obj)
}










function $(obj) {
	if(typeof obj == "string") return document.querySelector(obj);
	else return obj;
}

function $$(obj) {
	if(typeof obj == "string") return document.querySelectorAll(obj);