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
;
1508 exception_error("editTagsSave", e
);
1513 function editTagsInsert() {
1516 var form
= document
.forms
["tag_edit_form"];
1518 var found_tags
= form
.found_tags
;
1519 var tags_str
= form
.tags_str
;
1521 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1523 if (tags_str
.value
.length
> 0 &&
1524 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1526 tags_str
.value
= tags_str
.value
+ ", ";
1529 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1531 found_tags
.selectedIndex
= 0;
1534 exception_error("editTagsInsert", e
);
1538 function cdmScrollViewport(where
) {
1539 debug("cdmScrollViewport: " + where
);
1541 var ctr
= $("headlinesInnerContainer");
1545 if (where
== "bottom") {
1546 ctr
.scrollTop
= ctr
.scrollHeight
;
1548 ctr
.scrollTop
= where
;
1552 function cdmArticleIsBelowViewport(id
) {
1554 var ctr
= $("headlinesInnerContainer");
1555 var e
= $("RROW-" + id
);
1557 if (!e
|| !ctr
) return;
1559 // article starts below viewport
1561 if (ctr
.scrollTop
< e
.offsetTop
) {
1568 exception_error("cdmArticleIsVisible", e
);
1572 function cdmArticleIsAboveViewport(id
) {
1574 var ctr
= $("headlinesInnerContainer");
1575 var e
= $("RROW-" + id
);
1577 if (!e
|| !ctr
) return;
1579 // article starts above viewport
1581 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1588 exception_error("cdmArticleIsVisible", e
);
1592 function cdmScrollToArticleId(id
) {
1594 var ctr
= $("headlinesInnerContainer");
1595 var e
= $("RROW-" + id
);
1597 if (!e
|| !ctr
) return;
1599 ctr
.scrollTop
= e
.offsetTop
;
1602 exception_error("cdmScrollToArticleId", e
);
1606 function cdmArticleIsActuallyVisible(id
) {
1608 var ctr
= $("headlinesInnerContainer");
1609 var e
= $("RROW-" + id
);
1611 if (!e
|| !ctr
) return;
1613 // article fits in viewport OR article is longer than viewport and
1614 // its bottom is visible
1616 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1617 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1621 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1622 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1623 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1632 exception_error("cdmArticleIsVisible", e
);
1636 function cdmWatchdog() {
1640 var ctr
= $("headlinesInnerContainer");
1644 var ids
= new Array();
1646 var e
= ctr
.firstChild
;
1649 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1650 e
.id
.match("RROW-")) {
1652 // article fits in viewport OR article is longer than viewport and
1653 // its bottom is visible
1655 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1656 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1658 // debug(e.id + " is visible " + e.offsetTop + "." +
1659 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1660 // (ctr.scrollTop + ctr.offsetHeight));
1662 ids
.push(e
.id
.replace("RROW-", ""));
1664 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1665 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1666 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1668 ids
.push(e
.id
.replace("RROW-", ""));
1672 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1674 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1675 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1677 ids.push(e.id.replace("RROW-", ""));
1686 debug("cdmWatchdog, ids= " + ids
.toString());
1688 if (ids
.length
> 0) {
1690 for (var i
= 0; i
< ids
.length
; i
++) {
1691 var e
= $("RROW-" + ids
[i
]);
1693 e
.className
= e
.className
.replace("Unread", "");
1697 var query
= "?op=rpc&subop=catchupSelected" +
1698 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1700 new Ajax
.Request("backend.php", {
1702 onComplete: function(transport
) {
1703 all_counters_callback2(transport
);
1708 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1711 exception_error("cdmWatchdog", e
);
1717 function cache_inject(id
, article
, param
) {
1719 if (!cache_check_param(id
, param
)) {
1720 debug("cache_article: miss: " + id
+ " [p=" + param
+ "]");
1725 var date
= new Date();
1726 var ts
= Math
.round(date
.getTime() / 1000);
1728 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1729 [id
, article
, param
, ts
]);
1732 var cache_obj
= new Array();
1734 cache_obj
["id"] = id
;
1735 cache_obj
["data"] = article
;
1736 cache_obj
["param"] = param
;
1738 article_cache
.push(cache_obj
);
1742 debug("cache_article: hit: " + id
+ " [p=" + param
+ "]");
1745 exception_error("cache_inject", e
);
1749 function cache_find(id
) {
1752 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1755 if (rs
.isValidRow()) {
1756 var a
= rs
.field(0);
1764 for (var i
= 0; i
< article_cache
.length
; i
++) {
1765 if (article_cache
[i
]["id"] == id
) {
1766 return article_cache
[i
]["data"];
1773 function cache_find_param(id
, param
) {
1776 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1780 if (rs
.isValidRow()) {
1789 for (var i
= 0; i
< article_cache
.length
; i
++) {
1790 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1791 return article_cache
[i
]["data"];
1798 function cache_check(id
) {
1801 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1805 if (rs
.isValidRow()) {
1806 a
= rs
.field(0) != "0";
1814 for (var i
= 0; i
< article_cache
.length
; i
++) {
1815 if (article_cache
[i
]["id"] == id
) {
1823 function cache_check_param(id
, param
) {
1826 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1830 if (rs
.isValidRow()) {
1831 a
= rs
.field(0) != "0";
1839 for (var i
= 0; i
< article_cache
.length
; i
++) {
1840 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1848 function cache_expire() {
1850 var date
= new Date();
1851 var ts
= Math
.round(date
.getTime() / 1000);
1853 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1854 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1855 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1859 while (article_cache
.length
> 25) {
1860 article_cache
.shift();
1865 function cache_empty() {
1866 article_cache
= new Array();
1869 function cache_invalidate(id
) {
1873 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1874 return rs
.rowsAffected
!= 0;
1879 while (i
< article_cache
.length
) {
1880 if (article_cache
[i
]["id"] == id
) {
1881 debug("cache_invalidate: removed id " + id
);
1882 article_cache
.splice(i
, 1);
1889 debug("cache_invalidate: id not found: " + id
);
1892 exception_error("cache_invalidate", e
);
1896 function getActiveArticleId() {
1897 return active_post_id
;
1900 function cdmClicked(id
) {
1902 var elem
= $("RROW-" + id
);
1905 var id
= elem
.id
.replace("RROW-", "");
1906 active_post_id
= id
;
1908 // cdmSelectArticles("none");
1909 toggleUnread(id
, 0, true);
1910 // toggleSelected(id);
1914 exception_error("cdmClicked", e
);
1918 function preloadArticleUnderPointer(id
) {
1920 if (getInitParam("bw_limit") == "1") return;
1922 if (post_under_pointer
== id
&& !cache_check(id
)) {
1924 debug("trying to preload article " + id
);
1926 var neighbor_ids
= getRelativePostIds(id
, 1);
1928 /* only request uncached articles */
1930 var cids_to_request
= Array();
1932 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1933 if (!cache_check(neighbor_ids
[i
])) {
1934 cids_to_request
.push(neighbor_ids
[i
]);
1937 debug("additional ids: " + cids_to_request
.toString());
1939 cids_to_request
.push(id
);
1941 var query
= "?op=rpc&subop=getArticles&ids=" +
1942 cids_to_request
.toString();
1944 new Ajax
.Request("backend.php", {
1946 onComplete: function(transport
) {
1947 var articles
= transport
.responseXML
.getElementsByTagName("article");
1949 for (var i
= 0; i
< articles
.length
; i
++) {
1950 var id
= articles
[i
].getAttribute("id");
1951 if (!cache_check(id
)) {
1952 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1953 debug("preloaded article: " + id
);
1959 exception_error("preloadArticleUnderPointer", e
);
1963 function postMouseIn(id
) {
1965 if (post_under_pointer
!= id
) {
1966 post_under_pointer
= id
;
1968 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1973 exception_error("postMouseIn", e
);
1977 function postMouseOut(id
) {
1979 post_under_pointer
= false;
1981 exception_error("postMouseOut", e
);
1985 function headlines_scroll_handler() {
1988 var e
= $("headlinesInnerContainer");
1990 var toolbar_form
= document
.forms
["main_toolbar_form"];
1992 debug((e
.scrollTop
+ e
.offsetHeight
) + " vs " + e
.scrollHeight
+ " dis? " +
1993 _infscroll_disable
);
1995 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1996 if (!_infscroll_disable
) {
1997 debug("more cowbell!");
2003 exception_error("headlines_scroll_handler", e
);
2007 function catchupRelativeToArticle(below
) {
2012 if (!getActiveArticleId()) {
2013 alert(__("No article is selected."));
2019 if ($("headlinesList")) {
2020 visible_ids
= getVisibleHeadlineIds();
2022 visible_ids
= cdmGetVisibleArticles();
2025 var ids_to_mark
= new Array();
2028 for (var i
= 0; i
< visible_ids
.length
; i
++) {
2029 if (visible_ids
[i
] != getActiveArticleId()) {
2030 var e
= $("RROW-" + visible_ids
[i
]);
2032 if (e
&& e
.className
.match("Unread")) {
2033 ids_to_mark
.push(visible_ids
[i
]);
2040 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
2041 if (visible_ids
[i
] != getActiveArticleId()) {
2042 var e
= $("RROW-" + visible_ids
[i
]);
2044 if (e
&& e
.className
.match("Unread")) {
2045 ids_to_mark
.push(visible_ids
[i
]);
2053 if (ids_to_mark
.length
== 0) {
2054 alert(__("No articles found to mark"));
2056 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
2060 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
2061 var e
= $("RROW-" + ids_to_mark
[i
]);
2062 e
.className
= e
.className
.replace("Unread", "");
2065 var query
= "?op=rpc&subop=catchupSelected" +
2066 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
2068 new Ajax
.Request("backend.php", {
2070 onComplete: function(transport
) {
2071 catchup_callback2(transport
);
2078 exception_error("catchupRelativeToArticle", e
);
2082 function cdmExpandArticle(a_id
) {
2084 var id
= 'CICD-' + a_id
;
2087 Element
.hide("CEXC-" + a_id
);
2090 Effect
.Appear(id
, {duration
: 0.5,
2091 beforeStart: function(effect
) {
2092 var h_id
= 'CICH-' + a_id
;
2093 var h_elem
= $(h_id
);
2094 if (h_elem
) { h_elem
.style
.display
= "none"; }
2096 toggleUnread(a_id
, 0);
2101 exception_error("appearBlockElementF", e
);
2106 function fixHeadlinesOrder(ids
) {
2108 for (var i
= 0; i
< ids
.length
; i
++) {
2109 var e
= $("RROW-" + ids
[i
]);
2113 e
.className
= e
.className
.replace("even", "odd");
2115 e
.className
= e
.className
.replace("odd", "even");
2120 exception_error("fixHeadlinesOrder", e
);
2124 function hideReadHeadlines() {
2128 var vis_ids
= new Array();
2130 if ($("headlinesList")) {
2131 ids
= getVisibleHeadlineIds();
2133 ids
= cdmGetVisibleArticles();
2136 var read_headlines_visible
= true;
2138 for (var i
= 0; i
< ids
.length
; i
++) {
2139 var row
= $("RROW-" + ids
[i
]);
2141 if (row
&& row
.className
) {
2142 if (read_headlines_visible
) {
2143 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2145 vis_ids
.push(ids
[i
]);
2147 //Effect.Fade(row, {duration : 0.3});
2152 vis_ids
.push(ids
[i
]);
2157 fixHeadlinesOrder(vis_ids
);
2159 read_headlines_visible
= !read_headlines_visible
;
2162 exception_error("hideReadHeadlines", e
);
2166 function invertHeadlineSelection() {
2168 var rows
= new Array();
2172 r
= document
.getElementsByTagName("TR");
2174 r
= document
.getElementsByTagName("DIV");
2177 for (var i
= 0; i
< r
.length
; i
++) {
2178 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2183 for (var i
= 0; i
< rows
.length
; i
++) {
2184 var nc
= rows
[i
].className
;
2185 var id
= rows
[i
].id
.replace("RROW-", "");
2186 var cb
= $("RCHK-" + id
);
2188 if (!rows
[i
].className
.match("Selected")) {
2189 nc
= nc
+ "Selected";
2192 nc
= nc
.replace("Selected", "");
2196 rows
[i
].className
= nc
;
2201 exception_error("invertHeadlineSelection", e
);
2205 function getArticleUnderPointer() {
2206 return post_under_pointer
;
2209 function zoomToArticle(id
) {
2211 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2213 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2216 exception_error("zoomToArticle", e
);
2220 function showOriginalArticleInline(id
) {
2223 var query
= "?op=rpc&subop=getArticleLink&id=" + id
;
2225 notify_progress("Loading, please wait...", true);
2227 new Ajax
.Request("backend.php", {
2229 onComplete: function(transport
) {
2231 if (transport
.responseXML
) {
2233 var link
= transport
.responseXML
.getElementsByTagName("link")[0];
2234 var id
= transport
.responseXML
.getElementsByTagName("id")[0];
2239 link
= link
.firstChild
.nodeValue
;
2241 var ci
= $("content-insert");
2243 var tmp
= "<iframe id=\"inline_orig_article\" width=\""+ci
.offsetWidth
+"\" height=\""+ci
.offsetHeight
+"\" style=\"border-width : 0px;\" src=\""+link
+"\"></iframe>";
2245 render_article(tmp
);
2252 exception_error("showOriginalArticleInline", e
);
2257 function scrollArticle(offset
) {
2260 var ci
= $("content-insert");
2262 ci
.scrollTop
+= offset
;
2265 var hi
= $("headlinesInnerContainer");
2267 hi
.scrollTop
+= offset
;
2272 exception_error("scrollArticle", e
);
2276 function show_labels_in_headlines(transport
) {
2278 if (transport
.responseXML
) {
2279 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2281 var elems
= info
.getElementsByTagName("entry");
2283 for (var l
= 0; l
< elems
.length
; l
++) {
2284 var e_id
= elems
[l
].getAttribute("id");
2288 var ctr
= $("HLLCTR-" + e_id
);
2291 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2299 exception_error("show_labels_in_headlines", e
);
2304 function toggleHeadlineActions() {
2306 var e
= $("headlineActionsBody");
2307 var p
= $("headlineActionsDrop");
2309 if (!Element
.visible(e
)) {
2316 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2317 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2320 exception_error("toggleHeadlineActions", e
);
2324 function publishWithNote(id
, def_note
) {
2326 if (!def_note
) def_note
= '';
2328 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2330 if (note
!= undefined) {
2331 togglePub(id
, false, false, note
);
2335 exception_error("publishWithNote", e
);