offline features
This commit is contained in:
parent
3a85245a8d
commit
c588ae44cc
3 changed files with 52 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
||||||
img {
|
img {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#full header *, #full2 header * {
|
#full header *, #full2 header * {
|
||||||
|
@ -31,4 +32,6 @@ img {
|
||||||
}
|
}
|
||||||
|
|
||||||
.smallogo { text-align: center; margin: 0; padding: 0; }
|
.smallogo { text-align: center; margin: 0; padding: 0; }
|
||||||
.smallogo img { width: 50%; }
|
.smallogo img { width: 50%; }
|
||||||
|
|
||||||
|
.count { font-size: 0.8em; padding-top: 0.6em; padding-right: 0.2em; text-shadow: 0 0 2px black; }
|
11
js/App.js
11
js/App.js
|
@ -14,7 +14,7 @@ function App() {
|
||||||
$("#full").bind("taphold", this.setCurrentUnread.bind(this));
|
$("#full").bind("taphold", this.setCurrentUnread.bind(this));
|
||||||
|
|
||||||
$(".back").on("vclick", this.setCurrentRead.bind(this));
|
$(".back").on("vclick", this.setCurrentRead.bind(this));
|
||||||
$(".count").button();
|
//$(".count").button();
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var aop = function(event, ui) { setTimeout(function() { $("#popup").popup("close") }, 2000) };
|
var aop = function(event, ui) { setTimeout(function() { $("#popup").popup("close") }, 2000) };
|
||||||
|
@ -67,7 +67,7 @@ App.prototype.populateList = function() {
|
||||||
|
|
||||||
ul.listview("refresh");
|
ul.listview("refresh");
|
||||||
|
|
||||||
//$(".count").html(this.unread_articles.length + " / " + this.unread_articles.length);
|
$(".count").html(this.unread_articles.length + " / " + this.unread_articles.length);
|
||||||
//$(".count").button("refresh");
|
//$(".count").button("refresh");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ App.prototype.updateList = function() {
|
||||||
|
|
||||||
//$("#list ul").listview("refresh");
|
//$("#list ul").listview("refresh");
|
||||||
|
|
||||||
//$(".count").html(unread + " / " + this.unread_articles.length);
|
$(".count").html(unread + " / " + this.unread_articles.length);
|
||||||
//$(".count").button("refresh");
|
//$(".count").button("refresh");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ App.prototype.setCurrentRead = function() {
|
||||||
article.unread = false;
|
article.unread = false;
|
||||||
this.updateList();
|
this.updateList();
|
||||||
var _this = this;
|
var _this = this;
|
||||||
setTimeout(function() { this.ttrss.setArticleRead(article.id); }, 500);
|
setTimeout(function() { _this.ttrss.setArticleRead(article.id); },100);
|
||||||
}
|
}
|
||||||
|
|
||||||
article.set_unread = false;
|
article.set_unread = false;
|
||||||
|
@ -152,9 +152,10 @@ App.prototype.setCurrentUnread = function() {
|
||||||
var article = this.unread_articles[this.currentIndex];
|
var article = this.unread_articles[this.currentIndex];
|
||||||
article.unread = true;
|
article.unread = true;
|
||||||
article.set_unread = true;
|
article.set_unread = true;
|
||||||
this.ttrss.setArticleUnread(article.id);
|
|
||||||
this.updateList();
|
this.updateList();
|
||||||
$("#popup").popup("open");
|
$("#popup").popup("open");
|
||||||
|
var _this = this;
|
||||||
|
setTimeout(function() { _this.ttrss.setArticleUnread(article.id); }, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
App.prototype.goToList = function() {
|
App.prototype.goToList = function() {
|
||||||
|
|
|
@ -2,8 +2,34 @@ function TinyTinyRSS(app, server_url, session_id) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.server_url = server_url;
|
this.server_url = server_url;
|
||||||
this.session_id = session_id;
|
this.session_id = session_id;
|
||||||
|
|
||||||
|
window.addEventListener("offline", this.onoffline.bind(this));
|
||||||
|
window.addEventListener("online", this.ononline.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TinyTinyRSS.prototype.onoffline = function() {
|
||||||
|
// Do nothing
|
||||||
|
};
|
||||||
|
|
||||||
|
TinyTinyRSS.prototype.ononline = function() {
|
||||||
|
var read_articles = localStorage.read_articles;
|
||||||
|
if (typeof read_articles !== "undefined") {
|
||||||
|
read_articles = JSON.parse(localStorage.read_articles);
|
||||||
|
this.setArticleRead(read_articles.join(","), function() {
|
||||||
|
debug(read_articles)
|
||||||
|
localStorage.read_articles = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var unread_articles = localStorage.unread_articles;
|
||||||
|
if (unread_articles) {
|
||||||
|
unread_articles = JSON.parse(unread_articles);
|
||||||
|
this.setArticleUnread(unread_articles.join(","), function() {
|
||||||
|
localStorage.unread_articles();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
TinyTinyRSS.prototype.doOperation = function(operation, new_options, callback) {
|
TinyTinyRSS.prototype.doOperation = function(operation, new_options, callback) {
|
||||||
if(!navigator.onLine) {
|
if(!navigator.onLine) {
|
||||||
callback(null);
|
callback(null);
|
||||||
|
@ -58,7 +84,14 @@ TinyTinyRSS.prototype.setArticleRead = function(article_id) {
|
||||||
field: 2
|
field: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
this.doOperation("updateArticle", options);
|
if (navigator.onLine) this.doOperation("updateArticle", options);
|
||||||
|
else {
|
||||||
|
var read_articles = localStorage.read_articles;
|
||||||
|
if(typeof read_articles !== "undefined") read_articles = JSON.parse(read_articles);
|
||||||
|
else read_articles = [];
|
||||||
|
read_articles.push(article_id);
|
||||||
|
localStorage.read_articles = JSON.stringify(read_articles);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TinyTinyRSS.prototype.setArticleUnread = function(article_id) {
|
TinyTinyRSS.prototype.setArticleUnread = function(article_id) {
|
||||||
|
@ -68,7 +101,14 @@ TinyTinyRSS.prototype.setArticleUnread = function(article_id) {
|
||||||
field: 2
|
field: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
this.doOperation("updateArticle", options);
|
if (navigator.onLine) this.doOperation("updateArticle", options);
|
||||||
|
else {
|
||||||
|
var unread_articles = localStorage.unread_articles;
|
||||||
|
if (typeof unread_articles !== "undefined") unread_articles = JSON.parse(unread_articles);
|
||||||
|
else unread_articles = [];
|
||||||
|
unread_articles.push(article_id);
|
||||||
|
localStorage.unread_articles = JSON.stringify(unread_articles);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TinyTinyRSS.prototype.logOut = function() {
|
TinyTinyRSS.prototype.logOut = function() {
|
||||||
|
|
Reference in a new issue