diff --git a/index.html b/index.html index 5652662..7f09874 100644 --- a/index.html +++ b/index.html @@ -81,6 +81,7 @@
List Set unread + Set starred
diff --git a/js/App.js b/js/App.js index 2b13017..c62fbb5 100644 --- a/js/App.js +++ b/js/App.js @@ -45,6 +45,8 @@ App.prototype.after_login = function() { _this.showFull(_this.unread_articles[i]); } else if(url == "#unread") { _this.setCurrentUnread(); + } else if(url == "#starred") { + _this.setCurrentStarred(); } else if(url == "#logout") { _this.logout(); } else if(url == "#reset-info") { @@ -301,6 +303,13 @@ App.prototype.setCurrentRead = function() { this.updatePieChart(); }; +App.prototype.setCurrentStarred = function() { + var article = this.unread_articles[this.currentIndex]; + if(!article) return; // happens if we're not on a full article site + this.ttrss.setArticleStarred(article.id); + +}; + App.prototype.setCurrentUnread = function() { var article = this.unread_articles[this.currentIndex]; article.unread = true; @@ -348,4 +357,4 @@ App.prototype.fontChange = function(size) { } -}; \ No newline at end of file +}; diff --git a/js/TinyTinyRSS.js b/js/TinyTinyRSS.js index 4b877d3..cfa3708 100644 --- a/js/TinyTinyRSS.js +++ b/js/TinyTinyRSS.js @@ -13,7 +13,7 @@ TinyTinyRSS.prototype.onoffline = function() { TinyTinyRSS.prototype.ononline = function() { var read_articles = localStorage.read_articles; - if (typeof read_articles !== "undefined") { + if (read_articles ) { read_articles = JSON.parse(localStorage.read_articles); this.setArticleRead(read_articles.join(","), function() { localStorage.read_articles = null; @@ -27,6 +27,7 @@ TinyTinyRSS.prototype.ononline = function() { localStorage.unread_articles(); }); } + }; TinyTinyRSS.prototype.doOperation = function(operation, new_options, callback) { @@ -91,6 +92,18 @@ TinyTinyRSS.prototype.setArticleRead = function(article_id) { } }; +TinyTinyRSS.prototype.setArticleStarred = function(article_id) { + var options = { + article_ids: article_id, + mode: 1, + field: 0 + }; + + if (navigator.onLine) { + this.doOperation("updateArticle", options); + } +}; + TinyTinyRSS.prototype.setArticleUnread = function(article_id) { var options = { article_ids: article_id, @@ -129,4 +142,4 @@ TinyTinyRSS.login = function(server_url, user, password, callback) { } xhr.open("POST", url, true); xhr.send(JSON.stringify(options)); -} \ No newline at end of file +}