2010-09-09 12:50:10 +00:00
|
|
|
var last_feeds = [];
|
|
|
|
|
2010-09-09 17:44:04 +00:00
|
|
|
var _active_feed_id = false;
|
|
|
|
var _active_feed_offset = false;
|
|
|
|
|
2010-09-09 18:01:35 +00:00
|
|
|
function view(article_id) {
|
|
|
|
try {
|
|
|
|
new Effect.Fade('A-' + article_id, {duration : 0.3});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("view", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-09 17:44:04 +00:00
|
|
|
function viewfeed(feed_id, offset) {
|
2010-09-09 15:02:12 +00:00
|
|
|
try {
|
|
|
|
|
2010-09-09 17:44:04 +00:00
|
|
|
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);
|
|
|
|
|
2010-09-09 15:02:12 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
2010-09-09 17:44:04 +00:00
|
|
|
parameters: query,
|
2010-09-09 15:02:12 +00:00
|
|
|
onComplete: function(transport) {
|
|
|
|
digest_update(transport);
|
2010-09-09 17:44:04 +00:00
|
|
|
_active_feed_id = feed_id;
|
|
|
|
_active_feed_offset = offset;
|
2010-09-09 15:02:12 +00:00
|
|
|
} });
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("view", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-09 12:50:10 +00:00
|
|
|
function find_feed(feeds, feed_id) {
|
|
|
|
try {
|
|
|
|
for (var i = 0; i < feeds.length; i++) {
|
|
|
|
if (feeds[i].id == feed_id)
|
|
|
|
return feeds[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("find_feed", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-09 15:02:12 +00:00
|
|
|
function get_feed_icon(feed) {
|
|
|
|
try {
|
|
|
|
if (feed.has_icon)
|
|
|
|
return 'icons/' + feed.id + '.ico';
|
|
|
|
|
|
|
|
if (feed.id == -1)
|
|
|
|
return 'images/mark_set.png';
|
|
|
|
|
|
|
|
if (feed.id == -2)
|
|
|
|
return 'images/pub_set.png';
|
|
|
|
|
|
|
|
if (feed.id == -3)
|
|
|
|
return 'images/fresh.png';
|
|
|
|
|
|
|
|
if (feed.id == -4)
|
|
|
|
return 'images/tag.png';
|
|
|
|
|
|
|
|
if (feed.id < -10)
|
|
|
|
return 'images/label.png';
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("get_feed_icon", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-09 12:50:10 +00:00
|
|
|
function add_feed_entry(feed) {
|
|
|
|
try {
|
|
|
|
var icon_part = "";
|
|
|
|
|
2010-09-09 15:02:12 +00:00
|
|
|
icon_part = "<img src='" + get_feed_icon(feed) + "'/>";
|
2010-09-09 12:50:10 +00:00
|
|
|
|
|
|
|
var tmp_html = "<li>" +
|
|
|
|
icon_part +
|
2010-09-09 17:44:04 +00:00
|
|
|
"<a href=\"#\" onclick=\"viewfeed("+feed.id+")\">" + feed.title +
|
2010-09-09 12:50:10 +00:00
|
|
|
"<div class='unread-ctr'>" + feed.unread + "</div>" +
|
|
|
|
"</li>";
|
|
|
|
|
|
|
|
$("feeds-content").innerHTML += tmp_html;
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("add_feed_entry", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-09 15:02:12 +00:00
|
|
|
function add_latest_entry(article, feed) {
|
2010-09-09 12:50:10 +00:00
|
|
|
try {
|
2010-09-09 15:02:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
//$("latest-content").innerHTML += "bbb";
|
2010-09-09 12:50:10 +00:00
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("add_latest_entry", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_headline_entry(article, feed) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
var icon_part = "";
|
|
|
|
|
|
|
|
if (article.has_icon)
|
2010-09-09 17:44:04 +00:00
|
|
|
icon_part = "<img src='icons/" + article.feed_id + ".ico'/>";
|
2010-09-09 12:50:10 +00:00
|
|
|
|
2010-09-09 18:01:35 +00:00
|
|
|
var tmp_html = "<li id=\"A-"+article.id+"\">" +
|
2010-09-09 12:50:10 +00:00
|
|
|
icon_part +
|
2010-09-09 18:01:35 +00:00
|
|
|
"<a target=\"_blank\" href=\""+article.link+"\""+
|
|
|
|
"onclick=\"return view("+article.id+")\" class='title'>" +
|
|
|
|
article.title + "</a>" +
|
2010-09-09 17:44:04 +00:00
|
|
|
"<div class='body'><div class='excerpt'>" + article.excerpt + "</div>" +
|
2010-09-09 12:50:10 +00:00
|
|
|
"<div class='info'><a>" + feed.title + "</a> " + " @ " +
|
2010-09-09 15:02:12 +00:00
|
|
|
new Date(article.updated * 1000) + "</div>" +
|
2010-09-09 17:44:04 +00:00
|
|
|
"</div></li>";
|
2010-09-09 12:50:10 +00:00
|
|
|
|
|
|
|
$("headlines-content").innerHTML += tmp_html;
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("add_headline_entry", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function digest_update(transport) {
|
|
|
|
try {
|
|
|
|
var feeds = transport.responseXML.getElementsByTagName('feeds')[0];
|
|
|
|
var headlines = transport.responseXML.getElementsByTagName('headlines')[0];
|
|
|
|
|
|
|
|
if (feeds) {
|
|
|
|
feeds = eval("(" + feeds.firstChild.nodeValue + ")");
|
|
|
|
|
2010-09-09 17:44:04 +00:00
|
|
|
last_feeds = feeds;
|
|
|
|
|
2010-09-09 15:02:12 +00:00
|
|
|
$('feeds-content').innerHTML = "";
|
|
|
|
|
2010-09-09 12:50:10 +00:00
|
|
|
for (var i = 0; i < feeds.length; i++) {
|
|
|
|
add_feed_entry(feeds[i]);
|
|
|
|
}
|
2010-09-09 17:44:04 +00:00
|
|
|
} else {
|
|
|
|
feeds = last_feeds;
|
2010-09-09 12:50:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (headlines) {
|
|
|
|
headlines = eval("(" + headlines.firstChild.nodeValue + ")");
|
|
|
|
|
2010-09-09 15:02:12 +00:00
|
|
|
$('headlines-content').innerHTML = "";
|
|
|
|
|
2010-09-09 17:44:04 +00:00
|
|
|
Element.hide('headlines-content');
|
|
|
|
|
2010-09-09 12:50:10 +00:00
|
|
|
for (var i = 0; i < headlines.length; i++) {
|
|
|
|
add_headline_entry(headlines[i], find_feed(feeds, headlines[i].feed_id));
|
|
|
|
}
|
2010-09-09 15:02:12 +00:00
|
|
|
|
2010-09-09 18:01:35 +00:00
|
|
|
// $('headlines-content').innerHTML += "<li>" +
|
|
|
|
// "<div class='body'><a href=\"#\" onclick=\"viewfeed(false, 10)\">" +
|
|
|
|
// __("More articles...") + "</a></div></li>";
|
2010-09-09 17:44:04 +00:00
|
|
|
|
|
|
|
new Effect.Appear('headlines-content');
|
|
|
|
|
2010-09-09 12:50:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("digest_update", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function digest_init() {
|
|
|
|
try {
|
|
|
|
|
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: "backend.php?op=rpc&subop=digest-init",
|
|
|
|
onComplete: function(transport) {
|
|
|
|
digest_update(transport);
|
2010-09-09 17:44:04 +00:00
|
|
|
window.setTimeout('viewfeed(-4)', 100);
|
2010-09-09 12:50:10 +00:00
|
|
|
} });
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("digest_init", e);
|
|
|
|
}
|
|
|
|
}
|