From 45bf9957735cd9965879492128fd49e5213be8b5 Mon Sep 17 00:00:00 2001 From: Andy Valencia Date: Thu, 18 Feb 2016 20:58:07 -0800 Subject: [PATCH 1/6] Use document element (base is deprecated). Use timeout (updating URL hash, among others, resets scroll position). --- js/App.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/js/App.js b/js/App.js index ff92dad..cfac263 100644 --- a/js/App.js +++ b/js/App.js @@ -37,7 +37,7 @@ App.prototype.after_login = function(backend) { var url = window.location.hash; - if(url == "#list") { + if (url == "#list") { _this.setCurrentRead(); _this.changeToPage("#list"); } else if(url == "#reload") { @@ -135,18 +135,26 @@ App.prototype.changeToPage = function(page) { // FIXME var active = $(".active"); - if(active.id == "list") { - this.saveScrollTop = document.body.scrollTop; - } - if(page == "#list") { - document.body.scrollTop = this.saveScrollTop; - } else { - window.scroll(0, 0); + // Save old position + if (active.id == "list") { + this.saveScrollTop = document.documentElement.scrollTop; } + // Switch displays active.removeClass("active"); $(page).addClass("active"); + + if (page == "#list") { + var elem = document.documentElement; + var posit = this.saveScrollTop; + + // Restore old position, after display settles + setTimeout(function() { elem.scrollTop = posit; }, 500); + } else { + // Else top of page + window.scroll(0, 0); + } }; App.prototype.setColor = function(color) { From 0b2888d4a80b64bc30a1a53e5a1f7f2fd3698778 Mon Sep 17 00:00:00 2001 From: Andy Valencia Date: Sat, 28 Jan 2017 20:27:39 -0800 Subject: [PATCH 2/6] Group posts by feed name. Step #1 of getting collapsing feeds so it's easier to swim through larger feeds. --- css/screen.css | 4 +-- js/App.js | 84 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 64 insertions(+), 24 deletions(-) diff --git a/css/screen.css b/css/screen.css index 15170fc..b635a28 100644 --- a/css/screen.css +++ b/css/screen.css @@ -204,11 +204,11 @@ canvas { .blue #list li { border-bottom: 1px solid #2980b9; } .yellow #list li { border-bottom: 1px solid #f39c12; } -#list li:after { +#list li li:after { content: ""; position: absolute; right: 7px; - top: 0.1em; + top: -0.2em; font-weight: 100; font-size: 3em; font-family: "Entypo"; diff --git a/js/App.js b/js/App.js index cfac263..3a13209 100644 --- a/js/App.js +++ b/js/App.js @@ -22,9 +22,11 @@ App.prototype.authenticate = function() { App.prototype.after_login = function(backend) { - var request = window.navigator.mozApps.getSelf(); - request.onsuccess = function() { - $("#version").innerHTML = request.result.manifest.version; + if (window.navigator.mozApps) { + var request = window.navigator.mozApps.getSelf(); + request.onsuccess = function() { + $("#version").innerHTML = request.result.manifest.version; + } } var _this = this; @@ -227,15 +229,53 @@ App.prototype.validate = function(articles) { 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