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 date
= new Date();
443 var neighbor_ids
= getRelativePostIds(active_post_id
);
445 /* only request uncached articles */
447 var cids_to_request
= Array();
449 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
450 if (!cache_check(neighbor_ids
[i
])) {
451 cids_to_request
.push(neighbor_ids
[i
]);
455 debug("additional ids: " + cids_to_request
.toString());
457 /* additional info for piggyback counters */
459 if (tagsAreDisplayed()) {
460 query
= query
+ "&omode=lt";
462 query
= query
+ "&omode=flc";
465 var date
= new Date();
466 var timestamp
= Math
.round(date
.getTime() / 1000);
467 query
= query
+ "&ts=" + timestamp
;
469 query
= query
+ "&cids=" + cids_to_request
.toString();
471 var crow
= $("RROW-" + id
);
472 var article_is_unread
= crow
.className
.match("Unread");
474 if (!async_counters_work
) {
475 query
= query
+ "&csync=true";
478 showArticleInHeadlines(id
);
480 if (!cached_article
) {
482 // notify_progress("Loading, please wait...", true);
484 /* var content = $('HLC-' + id);
486 if (content && !$('LL-' + id)) {
487 var ll = document.createElement('img');
489 ll.src = 'images/indicator_tiny.gif';
490 ll.className = 'hlLoading';
493 content.appendChild(ll);
497 var upic
= $('FUPDPIC-' + id
);
500 upic
.src
= getInitParam("sign_progress");
503 } else if (cached_article
&& article_is_unread
) {
505 query
= query
+ "&mode=prefetch";
507 render_article(cached_article
);
509 } else if (cached_article
) {
511 query
= query
+ "&mode=prefetch_old";
512 render_article(cached_article
);
518 last_requested_article
= id
;
520 new Ajax
.Request("backend.php", {
522 onComplete: function(transport
) {
523 article_callback2(transport
, id
);
529 exception_error("view", e
);
534 return toggleMark(id
);
538 return togglePub(id
);
541 function tMark_afh_off(effect
) {
543 var elem
= effect
.effects
[0].element
;
545 debug("tMark_afh_off : " + elem
.id
);
548 elem
.src
= elem
.src
.replace("mark_set", "mark_unset");
549 elem
.alt
= __("Star article");
554 exception_error("tMark_afh_off", e
);
558 function tPub_afh_off(effect
) {
560 var elem
= effect
.effects
[0].element
;
562 debug("tPub_afh_off : " + elem
.id
);
565 elem
.src
= elem
.src
.replace("pub_set", "pub_unset");
566 elem
.alt
= __("Publish article");
571 exception_error("tPub_afh_off", e
);
575 function toggleMark(id
, client_only
, no_effects
) {
579 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
581 query
= query
+ "&afid=" + getActiveFeedId();
583 if (tagsAreDisplayed()) {
584 query
= query
+ "&omode=tl";
586 query
= query
+ "&omode=flc";
589 var mark_img
= $("FMPIC-" + id
);
591 if (!mark_img
) return;
593 var vfeedu
= $("FEEDU--1");
594 var crow
= $("RROW-" + id
);
596 if (mark_img
.src
.match("mark_unset")) {
597 mark_img
.src
= mark_img
.src
.replace("mark_unset", "mark_set");
598 mark_img
.alt
= __("Unstar article");
599 query
= query
+ "&mark=1";
602 db
.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id
]);
606 //mark_img.src = "images/mark_unset.png";
607 mark_img
.alt
= __("Please wait...");
608 query
= query
+ "&mark=0";
610 if ($("headlinesList") && !no_effects
) {
611 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tMark_afh_off
});
613 mark_img
.src
= mark_img
.src
.replace("mark_set", "mark_unset");
614 mark_img
.alt
= __("Star article");
618 db
.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id
]);
623 if (!no_effects
) update_local_feedlist_counters();
628 new Ajax
.Request("backend.php", {
630 onComplete: function(transport
) {
631 all_counters_callback2(transport
);
637 exception_error("toggleMark", e
);
641 function togglePub(id
, client_only
, no_effects
, note
) {
645 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
647 query
= query
+ "&afid=" + getActiveFeedId();
649 if (note
!= undefined) {
650 query
= query
+ "¬e=" + param_escape(note
);
652 query
= query
+ "¬e=undefined";
655 if (tagsAreDisplayed()) {
656 query
= query
+ "&omode=tl";
658 query
= query
+ "&omode=flc";
661 var mark_img
= $("FPPIC-" + id
);
663 if (!mark_img
) return;
665 var vfeedu
= $("FEEDU--2");
666 var crow
= $("RROW-" + id
);
668 if (mark_img
.src
.match("pub_unset") || note
!= undefined) {
669 mark_img
.src
= mark_img
.src
.replace("pub_unset", "pub_set");
670 mark_img
.alt
= __("Unpublish article");
671 query
= query
+ "&pub=1";
674 //mark_img.src = "images/pub_unset.png";
675 mark_img
.alt
= __("Please wait...");
676 query
= query
+ "&pub=0";
678 if ($("headlinesList") && !no_effects
) {
679 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tPub_afh_off
});
681 mark_img
.src
= mark_img
.src
.replace("pub_set", "pub_unset");
682 mark_img
.alt
= __("Publish article");
687 new Ajax
.Request("backend.php", {
689 onComplete: function(transport
) {
690 all_counters_callback2(transport
);
692 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
695 var note_id
= note
.getAttribute("id");
696 var note_size
= note
.getAttribute("size");
697 var note_content
= note
.firstChild
.nodeValue
;
699 var container
= $('POSTNOTE-' + note_id
);
701 cache_invalidate(note_id
);
704 if (note_size
== "0") {
705 Element
.hide(container
);
707 container
.innerHTML
= note_content
;
708 Element
.show(container
);
717 exception_error("togglePub", e
);
721 function correctHeadlinesOffset(id
) {
725 var hlist
= $("headlinesList");
726 var container
= $("headlinesInnerContainer");
727 var row
= $("RROW-" + id
);
729 var viewport
= container
.offsetHeight
;
731 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
732 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
734 debug("Rtop: " + rel_offset_top
+ " Rbtm: " + rel_offset_bottom
);
735 debug("Vport: " + viewport
);
737 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
738 container
.scrollTop
= row
.offsetTop
;
739 } else if (rel_offset_bottom
> viewport
) {
741 /* doesn't properly work with Opera in some cases because
742 Opera fucks up element scrolling */
744 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
748 exception_error("correctHeadlinesOffset", e
);
753 function moveToPost(mode
) {
760 rows
= cdmGetVisibleArticles();
762 rows
= getVisibleHeadlineIds();
768 if (!$('RROW-' + active_post_id
)) {
769 active_post_id
= false;
772 if (active_post_id
== false) {
773 next_id
= getFirstVisibleHeadlineId();
774 prev_id
= getLastVisibleHeadlineId();
776 for (var i
= 0; i
< rows
.length
; i
++) {
777 if (rows
[i
] == active_post_id
) {
784 if (mode
== "next") {
788 if (!cdmArticleIsActuallyVisible(next_id
)) {
789 cdmScrollToArticleId(next_id
);
791 cdmSelectArticles("none");
792 toggleUnread(next_id
, 0, true);
793 toggleSelected(next_id
);
796 correctHeadlinesOffset(next_id
);
797 view(next_id
, getActiveFeedId());
802 if (mode
== "prev") {
805 cdmScrollToArticleId(prev_id
);
806 cdmSelectArticles("none");
807 toggleUnread(prev_id
, 0, true);
808 toggleSelected(prev_id
);
810 correctHeadlinesOffset(prev_id
);
811 view(prev_id
, getActiveFeedId());
817 exception_error("moveToPost", e
);
821 function toggleSelected(id
) {
824 var cb
= $("RCHK-" + id
);
826 var row
= $("RROW-" + id
);
828 var nc
= row
.className
;
830 if (!nc
.match("Selected")) {
831 nc
= nc
+ "Selected";
836 // In CDM basically last selected article == active article
837 if (isCdmMode()) active_post_id
= id
;
839 nc
= nc
.replace("Selected", "");
849 exception_error("toggleSelected", e
);
853 function toggleUnread_afh(effect
) {
856 var elem
= effect
.element
;
857 elem
.style
.backgroundColor
= "";
860 exception_error("toggleUnread_afh", e
);
864 function toggleUnread(id
, cmode
, effect
) {
867 var row
= $("RROW-" + id
);
869 var nc
= row
.className
;
870 var is_selected
= row
.className
.match("Selected");
871 nc
= nc
.replace("Unread", "");
872 nc
= nc
.replace("Selected", "");
874 // since we are removing selection from the object, uncheck
875 // corresponding checkbox
877 var cb
= $("RCHK-" + id
);
882 // NOTE: I'm not sure that resetting selection here is a feature -fox
884 if (cmode
== undefined || cmode
== 2) {
885 if (row
.className
.match("Unread")) {
889 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
890 afterFinish
: toggleUnread_afh
,
891 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
895 row
.className
= nc
+ "Unread";
899 db
.execute("UPDATE articles SET unread = not unread "+
900 "WHERE id = ?", [id
]);
903 } else if (cmode
== 0) {
907 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
908 afterFinish
: toggleUnread_afh
,
909 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
913 db
.execute("UPDATE articles SET unread = 0 "+
914 "WHERE id = ?", [id
]);
917 } else if (cmode
== 1) {
918 row
.className
= nc
+ "Unread";
921 db
.execute("UPDATE articles SET unread = 1 "+
922 "WHERE id = ?", [id
]);
927 update_local_feedlist_counters();
929 // Disable unmarking as selected for the time being (16.05.08) -fox
930 if (is_selected
) row
.className
= row
.className
+ "Selected";
932 if (cmode
== undefined) cmode
= 2;
934 var query
= "?op=rpc&subop=catchupSelected" +
935 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
937 // notify_progress("Loading, please wait...");
939 new Ajax
.Request("backend.php", {
941 onComplete: function(transport
) {
942 all_counters_callback2(transport
);
948 exception_error("toggleUnread", e
);
952 function selectionRemoveLabel(id
) {
955 var ids
= getSelectedArticleIds2();
957 if (ids
.length
== 0) {
958 alert(__("No articles are selected."));
962 // var ok = confirm(__("Remove selected articles from label?"));
966 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
967 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
969 // notify_progress("Loading, please wait...");
971 cache_invalidate("F:" + (-11 - id
));
973 new Ajax
.Request("backend.php", {
975 onComplete: function(transport
) {
976 show_labels_in_headlines(transport
);
977 all_counters_callback2(transport
);
983 exception_error("selectionAssignLabel", e
);
988 function selectionAssignLabel(id
) {
991 var ids
= getSelectedArticleIds2();
993 if (ids
.length
== 0) {
994 alert(__("No articles are selected."));
998 // var ok = confirm(__("Assign selected articles to label?"));
1002 cache_invalidate("F:" + (-11 - id
));
1004 var query
= "?op=rpc&subop=assignToLabel&ids=" +
1005 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
1007 // notify_progress("Loading, please wait...");
1009 new Ajax
.Request("backend.php", {
1011 onComplete: function(transport
) {
1012 show_labels_in_headlines(transport
);
1013 all_counters_callback2(transport
);
1019 exception_error("selectionAssignLabel", e
);
1024 function selectionToggleUnread(cdm_mode
, set_state
, callback_func
, no_error
) {
1029 rows
= cdmGetSelectedArticles();
1031 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1034 if (rows
.length
== 0 && !no_error
) {
1035 alert(__("No articles are selected."));
1039 for (i
= 0; i
< rows
.length
; i
++) {
1040 var row
= $("RROW-" + rows
[i
]);
1042 var nc
= row
.className
;
1043 nc
= nc
.replace("Unread", "");
1044 nc
= nc
.replace("Selected", "");
1046 if (set_state
== undefined) {
1047 if (row
.className
.match("Unread")) {
1048 row
.className
= nc
+ "Selected";
1050 row
.className
= nc
+ "UnreadSelected";
1053 db
.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
1058 if (set_state
== false) {
1059 row
.className
= nc
+ "Selected";
1061 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?",
1066 if (set_state
== true) {
1067 row
.className
= nc
+ "UnreadSelected";
1069 db
.execute("UPDATE articles SET unread = 1 WHERE id = ?",
1076 if (rows
.length
> 0) {
1078 update_local_feedlist_counters();
1082 if (set_state
== undefined) {
1084 } else if (set_state
== true) {
1086 } else if (set_state
== false) {
1090 var query
= "?op=rpc&subop=catchupSelected" +
1091 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
1093 notify_progress("Loading, please wait...");
1095 new Ajax
.Request("backend.php", {
1097 onComplete: function(transport
) {
1098 catchup_callback2(transport
, callback_func
);
1104 exception_error("selectionToggleUnread", e
);
1108 function selectionToggleMarked(cdm_mode
) {
1114 rows
= cdmGetSelectedArticles();
1116 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1119 if (rows
.length
== 0) {
1120 alert(__("No articles are selected."));
1124 for (i
= 0; i
< rows
.length
; i
++) {
1125 toggleMark(rows
[i
], true, true);
1128 update_local_feedlist_counters();
1130 if (rows
.length
> 0) {
1132 var query
= "?op=rpc&subop=markSelected&ids=" +
1133 param_escape(rows
.toString()) + "&cmode=2";
1135 query
= query
+ "&afid=" + getActiveFeedId();
1137 /* if (tagsAreDisplayed()) {
1138 query = query + "&omode=tl";
1140 query = query + "&omode=flc";
1143 query
= query
+ "&omode=lc";
1145 new Ajax
.Request("backend.php", {
1147 onComplete: function(transport
) {
1148 all_counters_callback2(transport
);
1154 exception_error("selectionToggleMarked", e
);
1158 function selectionTogglePublished(cdm_mode
) {
1164 rows
= cdmGetSelectedArticles();
1166 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1169 if (rows
.length
== 0) {
1170 alert(__("No articles are selected."));
1174 for (i
= 0; i
< rows
.length
; i
++) {
1175 togglePub(rows
[i
], true, true);
1178 if (rows
.length
> 0) {
1180 var query
= "?op=rpc&subop=publishSelected&ids=" +
1181 param_escape(rows
.toString()) + "&cmode=2";
1183 query
= query
+ "&afid=" + getActiveFeedId();
1185 /* if (tagsAreDisplayed()) {
1186 query = query + "&omode=tl";
1188 query = query + "&omode=flc";
1191 query
= query
+ "&omode=lc";
1193 new Ajax
.Request("backend.php", {
1195 onComplete: function(transport
) {
1196 all_counters_callback2(transport
);
1202 exception_error("selectionToggleMarked", e
);
1206 function cdmGetSelectedArticles() {
1207 var sel_articles
= new Array();
1208 var container
= $("headlinesInnerContainer");
1210 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1211 var child
= container
.childNodes
[i
];
1213 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Selected")) {
1214 var c_id
= child
.id
.replace("RROW-", "");
1215 sel_articles
.push(c_id
);
1219 return sel_articles
;
1222 function cdmGetVisibleArticles() {
1223 var sel_articles
= new Array();
1224 var container
= $("headlinesInnerContainer");
1226 if (!container
) return sel_articles
;
1228 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1229 var child
= container
.childNodes
[i
];
1231 if (child
.id
&& child
.id
.match("RROW-")) {
1232 var c_id
= child
.id
.replace("RROW-", "");
1233 sel_articles
.push(c_id
);
1237 return sel_articles
;
1240 function cdmGetUnreadArticles() {
1241 var sel_articles
= new Array();
1242 var container
= $("headlinesInnerContainer");
1244 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1245 var child
= container
.childNodes
[i
];
1247 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Unread")) {
1248 var c_id
= child
.id
.replace("RROW-", "");
1249 sel_articles
.push(c_id
);
1253 return sel_articles
;
1257 // mode = all,none,unread
1258 function cdmSelectArticles(mode
) {
1259 var container
= $("headlinesInnerContainer");
1261 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1262 var child
= container
.childNodes
[i
];
1264 if (child
.id
&& child
.id
.match("RROW-")) {
1265 var aid
= child
.id
.replace("RROW-", "");
1267 var cb
= $("RCHK-" + aid
);
1269 if (mode
== "all") {
1270 if (!child
.className
.match("Selected")) {
1271 child
.className
= child
.className
+ "Selected";
1274 } else if (mode
== "unread") {
1275 if (child
.className
.match("Unread") && !child
.className
.match("Selected")) {
1276 child
.className
= child
.className
+ "Selected";
1280 child
.className
= child
.className
.replace("Selected", "");
1287 function catchupPage() {
1289 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1291 var str
= __("Mark all visible articles in %s as read?");
1293 str
= str
.replace("%s", fn
);
1295 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1299 if ($("headlinesList")) {
1300 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
1301 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1302 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1304 cdmSelectArticles('all');
1305 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1306 cdmSelectArticles('none');
1310 function deleteSelection() {
1316 if ($("headlinesList")) {
1317 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1319 rows
= cdmGetSelectedArticles();
1322 if (rows
.length
== 0) {
1323 alert(__("No articles are selected."));
1328 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1332 if (getActiveFeedId() != 0) {
1333 str
= __("Delete %d selected articles in %s?");
1335 str
= __("Delete %d selected articles?");
1338 str
= str
.replace("%d", rows
.length
);
1339 str
= str
.replace("%s", fn
);
1341 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1345 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
1349 new Ajax
.Request("backend.php", {
1351 onComplete: function(transport
) {
1356 exception_error("deleteSelection", e
);
1360 function archiveSelection() {
1366 if ($("headlinesList")) {
1367 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1369 rows
= cdmGetSelectedArticles();
1372 if (rows
.length
== 0) {
1373 alert(__("No articles are selected."));
1378 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1382 if (getActiveFeedId() != 0) {
1383 str
= __("Archive %d selected articles in %s?");
1386 str
= __("Move %d archived articles back?");
1390 str
= str
.replace("%d", rows
.length
);
1391 str
= str
.replace("%s", fn
);
1393 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1397 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1401 for (var i
= 0; i
< rows
.length
; i
++) {
1402 cache_invalidate(rows
[i
]);
1405 new Ajax
.Request("backend.php", {
1407 onComplete: function(transport
) {
1412 exception_error("archiveSelection", e
);
1416 function catchupSelection() {
1422 if ($("headlinesList")) {
1423 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1425 rows
= cdmGetSelectedArticles();
1428 if (rows
.length
== 0) {
1429 alert(__("No articles are selected."));
1434 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1436 var str
= __("Mark %d selected articles in %s as read?");
1438 str
= str
.replace("%d", rows
.length
);
1439 str
= str
.replace("%s", fn
);
1441 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1445 if ($("headlinesList")) {
1446 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1447 // selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1449 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1450 // cdmSelectArticles('none');
1454 exception_error("catchupSelection", e
);
1458 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1459 displayDlg('editArticleTags', id
,
1461 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1462 "backend.php?op=rpc&subop=completeTags",
1463 { tokens
: ',', paramName
: "search" });
1467 function editTagsSave() {
1469 notify_progress("Saving article tags...");
1471 var form
= document
.forms
["tag_edit_form"];
1473 var query
= Form
.serialize("tag_edit_form");
1475 query
= "?op=rpc&subop=setArticleTags&" + query
;
1479 new Ajax
.Request("backend.php", {
1481 onComplete: function(transport
) {
1483 debug("tags saved...");
1488 if (tagsAreDisplayed()) {
1489 _reload_feedlist_after_view
= true;
1492 if (transport
.responseXML
) {
1493 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1496 var id
= tags_str
.getAttribute("id");
1499 var tags
= $("ATSTR-" + id
);
1501 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1504 cache_invalidate(id
);
1510 exception_error("editTagsSave", e
);
1515 function editTagsInsert() {
1518 var form
= document
.forms
["tag_edit_form"];
1520 var found_tags
= form
.found_tags
;
1521 var tags_str
= form
.tags_str
;
1523 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1525 if (tags_str
.value
.length
> 0 &&
1526 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1528 tags_str
.value
= tags_str
.value
+ ", ";
1531 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1533 found_tags
.selectedIndex
= 0;
1536 exception_error("editTagsInsert", e
);
1540 function cdmScrollViewport(where
) {
1541 debug("cdmScrollViewport: " + where
);
1543 var ctr
= $("headlinesInnerContainer");
1547 if (where
== "bottom") {
1548 ctr
.scrollTop
= ctr
.scrollHeight
;
1550 ctr
.scrollTop
= where
;
1554 function cdmArticleIsBelowViewport(id
) {
1556 var ctr
= $("headlinesInnerContainer");
1557 var e
= $("RROW-" + id
);
1559 if (!e
|| !ctr
) return;
1561 // article starts below viewport
1563 if (ctr
.scrollTop
< e
.offsetTop
) {
1570 exception_error("cdmArticleIsVisible", e
);
1574 function cdmArticleIsAboveViewport(id
) {
1576 var ctr
= $("headlinesInnerContainer");
1577 var e
= $("RROW-" + id
);
1579 if (!e
|| !ctr
) return;
1581 // article starts above viewport
1583 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1590 exception_error("cdmArticleIsVisible", e
);
1594 function cdmScrollToArticleId(id
) {
1596 var ctr
= $("headlinesInnerContainer");
1597 var e
= $("RROW-" + id
);
1599 if (!e
|| !ctr
) return;
1601 ctr
.scrollTop
= e
.offsetTop
;
1604 exception_error("cdmScrollToArticleId", e
);
1608 function cdmArticleIsActuallyVisible(id
) {
1610 var ctr
= $("headlinesInnerContainer");
1611 var e
= $("RROW-" + id
);
1613 if (!e
|| !ctr
) return;
1615 // article fits in viewport OR article is longer than viewport and
1616 // its bottom is visible
1618 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1619 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1623 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1624 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1625 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1634 exception_error("cdmArticleIsVisible", e
);
1638 function cdmWatchdog() {
1642 var ctr
= $("headlinesInnerContainer");
1646 var ids
= new Array();
1648 var e
= ctr
.firstChild
;
1651 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1652 e
.id
.match("RROW-")) {
1654 // article fits in viewport OR article is longer than viewport and
1655 // its bottom is visible
1657 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1658 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1660 // debug(e.id + " is visible " + e.offsetTop + "." +
1661 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1662 // (ctr.scrollTop + ctr.offsetHeight));
1664 ids
.push(e
.id
.replace("RROW-", ""));
1666 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1667 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1668 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1670 ids
.push(e
.id
.replace("RROW-", ""));
1674 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1676 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1677 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1679 ids.push(e.id.replace("RROW-", ""));
1688 debug("cdmWatchdog, ids= " + ids
.toString());
1690 if (ids
.length
> 0) {
1692 for (var i
= 0; i
< ids
.length
; i
++) {
1693 var e
= $("RROW-" + ids
[i
]);
1695 e
.className
= e
.className
.replace("Unread", "");
1699 var query
= "?op=rpc&subop=catchupSelected" +
1700 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1702 new Ajax
.Request("backend.php", {
1704 onComplete: function(transport
) {
1705 all_counters_callback2(transport
);
1710 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1713 exception_error("cdmWatchdog", e
);
1719 function cache_inject(id
, article
, param
) {
1721 if (!cache_check_param(id
, param
)) {
1722 debug("cache_article: miss: " + id
+ " [p=" + param
+ "]");
1726 var date
= new Date();
1727 var ts
= Math
.round(date
.getTime() / 1000);
1729 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1730 [id
, article
, param
, ts
]);
1733 var cache_obj
= new Array();
1735 cache_obj
["id"] = id
;
1736 cache_obj
["data"] = article
;
1737 cache_obj
["param"] = param
;
1739 article_cache
.push(cache_obj
);
1743 debug("cache_article: hit: " + id
+ " [p=" + param
+ "]");
1746 exception_error("cache_inject", e
);
1750 function cache_find(id
) {
1753 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1756 if (rs
.isValidRow()) {
1757 var a
= rs
.field(0);
1765 for (var i
= 0; i
< article_cache
.length
; i
++) {
1766 if (article_cache
[i
]["id"] == id
) {
1767 return article_cache
[i
]["data"];
1774 function cache_find_param(id
, param
) {
1777 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1781 if (rs
.isValidRow()) {
1790 for (var i
= 0; i
< article_cache
.length
; i
++) {
1791 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1792 return article_cache
[i
]["data"];
1799 function cache_check(id
) {
1802 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1806 if (rs
.isValidRow()) {
1807 a
= rs
.field(0) != "0";
1815 for (var i
= 0; i
< article_cache
.length
; i
++) {
1816 if (article_cache
[i
]["id"] == id
) {
1824 function cache_check_param(id
, param
) {
1827 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1831 if (rs
.isValidRow()) {
1832 a
= rs
.field(0) != "0";
1840 for (var i
= 0; i
< article_cache
.length
; i
++) {
1841 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1849 function cache_expire() {
1851 var date
= new Date();
1852 var ts
= Math
.round(date
.getTime() / 1000);
1854 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1855 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1856 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1860 while (article_cache
.length
> 25) {
1861 article_cache
.shift();
1866 function cache_flush() {
1867 article_cache
= new Array();
1870 function cache_invalidate(id
) {
1874 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1875 return rs
.rowsAffected
!= 0;
1880 while (i
< article_cache
.length
) {
1881 if (article_cache
[i
]["id"] == id
) {
1882 debug("cache_invalidate: removed id " + id
);
1883 article_cache
.splice(i
, 1);
1890 debug("cache_invalidate: id not found: " + id
);
1893 exception_error("cache_invalidate", e
);
1897 function getActiveArticleId() {
1898 return active_post_id
;
1901 function cdmClicked(id
) {
1903 var elem
= $("RROW-" + id
);
1906 var id
= elem
.id
.replace("RROW-", "");
1907 active_post_id
= id
;
1909 // cdmSelectArticles("none");
1910 toggleUnread(id
, 0, true);
1911 // toggleSelected(id);
1915 exception_error("cdmClicked", e
);
1919 function preloadArticleUnderPointer(id
) {
1921 if (getInitParam("bw_limit") == "1") return;
1923 if (post_under_pointer
== id
&& !cache_check(id
)) {
1925 debug("trying to preload article " + id
);
1927 var neighbor_ids
= getRelativePostIds(id
, 1);
1929 /* only request uncached articles */
1931 var cids_to_request
= Array();
1933 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1934 if (!cache_check(neighbor_ids
[i
])) {
1935 cids_to_request
.push(neighbor_ids
[i
]);
1938 debug("additional ids: " + cids_to_request
.toString());
1940 cids_to_request
.push(id
);
1942 var query
= "?op=rpc&subop=getArticles&ids=" +
1943 cids_to_request
.toString();
1945 new Ajax
.Request("backend.php", {
1947 onComplete: function(transport
) {
1948 var articles
= transport
.responseXML
.getElementsByTagName("article");
1950 for (var i
= 0; i
< articles
.length
; i
++) {
1951 var id
= articles
[i
].getAttribute("id");
1952 if (!cache_check(id
)) {
1953 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1954 debug("preloaded article: " + id
);
1960 exception_error("preloadArticleUnderPointer", e
);
1964 function postMouseIn(id
) {
1966 if (post_under_pointer
!= id
) {
1967 post_under_pointer
= id
;
1969 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1974 exception_error("postMouseIn", e
);
1978 function postMouseOut(id
) {
1980 post_under_pointer
= false;
1982 exception_error("postMouseOut", e
);
1986 function headlines_scroll_handler() {
1989 var e
= $("headlinesInnerContainer");
1991 var toolbar_form
= document
.forms
["main_toolbar_form"];
1993 debug((e
.scrollTop
+ e
.offsetHeight
) + " vs " + e
.scrollHeight
+ " dis? " +
1994 _infscroll_disable
);
1996 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1997 if (!_infscroll_disable
) {
1998 debug("more cowbell!");
2004 exception_error("headlines_scroll_handler", e
);
2008 function catchupRelativeToArticle(below
) {
2013 if (!getActiveArticleId()) {
2014 alert(__("No article is selected."));
2020 if ($("headlinesList")) {
2021 visible_ids
= getVisibleHeadlineIds();
2023 visible_ids
= cdmGetVisibleArticles();
2026 var ids_to_mark
= new Array();
2029 for (var i
= 0; i
< visible_ids
.length
; i
++) {
2030 if (visible_ids
[i
] != getActiveArticleId()) {
2031 var e
= $("RROW-" + visible_ids
[i
]);
2033 if (e
&& e
.className
.match("Unread")) {
2034 ids_to_mark
.push(visible_ids
[i
]);
2041 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
2042 if (visible_ids
[i
] != getActiveArticleId()) {
2043 var e
= $("RROW-" + visible_ids
[i
]);
2045 if (e
&& e
.className
.match("Unread")) {
2046 ids_to_mark
.push(visible_ids
[i
]);
2054 if (ids_to_mark
.length
== 0) {
2055 alert(__("No articles found to mark"));
2057 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
2061 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
2062 var e
= $("RROW-" + ids_to_mark
[i
]);
2063 e
.className
= e
.className
.replace("Unread", "");
2066 var query
= "?op=rpc&subop=catchupSelected" +
2067 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
2069 new Ajax
.Request("backend.php", {
2071 onComplete: function(transport
) {
2072 catchup_callback2(transport
);
2079 exception_error("catchupRelativeToArticle", e
);
2083 function cdmExpandArticle(a_id
) {
2085 var id
= 'CICD-' + a_id
;
2088 Element
.hide("CEXC-" + a_id
);
2091 Effect
.Appear(id
, {duration
: 0.5,
2092 beforeStart: function(effect
) {
2093 var h_id
= 'CICH-' + a_id
;
2094 var h_elem
= $(h_id
);
2095 if (h_elem
) { h_elem
.style
.display
= "none"; }
2097 toggleUnread(a_id
, 0);
2102 exception_error("appearBlockElementF", e
);
2107 function fixHeadlinesOrder(ids
) {
2109 for (var i
= 0; i
< ids
.length
; i
++) {
2110 var e
= $("RROW-" + ids
[i
]);
2114 e
.className
= e
.className
.replace("even", "odd");
2116 e
.className
= e
.className
.replace("odd", "even");
2121 exception_error("fixHeadlinesOrder", e
);
2125 function hideReadHeadlines() {
2129 var vis_ids
= new Array();
2131 if ($("headlinesList")) {
2132 ids
= getVisibleHeadlineIds();
2134 ids
= cdmGetVisibleArticles();
2137 var read_headlines_visible
= true;
2139 for (var i
= 0; i
< ids
.length
; i
++) {
2140 var row
= $("RROW-" + ids
[i
]);
2142 if (row
&& row
.className
) {
2143 if (read_headlines_visible
) {
2144 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2146 vis_ids
.push(ids
[i
]);
2148 //Effect.Fade(row, {duration : 0.3});
2153 vis_ids
.push(ids
[i
]);
2158 fixHeadlinesOrder(vis_ids
);
2160 read_headlines_visible
= !read_headlines_visible
;
2163 exception_error("hideReadHeadlines", e
);
2167 function invertHeadlineSelection() {
2169 var rows
= new Array();
2173 r
= document
.getElementsByTagName("TR");
2175 r
= document
.getElementsByTagName("DIV");
2178 for (var i
= 0; i
< r
.length
; i
++) {
2179 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2184 for (var i
= 0; i
< rows
.length
; i
++) {
2185 var nc
= rows
[i
].className
;
2186 var id
= rows
[i
].id
.replace("RROW-", "");
2187 var cb
= $("RCHK-" + id
);
2189 if (!rows
[i
].className
.match("Selected")) {
2190 nc
= nc
+ "Selected";
2193 nc
= nc
.replace("Selected", "");
2197 rows
[i
].className
= nc
;
2202 exception_error("invertHeadlineSelection", e
);
2206 function getArticleUnderPointer() {
2207 return post_under_pointer
;
2210 function zoomToArticle(id
) {
2212 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2214 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2217 exception_error("zoomToArticle", e
);
2221 function showOriginalArticleInline(id
) {
2224 var query
= "?op=rpc&subop=getArticleLink&id=" + id
;
2226 notify_progress("Loading, please wait...", true);
2228 new Ajax
.Request("backend.php", {
2230 onComplete: function(transport
) {
2232 if (transport
.responseXML
) {
2234 var link
= transport
.responseXML
.getElementsByTagName("link")[0];
2235 var id
= transport
.responseXML
.getElementsByTagName("id")[0];
2240 link
= link
.firstChild
.nodeValue
;
2242 var ci
= $("content-insert");
2244 var tmp
= "<iframe id=\"inline_orig_article\" width=\""+ci
.offsetWidth
+"\" height=\""+ci
.offsetHeight
+"\" style=\"border-width : 0px;\" src=\""+link
+"\"></iframe>";
2246 render_article(tmp
);
2253 exception_error("showOriginalArticleInline", e
);
2258 function scrollArticle(offset
) {
2261 var ci
= $("content-insert");
2263 ci
.scrollTop
+= offset
;
2266 var hi
= $("headlinesInnerContainer");
2268 hi
.scrollTop
+= offset
;
2273 exception_error("scrollArticle", e
);
2277 function show_labels_in_headlines(transport
) {
2279 if (transport
.responseXML
) {
2280 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2282 var elems
= info
.getElementsByTagName("entry");
2284 for (var l
= 0; l
< elems
.length
; l
++) {
2285 var e_id
= elems
[l
].getAttribute("id");
2289 var ctr
= $("HLLCTR-" + e_id
);
2292 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2300 exception_error("show_labels_in_headlines", e
);
2305 function toggleHeadlineActions() {
2307 var e
= $("headlineActionsBody");
2308 var p
= $("headlineActionsDrop");
2310 if (!Element
.visible(e
)) {
2317 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2318 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2321 exception_error("toggleHeadlineActions", e
);
2325 function publishWithNote(id
, def_note
) {
2327 if (!def_note
) def_note
= '';
2329 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2331 if (note
!= undefined) {
2332 togglePub(id
, false, false, note
);
2336 exception_error("publishWithNote", e
);