more digest page improvements
This commit is contained in:
parent
432c64cace
commit
118e9399b7
17
digest.css
17
digest.css
|
@ -137,6 +137,13 @@ a:hover {
|
|||
#headlines {
|
||||
padding : 5px;
|
||||
font-size : 14px;
|
||||
max-width : 65%;
|
||||
}
|
||||
|
||||
#headlines ul#headlines-content img.digest-check {
|
||||
float : right;
|
||||
cursor : pointer;
|
||||
|
||||
}
|
||||
|
||||
#headlines ul#headlines-content img {
|
||||
|
@ -159,6 +166,10 @@ a:hover {
|
|||
clear : left;
|
||||
}
|
||||
|
||||
#headlines ul#headlines-content li:hover {
|
||||
background : #fafafa;
|
||||
}
|
||||
|
||||
#headlines ul#headlines-content a.title {
|
||||
font-weight : bold;
|
||||
font-size : 16px;
|
||||
|
@ -166,10 +177,16 @@ a:hover {
|
|||
|
||||
#headlines ul#headlines-content div.excerpt {
|
||||
color : #404040;
|
||||
cursor : pointer;
|
||||
}
|
||||
|
||||
#headlines ul#headlines-content div.content {
|
||||
color : #404040;
|
||||
}
|
||||
|
||||
#headlines ul#headlines-content div.body {
|
||||
margin-left : 21px;
|
||||
/*margin-left : 42px;*/
|
||||
}
|
||||
|
||||
#headlines ul#headlines-content div.info {
|
||||
|
|
131
digest.js
131
digest.js
|
@ -2,12 +2,81 @@ var last_feeds = [];
|
|||
|
||||
var _active_feed_id = false;
|
||||
var _active_feed_offset = false;
|
||||
var _update_timeout = false;
|
||||
|
||||
function view(article_id) {
|
||||
function zoom(article_id) {
|
||||
try {
|
||||
new Effect.Fade('A-' + article_id, {duration : 0.3});
|
||||
var elem = $('A-' + article_id);
|
||||
|
||||
return true;
|
||||
if (elem) {
|
||||
var divs = elem.getElementsByTagName('DIV');
|
||||
|
||||
for (var i = 0; i < divs.length; i++) {
|
||||
if (divs[i].className == 'excerpt')
|
||||
Element.hide(divs[i]);
|
||||
|
||||
if (divs[i].className == 'content')
|
||||
Element.show(divs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var query = "backend.php?op=rpc&subop=digest-mark&article_id=" + article_id;
|
||||
|
||||
new Ajax.Request("backend.php", {
|
||||
parameters: query,
|
||||
onComplete: function(transport) {
|
||||
window.clearTimeout(_update_timeout);
|
||||
_update_timeout = window.setTimeout('update()', 1000);
|
||||
} });
|
||||
|
||||
} catch (e) {
|
||||
exception_error("zoom", e);
|
||||
}
|
||||
}
|
||||
|
||||
function load_more() {
|
||||
try {
|
||||
var elem = $('MORE-PROMPT');
|
||||
|
||||
if (elem) {
|
||||
elem.id = '';
|
||||
Element.hide(elem);
|
||||
}
|
||||
|
||||
viewfeed(_active_feed_id, _active_feed_offset + 10);
|
||||
} catch (e) {
|
||||
exception_error("load_more", e);
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
try {
|
||||
viewfeed(_active_feed_id, _active_feed_offset);
|
||||
} catch (e) {
|
||||
exception_error("update", e);
|
||||
}
|
||||
}
|
||||
|
||||
function view(article_id, dismiss_only) {
|
||||
try {
|
||||
var elem = $('A-' + article_id);
|
||||
|
||||
elem.id = '';
|
||||
|
||||
//new Effect.Fade(elem, {duration : 0.3});
|
||||
|
||||
Element.hide(elem);
|
||||
|
||||
var query = "backend.php?op=rpc&subop=digest-mark&article_id=" + article_id;
|
||||
|
||||
new Ajax.Request("backend.php", {
|
||||
parameters: query,
|
||||
onComplete: function(transport) {
|
||||
window.clearTimeout(_update_timeout);
|
||||
_update_timeout = window.setTimeout('update()', 1000);
|
||||
} });
|
||||
|
||||
return dismiss_only != true;
|
||||
} catch (e) {
|
||||
exception_error("view", e);
|
||||
}
|
||||
|
@ -31,7 +100,7 @@ function viewfeed(feed_id, offset) {
|
|||
new Ajax.Request("backend.php", {
|
||||
parameters: query,
|
||||
onComplete: function(transport) {
|
||||
digest_update(transport);
|
||||
digest_update(transport, feed_id);
|
||||
_active_feed_id = feed_id;
|
||||
_active_feed_offset = offset;
|
||||
} });
|
||||
|
@ -41,6 +110,20 @@ function viewfeed(feed_id, offset) {
|
|||
}
|
||||
}
|
||||
|
||||
function find_article(articles, article_id) {
|
||||
try {
|
||||
for (var i = 0; i < articles.length; i++) {
|
||||
if (articles[i].id == article_id)
|
||||
return articles[i];
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} catch (e) {
|
||||
exception_error("find_article", e);
|
||||
}
|
||||
}
|
||||
|
||||
function find_feed(feeds, feed_id) {
|
||||
try {
|
||||
for (var i = 0; i < feeds.length; i++) {
|
||||
|
@ -120,10 +203,15 @@ function add_headline_entry(article, feed) {
|
|||
|
||||
var tmp_html = "<li id=\"A-"+article.id+"\">" +
|
||||
icon_part +
|
||||
"<img title='Dismiss' onclick=\"view("+article.id+", true)\" class='digest-check' src='images/digest_checkbox.png'>" +
|
||||
"<a target=\"_blank\" href=\""+article.link+"\""+
|
||||
"onclick=\"return view("+article.id+")\" class='title'>" +
|
||||
article.title + "</a>" +
|
||||
"<div class='body'><div class='excerpt'>" + article.excerpt + "</div>" +
|
||||
"<div class='body'>" +
|
||||
"<div title=\"Click to expand article\" onclick=\"zoom("+article.id+")\" class='excerpt'>" +
|
||||
article.excerpt + "</div>" +
|
||||
"<div style='display : none' class='content'>" +
|
||||
article.content + "</div>" +
|
||||
"<div class='info'><a>" + feed.title + "</a> " + " @ " +
|
||||
new Date(article.updated * 1000) + "</div>" +
|
||||
"</div></li>";
|
||||
|
@ -135,7 +223,7 @@ function add_headline_entry(article, feed) {
|
|||
}
|
||||
}
|
||||
|
||||
function digest_update(transport) {
|
||||
function digest_update(transport, feed_id) {
|
||||
try {
|
||||
var feeds = transport.responseXML.getElementsByTagName('feeds')[0];
|
||||
var headlines = transport.responseXML.getElementsByTagName('headlines')[0];
|
||||
|
@ -157,17 +245,32 @@ function digest_update(transport) {
|
|||
if (headlines) {
|
||||
headlines = eval("(" + headlines.firstChild.nodeValue + ")");
|
||||
|
||||
$('headlines-content').innerHTML = "";
|
||||
if (_active_feed_id != feed_id)
|
||||
$('headlines-content').innerHTML = "";
|
||||
|
||||
Element.hide('headlines-content');
|
||||
//Element.hide('headlines-content');
|
||||
|
||||
for (var i = 0; i < headlines.length; i++) {
|
||||
add_headline_entry(headlines[i], find_feed(feeds, headlines[i].feed_id));
|
||||
var pr = $('MORE-PROMPT');
|
||||
|
||||
if (pr) {
|
||||
pr.id = '';
|
||||
Element.hide(pr);
|
||||
}
|
||||
|
||||
// $('headlines-content').innerHTML += "<li>" +
|
||||
// "<div class='body'><a href=\"#\" onclick=\"viewfeed(false, 10)\">" +
|
||||
// __("More articles...") + "</a></div></li>";
|
||||
for (var i = 0; i < headlines.length; i++) {
|
||||
var elem = $('A-' + headlines[i].id);
|
||||
|
||||
if (elem && Element.visible(elem)) {
|
||||
|
||||
|
||||
} else {
|
||||
add_headline_entry(headlines[i], find_feed(feeds, headlines[i].feed_id));
|
||||
}
|
||||
}
|
||||
|
||||
$('headlines-content').innerHTML += "<li id='MORE-PROMPT'>" +
|
||||
"<div class='body'><a href=\"#\" onclick=\"load_more()\">" +
|
||||
__("More articles...") + "</a></div></li>";
|
||||
|
||||
new Effect.Appear('headlines-content');
|
||||
|
||||
|
@ -184,7 +287,7 @@ function digest_init() {
|
|||
new Ajax.Request("backend.php", {
|
||||
parameters: "backend.php?op=rpc&subop=digest-init",
|
||||
onComplete: function(transport) {
|
||||
digest_update(transport);
|
||||
digest_update(transport, -4);
|
||||
window.setTimeout('viewfeed(-4)', 100);
|
||||
} });
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 244 B |
|
@ -989,7 +989,7 @@
|
|||
print "<rpc-reply>";
|
||||
|
||||
$headlines = api_get_headlines($link, $feed_id, 10, $offset,
|
||||
'', ($feed_id == -4), true, false, "unread", "updated DESC");
|
||||
'', ($feed_id == -4), true, true, "unread", "updated DESC");
|
||||
|
||||
//function api_get_headlines($link, $feed_id, $limit, $offset,
|
||||
// $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {
|
||||
|
|
Loading…
Reference in New Issue