var last_feeds = [];
-function view(feed_id) {
+var _active_feed_id = false;
+var _active_feed_offset = false;
+
+function viewfeed(feed_id, offset) {
try {
+ if (!feed_id) feed_id = _active_feed_id;
+
+ if (!offset)
+ offset = 0;
+ else
+ offset = _active_feed_offset + offset;
+
+ var query = "backend.php?op=rpc&subop=digest-update&feed_id=" + feed_id +
+ "&offset=" + offset;
+
+ console.log(query);
+
new Ajax.Request("backend.php", {
- parameters: "backend.php?op=rpc&subop=digest-init&feed_id=" + feed_id,
+ parameters: query,
onComplete: function(transport) {
digest_update(transport);
+ _active_feed_id = feed_id;
+ _active_feed_offset = offset;
} });
} catch (e) {
var tmp_html = "<li>" +
icon_part +
- "<a href=\"#\" onclick=\"view("+feed.id+")\">" + feed.title +
+ "<a href=\"#\" onclick=\"viewfeed("+feed.id+")\">" + feed.title +
"<div class='unread-ctr'>" + feed.unread + "</div>" +
"</li>";
var icon_part = "";
if (article.has_icon)
- icon_part = "<img alt='zz' src='icons/" + article.feed_id + ".ico'/>";
+ icon_part = "<img src='icons/" + article.feed_id + ".ico'/>";
var tmp_html = "<li>" +
icon_part +
"<a class='title'>" + article.title + "</a>" +
- "<div class='excerpt'>" + article.excerpt + "</div>" +
+ "<div class='body'><div class='excerpt'>" + article.excerpt + "</div>" +
"<div class='info'><a>" + feed.title + "</a> " + " @ " +
new Date(article.updated * 1000) + "</div>" +
- "</li>";
+ "</div></li>";
$("headlines-content").innerHTML += tmp_html;
var headlines = transport.responseXML.getElementsByTagName('headlines')[0];
if (feeds) {
- last_feeds = feeds;
-
feeds = eval("(" + feeds.firstChild.nodeValue + ")");
+ last_feeds = feeds;
+
$('feeds-content').innerHTML = "";
for (var i = 0; i < feeds.length; i++) {
add_feed_entry(feeds[i]);
}
+ } else {
+ feeds = last_feeds;
}
if (headlines) {
$('headlines-content').innerHTML = "";
+ Element.hide('headlines-content');
+
for (var i = 0; i < headlines.length; i++) {
add_headline_entry(headlines[i], find_feed(feeds, headlines[i].feed_id));
}
- $('headlines-content').innerHTML += "<li><a>More articles...</a></li>";
+ $('headlines-content').innerHTML += "<li>" +
+ "<div class='body'><a href=\"#\" onclick=\"viewfeed(false, 10)\">" +
+ __("More articles...") + "</a></div></li>";
+
+ new Effect.Appear('headlines-content');
+
}
} catch (e) {
parameters: "backend.php?op=rpc&subop=digest-init",
onComplete: function(transport) {
digest_update(transport);
+ window.setTimeout('viewfeed(-4)', 100);
} });
} catch (e) {
return;
}
- if ($subop == "digest-init") {
+ if ($subop == "digest-update") {
$feed_id = db_escape_string($_REQUEST['feed_id']);
-
+ $offset = db_escape_string($_REQUEST['offset']);
+
if (!$feed_id) $feed_id = -4;
+ if (!$offset) $offset = 0;
+
+ print "<rpc-reply>";
+
+ $headlines = api_get_headlines($link, $feed_id, 10, $offset,
+ '', ($feed_id == -4), true, false, "unread", "updated DESC");
+
+ //function api_get_headlines($link, $feed_id, $limit, $offset,
+ // $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {
+
+ print "<headlines><![CDATA[" . json_encode($headlines) . "]]></headlines>";
+
+ print "</rpc-reply>";
+ return;
+ }
+
+ if ($subop == "digest-init") {
print "<rpc-reply>";
$tmp_feeds = api_get_feeds($link, false, true, false, 0);
print "<feeds><![CDATA[" . json_encode($feeds) . "]]></feeds>";
- $headlines = api_get_headlines($link, $feed_id, 10, 0,
- '', ($feed_id == -4), true, false, "all_articles", "updated DESC");
-
- //function api_get_headlines($link, $feed_id, $limit, $offset,
- // $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {
-
- print "<headlines><![CDATA[" . json_encode($headlines) . "]]></headlines>";
print "</rpc-reply>";
return;
}