From 1ca8997bcc818bdfa12f3c979b9e0981422cdbc0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 9 Sep 2010 21:44:04 +0400 Subject: more digest page improvements --- digest.css | 9 +++++++-- digest.js | 45 ++++++++++++++++++++++++++++++++++++--------- modules/backend-rpc.php | 29 ++++++++++++++++++++--------- 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/digest.css b/digest.css index 62852adb0..3c770b765 100644 --- a/digest.css +++ b/digest.css @@ -156,6 +156,7 @@ a:hover { #headlines ul#headlines-content li { margin : 0px 0px 10px 0px; color : #909090; + clear : left; } #headlines ul#headlines-content a.title { @@ -164,12 +165,16 @@ a:hover { } #headlines ul#headlines-content div.excerpt { - margin-left : 22px; color : #404040; } +#headlines ul#headlines-content div.body { + margin-left : 21px; +} + #headlines ul#headlines-content div.info { - margin-left : 22px; + margin-top : 2px; + font-size : 11px; } #headlines ul#headlines-content div.info a { diff --git a/digest.js b/digest.js index 3d58ca95f..f27f15f86 100644 --- a/digest.js +++ b/digest.js @@ -1,12 +1,29 @@ 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) { @@ -61,7 +78,7 @@ function add_feed_entry(feed) { var tmp_html = "
  • " + icon_part + - "" + feed.title + + "" + feed.title + "
    " + feed.unread + "
    " + "
  • "; @@ -89,15 +106,15 @@ function add_headline_entry(article, feed) { var icon_part = ""; if (article.has_icon) - icon_part = "zz"; + icon_part = ""; var tmp_html = "
  • " + icon_part + "" + article.title + "" + - "
    " + article.excerpt + "
    " + + "
    " + article.excerpt + "
    " + "
    " + feed.title + " " + " @ " + new Date(article.updated * 1000) + "
    " + - "
  • "; + ""; $("headlines-content").innerHTML += tmp_html; @@ -112,15 +129,17 @@ function digest_update(transport) { 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) { @@ -128,11 +147,18 @@ function digest_update(transport) { $('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 += "
  • More articles...
  • "; + $('headlines-content').innerHTML += "
  • " + + "
  • "; + + new Effect.Appear('headlines-content'); + } } catch (e) { @@ -147,6 +173,7 @@ function digest_init() { parameters: "backend.php?op=rpc&subop=digest-init", onComplete: function(transport) { digest_update(transport); + window.setTimeout('viewfeed(-4)', 100); } }); } catch (e) { diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index edf2ae2e4..80eda7c3f 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -978,11 +978,29 @@ 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 ""; + + $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 ""; + + print ""; + return; + } + + if ($subop == "digest-init") { print ""; $tmp_feeds = api_get_feeds($link, false, true, false, 0); @@ -1007,13 +1025,6 @@ print ""; - $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 ""; print ""; return; } -- cgit v1.2.3