From 1ed7b4c6101d6021f89b47b081ed4a5424d96452 Mon Sep 17 00:00:00 2001 From: Alvaro Rodriguez Date: Thu, 12 Sep 2013 19:53:53 +0200 Subject: [PATCH 1/3] Adding starred item button --- index.html | 1 + js/App.js | 11 ++++++++++- js/TinyTinyRSS.js | 17 +++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) 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 +} From d2219b0259e999c5ae52db80554e63a182143868 Mon Sep 17 00:00:00 2001 From: Alvaro Rodriguez Date: Sat, 14 Sep 2013 19:33:44 +0200 Subject: [PATCH 2/3] Shorted the length of star. --- index.html | 2 +- js/App.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 7f09874..d72c7b1 100644 --- a/index.html +++ b/index.html @@ -81,7 +81,7 @@
List Set unread - Set starred + no *
diff --git a/js/App.js b/js/App.js index c62fbb5..ab20ead 100644 --- a/js/App.js +++ b/js/App.js @@ -264,6 +264,7 @@ App.prototype.showFull = function(article, slide_back) { } else { $("#setunread").innerHTML = "Set unread"; } + $("#setstarred").innerHTML = "no *"; }; @@ -308,6 +309,7 @@ App.prototype.setCurrentStarred = function() { if(!article) return; // happens if we're not on a full article site this.ttrss.setArticleStarred(article.id); + $("#setstarred").innerHTML = "*"; }; App.prototype.setCurrentUnread = function() { From d123626f16cad5ccb3a925e67593f151523f6ebe Mon Sep 17 00:00:00 2001 From: Alvaro Rodriguez Date: Sat, 14 Sep 2013 20:19:21 +0200 Subject: [PATCH 3/3] using marked in the aricle that is the starred --- js/App.js | 35 +++++++++++++++++++++++++---------- js/TinyTinyRSS.js | 12 ++++++++++++ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/js/App.js b/js/App.js index ab20ead..296059d 100644 --- a/js/App.js +++ b/js/App.js @@ -46,7 +46,7 @@ App.prototype.after_login = function() { } else if(url == "#unread") { _this.setCurrentUnread(); } else if(url == "#starred") { - _this.setCurrentStarred(); + _this.ChangeStarred(); } else if(url == "#logout") { _this.logout(); } else if(url == "#reset-info") { @@ -264,7 +264,11 @@ App.prototype.showFull = function(article, slide_back) { } else { $("#setunread").innerHTML = "Set unread"; } - $("#setstarred").innerHTML = "no *"; + if(article.marked) { + $("#setstarred").innerHTML = "*"; + } else { + $("#setstarred").innerHTML = "no *"; + } }; @@ -304,14 +308,6 @@ 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); - - $("#setstarred").innerHTML = "*"; -}; - App.prototype.setCurrentUnread = function() { var article = this.unread_articles[this.currentIndex]; article.unread = true; @@ -323,6 +319,25 @@ App.prototype.setCurrentUnread = function() { $("#setunread").innerHTML = "✔ unread"; }; +App.prototype.ChangeStarred = function() { + var article = this.unread_articles[this.currentIndex]; + if(!article) return; // happens if we're not on a full article site + + if(!article.marked) { + article.marked = true; + this.updateList(); + this.ttrss.setArticleStarred(article.id); + $("#setstarred").innerHTML = "*"; + } + else { + article.marked = false; + this.updateList(); + this.ttrss.setArticleUnStarred(article.id); + $("#setstarred").innerHTML = "no *"; + } + +}; + App.prototype.goToList = function() { this.changeToPage("#list"); }; diff --git a/js/TinyTinyRSS.js b/js/TinyTinyRSS.js index cfa3708..05a4994 100644 --- a/js/TinyTinyRSS.js +++ b/js/TinyTinyRSS.js @@ -104,6 +104,18 @@ TinyTinyRSS.prototype.setArticleStarred = function(article_id) { } }; +TinyTinyRSS.prototype.setArticleUnStarred = function(article_id) { + var options = { + article_ids: article_id, + mode: 0, + field: 0 + }; + + if (navigator.onLine) { + this.doOperation("updateArticle", options); + } +}; + TinyTinyRSS.prototype.setArticleUnread = function(article_id) { var options = { article_ids: article_id,