move more stuff to offline.js
This commit is contained in:
parent
4681834e66
commit
774b8df873
85
feedlist.js
85
feedlist.js
|
@ -64,91 +64,6 @@ function printFeedEntry(id, title, row_class, unread, icon) {
|
|||
return tmp;
|
||||
}
|
||||
|
||||
function get_local_feed_unread(id) {
|
||||
try {
|
||||
var rs;
|
||||
|
||||
if (id == -4) {
|
||||
rs = db.execute("SELECT SUM(unread) FROM articles");
|
||||
} else if (id == -1) {
|
||||
rs = db.execute("SELECT SUM(unread) FROM articles WHERE marked = 1");
|
||||
} else {
|
||||
rs = db.execute("SELECT SUM(unread) FROM articles WHERE feed_id = ?", [id]);
|
||||
}
|
||||
|
||||
if (rs.isValidRow()) {
|
||||
return rs.field(0);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
exception_error("get_local_feed_unread", e);
|
||||
}
|
||||
}
|
||||
|
||||
function render_offline_feedlist() {
|
||||
try {
|
||||
var tmp = "<ul class=\"feedList\" id=\"feedList\">";
|
||||
|
||||
var unread = get_local_feed_unread(-4);
|
||||
|
||||
global_unread = unread;
|
||||
updateTitle();
|
||||
|
||||
tmp += printFeedEntry(-4, __("All articles"), "feed", unread,
|
||||
"images/tag.png");
|
||||
|
||||
var unread = get_local_feed_unread(-1);
|
||||
|
||||
tmp += printFeedEntry(-1, __("Starred articles"), "feed", unread,
|
||||
"images/mark_set.png");
|
||||
|
||||
tmp += "<li><hr/></li>";
|
||||
|
||||
var rs = db.execute("SELECT feeds.id,feeds.title,has_icon,COUNT(articles.id) "+
|
||||
"FROM feeds LEFT JOIN articles ON (feed_id = feeds.id) "+
|
||||
"WHERE unread = 1 OR unread IS NULL GROUP BY feeds.id "+
|
||||
"ORDER BY feeds.title");
|
||||
|
||||
while (rs.isValidRow()) {
|
||||
|
||||
var id = rs.field(0);
|
||||
var title = rs.field(1);
|
||||
var has_icon = rs.field(2);
|
||||
var unread = rs.field(3);
|
||||
|
||||
var icon = "";
|
||||
|
||||
if (has_icon) {
|
||||
icon = "icons/" + id + ".ico";
|
||||
}
|
||||
|
||||
|
||||
var feed_icon = "";
|
||||
|
||||
var row_class = "feed";
|
||||
|
||||
if (unread > 0) {
|
||||
row_class += "Unread";
|
||||
fctr_class = "feedCtrHasUnread";
|
||||
} else {
|
||||
fctr_class = "feedCtrNoUnread";
|
||||
}
|
||||
|
||||
tmp += printFeedEntry(id, title, "feed", unread, icon);
|
||||
|
||||
rs.next();
|
||||
}
|
||||
|
||||
tmp += "</ul>";
|
||||
|
||||
render_feedlist(tmp);
|
||||
} catch (e) {
|
||||
exception_error("render_offline_feedlist", e);
|
||||
}
|
||||
}
|
||||
|
||||
function render_feedlist(data) {
|
||||
try {
|
||||
|
||||
|
|
25
offline.js
25
offline.js
|
@ -490,3 +490,28 @@ function update_local_feedlist_counters() {
|
|||
exception_error("update_local_feedlist_counters", e);
|
||||
}
|
||||
}
|
||||
|
||||
function get_local_feed_unread(id) {
|
||||
try {
|
||||
var rs;
|
||||
|
||||
if (id == -4) {
|
||||
rs = db.execute("SELECT SUM(unread) FROM articles");
|
||||
} else if (id == -1) {
|
||||
rs = db.execute("SELECT SUM(unread) FROM articles WHERE marked = 1");
|
||||
} else {
|
||||
rs = db.execute("SELECT SUM(unread) FROM articles WHERE feed_id = ?", [id]);
|
||||
}
|
||||
|
||||
if (rs.isValidRow()) {
|
||||
return rs.field(0);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
exception_error("get_local_feed_unread", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue