1 var active_post_id
= false;
2 var last_article_view
= false;
3 var active_real_feed_id
= false;
5 // FIXME: kludges, needs proper implementation
6 var _reload_feedlist_after_view
= false;
8 var _cdm_wd_timeout
= false;
9 var _cdm_wd_vishist
= new Array();
11 var article_cache
= new Array();
13 var vgroup_last_feed
= false;
14 var post_under_pointer
= false;
16 var last_requested_article
= false;
18 var preload_id_batch
= [];
19 var preload_timeout_id
= false;
23 function catchup_callback2(transport
, callback
) {
25 console
.log("catchup_callback2 " + transport
+ ", " + callback
);
27 handle_rpc_reply(transport
);
29 setTimeout(callback
, 10);
32 exception_error("catchup_callback2", e
, transport
);
36 function clean_feed_selections() {
38 var feeds
= $("feedList").getElementsByTagName("LI");
40 for (var i
= 0; i
< feeds
.length
; i
++) {
41 if (feeds
[i
].id
&& feeds
[i
].id
.match("FEEDR-")) {
42 feeds
[i
].className
= feeds
[i
].className
.replace("Selected", "");
44 if (feeds
[i
].id
&& feeds
[i
].id
.match("FCAT-")) {
45 feeds
[i
].className
= feeds
[i
].className
.replace("Selected", "");
49 exception_error("clean_feed_selections", e
);
53 function headlines_callback2(transport
, feed_cur_page
) {
56 if (!handle_rpc_reply(transport
)) return;
58 loading_set_progress(100);
60 console
.log("headlines_callback2 [page=" + feed_cur_page
+ "]");
62 if (!transport_error_check(transport
)) return;
64 clean_feed_selections();
69 if (transport
.responseXML
) {
70 var headlines
= transport
.responseXML
.getElementsByTagName("headlines")[0];
72 is_cat
= headlines
.getAttribute("is_cat");
73 feed_id
= headlines
.getAttribute("id");
74 setActiveFeedId(feed_id
, is_cat
);
78 var ll
= $('FLL-' + feed_id
);
80 if (ll
&& ll
.parentNode
)
81 ll
.parentNode
.removeChild(ll
);
84 var feedr
= $("FEEDR-" + feed_id
);
85 if (feedr
&& !feedr
.className
.match("Selected")) {
86 feedr
.className
= feedr
.className
+ "Selected";
89 var feedr
= $("FCAT-" + feed_id
);
90 if (feedr
&& !feedr
.className
.match("Selected")) {
91 feedr
.className
= feedr
.className
+ "Selected";
95 var img
= $('FIMG-' + feed_id
);
101 var f
= $("headlines-frame");
103 if (feed_cur_page
== 0) {
104 //console.log("resetting headlines scrollTop");
109 if (transport
.responseXML
) {
110 var response
= transport
.responseXML
;
112 var headlines
= response
.getElementsByTagName("headlines")[0];
113 var headlines_info
= response
.getElementsByTagName("headlines-info")[0];
116 headlines_info
= JSON
.parse(headlines_info
.firstChild
.nodeValue
);
118 console
.error("didn't find headlines-info object in response");
122 var headlines_count
= headlines_info
.count
;
123 var headlines_unread
= headlines_info
.unread
;
124 var disable_cache
= headlines_info
.disable_cache
;
126 vgroup_last_feed
= headlines_info
.vgroup_last_feed
;
128 if (headlines_count
== 0) {
129 _infscroll_disable
= 1;
131 _infscroll_disable
= 0;
134 var counters
= response
.getElementsByTagName("counters")[0];
135 var articles
= response
.getElementsByTagName("article");
136 var runtime_info
= response
.getElementsByTagName("runtime-info");
138 if (feed_cur_page
== 0) {
140 f
.innerHTML
= headlines
.firstChild
.nodeValue
;
142 var cache_prefix
= "";
150 cache_invalidate(cache_prefix
+ feed_id
);
152 if (!disable_cache
) {
153 cache_inject(cache_prefix
+ feed_id
,
154 headlines
.firstChild
.nodeValue
, headlines_unread
);
158 console
.warn("headlines_callback: returned no data");
159 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
164 if (headlines_count
> 0) {
165 console
.log("adding some more headlines...");
167 var c
= $("headlinesList");
170 c
= $("headlinesInnerContainer");
173 var ids
= getSelectedArticleIds2();
175 c
.innerHTML
= c
.innerHTML
+ headlines
.firstChild
.nodeValue
;
177 console
.log("restore selected ids: " + ids
);
179 for (var i
= 0; i
< ids
.length
; i
++) {
180 markHeadline(ids
[i
]);
184 console
.log("no new headlines received");
187 console
.warn("headlines_callback: returned no data");
188 notify_error("Error while trying to load more headlines");
194 for (var i
= 0; i
< articles
.length
; i
++) {
195 var a_id
= articles
[i
].getAttribute("id");
196 //console.log("found id: " + a_id);
197 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
200 console
.log("no cached articles received");
204 parse_counters(counters
);
209 parse_runtime_info(runtime_info
[0]);
213 console
.warn("headlines_callback: returned no XML object");
214 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
218 if (_cdm_wd_timeout
) window
.clearTimeout(_cdm_wd_timeout
);
220 if (!$("headlinesList") &&
221 getActiveFeedId() != -3 &&
222 getInitParam("cdm_auto_catchup") == 1) {
223 console
.log("starting CDM watchdog");
224 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 5000);
225 _cdm_wd_vishist
= new Array();
227 console
.log("not in CDM mode or watchdog disabled");
230 _feed_cur_page
= feed_cur_page
;
231 _infscroll_request_sent
= 0;
238 exception_error("headlines_callback2", e
, transport
);
242 function render_article(article
) {
244 var f
= $("content-frame");
249 var fi
= $("content-insert");
255 fi
.innerHTML
= article
;
257 // article.evalScripts();
260 exception_error("render_article", e
);
264 function showArticleInHeadlines(id
) {
268 cleanSelected("headlinesList");
270 var crow
= $("RROW-" + id
);
274 var article_is_unread
= crow
.className
.match("Unread");
276 crow
.className
= crow
.className
.replace("Unread", "");
278 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
280 var upd_img_pic
= $("FUPDPIC-" + id
);
282 var cache_prefix
= "";
284 if (activeFeedIsCat()) {
290 var view_mode
= false;
293 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
294 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
299 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
300 upd_img_pic
.src
.match("fresh_sign.png"))) {
302 upd_img_pic
.src
= "images/blank_icon.gif";
304 cache_invalidate(cache_prefix
+ getActiveFeedId());
306 cache_inject(cache_prefix
+ getActiveFeedId(),
307 $("headlines-frame").innerHTML
,
308 get_feed_unread(getActiveFeedId()));
310 } else if (article_is_unread
&& view_mode
== "all_articles") {
312 cache_invalidate(cache_prefix
+ getActiveFeedId());
314 cache_inject(cache_prefix
+ getActiveFeedId(),
315 $("headlines-frame").innerHTML
,
316 get_feed_unread(getActiveFeedId())-1);
318 } else if (article_is_unread
) {
319 cache_invalidate(cache_prefix
+ getActiveFeedId());
324 if (article_is_unread
)
325 _force_scheduled_update
= true;
328 exception_error("showArticleInHeadlines", e
);
332 function article_callback2(transport
, id
) {
334 console
.log("article_callback2 " + id
);
336 if (!handle_rpc_reply(transport
)) return;
338 if (transport
.responseXML
) {
340 if (!transport_error_check(transport
)) return;
342 /* var ll = $('LL-' + id);
343 var content = $('HLC-' + id);
345 if (ll && content) content.removeChild(ll); */
347 var upic
= $('FUPDPIC-' + id
);
350 upic
.src
= 'images/blank_icon.gif';
353 if (id
!= last_requested_article
) {
354 console
.log("requested article id is out of sequence, aborting");
360 //console.log("looking for articles to cache...");
362 var articles
= transport
.responseXML
.getElementsByTagName("article");
364 for (var i
= 0; i
< articles
.length
; i
++) {
365 var a_id
= articles
[i
].getAttribute("id");
367 //console.log("found id: " + a_id);
369 if (a_id
== active_post_id
) {
370 //console.log("active article, rendering...");
371 render_article(articles
[i
].firstChild
.nodeValue
);
374 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
378 showArticleInHeadlines(id
);
381 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?", [id
]);
384 var reply
= transport
.responseXML
.firstChild
.firstChild
;
387 console
.warn("article_callback: returned no XML object");
388 //var f = $("content-frame");
389 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
392 var date
= new Date();
393 last_article_view
= date
.getTime() / 1000;
395 if (_reload_feedlist_after_view
) {
396 setTimeout('updateFeedList(false, false)', 50);
397 _reload_feedlist_after_view
= false;
404 exception_error("article_callback2", e
, transport
);
410 console
.log("loading article: " + id
);
412 if (offline_mode
) return view_offline(id
);
414 var cached_article
= cache_find(id
);
416 console
.log("cache check result: " + (cached_article
!= false));
421 var query
= "?op=view&id=" + param_escape(id
);
423 var neighbor_ids
= getRelativePostIds(active_post_id
);
425 /* only request uncached articles */
427 var cids_to_request
= Array();
429 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
430 if (!cache_check(neighbor_ids
[i
])) {
431 cids_to_request
.push(neighbor_ids
[i
]);
435 console
.log("additional ids: " + cids_to_request
.toString());
437 /* additional info for piggyback counters */
439 if (tagsAreDisplayed()) {
440 query
= query
+ "&omode=lt";
442 query
= query
+ "&omode=flc";
445 query
= query
+ "&cids=" + cids_to_request
.toString();
447 var crow
= $("RROW-" + id
);
448 var article_is_unread
= crow
.className
.match("Unread");
450 showArticleInHeadlines(id
);
452 if (!cached_article
) {
454 var upic
= $('FUPDPIC-' + id
);
457 upic
.src
= getInitParam("sign_progress");
460 } else if (cached_article
&& article_is_unread
) {
462 query
= query
+ "&mode=prefetch";
464 render_article(cached_article
);
466 } else if (cached_article
) {
468 query
= query
+ "&mode=prefetch_old";
469 render_article(cached_article
);
475 last_requested_article
= id
;
477 new Ajax
.Request("backend.php", {
479 onComplete: function(transport
) {
480 article_callback2(transport
, id
);
486 exception_error("view", e
);
491 return toggleMark(id
);
495 return togglePub(id
);
498 function tMark_afh_off(effect
) {
500 var elem
= effect
.effects
[0].element
;
502 //console.log("tMark_afh_off : " + elem.id);
505 elem
.src
= elem
.src
.replace("mark_set", "mark_unset");
506 elem
.alt
= __("Star article");
511 exception_error("tMark_afh_off", e
);
515 function tPub_afh_off(effect
) {
517 var elem
= effect
.effects
[0].element
;
519 //console.log("tPub_afh_off : " + elem.id);
522 elem
.src
= elem
.src
.replace("pub_set", "pub_unset");
523 elem
.alt
= __("Publish article");
528 exception_error("tPub_afh_off", e
);
532 function toggleMark(id
, client_only
, no_effects
) {
536 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
538 query
= query
+ "&afid=" + getActiveFeedId();
540 if (tagsAreDisplayed()) {
541 query
= query
+ "&omode=tl";
543 query
= query
+ "&omode=flc";
546 var mark_img
= $("FMPIC-" + id
);
548 if (!mark_img
) return;
550 var vfeedu
= $("FEEDU--1");
551 var crow
= $("RROW-" + id
);
553 if (mark_img
.src
.match("mark_unset")) {
554 mark_img
.src
= mark_img
.src
.replace("mark_unset", "mark_set");
555 mark_img
.alt
= __("Unstar article");
556 query
= query
+ "&mark=1";
559 db
.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id
]);
563 mark_img
.alt
= __("Please wait...");
564 query
= query
+ "&mark=0";
566 if ($("headlinesList") && !no_effects
) {
567 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tMark_afh_off
});
569 mark_img
.src
= mark_img
.src
.replace("mark_set", "mark_unset");
570 mark_img
.alt
= __("Star article");
574 db
.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id
]);
579 if (!no_effects
) update_local_feedlist_counters();
582 //console.log(query);
584 new Ajax
.Request("backend.php", {
586 onComplete: function(transport
) {
587 handle_rpc_reply(transport
);
593 exception_error("toggleMark", e
);
597 function togglePub(id
, client_only
, no_effects
, note
) {
601 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
603 query
= query
+ "&afid=" + getActiveFeedId();
605 if (note
!= undefined) {
606 query
= query
+ "¬e=" + param_escape(note
);
608 query
= query
+ "¬e=undefined";
611 if (tagsAreDisplayed()) {
612 query
= query
+ "&omode=tl";
614 query
= query
+ "&omode=flc";
617 var mark_img
= $("FPPIC-" + id
);
619 if (!mark_img
) return;
621 var vfeedu
= $("FEEDU--2");
622 var crow
= $("RROW-" + id
);
624 if (mark_img
.src
.match("pub_unset") || note
!= undefined) {
625 mark_img
.src
= mark_img
.src
.replace("pub_unset", "pub_set");
626 mark_img
.alt
= __("Unpublish article");
627 query
= query
+ "&pub=1";
630 mark_img
.alt
= __("Please wait...");
631 query
= query
+ "&pub=0";
633 if ($("headlinesList") && !no_effects
) {
634 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tPub_afh_off
});
636 mark_img
.src
= mark_img
.src
.replace("pub_set", "pub_unset");
637 mark_img
.alt
= __("Publish article");
642 new Ajax
.Request("backend.php", {
644 onComplete: function(transport
) {
645 handle_rpc_reply(transport
);
647 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
650 var note_id
= note
.getAttribute("id");
651 var note_size
= note
.getAttribute("size");
652 var note_content
= note
.firstChild
.nodeValue
;
654 var container
= $('POSTNOTE-' + note_id
);
656 cache_invalidate(note_id
);
659 if (note_size
== "0") {
660 Element
.hide(container
);
662 container
.innerHTML
= note_content
;
663 Element
.show(container
);
672 exception_error("togglePub", e
);
676 function correctHeadlinesOffset(id
) {
680 var hlist
= $("headlinesList");
681 var container
= $("headlinesInnerContainer");
682 var row
= $("RROW-" + id
);
684 var viewport
= container
.offsetHeight
;
686 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
687 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
689 console
.log("Rtop: " + rel_offset_top
+ " Rbtm: " + rel_offset_bottom
);
690 console
.log("Vport: " + viewport
);
692 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
693 container
.scrollTop
= row
.offsetTop
;
694 } else if (rel_offset_bottom
> viewport
) {
696 /* doesn't properly work with Opera in some cases because
697 Opera fucks up element scrolling */
699 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
703 exception_error("correctHeadlinesOffset", e
);
708 function moveToPost(mode
) {
715 rows
= cdmGetVisibleArticles();
717 rows
= getVisibleHeadlineIds();
723 if (!$('RROW-' + active_post_id
)) {
724 active_post_id
= false;
727 if (active_post_id
== false) {
728 next_id
= getFirstVisibleHeadlineId();
729 prev_id
= getLastVisibleHeadlineId();
731 for (var i
= 0; i
< rows
.length
; i
++) {
732 if (rows
[i
] == active_post_id
) {
739 if (mode
== "next") {
743 cdmExpandArticle(next_id
);
744 cdmScrollToArticleId(next_id
);
747 correctHeadlinesOffset(next_id
);
748 view(next_id
, getActiveFeedId());
753 if (mode
== "prev") {
756 cdmExpandArticle(prev_id
);
757 cdmScrollToArticleId(prev_id
);
759 correctHeadlinesOffset(prev_id
);
760 view(prev_id
, getActiveFeedId());
766 exception_error("moveToPost", e
);
770 function toggleSelected(id
) {
773 var cb
= $("RCHK-" + id
);
775 var row
= $("RROW-" + id
);
777 var nc
= row
.className
;
779 if (!nc
.match("Selected")) {
780 nc
= nc
+ "Selected";
785 // In CDM basically last selected article == active article
786 if (isCdmMode()) active_post_id
= id
;
788 nc
= nc
.replace("Selected", "");
798 exception_error("toggleSelected", e
);
802 function toggleUnread_afh(effect
) {
805 var elem
= effect
.element
;
806 elem
.style
.backgroundColor
= "";
809 exception_error("toggleUnread_afh", e
);
813 function toggleUnread(id
, cmode
, effect
) {
816 var row
= $("RROW-" + id
);
818 var nc
= row
.className
;
819 var is_selected
= row
.className
.match("Selected");
820 nc
= nc
.replace("Unread", "");
821 nc
= nc
.replace("Selected", "");
823 // since we are removing selection from the object, uncheck
824 // corresponding checkbox
826 var cb
= $("RCHK-" + id
);
831 // NOTE: I'm not sure that resetting selection here is a feature -fox
833 if (cmode
== undefined || cmode
== 2) {
834 if (row
.className
.match("Unread")) {
838 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
839 afterFinish
: toggleUnread_afh
,
840 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
844 row
.className
= nc
+ "Unread";
848 db
.execute("UPDATE articles SET unread = not unread "+
849 "WHERE id = ?", [id
]);
852 } else if (cmode
== 0) {
856 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
857 afterFinish
: toggleUnread_afh
,
858 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
862 db
.execute("UPDATE articles SET unread = 0 "+
863 "WHERE id = ?", [id
]);
866 } else if (cmode
== 1) {
867 row
.className
= nc
+ "Unread";
870 db
.execute("UPDATE articles SET unread = 1 "+
871 "WHERE id = ?", [id
]);
876 update_local_feedlist_counters();
878 // Disable unmarking as selected for the time being (16.05.08) -fox
879 if (is_selected
) row
.className
= row
.className
+ "Selected";
881 if (cmode
== undefined) cmode
= 2;
883 var query
= "?op=rpc&subop=catchupSelected" +
884 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
886 // notify_progress("Loading, please wait...");
888 new Ajax
.Request("backend.php", {
890 onComplete: function(transport
) {
891 handle_rpc_reply(transport
);
897 exception_error("toggleUnread", e
);
901 function selectionRemoveLabel(id
) {
904 var ids
= getSelectedArticleIds2();
906 if (ids
.length
== 0) {
907 alert(__("No articles are selected."));
911 // var ok = confirm(__("Remove selected articles from label?"));
915 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
916 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
920 // notify_progress("Loading, please wait...");
922 cache_invalidate("F:" + (-11 - id
));
924 new Ajax
.Request("backend.php", {
926 onComplete: function(transport
) {
927 show_labels_in_headlines(transport
);
928 handle_rpc_reply(transport
);
934 exception_error("selectionAssignLabel", e
);
939 function selectionAssignLabel(id
) {
942 var ids
= getSelectedArticleIds2();
944 if (ids
.length
== 0) {
945 alert(__("No articles are selected."));
949 // var ok = confirm(__("Assign selected articles to label?"));
953 cache_invalidate("F:" + (-11 - id
));
955 var query
= "?op=rpc&subop=assignToLabel&ids=" +
956 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
960 // notify_progress("Loading, please wait...");
962 new Ajax
.Request("backend.php", {
964 onComplete: function(transport
) {
965 show_labels_in_headlines(transport
);
966 handle_rpc_reply(transport
);
972 exception_error("selectionAssignLabel", e
);
977 function selectionToggleUnread(set_state
, callback_func
, no_error
) {
979 var rows
= getSelectedArticleIds2();
981 if (rows
.length
== 0 && !no_error
) {
982 alert(__("No articles are selected."));
986 for (i
= 0; i
< rows
.length
; i
++) {
987 var row
= $("RROW-" + rows
[i
]);
989 var nc
= row
.className
;
990 nc
= nc
.replace("Unread", "");
991 nc
= nc
.replace("Selected", "");
993 if (set_state
== undefined) {
994 if (row
.className
.match("Unread")) {
995 row
.className
= nc
+ "Selected";
997 row
.className
= nc
+ "UnreadSelected";
1000 db
.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
1005 if (set_state
== false) {
1006 row
.className
= nc
+ "Selected";
1008 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?",
1013 if (set_state
== true) {
1014 row
.className
= nc
+ "UnreadSelected";
1016 db
.execute("UPDATE articles SET unread = 1 WHERE id = ?",
1023 if (rows
.length
> 0) {
1025 update_local_feedlist_counters();
1029 if (set_state
== undefined) {
1031 } else if (set_state
== true) {
1033 } else if (set_state
== false) {
1037 var query
= "?op=rpc&subop=catchupSelected" +
1038 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
1040 notify_progress("Loading, please wait...");
1042 new Ajax
.Request("backend.php", {
1044 onComplete: function(transport
) {
1045 catchup_callback2(transport
, callback_func
);
1051 exception_error("selectionToggleUnread", e
);
1055 function selectionToggleMarked() {
1058 var rows
= getSelectedArticleIds2();
1060 if (rows
.length
== 0) {
1061 alert(__("No articles are selected."));
1065 for (i
= 0; i
< rows
.length
; i
++) {
1066 toggleMark(rows
[i
], true, true);
1069 update_local_feedlist_counters();
1071 if (rows
.length
> 0) {
1073 var query
= "?op=rpc&subop=markSelected&ids=" +
1074 param_escape(rows
.toString()) + "&cmode=2";
1076 query
= query
+ "&afid=" + getActiveFeedId();
1078 query
= query
+ "&omode=lc";
1080 new Ajax
.Request("backend.php", {
1082 onComplete: function(transport
) {
1083 handle_rpc_reply(transport
);
1089 exception_error("selectionToggleMarked", e
);
1093 function selectionTogglePublished() {
1096 var rows
= getSelectedArticleIds2();
1098 if (rows
.length
== 0) {
1099 alert(__("No articles are selected."));
1103 for (i
= 0; i
< rows
.length
; i
++) {
1104 togglePub(rows
[i
], true, true);
1107 if (rows
.length
> 0) {
1109 var query
= "?op=rpc&subop=publishSelected&ids=" +
1110 param_escape(rows
.toString()) + "&cmode=2";
1112 query
= query
+ "&afid=" + getActiveFeedId();
1114 query
= query
+ "&omode=lc";
1116 new Ajax
.Request("backend.php", {
1118 onComplete: function(transport
) {
1119 handle_rpc_reply(transport
);
1125 exception_error("selectionToggleMarked", e
);
1129 function cdmGetSelectedArticles() {
1130 var sel_articles
= new Array();
1131 var container
= $("headlinesInnerContainer");
1133 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1134 var child
= container
.childNodes
[i
];
1136 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Selected")) {
1137 var c_id
= child
.id
.replace("RROW-", "");
1138 sel_articles
.push(c_id
);
1142 return sel_articles
;
1145 function cdmGetVisibleArticles() {
1146 var sel_articles
= new Array();
1147 var container
= $("headlinesInnerContainer");
1149 if (!container
) return sel_articles
;
1151 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1152 var child
= container
.childNodes
[i
];
1154 if (child
.id
&& child
.id
.match("RROW-")) {
1155 var c_id
= child
.id
.replace("RROW-", "");
1156 sel_articles
.push(c_id
);
1160 return sel_articles
;
1163 function cdmGetUnreadArticles() {
1164 var sel_articles
= new Array();
1165 var container
= $("headlinesInnerContainer");
1167 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1168 var child
= container
.childNodes
[i
];
1170 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Unread")) {
1171 var c_id
= child
.id
.replace("RROW-", "");
1172 sel_articles
.push(c_id
);
1176 return sel_articles
;
1180 // mode = all,none,unread
1181 function cdmSelectArticles(mode
) {
1182 var container
= $("headlinesInnerContainer");
1184 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1185 var child
= container
.childNodes
[i
];
1187 if (child
.id
&& child
.id
.match("RROW-")) {
1188 var aid
= child
.id
.replace("RROW-", "");
1190 var cb
= $("RCHK-" + aid
);
1192 if (mode
== "all") {
1193 if (!child
.className
.match("Selected")) {
1194 child
.className
= child
.className
+ "Selected";
1197 } else if (mode
== "unread") {
1198 if (child
.className
.match("Unread") && !child
.className
.match("Selected")) {
1199 child
.className
= child
.className
+ "Selected";
1203 child
.className
= child
.className
.replace("Selected", "");
1210 function catchupPage() {
1212 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1214 var str
= __("Mark all visible articles in %s as read?");
1216 str
= str
.replace("%s", fn
);
1218 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1222 if ($("headlinesList")) {
1223 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
1224 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1225 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1227 cdmSelectArticles('all');
1228 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1229 cdmSelectArticles('none');
1233 function deleteSelection() {
1237 var rows
= getSelectedArticleIds2();
1239 if (rows
.length
== 0) {
1240 alert(__("No articles are selected."));
1244 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1248 if (getActiveFeedId() != 0) {
1249 str
= __("Delete %d selected articles in %s?");
1251 str
= __("Delete %d selected articles?");
1254 str
= str
.replace("%d", rows
.length
);
1255 str
= str
.replace("%s", fn
);
1257 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1261 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
1265 new Ajax
.Request("backend.php", {
1267 onComplete: function(transport
) {
1272 exception_error("deleteSelection", e
);
1276 function archiveSelection() {
1280 var rows
= getSelectedArticleIds2();
1282 if (rows
.length
== 0) {
1283 alert(__("No articles are selected."));
1287 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1291 if (getActiveFeedId() != 0) {
1292 str
= __("Archive %d selected articles in %s?");
1295 str
= __("Move %d archived articles back?");
1299 str
= str
.replace("%d", rows
.length
);
1300 str
= str
.replace("%s", fn
);
1302 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1306 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1310 for (var i
= 0; i
< rows
.length
; i
++) {
1311 cache_invalidate(rows
[i
]);
1314 new Ajax
.Request("backend.php", {
1316 onComplete: function(transport
) {
1321 exception_error("archiveSelection", e
);
1325 function catchupSelection() {
1329 var rows
= getSelectedArticleIds2();
1331 if (rows
.length
== 0) {
1332 alert(__("No articles are selected."));
1336 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1338 var str
= __("Mark %d selected articles in %s as read?");
1340 str
= str
.replace("%d", rows
.length
);
1341 str
= str
.replace("%s", fn
);
1343 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1347 if ($("headlinesList")) {
1348 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1350 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1354 exception_error("catchupSelection", e
);
1358 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1359 displayDlg('editArticleTags', id
,
1361 $("tags_str").focus();
1363 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1364 "backend.php?op=rpc&subop=completeTags",
1365 { tokens
: ',', paramName
: "search" });
1369 function editTagsSave() {
1371 notify_progress("Saving article tags...");
1373 var form
= document
.forms
["tag_edit_form"];
1375 var query
= Form
.serialize("tag_edit_form");
1377 query
= "?op=rpc&subop=setArticleTags&" + query
;
1379 //console.log(query);
1381 new Ajax
.Request("backend.php", {
1383 onComplete: function(transport
) {
1385 //console.log("tags saved...");
1390 if (tagsAreDisplayed()) {
1391 _reload_feedlist_after_view
= true;
1394 if (transport
.responseXML
) {
1395 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1398 var id
= tags_str
.getAttribute("id");
1401 var tags
= $("ATSTR-" + id
);
1403 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1406 cache_invalidate(id
);
1412 exception_error("editTagsSave", e
);
1417 function editTagsInsert() {
1420 var form
= document
.forms
["tag_edit_form"];
1422 var found_tags
= form
.found_tags
;
1423 var tags_str
= form
.tags_str
;
1425 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1427 if (tags_str
.value
.length
> 0 &&
1428 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1430 tags_str
.value
= tags_str
.value
+ ", ";
1433 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1435 found_tags
.selectedIndex
= 0;
1438 exception_error("editTagsInsert", e
);
1442 function cdmScrollViewport(where
) {
1443 console
.log("cdmScrollViewport: " + where
);
1445 var ctr
= $("headlinesInnerContainer");
1449 if (where
== "bottom") {
1450 ctr
.scrollTop
= ctr
.scrollHeight
;
1452 ctr
.scrollTop
= where
;
1456 function cdmArticleIsBelowViewport(id
) {
1458 var ctr
= $("headlinesInnerContainer");
1459 var e
= $("RROW-" + id
);
1461 if (!e
|| !ctr
) return;
1463 // article starts below viewport
1465 if (ctr
.scrollTop
< e
.offsetTop
) {
1472 exception_error("cdmArticleIsVisible", e
);
1476 function cdmArticleIsAboveViewport(id
) {
1478 var ctr
= $("headlinesInnerContainer");
1479 var e
= $("RROW-" + id
);
1481 if (!e
|| !ctr
) return;
1483 // article starts above viewport
1485 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1492 exception_error("cdmArticleIsVisible", e
);
1496 function cdmScrollToArticleId(id
) {
1498 var ctr
= $("headlinesInnerContainer");
1499 var e
= $("RROW-" + id
);
1501 if (!e
|| !ctr
) return;
1503 ctr
.scrollTop
= e
.offsetTop
;
1506 exception_error("cdmScrollToArticleId", e
);
1510 function cdmArticleIsActuallyVisible(id
) {
1512 var ctr
= $("headlinesInnerContainer");
1513 var e
= $("RROW-" + id
);
1515 if (!e
|| !ctr
) return;
1517 // article fits in viewport OR article is longer than viewport and
1518 // its bottom is visible
1520 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1521 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1525 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1526 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1527 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1536 exception_error("cdmArticleIsVisible", e
);
1540 function cdmWatchdog() {
1544 var ctr
= $("headlinesInnerContainer");
1548 var ids
= new Array();
1550 var e
= ctr
.firstChild
;
1553 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1554 e
.id
.match("RROW-")) {
1556 // article fits in viewport OR article is longer than viewport and
1557 // its bottom is visible
1559 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1560 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1562 // console.log(e.id + " is visible " + e.offsetTop + "." +
1563 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1564 // (ctr.scrollTop + ctr.offsetHeight));
1566 ids
.push(e
.id
.replace("RROW-", ""));
1568 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1569 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1570 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1572 ids
.push(e
.id
.replace("RROW-", ""));
1576 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1578 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1579 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1581 ids.push(e.id.replace("RROW-", ""));
1590 console
.log("cdmWatchdog, ids= " + ids
.toString());
1592 if (ids
.length
> 0) {
1594 for (var i
= 0; i
< ids
.length
; i
++) {
1595 var e
= $("RROW-" + ids
[i
]);
1597 e
.className
= e
.className
.replace("Unread", "");
1601 var query
= "?op=rpc&subop=catchupSelected" +
1602 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1604 new Ajax
.Request("backend.php", {
1606 onComplete: function(transport
) {
1607 handle_rpc_reply(transport
);
1612 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1615 exception_error("cdmWatchdog", e
);
1621 function cache_inject(id
, article
, param
) {
1624 if (!cache_check_param(id
, param
)) {
1625 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1627 var date
= new Date();
1628 var ts
= Math
.round(date
.getTime() / 1000);
1632 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1633 [id
, article
, param
, ts
]);
1638 cache_obj
["id"] = id
;
1639 cache_obj
["data"] = article
;
1640 cache_obj
["param"] = param
;
1642 if (param
) id
= id
+ ":" + param
;
1644 cache_added
["TS:" + id
] = ts
;
1646 if (has_local_storage())
1647 localStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1649 article_cache
.push(cache_obj
);
1653 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1656 exception_error("cache_inject", e
);
1660 function cache_find(id
) {
1663 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1666 if (rs
.isValidRow()) {
1667 var a
= rs
.field(0);
1676 if (has_local_storage()) {
1677 var cache_obj
= localStorage
.getItem(id
);
1680 cache_obj
= JSON
.parse(cache_obj
);
1683 return cache_obj
['data'];
1687 for (var i
= 0; i
< article_cache
.length
; i
++) {
1688 if (article_cache
[i
]["id"] == id
) {
1689 return article_cache
[i
]["data"];
1697 function cache_find_param(id
, param
) {
1700 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1704 if (rs
.isValidRow()) {
1714 if (has_local_storage()) {
1716 if (param
) id
= id
+ ":" + param
;
1718 var cache_obj
= localStorage
.getItem(id
);
1721 cache_obj
= JSON
.parse(cache_obj
);
1724 return cache_obj
['data'];
1728 for (var i
= 0; i
< article_cache
.length
; i
++) {
1729 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1730 return article_cache
[i
]["data"];
1738 function cache_check(id
) {
1741 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1745 if (rs
.isValidRow()) {
1746 a
= rs
.field(0) != "0";
1754 if (has_local_storage()) {
1755 if (localStorage
.getItem(id
))
1758 for (var i
= 0; i
< article_cache
.length
; i
++) {
1759 if (article_cache
[i
]["id"] == id
) {
1768 function cache_check_param(id
, param
) {
1771 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1775 if (rs
.isValidRow()) {
1776 a
= rs
.field(0) != "0";
1785 if (has_local_storage()) {
1787 if (param
) id
= id
+ ":" + param
;
1789 if (localStorage
.getItem(id
))
1793 for (var i
= 0; i
< article_cache
.length
; i
++) {
1794 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1803 function cache_expire() {
1805 var date
= new Date();
1806 var ts
= Math
.round(date
.getTime() / 1000);
1808 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1809 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1810 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1814 if (has_local_storage()) {
1816 var date
= new Date();
1817 var timestamp
= Math
.round(date
.getTime() / 1000);
1819 for (var i
= 0; i
< localStorage
.length
; i
++) {
1821 var id
= localStorage
.key(i
);
1823 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1824 localStorage
.removeItem(id
);
1829 while (article_cache
.length
> 25) {
1830 article_cache
.shift();
1836 function cache_flush() {
1838 db
.execute("DELETE FROM cache");
1839 } else if (has_local_storage()) {
1840 localStorage
.clear();
1842 article_cache
= new Array();
1846 function cache_invalidate(id
) {
1850 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1851 return rs
.rowsAffected
!= 0;
1854 if (has_local_storage()) {
1858 for (var i
= 0; i
< localStorage
.length
; i
++) {
1859 var key
= localStorage
.key(i
);
1861 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1863 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1864 localStorage
.removeItem(key
);
1875 while (i
< article_cache
.length
) {
1876 if (article_cache
[i
]["id"] == id
) {
1877 //console.log("cache_invalidate: removed id " + id);
1878 article_cache
.splice(i
, 1);
1886 //console.log("cache_invalidate: id not found: " + id);
1889 exception_error("cache_invalidate", e
);
1893 function getActiveArticleId() {
1894 return active_post_id
;
1897 function preloadBatchedArticles() {
1900 var query
= "?op=rpc&subop=getArticles&ids=" +
1901 preload_id_batch
.toString();
1903 new Ajax
.Request("backend.php", {
1905 onComplete: function(transport
) {
1907 preload_id_batch
= [];
1909 var articles
= transport
.responseXML
.getElementsByTagName("article");
1911 for (var i
= 0; i
< articles
.length
; i
++) {
1912 var id
= articles
[i
].getAttribute("id");
1913 if (!cache_check(id
)) {
1914 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1915 console
.log("preloaded article: " + id
);
1921 exception_error("preloadBatchedArticles", e
);
1925 function preloadArticleUnderPointer(id
) {
1927 if (getInitParam("bw_limit") == "1") return;
1929 if (post_under_pointer
== id
&& !cache_check(id
)) {
1931 console
.log("trying to preload article " + id
);
1933 var neighbor_ids
= getRelativePostIds(id
, 1);
1935 /* only request uncached articles */
1937 if (preload_id_batch
.indexOf(id
) == -1) {
1938 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1939 if (!cache_check(neighbor_ids
[i
])) {
1940 preload_id_batch
.push(neighbor_ids
[i
]);
1945 if (preload_id_batch
.indexOf(id
) == -1)
1946 preload_id_batch
.push(id
);
1948 //console.log("preload ids batch: " + preload_id_batch.toString());
1950 window
.clearTimeout(preload_timeout_id
);
1951 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1955 exception_error("preloadArticleUnderPointer", e
);
1959 function postMouseIn(id
) {
1961 if (post_under_pointer
!= id
) {
1962 post_under_pointer
= id
;
1964 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1969 exception_error("postMouseIn", e
);
1973 function postMouseOut(id
) {
1975 post_under_pointer
= false;
1977 exception_error("postMouseOut", e
);
1981 function headlines_scroll_handler() {
1984 var e
= $("headlinesInnerContainer");
1986 var toolbar_form
= document
.forms
["main_toolbar_form"];
1988 // console.log((e.scrollTop + e.offsetHeight) + " vs " + e.scrollHeight + " dis? " +
1989 // _infscroll_disable);
1991 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1992 if (!_infscroll_disable
) {
1998 exception_error("headlines_scroll_handler", e
);
2002 function catchupRelativeToArticle(below
) {
2007 if (!getActiveArticleId()) {
2008 alert(__("No article is selected."));
2014 if ($("headlinesList")) {
2015 visible_ids
= getVisibleHeadlineIds();
2017 visible_ids
= cdmGetVisibleArticles();
2020 var ids_to_mark
= new Array();
2023 for (var i
= 0; i
< visible_ids
.length
; i
++) {
2024 if (visible_ids
[i
] != getActiveArticleId()) {
2025 var e
= $("RROW-" + visible_ids
[i
]);
2027 if (e
&& e
.className
.match("Unread")) {
2028 ids_to_mark
.push(visible_ids
[i
]);
2035 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
2036 if (visible_ids
[i
] != getActiveArticleId()) {
2037 var e
= $("RROW-" + visible_ids
[i
]);
2039 if (e
&& e
.className
.match("Unread")) {
2040 ids_to_mark
.push(visible_ids
[i
]);
2048 if (ids_to_mark
.length
== 0) {
2049 alert(__("No articles found to mark"));
2051 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
2053 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
2055 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
2056 var e
= $("RROW-" + ids_to_mark
[i
]);
2057 e
.className
= e
.className
.replace("Unread", "");
2060 var query
= "?op=rpc&subop=catchupSelected" +
2061 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
2063 new Ajax
.Request("backend.php", {
2065 onComplete: function(transport
) {
2066 catchup_callback2(transport
);
2073 exception_error("catchupRelativeToArticle", e
);
2077 function cdmExpandArticle(id
) {
2080 var elem
= $("CICD-" + active_post_id
);
2082 if (id
== active_post_id
&& Element
.visible(elem
))
2085 cdmSelectArticles("none");
2087 var old_offset
= $("RROW-" + id
).offsetTop
;
2089 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
2091 Element
.show("CEXC-" + active_post_id
);
2094 active_post_id
= id
;
2096 elem
= $("CICD-" + id
);
2098 if (!Element
.visible(elem
)) {
2100 Element
.hide("CEXC-" + id
);
2103 var new_offset
= $("RROW-" + id
).offsetTop
;
2105 $("headlinesInnerContainer").scrollTop
+= (new_offset
-old_offset
);
2107 if ($("RROW-" + id
).offsetTop
!= old_offset
)
2108 $("headlinesInnerContainer").scrollTop
= new_offset
;
2110 toggleUnread(id
, 0, true);
2114 exception_error("cdmExpandArticle", e
);
2120 function fixHeadlinesOrder(ids
) {
2122 for (var i
= 0; i
< ids
.length
; i
++) {
2123 var e
= $("RROW-" + ids
[i
]);
2127 e
.className
= e
.className
.replace("even", "odd");
2129 e
.className
= e
.className
.replace("odd", "even");
2134 exception_error("fixHeadlinesOrder", e
);
2138 function hideReadHeadlines() {
2142 var vis_ids
= new Array();
2144 if ($("headlinesList")) {
2145 ids
= getVisibleHeadlineIds();
2147 ids
= cdmGetVisibleArticles();
2150 var read_headlines_visible
= true;
2152 for (var i
= 0; i
< ids
.length
; i
++) {
2153 var row
= $("RROW-" + ids
[i
]);
2155 if (row
&& row
.className
) {
2156 if (read_headlines_visible
) {
2157 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2159 vis_ids
.push(ids
[i
]);
2161 //Effect.Fade(row, {duration : 0.3});
2166 vis_ids
.push(ids
[i
]);
2171 fixHeadlinesOrder(vis_ids
);
2173 read_headlines_visible
= !read_headlines_visible
;
2176 exception_error("hideReadHeadlines", e
);
2180 function invertHeadlineSelection() {
2182 var rows
= new Array();
2186 r
= document
.getElementsByTagName("TR");
2188 r
= document
.getElementsByTagName("DIV");
2191 for (var i
= 0; i
< r
.length
; i
++) {
2192 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2197 for (var i
= 0; i
< rows
.length
; i
++) {
2198 var nc
= rows
[i
].className
;
2199 var id
= rows
[i
].id
.replace("RROW-", "");
2200 var cb
= $("RCHK-" + id
);
2202 if (!rows
[i
].className
.match("Selected")) {
2203 nc
= nc
+ "Selected";
2206 nc
= nc
.replace("Selected", "");
2210 rows
[i
].className
= nc
;
2215 exception_error("invertHeadlineSelection", e
);
2219 function getArticleUnderPointer() {
2220 return post_under_pointer
;
2223 function zoomToArticle(id
) {
2225 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2227 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2230 exception_error("zoomToArticle", e
);
2234 function scrollArticle(offset
) {
2237 var ci
= $("content-insert");
2239 ci
.scrollTop
+= offset
;
2242 var hi
= $("headlinesInnerContainer");
2244 hi
.scrollTop
+= offset
;
2249 exception_error("scrollArticle", e
);
2253 function show_labels_in_headlines(transport
) {
2255 if (transport
.responseXML
) {
2256 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2258 var elems
= info
.getElementsByTagName("entry");
2260 for (var l
= 0; l
< elems
.length
; l
++) {
2261 var e_id
= elems
[l
].getAttribute("id");
2265 var ctr
= $("HLLCTR-" + e_id
);
2268 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2276 exception_error("show_labels_in_headlines", e
);
2281 function toggleHeadlineActions() {
2283 var e
= $("headlineActionsBody");
2284 var p
= $("headlineActionsDrop");
2286 if (!Element
.visible(e
)) {
2293 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2294 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2297 exception_error("toggleHeadlineActions", e
);
2301 function publishWithNote(id
, def_note
) {
2303 if (!def_note
) def_note
= '';
2305 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2307 if (note
!= undefined) {
2308 togglePub(id
, false, false, note
);
2312 exception_error("publishWithNote", e
);
2316 function emailArticle(id
) {
2319 var ids
= getSelectedArticleIds2();
2321 if (ids
.length
== 0) {
2322 alert(__("No articles are selected."));
2326 id
= ids
.toString();
2329 displayDlg('emailArticle', id
,
2331 document
.forms
['article_email_form'].destination
.focus();
2333 new Ajax
.Autocompleter('destination', 'destination_choices',
2334 "backend.php?op=rpc&subop=completeEmails",
2335 { tokens
: '', paramName
: "search" });
2340 exception_error("emailArticle", e
);
2344 function emailArticleDo() {
2346 var f
= document
.forms
['article_email_form'];
2348 if (f
.destination
.value
== "") {
2349 alert("Please fill in the destination email.");
2353 if (f
.subject
.value
== "") {
2354 alert("Please fill in the subject.");
2358 var query
= Form
.serialize("article_email_form");
2360 // console.log(query);
2362 new Ajax
.Request("backend.php", {
2364 onComplete: function(transport
) {
2367 var error
= transport
.responseXML
.getElementsByTagName('error')[0];
2370 alert(__('Error sending email:') + ' ' + error
.firstChild
.nodeValue
);
2372 notify_info('Your message has been sent.');
2377 exception_error("sendEmailDo", e
);
2383 exception_error("emailArticleDo", e
);
2387 function dismissArticle(id
) {
2389 var elem
= $("RROW-" + id
);
2391 toggleUnread(id
, 0, true);
2393 new Effect
.Fade(elem
, {duration
: 0.5});
2396 exception_error("dismissArticle", e
);
2400 function dismissSelectedArticles() {
2403 var ids
= getSelectedArticleIds2();
2405 for (var i
= 0; i
< ids
.length
; i
++) {
2406 var elem
= $("RROW-" + ids
[i
]);
2407 new Effect
.Fade(elem
, {duration
: 0.5});
2411 selectionToggleUnread(false);
2414 exception_error("dismissSelectedArticles", e
);
2418 function dismissReadArticles() {
2421 var ids
= getVisibleArticleIds();
2423 for (var i
= 0; i
< ids
.length
; i
++) {
2424 var elem
= $("RROW-" + ids
[i
]);
2426 if (elem
.className
&& !elem
.className
.match("Unread") &&
2427 !elem
.className
.match("Selected")) {
2429 new Effect
.Fade(elem
, {duration
: 0.5});
2434 exception_error("dismissSelectedArticles", e
);
2438 function getVisibleArticleIds() {
2441 return cdmGetVisibleArticles();
2443 return getVisibleHeadlineIds();
2446 exception_error("getVisibleArticleIds");
2450 function cdmClicked(event
, id
) {
2452 var shift_key
= event
.shiftKey
;
2454 if (!event
.ctrlKey
) {
2455 cdmSelectArticles("none");
2458 var elem
= $("RROW-" + id
);
2461 elem
.className
= elem
.className
.replace("Unread", "");
2463 var query
= "?op=rpc&subop=catchupSelected" +
2464 "&cmode=0&ids=" + param_escape(id
);
2466 new Ajax
.Request("backend.php", {
2468 onComplete: function(transport
) {
2469 handle_rpc_reply(transport
);
2477 exception_error("cdmClicked");
2483 function hlClicked(event
, id
) {
2485 var shift_key
= event
.shiftKey
;
2487 if (!event
.ctrlKey
) {
2496 exception_error("hlClicked");