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 function catchup_callback2(transport
, callback
) {
20 debug("catchup_callback2 " + transport
+ ", " + callback
);
22 all_counters_callback2(transport
);
24 setTimeout(callback
, 10);
27 exception_error("catchup_callback2", e
, transport
);
31 function clean_feed_selections() {
33 var feeds
= $("feedList").getElementsByTagName("LI");
35 for (var i
= 0; i
< feeds
.length
; i
++) {
36 if (feeds
[i
].id
&& feeds
[i
].id
.match("FEEDR-")) {
37 feeds
[i
].className
= feeds
[i
].className
.replace("Selected", "");
39 if (feeds
[i
].id
&& feeds
[i
].id
.match("FCAT-")) {
40 feeds
[i
].className
= feeds
[i
].className
.replace("Selected", "");
44 exception_error("clean_feed_selections", e
);
48 function headlines_callback2(transport
, feed_cur_page
) {
51 if (!transport
.responseText
&& db
) {
52 offlineConfirmModeChange();
56 loading_set_progress(100);
58 debug("headlines_callback2 [page=" + feed_cur_page
+ "]");
60 if (!transport_error_check(transport
)) return;
62 clean_feed_selections();
67 if (transport
.responseXML
) {
68 var headlines
= transport
.responseXML
.getElementsByTagName("headlines")[0];
70 is_cat
= headlines
.getAttribute("is_cat");
71 feed_id
= headlines
.getAttribute("id");
72 setActiveFeedId(feed_id
, is_cat
);
76 var ll
= $('FLL-' + feed_id
);
79 var feedr
= $("FEEDR-" + feed_id
);
80 if (feedr
&& !feedr
.className
.match("Selected")) {
81 feedr
.className
= feedr
.className
+ "Selected";
83 if (feedr
&& ll
) feedr
.removeChild(ll
);
85 var feedr
= $("FCAT-" + feed_id
);
86 if (feedr
&& !feedr
.className
.match("Selected")) {
87 feedr
.className
= feedr
.className
+ "Selected";
90 var fcap
= $("FCAP-" + feed_id
);
91 if (fcap
&& ll
) fcap
.removeChild(ll
);
95 var img
= $('FIMG-' + feed_id
);
101 var f
= $("headlines-frame");
103 if (feed_cur_page
== 0) {
104 debug("resetting headlines scrollTop");
109 if (transport
.responseXML
) {
110 var headlines
= transport
.responseXML
.getElementsByTagName("headlines")[0];
111 var headlines_count_obj
= transport
.responseXML
.getElementsByTagName("headlines-count")[0];
112 var headlines_unread_obj
= transport
.responseXML
.getElementsByTagName("headlines-unread")[0];
113 var disable_cache_obj
= transport
.responseXML
.getElementsByTagName("disable-cache")[0];
115 var vgroup_last_feed_obj
= transport
.responseXML
.getElementsByTagName("vgroup-last-feed")[0];
117 var headlines_count
= headlines_count_obj
.getAttribute("value");
118 var headlines_unread
= headlines_unread_obj
.getAttribute("value");
119 var disable_cache
= disable_cache_obj
.getAttribute("value") != "0";
121 vgroup_last_feed
= vgroup_last_feed_obj
.getAttribute("value");
123 if (headlines_count
== 0) {
124 _infscroll_disable
= 1;
126 _infscroll_disable
= 0;
129 var counters
= transport
.responseXML
.getElementsByTagName("counters")[0];
130 var articles
= transport
.responseXML
.getElementsByTagName("article");
131 var runtime_info
= transport
.responseXML
.getElementsByTagName("runtime-info");
133 if (feed_cur_page
== 0) {
135 f
.innerHTML
= headlines
.firstChild
.nodeValue
;
137 var cache_prefix
= "";
145 cache_invalidate(cache_prefix
+ feed_id
);
147 if (!disable_cache
) {
148 cache_inject(cache_prefix
+ feed_id
,
149 headlines
.firstChild
.nodeValue
, headlines_unread
);
153 debug("headlines_callback: returned no data");
154 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
159 if (headlines_count
> 0) {
160 debug("adding some more headlines...");
162 var c
= $("headlinesList");
165 c
= $("headlinesInnerContainer");
168 var ids
= getSelectedArticleIds2();
170 c
.innerHTML
= c
.innerHTML
+ headlines
.firstChild
.nodeValue
;
172 debug("restore selected ids: " + ids
);
174 for (var i
= 0; i
< ids
.length
; i
++) {
175 markHeadline(ids
[i
]);
179 debug("no new headlines received");
182 debug("headlines_callback: returned no data");
183 notify_error("Error while trying to load more headlines");
189 for (var i
= 0; i
< articles
.length
; i
++) {
190 var a_id
= articles
[i
].getAttribute("id");
191 debug("found id: " + a_id
);
192 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
195 debug("no cached articles received");
199 debug("parsing piggybacked counters: " + counters
);
200 parse_counters(counters
, false);
202 debug("counters container not found in reply, requesting...");
207 debug("parsing runtime info: " + runtime_info
[0]);
208 parse_runtime_info(runtime_info
[0]);
210 debug("counters container not found in reply");
214 debug("headlines_callback: returned no XML object");
215 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
218 if (typeof correctPNG
!= 'undefined') {
222 if (_cdm_wd_timeout
) window
.clearTimeout(_cdm_wd_timeout
);
224 if (!$("headlinesList") &&
225 getActiveFeedId() != -3 &&
226 getInitParam("cdm_auto_catchup") == 1) {
227 debug("starting CDM watchdog");
228 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 5000);
229 _cdm_wd_vishist
= new Array();
231 debug("not in CDM mode or watchdog disabled");
234 _feed_cur_page
= feed_cur_page
;
235 _infscroll_request_sent
= 0;
242 exception_error("headlines_callback2", e
, transport
);
246 function render_article(article
) {
248 var f
= $("content-frame");
253 var fi
= $("content-insert");
259 fi
.innerHTML
= article
;
261 // article.evalScripts();
264 exception_error("render_article", e
);
268 function showArticleInHeadlines(id
) {
272 cleanSelected("headlinesList");
274 var crow
= $("RROW-" + id
);
278 var article_is_unread
= crow
.className
.match("Unread");
280 crow
.className
= crow
.className
.replace("Unread", "");
282 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
284 var upd_img_pic
= $("FUPDPIC-" + id
);
286 var cache_prefix
= "";
288 if (activeFeedIsCat()) {
294 var view_mode
= false;
297 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
298 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
303 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
304 upd_img_pic
.src
.match("fresh_sign.png"))) {
306 upd_img_pic
.src
= "images/blank_icon.gif";
308 cache_invalidate(cache_prefix
+ getActiveFeedId());
310 cache_inject(cache_prefix
+ getActiveFeedId(),
311 $("headlines-frame").innerHTML
,
312 get_feed_unread(getActiveFeedId()));
314 } else if (article_is_unread
&& view_mode
== "all_articles") {
316 cache_invalidate(cache_prefix
+ getActiveFeedId());
318 cache_inject(cache_prefix
+ getActiveFeedId(),
319 $("headlines-frame").innerHTML
,
320 get_feed_unread(getActiveFeedId())-1);
322 } else if (article_is_unread
) {
323 cache_invalidate(cache_prefix
+ getActiveFeedId());
329 exception_error("showArticleInHeadlines", e
);
333 function article_callback2(transport
, id
) {
335 debug("article_callback2 " + id
);
337 if (!transport
.responseText
&& db
) {
338 offlineConfirmModeChange();
342 if (transport
.responseXML
) {
344 if (!transport_error_check(transport
)) return;
346 /* var ll = $('LL-' + id);
347 var content = $('HLC-' + id);
349 if (ll && content) content.removeChild(ll); */
351 var upic
= $('FUPDPIC-' + id
);
354 upic
.src
= 'images/blank_icon.gif';
357 if (id
!= last_requested_article
) {
358 debug("requested article id is out of sequence, aborting");
364 debug("looking for articles to cache...");
366 var articles
= transport
.responseXML
.getElementsByTagName("article");
368 for (var i
= 0; i
< articles
.length
; i
++) {
369 var a_id
= articles
[i
].getAttribute("id");
371 debug("found id: " + a_id
);
373 if (a_id
== active_post_id
) {
374 debug("active article, rendering...");
375 render_article(articles
[i
].firstChild
.nodeValue
);
378 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
382 showArticleInHeadlines(id
);
385 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?", [id
]);
388 var reply
= transport
.responseXML
.firstChild
.firstChild
;
391 debug("article_callback: returned no XML object");
392 //var f = $("content-frame");
393 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
396 var date
= new Date();
397 last_article_view
= date
.getTime() / 1000;
399 if (typeof correctPNG
!= 'undefined') {
403 if (_reload_feedlist_after_view
) {
404 setTimeout('updateFeedList(false, false)', 50);
405 _reload_feedlist_after_view
= false;
407 if (transport
.responseXML
) {
408 var counters
= transport
.responseXML
.getElementsByTagName("counters")[0];
411 debug("parsing piggybacked counters: " + counters
);
412 parse_counters(counters
, false);
414 debug("counters container not found in reply, requesting...");
422 exception_error("article_callback2", e
, transport
);
428 debug("loading article: " + id
);
430 if (offline_mode
) return view_offline(id
);
432 var cached_article
= cache_find(id
);
434 debug("cache check result: " + (cached_article
!= false));
439 var query
= "?op=view&id=" + param_escape(id
);
441 var neighbor_ids
= getRelativePostIds(active_post_id
);
443 /* only request uncached articles */
445 var cids_to_request
= Array();
447 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
448 if (!cache_check(neighbor_ids
[i
])) {
449 cids_to_request
.push(neighbor_ids
[i
]);
453 debug("additional ids: " + cids_to_request
.toString());
455 /* additional info for piggyback counters */
457 if (tagsAreDisplayed()) {
458 query
= query
+ "&omode=lt";
460 query
= query
+ "&omode=flc";
463 query
= query
+ "&cids=" + cids_to_request
.toString();
465 var crow
= $("RROW-" + id
);
466 var article_is_unread
= crow
.className
.match("Unread");
468 if (!async_counters_work
) {
469 query
= query
+ "&csync=true";
472 showArticleInHeadlines(id
);
474 if (!cached_article
) {
476 // notify_progress("Loading, please wait...", true);
478 /* var content = $('HLC-' + id);
480 if (content && !$('LL-' + id)) {
481 var ll = document.createElement('img');
483 ll.src = 'images/indicator_tiny.gif';
484 ll.className = 'hlLoading';
487 content.appendChild(ll);
491 var upic
= $('FUPDPIC-' + id
);
494 upic
.src
= getInitParam("sign_progress");
497 } else if (cached_article
&& article_is_unread
) {
499 query
= query
+ "&mode=prefetch";
501 render_article(cached_article
);
503 } else if (cached_article
) {
505 query
= query
+ "&mode=prefetch_old";
506 render_article(cached_article
);
512 last_requested_article
= id
;
514 new Ajax
.Request("backend.php", {
516 onComplete: function(transport
) {
517 article_callback2(transport
, id
);
523 exception_error("view", e
);
528 return toggleMark(id
);
532 return togglePub(id
);
535 function tMark_afh_off(effect
) {
537 var elem
= effect
.effects
[0].element
;
539 debug("tMark_afh_off : " + elem
.id
);
542 elem
.src
= elem
.src
.replace("mark_set", "mark_unset");
543 elem
.alt
= __("Star article");
548 exception_error("tMark_afh_off", e
);
552 function tPub_afh_off(effect
) {
554 var elem
= effect
.effects
[0].element
;
556 debug("tPub_afh_off : " + elem
.id
);
559 elem
.src
= elem
.src
.replace("pub_set", "pub_unset");
560 elem
.alt
= __("Publish article");
565 exception_error("tPub_afh_off", e
);
569 function toggleMark(id
, client_only
, no_effects
) {
573 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
575 query
= query
+ "&afid=" + getActiveFeedId();
577 if (tagsAreDisplayed()) {
578 query
= query
+ "&omode=tl";
580 query
= query
+ "&omode=flc";
583 var mark_img
= $("FMPIC-" + id
);
585 if (!mark_img
) return;
587 var vfeedu
= $("FEEDU--1");
588 var crow
= $("RROW-" + id
);
590 if (mark_img
.src
.match("mark_unset")) {
591 mark_img
.src
= mark_img
.src
.replace("mark_unset", "mark_set");
592 mark_img
.alt
= __("Unstar article");
593 query
= query
+ "&mark=1";
596 db
.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id
]);
600 //mark_img.src = "images/mark_unset.png";
601 mark_img
.alt
= __("Please wait...");
602 query
= query
+ "&mark=0";
604 if ($("headlinesList") && !no_effects
) {
605 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tMark_afh_off
});
607 mark_img
.src
= mark_img
.src
.replace("mark_set", "mark_unset");
608 mark_img
.alt
= __("Star article");
612 db
.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id
]);
617 if (!no_effects
) update_local_feedlist_counters();
622 new Ajax
.Request("backend.php", {
624 onComplete: function(transport
) {
625 all_counters_callback2(transport
);
631 exception_error("toggleMark", e
);
635 function togglePub(id
, client_only
, no_effects
, note
) {
639 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
641 query
= query
+ "&afid=" + getActiveFeedId();
643 if (note
!= undefined) {
644 query
= query
+ "¬e=" + param_escape(note
);
646 query
= query
+ "¬e=undefined";
649 if (tagsAreDisplayed()) {
650 query
= query
+ "&omode=tl";
652 query
= query
+ "&omode=flc";
655 var mark_img
= $("FPPIC-" + id
);
657 if (!mark_img
) return;
659 var vfeedu
= $("FEEDU--2");
660 var crow
= $("RROW-" + id
);
662 if (mark_img
.src
.match("pub_unset") || note
!= undefined) {
663 mark_img
.src
= mark_img
.src
.replace("pub_unset", "pub_set");
664 mark_img
.alt
= __("Unpublish article");
665 query
= query
+ "&pub=1";
668 //mark_img.src = "images/pub_unset.png";
669 mark_img
.alt
= __("Please wait...");
670 query
= query
+ "&pub=0";
672 if ($("headlinesList") && !no_effects
) {
673 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tPub_afh_off
});
675 mark_img
.src
= mark_img
.src
.replace("pub_set", "pub_unset");
676 mark_img
.alt
= __("Publish article");
681 new Ajax
.Request("backend.php", {
683 onComplete: function(transport
) {
684 all_counters_callback2(transport
);
686 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
689 var note_id
= note
.getAttribute("id");
690 var note_size
= note
.getAttribute("size");
691 var note_content
= note
.firstChild
.nodeValue
;
693 var container
= $('POSTNOTE-' + note_id
);
695 cache_invalidate(note_id
);
698 if (note_size
== "0") {
699 Element
.hide(container
);
701 container
.innerHTML
= note_content
;
702 Element
.show(container
);
711 exception_error("togglePub", e
);
715 function correctHeadlinesOffset(id
) {
719 var hlist
= $("headlinesList");
720 var container
= $("headlinesInnerContainer");
721 var row
= $("RROW-" + id
);
723 var viewport
= container
.offsetHeight
;
725 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
726 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
728 debug("Rtop: " + rel_offset_top
+ " Rbtm: " + rel_offset_bottom
);
729 debug("Vport: " + viewport
);
731 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
732 container
.scrollTop
= row
.offsetTop
;
733 } else if (rel_offset_bottom
> viewport
) {
735 /* doesn't properly work with Opera in some cases because
736 Opera fucks up element scrolling */
738 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
742 exception_error("correctHeadlinesOffset", e
);
747 function moveToPost(mode
) {
754 rows
= cdmGetVisibleArticles();
756 rows
= getVisibleHeadlineIds();
762 if (!$('RROW-' + active_post_id
)) {
763 active_post_id
= false;
766 if (active_post_id
== false) {
767 next_id
= getFirstVisibleHeadlineId();
768 prev_id
= getLastVisibleHeadlineId();
770 for (var i
= 0; i
< rows
.length
; i
++) {
771 if (rows
[i
] == active_post_id
) {
778 if (mode
== "next") {
782 if (!cdmArticleIsActuallyVisible(next_id
)) {
783 cdmScrollToArticleId(next_id
);
785 cdmSelectArticles("none");
786 toggleUnread(next_id
, 0, true);
787 toggleSelected(next_id
);
790 correctHeadlinesOffset(next_id
);
791 view(next_id
, getActiveFeedId());
796 if (mode
== "prev") {
799 cdmScrollToArticleId(prev_id
);
800 cdmSelectArticles("none");
801 toggleUnread(prev_id
, 0, true);
802 toggleSelected(prev_id
);
804 correctHeadlinesOffset(prev_id
);
805 view(prev_id
, getActiveFeedId());
811 exception_error("moveToPost", e
);
815 function toggleSelected(id
) {
818 var cb
= $("RCHK-" + id
);
820 var row
= $("RROW-" + id
);
822 var nc
= row
.className
;
824 if (!nc
.match("Selected")) {
825 nc
= nc
+ "Selected";
830 // In CDM basically last selected article == active article
831 if (isCdmMode()) active_post_id
= id
;
833 nc
= nc
.replace("Selected", "");
843 exception_error("toggleSelected", e
);
847 function toggleUnread_afh(effect
) {
850 var elem
= effect
.element
;
851 elem
.style
.backgroundColor
= "";
854 exception_error("toggleUnread_afh", e
);
858 function toggleUnread(id
, cmode
, effect
) {
861 var row
= $("RROW-" + id
);
863 var nc
= row
.className
;
864 var is_selected
= row
.className
.match("Selected");
865 nc
= nc
.replace("Unread", "");
866 nc
= nc
.replace("Selected", "");
868 // since we are removing selection from the object, uncheck
869 // corresponding checkbox
871 var cb
= $("RCHK-" + id
);
876 // NOTE: I'm not sure that resetting selection here is a feature -fox
878 if (cmode
== undefined || cmode
== 2) {
879 if (row
.className
.match("Unread")) {
883 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
884 afterFinish
: toggleUnread_afh
,
885 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
889 row
.className
= nc
+ "Unread";
893 db
.execute("UPDATE articles SET unread = not unread "+
894 "WHERE id = ?", [id
]);
897 } else if (cmode
== 0) {
901 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
902 afterFinish
: toggleUnread_afh
,
903 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
907 db
.execute("UPDATE articles SET unread = 0 "+
908 "WHERE id = ?", [id
]);
911 } else if (cmode
== 1) {
912 row
.className
= nc
+ "Unread";
915 db
.execute("UPDATE articles SET unread = 1 "+
916 "WHERE id = ?", [id
]);
921 update_local_feedlist_counters();
923 // Disable unmarking as selected for the time being (16.05.08) -fox
924 if (is_selected
) row
.className
= row
.className
+ "Selected";
926 if (cmode
== undefined) cmode
= 2;
928 var query
= "?op=rpc&subop=catchupSelected" +
929 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
931 // notify_progress("Loading, please wait...");
933 new Ajax
.Request("backend.php", {
935 onComplete: function(transport
) {
936 all_counters_callback2(transport
);
942 exception_error("toggleUnread", e
);
946 function selectionRemoveLabel(id
) {
949 var ids
= getSelectedArticleIds2();
951 if (ids
.length
== 0) {
952 alert(__("No articles are selected."));
956 // var ok = confirm(__("Remove selected articles from label?"));
960 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
961 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
963 // notify_progress("Loading, please wait...");
965 cache_invalidate("F:" + (-11 - id
));
967 new Ajax
.Request("backend.php", {
969 onComplete: function(transport
) {
970 show_labels_in_headlines(transport
);
971 all_counters_callback2(transport
);
977 exception_error("selectionAssignLabel", e
);
982 function selectionAssignLabel(id
) {
985 var ids
= getSelectedArticleIds2();
987 if (ids
.length
== 0) {
988 alert(__("No articles are selected."));
992 // var ok = confirm(__("Assign selected articles to label?"));
996 cache_invalidate("F:" + (-11 - id
));
998 var query
= "?op=rpc&subop=assignToLabel&ids=" +
999 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
1001 // notify_progress("Loading, please wait...");
1003 new Ajax
.Request("backend.php", {
1005 onComplete: function(transport
) {
1006 show_labels_in_headlines(transport
);
1007 all_counters_callback2(transport
);
1013 exception_error("selectionAssignLabel", e
);
1018 function selectionToggleUnread(cdm_mode
, set_state
, callback_func
, no_error
) {
1023 rows
= cdmGetSelectedArticles();
1025 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1028 if (rows
.length
== 0 && !no_error
) {
1029 alert(__("No articles are selected."));
1033 for (i
= 0; i
< rows
.length
; i
++) {
1034 var row
= $("RROW-" + rows
[i
]);
1036 var nc
= row
.className
;
1037 nc
= nc
.replace("Unread", "");
1038 nc
= nc
.replace("Selected", "");
1040 if (set_state
== undefined) {
1041 if (row
.className
.match("Unread")) {
1042 row
.className
= nc
+ "Selected";
1044 row
.className
= nc
+ "UnreadSelected";
1047 db
.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
1052 if (set_state
== false) {
1053 row
.className
= nc
+ "Selected";
1055 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?",
1060 if (set_state
== true) {
1061 row
.className
= nc
+ "UnreadSelected";
1063 db
.execute("UPDATE articles SET unread = 1 WHERE id = ?",
1070 if (rows
.length
> 0) {
1072 update_local_feedlist_counters();
1076 if (set_state
== undefined) {
1078 } else if (set_state
== true) {
1080 } else if (set_state
== false) {
1084 var query
= "?op=rpc&subop=catchupSelected" +
1085 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
1087 notify_progress("Loading, please wait...");
1089 new Ajax
.Request("backend.php", {
1091 onComplete: function(transport
) {
1092 catchup_callback2(transport
, callback_func
);
1098 exception_error("selectionToggleUnread", e
);
1102 function selectionToggleMarked(cdm_mode
) {
1108 rows
= cdmGetSelectedArticles();
1110 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1113 if (rows
.length
== 0) {
1114 alert(__("No articles are selected."));
1118 for (i
= 0; i
< rows
.length
; i
++) {
1119 toggleMark(rows
[i
], true, true);
1122 update_local_feedlist_counters();
1124 if (rows
.length
> 0) {
1126 var query
= "?op=rpc&subop=markSelected&ids=" +
1127 param_escape(rows
.toString()) + "&cmode=2";
1129 query
= query
+ "&afid=" + getActiveFeedId();
1131 /* if (tagsAreDisplayed()) {
1132 query = query + "&omode=tl";
1134 query = query + "&omode=flc";
1137 query
= query
+ "&omode=lc";
1139 new Ajax
.Request("backend.php", {
1141 onComplete: function(transport
) {
1142 all_counters_callback2(transport
);
1148 exception_error("selectionToggleMarked", e
);
1152 function selectionTogglePublished(cdm_mode
) {
1158 rows
= cdmGetSelectedArticles();
1160 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1163 if (rows
.length
== 0) {
1164 alert(__("No articles are selected."));
1168 for (i
= 0; i
< rows
.length
; i
++) {
1169 togglePub(rows
[i
], true, true);
1172 if (rows
.length
> 0) {
1174 var query
= "?op=rpc&subop=publishSelected&ids=" +
1175 param_escape(rows
.toString()) + "&cmode=2";
1177 query
= query
+ "&afid=" + getActiveFeedId();
1179 /* if (tagsAreDisplayed()) {
1180 query = query + "&omode=tl";
1182 query = query + "&omode=flc";
1185 query
= query
+ "&omode=lc";
1187 new Ajax
.Request("backend.php", {
1189 onComplete: function(transport
) {
1190 all_counters_callback2(transport
);
1196 exception_error("selectionToggleMarked", e
);
1200 function cdmGetSelectedArticles() {
1201 var sel_articles
= new Array();
1202 var container
= $("headlinesInnerContainer");
1204 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1205 var child
= container
.childNodes
[i
];
1207 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Selected")) {
1208 var c_id
= child
.id
.replace("RROW-", "");
1209 sel_articles
.push(c_id
);
1213 return sel_articles
;
1216 function cdmGetVisibleArticles() {
1217 var sel_articles
= new Array();
1218 var container
= $("headlinesInnerContainer");
1220 if (!container
) return sel_articles
;
1222 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1223 var child
= container
.childNodes
[i
];
1225 if (child
.id
&& child
.id
.match("RROW-")) {
1226 var c_id
= child
.id
.replace("RROW-", "");
1227 sel_articles
.push(c_id
);
1231 return sel_articles
;
1234 function cdmGetUnreadArticles() {
1235 var sel_articles
= new Array();
1236 var container
= $("headlinesInnerContainer");
1238 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1239 var child
= container
.childNodes
[i
];
1241 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Unread")) {
1242 var c_id
= child
.id
.replace("RROW-", "");
1243 sel_articles
.push(c_id
);
1247 return sel_articles
;
1251 // mode = all,none,unread
1252 function cdmSelectArticles(mode
) {
1253 var container
= $("headlinesInnerContainer");
1255 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1256 var child
= container
.childNodes
[i
];
1258 if (child
.id
&& child
.id
.match("RROW-")) {
1259 var aid
= child
.id
.replace("RROW-", "");
1261 var cb
= $("RCHK-" + aid
);
1263 if (mode
== "all") {
1264 if (!child
.className
.match("Selected")) {
1265 child
.className
= child
.className
+ "Selected";
1268 } else if (mode
== "unread") {
1269 if (child
.className
.match("Unread") && !child
.className
.match("Selected")) {
1270 child
.className
= child
.className
+ "Selected";
1274 child
.className
= child
.className
.replace("Selected", "");
1281 function catchupPage() {
1283 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1285 var str
= __("Mark all visible articles in %s as read?");
1287 str
= str
.replace("%s", fn
);
1289 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1293 if ($("headlinesList")) {
1294 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
1295 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1296 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1298 cdmSelectArticles('all');
1299 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1300 cdmSelectArticles('none');
1304 function deleteSelection() {
1310 if ($("headlinesList")) {
1311 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1313 rows
= cdmGetSelectedArticles();
1316 if (rows
.length
== 0) {
1317 alert(__("No articles are selected."));
1322 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1326 if (getActiveFeedId() != 0) {
1327 str
= __("Delete %d selected articles in %s?");
1329 str
= __("Delete %d selected articles?");
1332 str
= str
.replace("%d", rows
.length
);
1333 str
= str
.replace("%s", fn
);
1335 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1339 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
1343 new Ajax
.Request("backend.php", {
1345 onComplete: function(transport
) {
1350 exception_error("deleteSelection", e
);
1354 function archiveSelection() {
1360 if ($("headlinesList")) {
1361 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1363 rows
= cdmGetSelectedArticles();
1366 if (rows
.length
== 0) {
1367 alert(__("No articles are selected."));
1372 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1376 if (getActiveFeedId() != 0) {
1377 str
= __("Archive %d selected articles in %s?");
1380 str
= __("Move %d archived articles back?");
1384 str
= str
.replace("%d", rows
.length
);
1385 str
= str
.replace("%s", fn
);
1387 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1391 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1395 for (var i
= 0; i
< rows
.length
; i
++) {
1396 cache_invalidate(rows
[i
]);
1399 new Ajax
.Request("backend.php", {
1401 onComplete: function(transport
) {
1406 exception_error("archiveSelection", e
);
1410 function catchupSelection() {
1416 if ($("headlinesList")) {
1417 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1419 rows
= cdmGetSelectedArticles();
1422 if (rows
.length
== 0) {
1423 alert(__("No articles are selected."));
1428 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1430 var str
= __("Mark %d selected articles in %s as read?");
1432 str
= str
.replace("%d", rows
.length
);
1433 str
= str
.replace("%s", fn
);
1435 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1439 if ($("headlinesList")) {
1440 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1441 // selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1443 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1444 // cdmSelectArticles('none');
1448 exception_error("catchupSelection", e
);
1452 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1453 displayDlg('editArticleTags', id
,
1455 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1456 "backend.php?op=rpc&subop=completeTags",
1457 { tokens
: ',', paramName
: "search" });
1461 function editTagsSave() {
1463 notify_progress("Saving article tags...");
1465 var form
= document
.forms
["tag_edit_form"];
1467 var query
= Form
.serialize("tag_edit_form");
1469 query
= "?op=rpc&subop=setArticleTags&" + query
;
1473 new Ajax
.Request("backend.php", {
1475 onComplete: function(transport
) {
1477 debug("tags saved...");
1482 if (tagsAreDisplayed()) {
1483 _reload_feedlist_after_view
= true;
1486 if (transport
.responseXML
) {
1487 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1490 var id
= tags_str
.getAttribute("id");
1493 var tags
= $("ATSTR-" + id
);
1495 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1498 cache_invalidate(id
);
1504 exception_error("editTagsSave", e
);
1509 function editTagsInsert() {
1512 var form
= document
.forms
["tag_edit_form"];
1514 var found_tags
= form
.found_tags
;
1515 var tags_str
= form
.tags_str
;
1517 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1519 if (tags_str
.value
.length
> 0 &&
1520 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1522 tags_str
.value
= tags_str
.value
+ ", ";
1525 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1527 found_tags
.selectedIndex
= 0;
1530 exception_error("editTagsInsert", e
);
1534 function cdmScrollViewport(where
) {
1535 debug("cdmScrollViewport: " + where
);
1537 var ctr
= $("headlinesInnerContainer");
1541 if (where
== "bottom") {
1542 ctr
.scrollTop
= ctr
.scrollHeight
;
1544 ctr
.scrollTop
= where
;
1548 function cdmArticleIsBelowViewport(id
) {
1550 var ctr
= $("headlinesInnerContainer");
1551 var e
= $("RROW-" + id
);
1553 if (!e
|| !ctr
) return;
1555 // article starts below viewport
1557 if (ctr
.scrollTop
< e
.offsetTop
) {
1564 exception_error("cdmArticleIsVisible", e
);
1568 function cdmArticleIsAboveViewport(id
) {
1570 var ctr
= $("headlinesInnerContainer");
1571 var e
= $("RROW-" + id
);
1573 if (!e
|| !ctr
) return;
1575 // article starts above viewport
1577 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1584 exception_error("cdmArticleIsVisible", e
);
1588 function cdmScrollToArticleId(id
) {
1590 var ctr
= $("headlinesInnerContainer");
1591 var e
= $("RROW-" + id
);
1593 if (!e
|| !ctr
) return;
1595 ctr
.scrollTop
= e
.offsetTop
;
1598 exception_error("cdmScrollToArticleId", e
);
1602 function cdmArticleIsActuallyVisible(id
) {
1604 var ctr
= $("headlinesInnerContainer");
1605 var e
= $("RROW-" + id
);
1607 if (!e
|| !ctr
) return;
1609 // article fits in viewport OR article is longer than viewport and
1610 // its bottom is visible
1612 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1613 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1617 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1618 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1619 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1628 exception_error("cdmArticleIsVisible", e
);
1632 function cdmWatchdog() {
1636 var ctr
= $("headlinesInnerContainer");
1640 var ids
= new Array();
1642 var e
= ctr
.firstChild
;
1645 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1646 e
.id
.match("RROW-")) {
1648 // article fits in viewport OR article is longer than viewport and
1649 // its bottom is visible
1651 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1652 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1654 // debug(e.id + " is visible " + e.offsetTop + "." +
1655 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1656 // (ctr.scrollTop + ctr.offsetHeight));
1658 ids
.push(e
.id
.replace("RROW-", ""));
1660 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1661 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1662 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1664 ids
.push(e
.id
.replace("RROW-", ""));
1668 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1670 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1671 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1673 ids.push(e.id.replace("RROW-", ""));
1682 debug("cdmWatchdog, ids= " + ids
.toString());
1684 if (ids
.length
> 0) {
1686 for (var i
= 0; i
< ids
.length
; i
++) {
1687 var e
= $("RROW-" + ids
[i
]);
1689 e
.className
= e
.className
.replace("Unread", "");
1693 var query
= "?op=rpc&subop=catchupSelected" +
1694 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1696 new Ajax
.Request("backend.php", {
1698 onComplete: function(transport
) {
1699 all_counters_callback2(transport
);
1704 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1707 exception_error("cdmWatchdog", e
);
1713 function cache_inject(id
, article
, param
) {
1715 if (!cache_check_param(id
, param
)) {
1716 debug("cache_article: miss: " + id
+ " [p=" + param
+ "]");
1720 var date
= new Date();
1721 var ts
= Math
.round(date
.getTime() / 1000);
1723 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1724 [id
, article
, param
, ts
]);
1727 var cache_obj
= new Array();
1729 cache_obj
["id"] = id
;
1730 cache_obj
["data"] = article
;
1731 cache_obj
["param"] = param
;
1733 article_cache
.push(cache_obj
);
1737 debug("cache_article: hit: " + id
+ " [p=" + param
+ "]");
1740 exception_error("cache_inject", e
);
1744 function cache_find(id
) {
1747 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1750 if (rs
.isValidRow()) {
1751 var a
= rs
.field(0);
1759 for (var i
= 0; i
< article_cache
.length
; i
++) {
1760 if (article_cache
[i
]["id"] == id
) {
1761 return article_cache
[i
]["data"];
1768 function cache_find_param(id
, param
) {
1771 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1775 if (rs
.isValidRow()) {
1784 for (var i
= 0; i
< article_cache
.length
; i
++) {
1785 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1786 return article_cache
[i
]["data"];
1793 function cache_check(id
) {
1796 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1800 if (rs
.isValidRow()) {
1801 a
= rs
.field(0) != "0";
1809 for (var i
= 0; i
< article_cache
.length
; i
++) {
1810 if (article_cache
[i
]["id"] == id
) {
1818 function cache_check_param(id
, param
) {
1821 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1825 if (rs
.isValidRow()) {
1826 a
= rs
.field(0) != "0";
1834 for (var i
= 0; i
< article_cache
.length
; i
++) {
1835 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1843 function cache_expire() {
1845 var date
= new Date();
1846 var ts
= Math
.round(date
.getTime() / 1000);
1848 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1849 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1850 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1854 while (article_cache
.length
> 25) {
1855 article_cache
.shift();
1860 function cache_flush() {
1861 article_cache
= new Array();
1864 function cache_invalidate(id
) {
1868 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1869 return rs
.rowsAffected
!= 0;
1874 while (i
< article_cache
.length
) {
1875 if (article_cache
[i
]["id"] == id
) {
1876 debug("cache_invalidate: removed id " + id
);
1877 article_cache
.splice(i
, 1);
1884 debug("cache_invalidate: id not found: " + id
);
1887 exception_error("cache_invalidate", e
);
1891 function getActiveArticleId() {
1892 return active_post_id
;
1895 function cdmClicked(id
) {
1897 var elem
= $("RROW-" + id
);
1900 var id
= elem
.id
.replace("RROW-", "");
1901 active_post_id
= id
;
1903 // cdmSelectArticles("none");
1904 toggleUnread(id
, 0, true);
1905 // toggleSelected(id);
1909 exception_error("cdmClicked", e
);
1913 function preloadArticleUnderPointer(id
) {
1915 if (getInitParam("bw_limit") == "1") return;
1917 if (post_under_pointer
== id
&& !cache_check(id
)) {
1919 debug("trying to preload article " + id
);
1921 var neighbor_ids
= getRelativePostIds(id
, 1);
1923 /* only request uncached articles */
1925 var cids_to_request
= Array();
1927 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1928 if (!cache_check(neighbor_ids
[i
])) {
1929 cids_to_request
.push(neighbor_ids
[i
]);
1932 debug("additional ids: " + cids_to_request
.toString());
1934 cids_to_request
.push(id
);
1936 var query
= "?op=rpc&subop=getArticles&ids=" +
1937 cids_to_request
.toString();
1939 new Ajax
.Request("backend.php", {
1941 onComplete: function(transport
) {
1942 var articles
= transport
.responseXML
.getElementsByTagName("article");
1944 for (var i
= 0; i
< articles
.length
; i
++) {
1945 var id
= articles
[i
].getAttribute("id");
1946 if (!cache_check(id
)) {
1947 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1948 debug("preloaded article: " + id
);
1954 exception_error("preloadArticleUnderPointer", e
);
1958 function postMouseIn(id
) {
1960 if (post_under_pointer
!= id
) {
1961 post_under_pointer
= id
;
1963 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1968 exception_error("postMouseIn", e
);
1972 function postMouseOut(id
) {
1974 post_under_pointer
= false;
1976 exception_error("postMouseOut", e
);
1980 function headlines_scroll_handler() {
1983 var e
= $("headlinesInnerContainer");
1985 var toolbar_form
= document
.forms
["main_toolbar_form"];
1987 debug((e
.scrollTop
+ e
.offsetHeight
) + " vs " + e
.scrollHeight
+ " dis? " +
1988 _infscroll_disable
);
1990 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1991 if (!_infscroll_disable
) {
1992 debug("more cowbell!");
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
);
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(a_id
) {
2079 var id
= 'CICD-' + a_id
;
2082 Element
.hide("CEXC-" + a_id
);
2085 Effect
.Appear(id
, {duration
: 0.5,
2086 beforeStart: function(effect
) {
2087 var h_id
= 'CICH-' + a_id
;
2088 var h_elem
= $(h_id
);
2089 if (h_elem
) { h_elem
.style
.display
= "none"; }
2091 toggleUnread(a_id
, 0);
2096 exception_error("appearBlockElementF", e
);
2101 function fixHeadlinesOrder(ids
) {
2103 for (var i
= 0; i
< ids
.length
; i
++) {
2104 var e
= $("RROW-" + ids
[i
]);
2108 e
.className
= e
.className
.replace("even", "odd");
2110 e
.className
= e
.className
.replace("odd", "even");
2115 exception_error("fixHeadlinesOrder", e
);
2119 function hideReadHeadlines() {
2123 var vis_ids
= new Array();
2125 if ($("headlinesList")) {
2126 ids
= getVisibleHeadlineIds();
2128 ids
= cdmGetVisibleArticles();
2131 var read_headlines_visible
= true;
2133 for (var i
= 0; i
< ids
.length
; i
++) {
2134 var row
= $("RROW-" + ids
[i
]);
2136 if (row
&& row
.className
) {
2137 if (read_headlines_visible
) {
2138 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2140 vis_ids
.push(ids
[i
]);
2142 //Effect.Fade(row, {duration : 0.3});
2147 vis_ids
.push(ids
[i
]);
2152 fixHeadlinesOrder(vis_ids
);
2154 read_headlines_visible
= !read_headlines_visible
;
2157 exception_error("hideReadHeadlines", e
);
2161 function invertHeadlineSelection() {
2163 var rows
= new Array();
2167 r
= document
.getElementsByTagName("TR");
2169 r
= document
.getElementsByTagName("DIV");
2172 for (var i
= 0; i
< r
.length
; i
++) {
2173 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2178 for (var i
= 0; i
< rows
.length
; i
++) {
2179 var nc
= rows
[i
].className
;
2180 var id
= rows
[i
].id
.replace("RROW-", "");
2181 var cb
= $("RCHK-" + id
);
2183 if (!rows
[i
].className
.match("Selected")) {
2184 nc
= nc
+ "Selected";
2187 nc
= nc
.replace("Selected", "");
2191 rows
[i
].className
= nc
;
2196 exception_error("invertHeadlineSelection", e
);
2200 function getArticleUnderPointer() {
2201 return post_under_pointer
;
2204 function zoomToArticle(id
) {
2206 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2208 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2211 exception_error("zoomToArticle", e
);
2215 function showOriginalArticleInline(id
) {
2218 var query
= "?op=rpc&subop=getArticleLink&id=" + id
;
2220 notify_progress("Loading, please wait...", true);
2222 new Ajax
.Request("backend.php", {
2224 onComplete: function(transport
) {
2226 if (transport
.responseXML
) {
2228 var link
= transport
.responseXML
.getElementsByTagName("link")[0];
2229 var id
= transport
.responseXML
.getElementsByTagName("id")[0];
2234 link
= link
.firstChild
.nodeValue
;
2236 var ci
= $("content-insert");
2238 var tmp
= "<iframe id=\"inline_orig_article\" width=\""+ci
.offsetWidth
+"\" height=\""+ci
.offsetHeight
+"\" style=\"border-width : 0px;\" src=\""+link
+"\"></iframe>";
2240 render_article(tmp
);
2247 exception_error("showOriginalArticleInline", e
);
2252 function scrollArticle(offset
) {
2255 var ci
= $("content-insert");
2257 ci
.scrollTop
+= offset
;
2260 var hi
= $("headlinesInnerContainer");
2262 hi
.scrollTop
+= offset
;
2267 exception_error("scrollArticle", e
);
2271 function show_labels_in_headlines(transport
) {
2273 if (transport
.responseXML
) {
2274 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2276 var elems
= info
.getElementsByTagName("entry");
2278 for (var l
= 0; l
< elems
.length
; l
++) {
2279 var e_id
= elems
[l
].getAttribute("id");
2283 var ctr
= $("HLLCTR-" + e_id
);
2286 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2294 exception_error("show_labels_in_headlines", e
);
2299 function toggleHeadlineActions() {
2301 var e
= $("headlineActionsBody");
2302 var p
= $("headlineActionsDrop");
2304 if (!Element
.visible(e
)) {
2311 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2312 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2315 exception_error("toggleHeadlineActions", e
);
2319 function publishWithNote(id
, def_note
) {
2321 if (!def_note
) def_note
= '';
2323 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2325 if (note
!= undefined) {
2326 togglePub(id
, false, false, note
);
2330 exception_error("publishWithNote", e
);