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
);
81 var feedr
= $("FEEDR-" + feed_id
);
82 if (feedr
&& !feedr
.className
.match("Selected")) {
83 feedr
.className
= feedr
.className
+ "Selected";
85 if (feedr
&& ll
) feedr
.removeChild(ll
);
87 var feedr
= $("FCAT-" + feed_id
);
88 if (feedr
&& !feedr
.className
.match("Selected")) {
89 feedr
.className
= feedr
.className
+ "Selected";
92 var fcap
= $("FCAP-" + feed_id
);
93 if (fcap
&& ll
) fcap
.removeChild(ll
);
97 var img
= $('FIMG-' + feed_id
);
103 var f
= $("headlines-frame");
105 if (feed_cur_page
== 0) {
106 //console.log("resetting headlines scrollTop");
111 if (transport
.responseXML
) {
112 var response
= transport
.responseXML
;
114 var headlines
= response
.getElementsByTagName("headlines")[0];
115 var headlines_info
= response
.getElementsByTagName("headlines-info")[0];
118 headlines_info
= JSON
.parse(headlines_info
.firstChild
.nodeValue
);
120 console
.error("didn't find headlines-info object in response");
124 var headlines_count
= headlines_info
.count
;
125 var headlines_unread
= headlines_info
.unread
;
126 var disable_cache
= headlines_info
.disable_cache
;
128 vgroup_last_feed
= headlines_info
.vgroup_last_feed
;
130 if (headlines_count
== 0) {
131 _infscroll_disable
= 1;
133 _infscroll_disable
= 0;
136 var counters
= response
.getElementsByTagName("counters")[0];
137 var articles
= response
.getElementsByTagName("article");
138 var runtime_info
= response
.getElementsByTagName("runtime-info");
140 if (feed_cur_page
== 0) {
142 f
.innerHTML
= headlines
.firstChild
.nodeValue
;
144 var cache_prefix
= "";
152 cache_invalidate(cache_prefix
+ feed_id
);
154 if (!disable_cache
) {
155 cache_inject(cache_prefix
+ feed_id
,
156 headlines
.firstChild
.nodeValue
, headlines_unread
);
160 console
.warn("headlines_callback: returned no data");
161 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
166 if (headlines_count
> 0) {
167 console
.warn("adding some more headlines...");
169 var c
= $("headlinesList");
172 c
= $("headlinesInnerContainer");
175 var ids
= getSelectedArticleIds2();
177 c
.innerHTML
= c
.innerHTML
+ headlines
.firstChild
.nodeValue
;
179 console
.log("restore selected ids: " + ids
);
181 for (var i
= 0; i
< ids
.length
; i
++) {
182 markHeadline(ids
[i
]);
186 console
.log("no new headlines received");
189 console
.warn("headlines_callback: returned no data");
190 notify_error("Error while trying to load more headlines");
196 for (var i
= 0; i
< articles
.length
; i
++) {
197 var a_id
= articles
[i
].getAttribute("id");
198 //console.log("found id: " + a_id);
199 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
202 console
.log("no cached articles received");
208 parse_runtime_info(runtime_info
[0]);
212 console
.warn("headlines_callback: returned no XML object");
213 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
217 if (_cdm_wd_timeout
) window
.clearTimeout(_cdm_wd_timeout
);
219 if (!$("headlinesList") &&
220 getActiveFeedId() != -3 &&
221 getInitParam("cdm_auto_catchup") == 1) {
222 console
.log("starting CDM watchdog");
223 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 5000);
224 _cdm_wd_vishist
= new Array();
226 console
.log("not in CDM mode or watchdog disabled");
229 _feed_cur_page
= feed_cur_page
;
230 _infscroll_request_sent
= 0;
237 exception_error("headlines_callback2", e
, transport
);
241 function render_article(article
) {
243 var f
= $("content-frame");
248 var fi
= $("content-insert");
254 fi
.innerHTML
= article
;
256 // article.evalScripts();
259 exception_error("render_article", e
);
263 function showArticleInHeadlines(id
) {
267 cleanSelected("headlinesList");
269 var crow
= $("RROW-" + id
);
273 var article_is_unread
= crow
.className
.match("Unread");
275 crow
.className
= crow
.className
.replace("Unread", "");
277 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
279 var upd_img_pic
= $("FUPDPIC-" + id
);
281 var cache_prefix
= "";
283 if (activeFeedIsCat()) {
289 var view_mode
= false;
292 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
293 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
298 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
299 upd_img_pic
.src
.match("fresh_sign.png"))) {
301 upd_img_pic
.src
= "images/blank_icon.gif";
303 cache_invalidate(cache_prefix
+ getActiveFeedId());
305 cache_inject(cache_prefix
+ getActiveFeedId(),
306 $("headlines-frame").innerHTML
,
307 get_feed_unread(getActiveFeedId()));
309 } else if (article_is_unread
&& view_mode
== "all_articles") {
311 cache_invalidate(cache_prefix
+ getActiveFeedId());
313 cache_inject(cache_prefix
+ getActiveFeedId(),
314 $("headlines-frame").innerHTML
,
315 get_feed_unread(getActiveFeedId())-1);
317 } else if (article_is_unread
) {
318 cache_invalidate(cache_prefix
+ getActiveFeedId());
324 exception_error("showArticleInHeadlines", e
);
328 function article_callback2(transport
, id
) {
330 console
.log("article_callback2 " + id
);
332 if (!handle_rpc_reply(transport
)) return;
334 if (transport
.responseXML
) {
336 if (!transport_error_check(transport
)) return;
338 /* var ll = $('LL-' + id);
339 var content = $('HLC-' + id);
341 if (ll && content) content.removeChild(ll); */
343 var upic
= $('FUPDPIC-' + id
);
346 upic
.src
= 'images/blank_icon.gif';
349 if (id
!= last_requested_article
) {
350 console
.log("requested article id is out of sequence, aborting");
356 //console.log("looking for articles to cache...");
358 var articles
= transport
.responseXML
.getElementsByTagName("article");
360 for (var i
= 0; i
< articles
.length
; i
++) {
361 var a_id
= articles
[i
].getAttribute("id");
363 //console.log("found id: " + a_id);
365 if (a_id
== active_post_id
) {
366 //console.log("active article, rendering...");
367 render_article(articles
[i
].firstChild
.nodeValue
);
370 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
374 showArticleInHeadlines(id
);
377 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?", [id
]);
380 var reply
= transport
.responseXML
.firstChild
.firstChild
;
383 console
.warn("article_callback: returned no XML object");
384 //var f = $("content-frame");
385 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
388 var date
= new Date();
389 last_article_view
= date
.getTime() / 1000;
391 if (_reload_feedlist_after_view
) {
392 setTimeout('updateFeedList(false, false)', 50);
393 _reload_feedlist_after_view
= false;
400 exception_error("article_callback2", e
, transport
);
406 console
.log("loading article: " + id
);
408 if (offline_mode
) return view_offline(id
);
410 var cached_article
= cache_find(id
);
412 console
.log("cache check result: " + (cached_article
!= false));
417 var query
= "?op=view&id=" + param_escape(id
);
419 var neighbor_ids
= getRelativePostIds(active_post_id
);
421 /* only request uncached articles */
423 var cids_to_request
= Array();
425 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
426 if (!cache_check(neighbor_ids
[i
])) {
427 cids_to_request
.push(neighbor_ids
[i
]);
431 console
.log("additional ids: " + cids_to_request
.toString());
433 /* additional info for piggyback counters */
435 if (tagsAreDisplayed()) {
436 query
= query
+ "&omode=lt";
438 query
= query
+ "&omode=flc";
441 query
= query
+ "&cids=" + cids_to_request
.toString();
443 var crow
= $("RROW-" + id
);
444 var article_is_unread
= crow
.className
.match("Unread");
446 showArticleInHeadlines(id
);
448 if (!cached_article
) {
450 var upic
= $('FUPDPIC-' + id
);
453 upic
.src
= getInitParam("sign_progress");
456 } else if (cached_article
&& article_is_unread
) {
458 query
= query
+ "&mode=prefetch";
460 render_article(cached_article
);
462 } else if (cached_article
) {
464 query
= query
+ "&mode=prefetch_old";
465 render_article(cached_article
);
471 last_requested_article
= id
;
473 new Ajax
.Request("backend.php", {
475 onComplete: function(transport
) {
476 article_callback2(transport
, id
);
482 exception_error("view", e
);
487 return toggleMark(id
);
491 return togglePub(id
);
494 function tMark_afh_off(effect
) {
496 var elem
= effect
.effects
[0].element
;
498 //console.log("tMark_afh_off : " + elem.id);
501 elem
.src
= elem
.src
.replace("mark_set", "mark_unset");
502 elem
.alt
= __("Star article");
507 exception_error("tMark_afh_off", e
);
511 function tPub_afh_off(effect
) {
513 var elem
= effect
.effects
[0].element
;
515 //console.log("tPub_afh_off : " + elem.id);
518 elem
.src
= elem
.src
.replace("pub_set", "pub_unset");
519 elem
.alt
= __("Publish article");
524 exception_error("tPub_afh_off", e
);
528 function toggleMark(id
, client_only
, no_effects
) {
532 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
534 query
= query
+ "&afid=" + getActiveFeedId();
536 if (tagsAreDisplayed()) {
537 query
= query
+ "&omode=tl";
539 query
= query
+ "&omode=flc";
542 var mark_img
= $("FMPIC-" + id
);
544 if (!mark_img
) return;
546 var vfeedu
= $("FEEDU--1");
547 var crow
= $("RROW-" + id
);
549 if (mark_img
.src
.match("mark_unset")) {
550 mark_img
.src
= mark_img
.src
.replace("mark_unset", "mark_set");
551 mark_img
.alt
= __("Unstar article");
552 query
= query
+ "&mark=1";
555 db
.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id
]);
559 mark_img
.alt
= __("Please wait...");
560 query
= query
+ "&mark=0";
562 if ($("headlinesList") && !no_effects
) {
563 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tMark_afh_off
});
565 mark_img
.src
= mark_img
.src
.replace("mark_set", "mark_unset");
566 mark_img
.alt
= __("Star article");
570 db
.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id
]);
575 if (!no_effects
) update_local_feedlist_counters();
578 //console.log(query);
580 new Ajax
.Request("backend.php", {
582 onComplete: function(transport
) {
583 handle_rpc_reply(transport
);
589 exception_error("toggleMark", e
);
593 function togglePub(id
, client_only
, no_effects
, note
) {
597 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
599 query
= query
+ "&afid=" + getActiveFeedId();
601 if (note
!= undefined) {
602 query
= query
+ "¬e=" + param_escape(note
);
604 query
= query
+ "¬e=undefined";
607 if (tagsAreDisplayed()) {
608 query
= query
+ "&omode=tl";
610 query
= query
+ "&omode=flc";
613 var mark_img
= $("FPPIC-" + id
);
615 if (!mark_img
) return;
617 var vfeedu
= $("FEEDU--2");
618 var crow
= $("RROW-" + id
);
620 if (mark_img
.src
.match("pub_unset") || note
!= undefined) {
621 mark_img
.src
= mark_img
.src
.replace("pub_unset", "pub_set");
622 mark_img
.alt
= __("Unpublish article");
623 query
= query
+ "&pub=1";
626 mark_img
.alt
= __("Please wait...");
627 query
= query
+ "&pub=0";
629 if ($("headlinesList") && !no_effects
) {
630 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tPub_afh_off
});
632 mark_img
.src
= mark_img
.src
.replace("pub_set", "pub_unset");
633 mark_img
.alt
= __("Publish article");
638 new Ajax
.Request("backend.php", {
640 onComplete: function(transport
) {
641 handle_rpc_reply(transport
);
643 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
646 var note_id
= note
.getAttribute("id");
647 var note_size
= note
.getAttribute("size");
648 var note_content
= note
.firstChild
.nodeValue
;
650 var container
= $('POSTNOTE-' + note_id
);
652 cache_invalidate(note_id
);
655 if (note_size
== "0") {
656 Element
.hide(container
);
658 container
.innerHTML
= note_content
;
659 Element
.show(container
);
668 exception_error("togglePub", e
);
672 function correctHeadlinesOffset(id
) {
676 var hlist
= $("headlinesList");
677 var container
= $("headlinesInnerContainer");
678 var row
= $("RROW-" + id
);
680 var viewport
= container
.offsetHeight
;
682 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
683 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
685 console
.log("Rtop: " + rel_offset_top
+ " Rbtm: " + rel_offset_bottom
);
686 console
.log("Vport: " + viewport
);
688 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
689 container
.scrollTop
= row
.offsetTop
;
690 } else if (rel_offset_bottom
> viewport
) {
692 /* doesn't properly work with Opera in some cases because
693 Opera fucks up element scrolling */
695 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
699 exception_error("correctHeadlinesOffset", e
);
704 function moveToPost(mode
) {
711 rows
= cdmGetVisibleArticles();
713 rows
= getVisibleHeadlineIds();
719 if (!$('RROW-' + active_post_id
)) {
720 active_post_id
= false;
723 if (active_post_id
== false) {
724 next_id
= getFirstVisibleHeadlineId();
725 prev_id
= getLastVisibleHeadlineId();
727 for (var i
= 0; i
< rows
.length
; i
++) {
728 if (rows
[i
] == active_post_id
) {
735 if (mode
== "next") {
739 cdmExpandArticle(next_id
);
740 cdmScrollToArticleId(next_id
);
743 correctHeadlinesOffset(next_id
);
744 view(next_id
, getActiveFeedId());
749 if (mode
== "prev") {
752 cdmExpandArticle(prev_id
);
753 cdmScrollToArticleId(prev_id
);
755 correctHeadlinesOffset(prev_id
);
756 view(prev_id
, getActiveFeedId());
762 exception_error("moveToPost", e
);
766 function toggleSelected(id
) {
769 var cb
= $("RCHK-" + id
);
771 var row
= $("RROW-" + id
);
773 var nc
= row
.className
;
775 if (!nc
.match("Selected")) {
776 nc
= nc
+ "Selected";
781 // In CDM basically last selected article == active article
782 if (isCdmMode()) active_post_id
= id
;
784 nc
= nc
.replace("Selected", "");
794 exception_error("toggleSelected", e
);
798 function toggleUnread_afh(effect
) {
801 var elem
= effect
.element
;
802 elem
.style
.backgroundColor
= "";
805 exception_error("toggleUnread_afh", e
);
809 function toggleUnread(id
, cmode
, effect
) {
812 var row
= $("RROW-" + id
);
814 var nc
= row
.className
;
815 var is_selected
= row
.className
.match("Selected");
816 nc
= nc
.replace("Unread", "");
817 nc
= nc
.replace("Selected", "");
819 // since we are removing selection from the object, uncheck
820 // corresponding checkbox
822 var cb
= $("RCHK-" + id
);
827 // NOTE: I'm not sure that resetting selection here is a feature -fox
829 if (cmode
== undefined || cmode
== 2) {
830 if (row
.className
.match("Unread")) {
834 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
835 afterFinish
: toggleUnread_afh
,
836 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
840 row
.className
= nc
+ "Unread";
844 db
.execute("UPDATE articles SET unread = not unread "+
845 "WHERE id = ?", [id
]);
848 } else if (cmode
== 0) {
852 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
853 afterFinish
: toggleUnread_afh
,
854 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
858 db
.execute("UPDATE articles SET unread = 0 "+
859 "WHERE id = ?", [id
]);
862 } else if (cmode
== 1) {
863 row
.className
= nc
+ "Unread";
866 db
.execute("UPDATE articles SET unread = 1 "+
867 "WHERE id = ?", [id
]);
872 update_local_feedlist_counters();
874 // Disable unmarking as selected for the time being (16.05.08) -fox
875 if (is_selected
) row
.className
= row
.className
+ "Selected";
877 if (cmode
== undefined) cmode
= 2;
879 var query
= "?op=rpc&subop=catchupSelected" +
880 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
882 // notify_progress("Loading, please wait...");
884 new Ajax
.Request("backend.php", {
886 onComplete: function(transport
) {
887 handle_rpc_reply(transport
);
893 exception_error("toggleUnread", e
);
897 function selectionRemoveLabel(id
) {
900 var ids
= getSelectedArticleIds2();
902 if (ids
.length
== 0) {
903 alert(__("No articles are selected."));
907 // var ok = confirm(__("Remove selected articles from label?"));
911 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
912 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
916 // notify_progress("Loading, please wait...");
918 cache_invalidate("F:" + (-11 - id
));
920 new Ajax
.Request("backend.php", {
922 onComplete: function(transport
) {
923 show_labels_in_headlines(transport
);
924 handle_rpc_reply(transport
);
930 exception_error("selectionAssignLabel", e
);
935 function selectionAssignLabel(id
) {
938 var ids
= getSelectedArticleIds2();
940 if (ids
.length
== 0) {
941 alert(__("No articles are selected."));
945 // var ok = confirm(__("Assign selected articles to label?"));
949 cache_invalidate("F:" + (-11 - id
));
951 var query
= "?op=rpc&subop=assignToLabel&ids=" +
952 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
956 // notify_progress("Loading, please wait...");
958 new Ajax
.Request("backend.php", {
960 onComplete: function(transport
) {
961 show_labels_in_headlines(transport
);
962 handle_rpc_reply(transport
);
968 exception_error("selectionAssignLabel", e
);
973 function selectionToggleUnread(set_state
, callback_func
, no_error
) {
975 var rows
= getSelectedArticleIds2();
977 if (rows
.length
== 0 && !no_error
) {
978 alert(__("No articles are selected."));
982 for (i
= 0; i
< rows
.length
; i
++) {
983 var row
= $("RROW-" + rows
[i
]);
985 var nc
= row
.className
;
986 nc
= nc
.replace("Unread", "");
987 nc
= nc
.replace("Selected", "");
989 if (set_state
== undefined) {
990 if (row
.className
.match("Unread")) {
991 row
.className
= nc
+ "Selected";
993 row
.className
= nc
+ "UnreadSelected";
996 db
.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
1001 if (set_state
== false) {
1002 row
.className
= nc
+ "Selected";
1004 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?",
1009 if (set_state
== true) {
1010 row
.className
= nc
+ "UnreadSelected";
1012 db
.execute("UPDATE articles SET unread = 1 WHERE id = ?",
1019 if (rows
.length
> 0) {
1021 update_local_feedlist_counters();
1025 if (set_state
== undefined) {
1027 } else if (set_state
== true) {
1029 } else if (set_state
== false) {
1033 var query
= "?op=rpc&subop=catchupSelected" +
1034 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
1036 notify_progress("Loading, please wait...");
1038 new Ajax
.Request("backend.php", {
1040 onComplete: function(transport
) {
1041 catchup_callback2(transport
, callback_func
);
1047 exception_error("selectionToggleUnread", e
);
1051 function selectionToggleMarked() {
1054 var rows
= getSelectedArticleIds2();
1056 if (rows
.length
== 0) {
1057 alert(__("No articles are selected."));
1061 for (i
= 0; i
< rows
.length
; i
++) {
1062 toggleMark(rows
[i
], true, true);
1065 update_local_feedlist_counters();
1067 if (rows
.length
> 0) {
1069 var query
= "?op=rpc&subop=markSelected&ids=" +
1070 param_escape(rows
.toString()) + "&cmode=2";
1072 query
= query
+ "&afid=" + getActiveFeedId();
1074 query
= query
+ "&omode=lc";
1076 new Ajax
.Request("backend.php", {
1078 onComplete: function(transport
) {
1079 handle_rpc_reply(transport
);
1085 exception_error("selectionToggleMarked", e
);
1089 function selectionTogglePublished() {
1092 var rows
= getSelectedArticleIds2();
1094 if (rows
.length
== 0) {
1095 alert(__("No articles are selected."));
1099 for (i
= 0; i
< rows
.length
; i
++) {
1100 togglePub(rows
[i
], true, true);
1103 if (rows
.length
> 0) {
1105 var query
= "?op=rpc&subop=publishSelected&ids=" +
1106 param_escape(rows
.toString()) + "&cmode=2";
1108 query
= query
+ "&afid=" + getActiveFeedId();
1110 query
= query
+ "&omode=lc";
1112 new Ajax
.Request("backend.php", {
1114 onComplete: function(transport
) {
1115 handle_rpc_reply(transport
);
1121 exception_error("selectionToggleMarked", e
);
1125 function cdmGetSelectedArticles() {
1126 var sel_articles
= new Array();
1127 var container
= $("headlinesInnerContainer");
1129 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1130 var child
= container
.childNodes
[i
];
1132 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Selected")) {
1133 var c_id
= child
.id
.replace("RROW-", "");
1134 sel_articles
.push(c_id
);
1138 return sel_articles
;
1141 function cdmGetVisibleArticles() {
1142 var sel_articles
= new Array();
1143 var container
= $("headlinesInnerContainer");
1145 if (!container
) return sel_articles
;
1147 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1148 var child
= container
.childNodes
[i
];
1150 if (child
.id
&& child
.id
.match("RROW-")) {
1151 var c_id
= child
.id
.replace("RROW-", "");
1152 sel_articles
.push(c_id
);
1156 return sel_articles
;
1159 function cdmGetUnreadArticles() {
1160 var sel_articles
= new Array();
1161 var container
= $("headlinesInnerContainer");
1163 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1164 var child
= container
.childNodes
[i
];
1166 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Unread")) {
1167 var c_id
= child
.id
.replace("RROW-", "");
1168 sel_articles
.push(c_id
);
1172 return sel_articles
;
1176 // mode = all,none,unread
1177 function cdmSelectArticles(mode
) {
1178 var container
= $("headlinesInnerContainer");
1180 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1181 var child
= container
.childNodes
[i
];
1183 if (child
.id
&& child
.id
.match("RROW-")) {
1184 var aid
= child
.id
.replace("RROW-", "");
1186 var cb
= $("RCHK-" + aid
);
1188 if (mode
== "all") {
1189 if (!child
.className
.match("Selected")) {
1190 child
.className
= child
.className
+ "Selected";
1193 } else if (mode
== "unread") {
1194 if (child
.className
.match("Unread") && !child
.className
.match("Selected")) {
1195 child
.className
= child
.className
+ "Selected";
1199 child
.className
= child
.className
.replace("Selected", "");
1206 function catchupPage() {
1208 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1210 var str
= __("Mark all visible articles in %s as read?");
1212 str
= str
.replace("%s", fn
);
1214 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1218 if ($("headlinesList")) {
1219 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
1220 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1221 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1223 cdmSelectArticles('all');
1224 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1225 cdmSelectArticles('none');
1229 function deleteSelection() {
1233 var rows
= getSelectedArticleIds2();
1235 if (rows
.length
== 0) {
1236 alert(__("No articles are selected."));
1240 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1244 if (getActiveFeedId() != 0) {
1245 str
= __("Delete %d selected articles in %s?");
1247 str
= __("Delete %d selected articles?");
1250 str
= str
.replace("%d", rows
.length
);
1251 str
= str
.replace("%s", fn
);
1253 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1257 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
1261 new Ajax
.Request("backend.php", {
1263 onComplete: function(transport
) {
1268 exception_error("deleteSelection", e
);
1272 function archiveSelection() {
1276 var rows
= getSelectedArticleIds2();
1278 if (rows
.length
== 0) {
1279 alert(__("No articles are selected."));
1283 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1287 if (getActiveFeedId() != 0) {
1288 str
= __("Archive %d selected articles in %s?");
1291 str
= __("Move %d archived articles back?");
1295 str
= str
.replace("%d", rows
.length
);
1296 str
= str
.replace("%s", fn
);
1298 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1302 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1306 for (var i
= 0; i
< rows
.length
; i
++) {
1307 cache_invalidate(rows
[i
]);
1310 new Ajax
.Request("backend.php", {
1312 onComplete: function(transport
) {
1317 exception_error("archiveSelection", e
);
1321 function catchupSelection() {
1325 var rows
= getSelectedArticleIds2();
1327 if (rows
.length
== 0) {
1328 alert(__("No articles are selected."));
1332 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1334 var str
= __("Mark %d selected articles in %s as read?");
1336 str
= str
.replace("%d", rows
.length
);
1337 str
= str
.replace("%s", fn
);
1339 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1343 if ($("headlinesList")) {
1344 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1346 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1350 exception_error("catchupSelection", e
);
1354 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1355 displayDlg('editArticleTags', id
,
1357 $("tags_str").focus();
1359 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1360 "backend.php?op=rpc&subop=completeTags",
1361 { tokens
: ',', paramName
: "search" });
1365 function editTagsSave() {
1367 notify_progress("Saving article tags...");
1369 var form
= document
.forms
["tag_edit_form"];
1371 var query
= Form
.serialize("tag_edit_form");
1373 query
= "?op=rpc&subop=setArticleTags&" + query
;
1375 //console.log(query);
1377 new Ajax
.Request("backend.php", {
1379 onComplete: function(transport
) {
1381 //console.log("tags saved...");
1386 if (tagsAreDisplayed()) {
1387 _reload_feedlist_after_view
= true;
1390 if (transport
.responseXML
) {
1391 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1394 var id
= tags_str
.getAttribute("id");
1397 var tags
= $("ATSTR-" + id
);
1399 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1402 cache_invalidate(id
);
1408 exception_error("editTagsSave", e
);
1413 function editTagsInsert() {
1416 var form
= document
.forms
["tag_edit_form"];
1418 var found_tags
= form
.found_tags
;
1419 var tags_str
= form
.tags_str
;
1421 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1423 if (tags_str
.value
.length
> 0 &&
1424 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1426 tags_str
.value
= tags_str
.value
+ ", ";
1429 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1431 found_tags
.selectedIndex
= 0;
1434 exception_error("editTagsInsert", e
);
1438 function cdmScrollViewport(where
) {
1439 console
.log("cdmScrollViewport: " + where
);
1441 var ctr
= $("headlinesInnerContainer");
1445 if (where
== "bottom") {
1446 ctr
.scrollTop
= ctr
.scrollHeight
;
1448 ctr
.scrollTop
= where
;
1452 function cdmArticleIsBelowViewport(id
) {
1454 var ctr
= $("headlinesInnerContainer");
1455 var e
= $("RROW-" + id
);
1457 if (!e
|| !ctr
) return;
1459 // article starts below viewport
1461 if (ctr
.scrollTop
< e
.offsetTop
) {
1468 exception_error("cdmArticleIsVisible", e
);
1472 function cdmArticleIsAboveViewport(id
) {
1474 var ctr
= $("headlinesInnerContainer");
1475 var e
= $("RROW-" + id
);
1477 if (!e
|| !ctr
) return;
1479 // article starts above viewport
1481 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1488 exception_error("cdmArticleIsVisible", e
);
1492 function cdmScrollToArticleId(id
) {
1494 var ctr
= $("headlinesInnerContainer");
1495 var e
= $("RROW-" + id
);
1497 if (!e
|| !ctr
) return;
1499 ctr
.scrollTop
= e
.offsetTop
;
1502 exception_error("cdmScrollToArticleId", e
);
1506 function cdmArticleIsActuallyVisible(id
) {
1508 var ctr
= $("headlinesInnerContainer");
1509 var e
= $("RROW-" + id
);
1511 if (!e
|| !ctr
) return;
1513 // article fits in viewport OR article is longer than viewport and
1514 // its bottom is visible
1516 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1517 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1521 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1522 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1523 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1532 exception_error("cdmArticleIsVisible", e
);
1536 function cdmWatchdog() {
1540 var ctr
= $("headlinesInnerContainer");
1544 var ids
= new Array();
1546 var e
= ctr
.firstChild
;
1549 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1550 e
.id
.match("RROW-")) {
1552 // article fits in viewport OR article is longer than viewport and
1553 // its bottom is visible
1555 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1556 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1558 // console.log(e.id + " is visible " + e.offsetTop + "." +
1559 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1560 // (ctr.scrollTop + ctr.offsetHeight));
1562 ids
.push(e
.id
.replace("RROW-", ""));
1564 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1565 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1566 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1568 ids
.push(e
.id
.replace("RROW-", ""));
1572 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1574 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1575 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1577 ids.push(e.id.replace("RROW-", ""));
1586 console
.log("cdmWatchdog, ids= " + ids
.toString());
1588 if (ids
.length
> 0) {
1590 for (var i
= 0; i
< ids
.length
; i
++) {
1591 var e
= $("RROW-" + ids
[i
]);
1593 e
.className
= e
.className
.replace("Unread", "");
1597 var query
= "?op=rpc&subop=catchupSelected" +
1598 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1600 new Ajax
.Request("backend.php", {
1602 onComplete: function(transport
) {
1603 handle_rpc_reply(transport
);
1608 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1611 exception_error("cdmWatchdog", e
);
1617 function cache_inject(id
, article
, param
) {
1620 if (!cache_check_param(id
, param
)) {
1621 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1623 var date
= new Date();
1624 var ts
= Math
.round(date
.getTime() / 1000);
1628 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1629 [id
, article
, param
, ts
]);
1634 cache_obj
["id"] = id
;
1635 cache_obj
["data"] = article
;
1636 cache_obj
["param"] = param
;
1638 if (param
) id
= id
+ ":" + param
;
1640 cache_added
["TS:" + id
] = ts
;
1642 if (has_local_storage())
1643 localStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1645 article_cache
.push(cache_obj
);
1649 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1652 exception_error("cache_inject", e
);
1656 function cache_find(id
) {
1659 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1662 if (rs
.isValidRow()) {
1663 var a
= rs
.field(0);
1672 if (has_local_storage()) {
1673 var cache_obj
= localStorage
.getItem(id
);
1676 cache_obj
= JSON
.parse(cache_obj
);
1679 return cache_obj
['data'];
1683 for (var i
= 0; i
< article_cache
.length
; i
++) {
1684 if (article_cache
[i
]["id"] == id
) {
1685 return article_cache
[i
]["data"];
1693 function cache_find_param(id
, param
) {
1696 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1700 if (rs
.isValidRow()) {
1710 if (has_local_storage()) {
1712 if (param
) id
= id
+ ":" + param
;
1714 var cache_obj
= localStorage
.getItem(id
);
1717 cache_obj
= JSON
.parse(cache_obj
);
1720 return cache_obj
['data'];
1724 for (var i
= 0; i
< article_cache
.length
; i
++) {
1725 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1726 return article_cache
[i
]["data"];
1734 function cache_check(id
) {
1737 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1741 if (rs
.isValidRow()) {
1742 a
= rs
.field(0) != "0";
1750 if (has_local_storage()) {
1751 if (localStorage
.getItem(id
))
1754 for (var i
= 0; i
< article_cache
.length
; i
++) {
1755 if (article_cache
[i
]["id"] == id
) {
1764 function cache_check_param(id
, param
) {
1767 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1771 if (rs
.isValidRow()) {
1772 a
= rs
.field(0) != "0";
1781 if (has_local_storage()) {
1783 if (param
) id
= id
+ ":" + param
;
1785 if (localStorage
.getItem(id
))
1789 for (var i
= 0; i
< article_cache
.length
; i
++) {
1790 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1799 function cache_expire() {
1801 var date
= new Date();
1802 var ts
= Math
.round(date
.getTime() / 1000);
1804 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1805 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1806 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1810 if (has_local_storage()) {
1812 var date
= new Date();
1813 var timestamp
= Math
.round(date
.getTime() / 1000);
1815 for (var i
= 0; i
< localStorage
.length
; i
++) {
1817 var id
= localStorage
.key(i
);
1819 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1820 localStorage
.removeItem(id
);
1825 while (article_cache
.length
> 25) {
1826 article_cache
.shift();
1832 function cache_flush() {
1834 db
.execute("DELETE FROM cache");
1835 } else if (has_local_storage()) {
1836 localStorage
.clear();
1838 article_cache
= new Array();
1842 function cache_invalidate(id
) {
1846 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1847 return rs
.rowsAffected
!= 0;
1850 if (has_local_storage()) {
1854 for (var i
= 0; i
< localStorage
.length
; i
++) {
1855 var key
= localStorage
.key(i
);
1857 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1859 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1860 localStorage
.removeItem(key
);
1871 while (i
< article_cache
.length
) {
1872 if (article_cache
[i
]["id"] == id
) {
1873 //console.log("cache_invalidate: removed id " + id);
1874 article_cache
.splice(i
, 1);
1882 //console.log("cache_invalidate: id not found: " + id);
1885 exception_error("cache_invalidate", e
);
1889 function getActiveArticleId() {
1890 return active_post_id
;
1893 function preloadBatchedArticles() {
1896 var query
= "?op=rpc&subop=getArticles&ids=" +
1897 preload_id_batch
.toString();
1899 new Ajax
.Request("backend.php", {
1901 onComplete: function(transport
) {
1903 preload_id_batch
= [];
1905 var articles
= transport
.responseXML
.getElementsByTagName("article");
1907 for (var i
= 0; i
< articles
.length
; i
++) {
1908 var id
= articles
[i
].getAttribute("id");
1909 if (!cache_check(id
)) {
1910 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1911 console
.log("preloaded article: " + id
);
1917 exception_error("preloadBatchedArticles", e
);
1921 function preloadArticleUnderPointer(id
) {
1923 if (getInitParam("bw_limit") == "1") return;
1925 if (post_under_pointer
== id
&& !cache_check(id
)) {
1927 console
.log("trying to preload article " + id
);
1929 var neighbor_ids
= getRelativePostIds(id
, 1);
1931 /* only request uncached articles */
1933 if (preload_id_batch
.indexOf(id
) == -1) {
1934 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1935 if (!cache_check(neighbor_ids
[i
])) {
1936 preload_id_batch
.push(neighbor_ids
[i
]);
1941 if (preload_id_batch
.indexOf(id
) == -1)
1942 preload_id_batch
.push(id
);
1944 //console.log("preload ids batch: " + preload_id_batch.toString());
1946 window
.clearTimeout(preload_timeout_id
);
1947 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1951 exception_error("preloadArticleUnderPointer", e
);
1955 function postMouseIn(id
) {
1957 if (post_under_pointer
!= id
) {
1958 post_under_pointer
= id
;
1960 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1965 exception_error("postMouseIn", e
);
1969 function postMouseOut(id
) {
1971 post_under_pointer
= false;
1973 exception_error("postMouseOut", e
);
1977 function headlines_scroll_handler() {
1980 var e
= $("headlinesInnerContainer");
1982 var toolbar_form
= document
.forms
["main_toolbar_form"];
1984 // console.log((e.scrollTop + e.offsetHeight) + " vs " + e.scrollHeight + " dis? " +
1985 // _infscroll_disable);
1987 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1988 if (!_infscroll_disable
) {
1994 exception_error("headlines_scroll_handler", e
);
1998 function catchupRelativeToArticle(below
) {
2003 if (!getActiveArticleId()) {
2004 alert(__("No article is selected."));
2010 if ($("headlinesList")) {
2011 visible_ids
= getVisibleHeadlineIds();
2013 visible_ids
= cdmGetVisibleArticles();
2016 var ids_to_mark
= new Array();
2019 for (var i
= 0; i
< visible_ids
.length
; i
++) {
2020 if (visible_ids
[i
] != getActiveArticleId()) {
2021 var e
= $("RROW-" + visible_ids
[i
]);
2023 if (e
&& e
.className
.match("Unread")) {
2024 ids_to_mark
.push(visible_ids
[i
]);
2031 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
2032 if (visible_ids
[i
] != getActiveArticleId()) {
2033 var e
= $("RROW-" + visible_ids
[i
]);
2035 if (e
&& e
.className
.match("Unread")) {
2036 ids_to_mark
.push(visible_ids
[i
]);
2044 if (ids_to_mark
.length
== 0) {
2045 alert(__("No articles found to mark"));
2047 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
2049 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
2051 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
2052 var e
= $("RROW-" + ids_to_mark
[i
]);
2053 e
.className
= e
.className
.replace("Unread", "");
2056 var query
= "?op=rpc&subop=catchupSelected" +
2057 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
2059 new Ajax
.Request("backend.php", {
2061 onComplete: function(transport
) {
2062 catchup_callback2(transport
);
2069 exception_error("catchupRelativeToArticle", e
);
2073 function cdmExpandArticle(id
) {
2076 var elem
= $("CICD-" + active_post_id
);
2078 if (id
== active_post_id
&& Element
.visible(elem
))
2081 cdmSelectArticles("none");
2083 var old_offset
= $("RROW-" + id
).offsetTop
;
2085 if (active_post_id
&& elem
) {
2087 Element
.show("CEXC-" + active_post_id
);
2090 active_post_id
= id
;
2092 elem
= $("CICD-" + id
);
2094 if (!Element
.visible(elem
)) {
2096 Element
.hide("CEXC-" + id
);
2099 var new_offset
= $("RROW-" + id
).offsetTop
;
2101 $("headlinesInnerContainer").scrollTop
+= (new_offset
-old_offset
);
2103 if ($("RROW-" + id
).offsetTop
!= old_offset
)
2104 $("headlinesInnerContainer").scrollTop
= new_offset
;
2106 toggleUnread(id
, 0, true);
2110 exception_error("cdmExpandArticle", e
);
2116 function fixHeadlinesOrder(ids
) {
2118 for (var i
= 0; i
< ids
.length
; i
++) {
2119 var e
= $("RROW-" + ids
[i
]);
2123 e
.className
= e
.className
.replace("even", "odd");
2125 e
.className
= e
.className
.replace("odd", "even");
2130 exception_error("fixHeadlinesOrder", e
);
2134 function hideReadHeadlines() {
2138 var vis_ids
= new Array();
2140 if ($("headlinesList")) {
2141 ids
= getVisibleHeadlineIds();
2143 ids
= cdmGetVisibleArticles();
2146 var read_headlines_visible
= true;
2148 for (var i
= 0; i
< ids
.length
; i
++) {
2149 var row
= $("RROW-" + ids
[i
]);
2151 if (row
&& row
.className
) {
2152 if (read_headlines_visible
) {
2153 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2155 vis_ids
.push(ids
[i
]);
2157 //Effect.Fade(row, {duration : 0.3});
2162 vis_ids
.push(ids
[i
]);
2167 fixHeadlinesOrder(vis_ids
);
2169 read_headlines_visible
= !read_headlines_visible
;
2172 exception_error("hideReadHeadlines", e
);
2176 function invertHeadlineSelection() {
2178 var rows
= new Array();
2182 r
= document
.getElementsByTagName("TR");
2184 r
= document
.getElementsByTagName("DIV");
2187 for (var i
= 0; i
< r
.length
; i
++) {
2188 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2193 for (var i
= 0; i
< rows
.length
; i
++) {
2194 var nc
= rows
[i
].className
;
2195 var id
= rows
[i
].id
.replace("RROW-", "");
2196 var cb
= $("RCHK-" + id
);
2198 if (!rows
[i
].className
.match("Selected")) {
2199 nc
= nc
+ "Selected";
2202 nc
= nc
.replace("Selected", "");
2206 rows
[i
].className
= nc
;
2211 exception_error("invertHeadlineSelection", e
);
2215 function getArticleUnderPointer() {
2216 return post_under_pointer
;
2219 function zoomToArticle(id
) {
2221 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2223 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2226 exception_error("zoomToArticle", e
);
2230 function scrollArticle(offset
) {
2233 var ci
= $("content-insert");
2235 ci
.scrollTop
+= offset
;
2238 var hi
= $("headlinesInnerContainer");
2240 hi
.scrollTop
+= offset
;
2245 exception_error("scrollArticle", e
);
2249 function show_labels_in_headlines(transport
) {
2251 if (transport
.responseXML
) {
2252 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2254 var elems
= info
.getElementsByTagName("entry");
2256 for (var l
= 0; l
< elems
.length
; l
++) {
2257 var e_id
= elems
[l
].getAttribute("id");
2261 var ctr
= $("HLLCTR-" + e_id
);
2264 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2272 exception_error("show_labels_in_headlines", e
);
2277 function toggleHeadlineActions() {
2279 var e
= $("headlineActionsBody");
2280 var p
= $("headlineActionsDrop");
2282 if (!Element
.visible(e
)) {
2289 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2290 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2293 exception_error("toggleHeadlineActions", e
);
2297 function publishWithNote(id
, def_note
) {
2299 if (!def_note
) def_note
= '';
2301 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2303 if (note
!= undefined) {
2304 togglePub(id
, false, false, note
);
2308 exception_error("publishWithNote", e
);
2312 function emailArticle(id
) {
2315 var ids
= getSelectedArticleIds2();
2317 if (ids
.length
== 0) {
2318 alert(__("No articles are selected."));
2322 id
= ids
.toString();
2325 displayDlg('emailArticle', id
,
2327 document
.forms
['article_email_form'].destination
.focus();
2329 new Ajax
.Autocompleter('destination', 'destination_choices',
2330 "backend.php?op=rpc&subop=completeEmails",
2331 { tokens
: '', paramName
: "search" });
2336 exception_error("emailArticle", e
);
2340 function emailArticleDo() {
2342 var f
= document
.forms
['article_email_form'];
2344 if (f
.destination
.value
== "") {
2345 alert("Please fill in the destination email.");
2349 if (f
.subject
.value
== "") {
2350 alert("Please fill in the subject.");
2354 var query
= Form
.serialize("article_email_form");
2356 // console.log(query);
2358 new Ajax
.Request("backend.php", {
2360 onComplete: function(transport
) {
2363 var error
= transport
.responseXML
.getElementsByTagName('error')[0];
2366 alert(__('Error sending email:') + ' ' + error
.firstChild
.nodeValue
);
2368 notify_info('Your message has been sent.');
2373 exception_error("sendEmailDo", e
);
2379 exception_error("emailArticleDo", e
);
2383 function cdmDismissArticle(id
) {
2385 var elem
= $("RROW-" + id
);
2387 toggleUnread(id
, 0, true);
2389 new Effect
.Fade(elem
, {duration
: 0.5});
2392 exception_error("cdmDismissArticle", e
);
2396 function cdmDismissSelectedArticles() {
2399 var ids
= getSelectedArticleIds2();
2401 for (var i
= 0; i
< ids
.length
; i
++) {
2402 var elem
= $("RROW-" + ids
[i
]);
2403 new Effect
.Fade(elem
, {duration
: 0.5});
2407 selectionToggleUnread(false);
2410 exception_error("cdmDismissArticle", e
);