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 toggle_published_callback(transport
) {
20 if (transport
.responseXML
) {
22 all_counters_callback2(transport
);
24 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
27 var note_id
= note
.getAttribute("id");
28 var note_size
= note
.getAttribute("size");
29 var note_content
= note
.firstChild
.nodeValue
;
31 var container
= $('POSTNOTE-' + note_id
);
33 cache_invalidate(note_id
);
36 if (note_size
== "0") {
37 Element
.hide(container
);
39 container
.innerHTML
= note_content
;
40 Element
.show(container
);
47 exception_error("toggle_published_callback", e
, transport
);
51 function catchup_callback2(transport
, callback
) {
53 debug("catchup_callback2 " + transport
+ ", " + callback
);
55 all_counters_callback2(transport
);
57 setTimeout(callback
, 10);
60 exception_error("catchup_callback2", e
, transport
);
64 function clean_feed_selections() {
66 var feeds
= $("feedList").getElementsByTagName("LI");
68 for (var i
= 0; i
< feeds
.length
; i
++) {
69 if (feeds
[i
].id
&& feeds
[i
].id
.match("FEEDR-")) {
70 feeds
[i
].className
= feeds
[i
].className
.replace("Selected", "");
72 if (feeds
[i
].id
&& feeds
[i
].id
.match("FCAT-")) {
73 feeds
[i
].className
= feeds
[i
].className
.replace("Selected", "");
77 exception_error("clean_feed_selections", e
);
81 function headlines_callback2(transport
, feed_cur_page
) {
84 if (!transport
.responseText
&& db
) {
85 offlineConfirmModeChange();
89 loading_set_progress(100);
91 debug("headlines_callback2 [page=" + feed_cur_page
+ "]");
93 if (!transport_error_check(transport
)) return;
95 clean_feed_selections();
100 if (transport
.responseXML
) {
101 var headlines
= transport
.responseXML
.getElementsByTagName("headlines")[0];
103 is_cat
= headlines
.getAttribute("is_cat");
104 feed_id
= headlines
.getAttribute("id");
105 setActiveFeedId(feed_id
, is_cat
);
109 var ll
= $('FLL-' + feed_id
);
112 var feedr
= $("FEEDR-" + feed_id
);
113 if (feedr
&& !feedr
.className
.match("Selected")) {
114 feedr
.className
= feedr
.className
+ "Selected";
116 if (feedr
&& ll
) feedr
.removeChild(ll
);
118 var feedr
= $("FCAT-" + feed_id
);
119 if (feedr
&& !feedr
.className
.match("Selected")) {
120 feedr
.className
= feedr
.className
+ "Selected";
123 var fcap
= $("FCAP-" + feed_id
);
124 if (fcap
&& ll
) fcap
.removeChild(ll
);
128 var img
= $('FIMG-' + feed_id
);
130 if (img
&& !is_cat
) {
134 var f
= $("headlines-frame");
136 if (feed_cur_page
== 0) {
137 debug("resetting headlines scrollTop");
142 if (transport
.responseXML
) {
143 var headlines
= transport
.responseXML
.getElementsByTagName("headlines")[0];
144 var headlines_count_obj
= transport
.responseXML
.getElementsByTagName("headlines-count")[0];
145 var headlines_unread_obj
= transport
.responseXML
.getElementsByTagName("headlines-unread")[0];
146 var disable_cache_obj
= transport
.responseXML
.getElementsByTagName("disable-cache")[0];
148 var vgroup_last_feed_obj
= transport
.responseXML
.getElementsByTagName("vgroup-last-feed")[0];
150 var headlines_count
= headlines_count_obj
.getAttribute("value");
151 var headlines_unread
= headlines_unread_obj
.getAttribute("value");
152 var disable_cache
= disable_cache_obj
.getAttribute("value") != "0";
154 vgroup_last_feed
= vgroup_last_feed_obj
.getAttribute("value");
156 if (headlines_count
== 0) {
157 _infscroll_disable
= 1;
159 _infscroll_disable
= 0;
162 var counters
= transport
.responseXML
.getElementsByTagName("counters")[0];
163 var articles
= transport
.responseXML
.getElementsByTagName("article");
164 var runtime_info
= transport
.responseXML
.getElementsByTagName("runtime-info");
166 if (feed_cur_page
== 0) {
168 f
.innerHTML
= headlines
.firstChild
.nodeValue
;
170 var cache_prefix
= "";
178 cache_invalidate(cache_prefix
+ feed_id
);
180 if (!disable_cache
) {
181 cache_inject(cache_prefix
+ feed_id
,
182 headlines
.firstChild
.nodeValue
, headlines_unread
);
186 debug("headlines_callback: returned no data");
187 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
192 if (headlines_count
> 0) {
193 debug("adding some more headlines...");
195 var c
= $("headlinesList");
198 c
= $("headlinesInnerContainer");
201 var ids
= getSelectedArticleIds2();
203 c
.innerHTML
= c
.innerHTML
+ headlines
.firstChild
.nodeValue
;
205 debug("restore selected ids: " + ids
);
207 for (var i
= 0; i
< ids
.length
; i
++) {
208 markHeadline(ids
[i
]);
212 debug("no new headlines received");
215 debug("headlines_callback: returned no data");
216 notify_error("Error while trying to load more headlines");
222 for (var i
= 0; i
< articles
.length
; i
++) {
223 var a_id
= articles
[i
].getAttribute("id");
224 debug("found id: " + a_id
);
225 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
228 debug("no cached articles received");
232 debug("parsing piggybacked counters: " + counters
);
233 parse_counters(counters
, false);
235 debug("counters container not found in reply, requesting...");
240 debug("parsing runtime info: " + runtime_info
[0]);
241 parse_runtime_info(runtime_info
[0]);
243 debug("counters container not found in reply");
247 debug("headlines_callback: returned no XML object");
248 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
251 if (typeof correctPNG
!= 'undefined') {
255 if (_cdm_wd_timeout
) window
.clearTimeout(_cdm_wd_timeout
);
257 if (!$("headlinesList") &&
258 getActiveFeedId() != -3 &&
259 getInitParam("cdm_auto_catchup") == 1) {
260 debug("starting CDM watchdog");
261 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 5000);
262 _cdm_wd_vishist
= new Array();
264 debug("not in CDM mode or watchdog disabled");
267 _feed_cur_page
= feed_cur_page
;
268 _infscroll_request_sent
= 0;
275 exception_error("headlines_callback2", e
, transport
);
279 function render_article(article
) {
281 var f
= $("content-frame");
286 var fi
= $("content-insert");
292 fi
.innerHTML
= article
;
294 // article.evalScripts();
297 exception_error("render_article", e
);
301 function showArticleInHeadlines(id
) {
305 cleanSelected("headlinesList");
307 var crow
= $("RROW-" + id
);
311 var article_is_unread
= crow
.className
.match("Unread");
313 crow
.className
= crow
.className
.replace("Unread", "");
315 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
317 var upd_img_pic
= $("FUPDPIC-" + id
);
319 var cache_prefix
= "";
321 if (activeFeedIsCat()) {
327 var view_mode
= false;
330 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
331 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
336 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
337 upd_img_pic
.src
.match("fresh_sign.png"))) {
339 upd_img_pic
.src
= "images/blank_icon.gif";
341 cache_invalidate(cache_prefix
+ getActiveFeedId());
343 cache_inject(cache_prefix
+ getActiveFeedId(),
344 $("headlines-frame").innerHTML
,
345 get_feed_unread(getActiveFeedId()));
347 } else if (article_is_unread
&& view_mode
== "all_articles") {
349 cache_invalidate(cache_prefix
+ getActiveFeedId());
351 cache_inject(cache_prefix
+ getActiveFeedId(),
352 $("headlines-frame").innerHTML
,
353 get_feed_unread(getActiveFeedId())-1);
355 } else if (article_is_unread
) {
356 cache_invalidate(cache_prefix
+ getActiveFeedId());
362 exception_error("showArticleInHeadlines", e
);
366 function article_callback2(transport
, id
) {
368 debug("article_callback2 " + id
);
370 if (!transport
.responseText
&& db
) {
371 offlineConfirmModeChange();
375 if (transport
.responseXML
) {
377 if (!transport_error_check(transport
)) return;
379 /* var ll = $('LL-' + id);
380 var content = $('HLC-' + id);
382 if (ll && content) content.removeChild(ll); */
384 var upic
= $('FUPDPIC-' + id
);
387 upic
.src
= 'images/blank_icon.gif';
390 if (id
!= last_requested_article
) {
391 debug("requested article id is out of sequence, aborting");
397 debug("looking for articles to cache...");
399 var articles
= transport
.responseXML
.getElementsByTagName("article");
401 for (var i
= 0; i
< articles
.length
; i
++) {
402 var a_id
= articles
[i
].getAttribute("id");
404 debug("found id: " + a_id
);
406 if (a_id
== active_post_id
) {
407 debug("active article, rendering...");
408 render_article(articles
[i
].firstChild
.nodeValue
);
411 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
415 showArticleInHeadlines(id
);
418 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?", [id
]);
421 var reply
= transport
.responseXML
.firstChild
.firstChild
;
424 debug("article_callback: returned no XML object");
425 //var f = $("content-frame");
426 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
429 var date
= new Date();
430 last_article_view
= date
.getTime() / 1000;
432 if (typeof correctPNG
!= 'undefined') {
436 if (_reload_feedlist_after_view
) {
437 setTimeout('updateFeedList(false, false)', 50);
438 _reload_feedlist_after_view
= false;
440 if (transport
.responseXML
) {
441 var counters
= transport
.responseXML
.getElementsByTagName("counters")[0];
444 debug("parsing piggybacked counters: " + counters
);
445 parse_counters(counters
, false);
447 debug("counters container not found in reply, requesting...");
455 exception_error("article_callback2", e
, transport
);
461 debug("loading article: " + id
);
463 if (offline_mode
) return view_offline(id
);
465 var cached_article
= cache_find(id
);
467 debug("cache check result: " + (cached_article
!= false));
472 var query
= "?op=view&id=" + param_escape(id
);
474 var date
= new Date();
476 var neighbor_ids
= getRelativePostIds(active_post_id
);
478 /* only request uncached articles */
480 var cids_to_request
= Array();
482 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
483 if (!cache_check(neighbor_ids
[i
])) {
484 cids_to_request
.push(neighbor_ids
[i
]);
488 debug("additional ids: " + cids_to_request
.toString());
490 /* additional info for piggyback counters */
492 if (tagsAreDisplayed()) {
493 query
= query
+ "&omode=lt";
495 query
= query
+ "&omode=flc";
498 var date
= new Date();
499 var timestamp
= Math
.round(date
.getTime() / 1000);
500 query
= query
+ "&ts=" + timestamp
;
502 query
= query
+ "&cids=" + cids_to_request
.toString();
504 var crow
= $("RROW-" + id
);
505 var article_is_unread
= crow
.className
.match("Unread");
507 if (!async_counters_work
) {
508 query
= query
+ "&csync=true";
511 showArticleInHeadlines(id
);
513 if (!cached_article
) {
515 // notify_progress("Loading, please wait...", true);
517 /* var content = $('HLC-' + id);
519 if (content && !$('LL-' + id)) {
520 var ll = document.createElement('img');
522 ll.src = 'images/indicator_tiny.gif';
523 ll.className = 'hlLoading';
526 content.appendChild(ll);
530 var upic
= $('FUPDPIC-' + id
);
533 upic
.src
= 'images/indicator_white.gif';
536 } else if (cached_article
&& article_is_unread
) {
538 query
= query
+ "&mode=prefetch";
540 render_article(cached_article
);
542 } else if (cached_article
) {
544 query
= query
+ "&mode=prefetch_old";
545 render_article(cached_article
);
551 last_requested_article
= id
;
553 new Ajax
.Request("backend.php", {
555 onComplete: function(transport
) {
556 article_callback2(transport
, id
);
562 exception_error("view", e
);
567 return toggleMark(id
);
571 return togglePub(id
);
574 function tMark_afh_off(effect
) {
576 var elem
= effect
.effects
[0].element
;
578 debug("tMark_afh_off : " + elem
.id
);
581 elem
.src
= elem
.src
.replace("mark_set", "mark_unset");
582 elem
.alt
= __("Star article");
587 exception_error("tMark_afh_off", e
);
591 function tPub_afh_off(effect
) {
593 var elem
= effect
.effects
[0].element
;
595 debug("tPub_afh_off : " + elem
.id
);
598 elem
.src
= elem
.src
.replace("pub_set", "pub_unset");
599 elem
.alt
= __("Publish article");
604 exception_error("tPub_afh_off", e
);
608 function toggleMark(id
, client_only
, no_effects
) {
612 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
614 query
= query
+ "&afid=" + getActiveFeedId();
616 if (tagsAreDisplayed()) {
617 query
= query
+ "&omode=tl";
619 query
= query
+ "&omode=flc";
622 var mark_img
= $("FMPIC-" + id
);
624 if (!mark_img
) return;
626 var vfeedu
= $("FEEDU--1");
627 var crow
= $("RROW-" + id
);
629 if (mark_img
.src
.match("mark_unset")) {
630 mark_img
.src
= mark_img
.src
.replace("mark_unset", "mark_set");
631 mark_img
.alt
= __("Unstar article");
632 query
= query
+ "&mark=1";
635 db
.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id
]);
639 //mark_img.src = "images/mark_unset.png";
640 mark_img
.alt
= __("Please wait...");
641 query
= query
+ "&mark=0";
643 if ($("headlinesList") && !no_effects
) {
644 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tMark_afh_off
});
646 mark_img
.src
= mark_img
.src
.replace("mark_set", "mark_unset");
647 mark_img
.alt
= __("Star article");
651 db
.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id
]);
656 if (!no_effects
) update_local_feedlist_counters();
661 new Ajax
.Request("backend.php", {
663 onComplete: function(transport
) {
664 all_counters_callback2(transport
);
670 exception_error("toggleMark", e
);
674 function togglePub(id
, client_only
, no_effects
, note
) {
678 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
680 query
= query
+ "&afid=" + getActiveFeedId();
682 if (note
!= undefined) {
683 query
= query
+ "¬e=" + param_escape(note
);
685 query
= query
+ "¬e=undefined";
688 if (tagsAreDisplayed()) {
689 query
= query
+ "&omode=tl";
691 query
= query
+ "&omode=flc";
694 var mark_img
= $("FPPIC-" + id
);
696 if (!mark_img
) return;
698 var vfeedu
= $("FEEDU--2");
699 var crow
= $("RROW-" + id
);
701 if (mark_img
.src
.match("pub_unset") || note
!= undefined) {
702 mark_img
.src
= mark_img
.src
.replace("pub_unset", "pub_set");
703 mark_img
.alt
= __("Unpublish article");
704 query
= query
+ "&pub=1";
707 //mark_img.src = "images/pub_unset.png";
708 mark_img
.alt
= __("Please wait...");
709 query
= query
+ "&pub=0";
711 if ($("headlinesList") && !no_effects
) {
712 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tPub_afh_off
});
714 mark_img
.src
= mark_img
.src
.replace("pub_set", "pub_unset");
715 mark_img
.alt
= __("Publish article");
720 new Ajax
.Request("backend.php", {
722 onComplete: function(transport
) {
723 toggle_published_callback(transport
);
729 exception_error("togglePub", e
);
733 function correctHeadlinesOffset(id
) {
737 var hlist
= $("headlinesList");
738 var container
= $("headlinesInnerContainer");
739 var row
= $("RROW-" + id
);
741 var viewport
= container
.offsetHeight
;
743 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
744 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
746 debug("Rtop: " + rel_offset_top
+ " Rbtm: " + rel_offset_bottom
);
747 debug("Vport: " + viewport
);
749 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
750 container
.scrollTop
= row
.offsetTop
;
751 } else if (rel_offset_bottom
> viewport
) {
753 /* doesn't properly work with Opera in some cases because
754 Opera fucks up element scrolling */
756 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
760 exception_error("correctHeadlinesOffset", e
);
765 function moveToPost(mode
) {
772 rows
= cdmGetVisibleArticles();
774 rows
= getVisibleHeadlineIds();
780 if (!$('RROW-' + active_post_id
)) {
781 active_post_id
= false;
784 if (active_post_id
== false) {
785 next_id
= getFirstVisibleHeadlineId();
786 prev_id
= getLastVisibleHeadlineId();
788 for (var i
= 0; i
< rows
.length
; i
++) {
789 if (rows
[i
] == active_post_id
) {
796 if (mode
== "next") {
800 if (!cdmArticleIsActuallyVisible(next_id
)) {
801 cdmScrollToArticleId(next_id
);
803 cdmSelectArticles("none");
804 toggleUnread(next_id
, 0, true);
805 toggleSelected(next_id
);
808 correctHeadlinesOffset(next_id
);
809 view(next_id
, getActiveFeedId());
814 if (mode
== "prev") {
817 cdmScrollToArticleId(prev_id
);
818 cdmSelectArticles("none");
819 toggleUnread(prev_id
, 0, true);
820 toggleSelected(prev_id
);
822 correctHeadlinesOffset(prev_id
);
823 view(prev_id
, getActiveFeedId());
829 exception_error("moveToPost", e
);
833 function toggleSelected(id
) {
836 var cb
= $("RCHK-" + id
);
838 var row
= $("RROW-" + id
);
840 var nc
= row
.className
;
842 if (!nc
.match("Selected")) {
843 nc
= nc
+ "Selected";
848 // In CDM basically last selected article == active article
849 if (isCdmMode()) active_post_id
= id
;
851 nc
= nc
.replace("Selected", "");
861 exception_error("toggleSelected", e
);
865 function toggleUnread_afh(effect
) {
868 var elem
= effect
.element
;
869 elem
.style
.backgroundColor
= "";
872 exception_error("toggleUnread_afh", e
);
876 function toggleUnread(id
, cmode
, effect
) {
879 var row
= $("RROW-" + id
);
881 var nc
= row
.className
;
882 var is_selected
= row
.className
.match("Selected");
883 nc
= nc
.replace("Unread", "");
884 nc
= nc
.replace("Selected", "");
886 // since we are removing selection from the object, uncheck
887 // corresponding checkbox
889 var cb
= $("RCHK-" + id
);
894 // NOTE: I'm not sure that resetting selection here is a feature -fox
896 if (cmode
== undefined || cmode
== 2) {
897 if (row
.className
.match("Unread")) {
901 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
902 afterFinish
: toggleUnread_afh
,
903 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
907 row
.className
= nc
+ "Unread";
911 db
.execute("UPDATE articles SET unread = not unread "+
912 "WHERE id = ?", [id
]);
915 } else if (cmode
== 0) {
919 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
920 afterFinish
: toggleUnread_afh
,
921 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
925 db
.execute("UPDATE articles SET unread = 0 "+
926 "WHERE id = ?", [id
]);
929 } else if (cmode
== 1) {
930 row
.className
= nc
+ "Unread";
933 db
.execute("UPDATE articles SET unread = 1 "+
934 "WHERE id = ?", [id
]);
939 update_local_feedlist_counters();
941 // Disable unmarking as selected for the time being (16.05.08) -fox
942 if (is_selected
) row
.className
= row
.className
+ "Selected";
944 if (cmode
== undefined) cmode
= 2;
946 var query
= "?op=rpc&subop=catchupSelected" +
947 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
949 // notify_progress("Loading, please wait...");
951 new Ajax
.Request("backend.php", {
953 onComplete: function(transport
) {
954 all_counters_callback2(transport
);
960 exception_error("toggleUnread", e
);
964 function selectionRemoveLabel(id
) {
967 var ids
= getSelectedArticleIds2();
969 if (ids
.length
== 0) {
970 alert(__("No articles are selected."));
974 // var ok = confirm(__("Remove selected articles from label?"));
978 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
979 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
981 // notify_progress("Loading, please wait...");
983 cache_invalidate("F:" + (-11 - id
));
985 new Ajax
.Request("backend.php", {
987 onComplete: function(transport
) {
988 show_labels_in_headlines(transport
);
989 all_counters_callback2(transport
);
995 exception_error("selectionAssignLabel", e
);
1000 function selectionAssignLabel(id
) {
1003 var ids
= getSelectedArticleIds2();
1005 if (ids
.length
== 0) {
1006 alert(__("No articles are selected."));
1010 // var ok = confirm(__("Assign selected articles to label?"));
1014 cache_invalidate("F:" + (-11 - id
));
1016 var query
= "?op=rpc&subop=assignToLabel&ids=" +
1017 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
1019 // notify_progress("Loading, please wait...");
1021 new Ajax
.Request("backend.php", {
1023 onComplete: function(transport
) {
1024 show_labels_in_headlines(transport
);
1025 all_counters_callback2(transport
);
1031 exception_error("selectionAssignLabel", e
);
1036 function selectionToggleUnread(cdm_mode
, set_state
, callback_func
, no_error
) {
1041 rows
= cdmGetSelectedArticles();
1043 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1046 if (rows
.length
== 0 && !no_error
) {
1047 alert(__("No articles are selected."));
1051 for (i
= 0; i
< rows
.length
; i
++) {
1052 var row
= $("RROW-" + rows
[i
]);
1054 var nc
= row
.className
;
1055 nc
= nc
.replace("Unread", "");
1056 nc
= nc
.replace("Selected", "");
1058 if (set_state
== undefined) {
1059 if (row
.className
.match("Unread")) {
1060 row
.className
= nc
+ "Selected";
1062 row
.className
= nc
+ "UnreadSelected";
1065 db
.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
1070 if (set_state
== false) {
1071 row
.className
= nc
+ "Selected";
1073 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?",
1078 if (set_state
== true) {
1079 row
.className
= nc
+ "UnreadSelected";
1081 db
.execute("UPDATE articles SET unread = 1 WHERE id = ?",
1088 if (rows
.length
> 0) {
1090 update_local_feedlist_counters();
1094 if (set_state
== undefined) {
1096 } else if (set_state
== true) {
1098 } else if (set_state
== false) {
1102 var query
= "?op=rpc&subop=catchupSelected" +
1103 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
1105 notify_progress("Loading, please wait...");
1107 new Ajax
.Request("backend.php", {
1109 onComplete: function(transport
) {
1110 catchup_callback2(transport
, callback_func
);
1116 exception_error("selectionToggleUnread", e
);
1120 function selectionToggleMarked(cdm_mode
) {
1126 rows
= cdmGetSelectedArticles();
1128 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1131 if (rows
.length
== 0) {
1132 alert(__("No articles are selected."));
1136 for (i
= 0; i
< rows
.length
; i
++) {
1137 toggleMark(rows
[i
], true, true);
1140 update_local_feedlist_counters();
1142 if (rows
.length
> 0) {
1144 var query
= "?op=rpc&subop=markSelected&ids=" +
1145 param_escape(rows
.toString()) + "&cmode=2";
1147 query
= query
+ "&afid=" + getActiveFeedId();
1149 /* if (tagsAreDisplayed()) {
1150 query = query + "&omode=tl";
1152 query = query + "&omode=flc";
1155 query
= query
+ "&omode=lc";
1157 new Ajax
.Request("backend.php", {
1159 onComplete: function(transport
) {
1160 all_counters_callback2(transport
);
1166 exception_error("selectionToggleMarked", e
);
1170 function selectionTogglePublished(cdm_mode
) {
1176 rows
= cdmGetSelectedArticles();
1178 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1181 if (rows
.length
== 0) {
1182 alert(__("No articles are selected."));
1186 for (i
= 0; i
< rows
.length
; i
++) {
1187 togglePub(rows
[i
], true, true);
1190 if (rows
.length
> 0) {
1192 var query
= "?op=rpc&subop=publishSelected&ids=" +
1193 param_escape(rows
.toString()) + "&cmode=2";
1195 query
= query
+ "&afid=" + getActiveFeedId();
1197 /* if (tagsAreDisplayed()) {
1198 query = query + "&omode=tl";
1200 query = query + "&omode=flc";
1203 query
= query
+ "&omode=lc";
1205 new Ajax
.Request("backend.php", {
1207 onComplete: function(transport
) {
1208 all_counters_callback2(transport
);
1214 exception_error("selectionToggleMarked", e
);
1218 function cdmGetSelectedArticles() {
1219 var sel_articles
= new Array();
1220 var container
= $("headlinesInnerContainer");
1222 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1223 var child
= container
.childNodes
[i
];
1225 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Selected")) {
1226 var c_id
= child
.id
.replace("RROW-", "");
1227 sel_articles
.push(c_id
);
1231 return sel_articles
;
1234 function cdmGetVisibleArticles() {
1235 var sel_articles
= new Array();
1236 var container
= $("headlinesInnerContainer");
1238 if (!container
) return sel_articles
;
1240 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1241 var child
= container
.childNodes
[i
];
1243 if (child
.id
&& child
.id
.match("RROW-")) {
1244 var c_id
= child
.id
.replace("RROW-", "");
1245 sel_articles
.push(c_id
);
1249 return sel_articles
;
1252 function cdmGetUnreadArticles() {
1253 var sel_articles
= new Array();
1254 var container
= $("headlinesInnerContainer");
1256 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1257 var child
= container
.childNodes
[i
];
1259 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Unread")) {
1260 var c_id
= child
.id
.replace("RROW-", "");
1261 sel_articles
.push(c_id
);
1265 return sel_articles
;
1269 // mode = all,none,unread
1270 function cdmSelectArticles(mode
) {
1271 var container
= $("headlinesInnerContainer");
1273 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1274 var child
= container
.childNodes
[i
];
1276 if (child
.id
&& child
.id
.match("RROW-")) {
1277 var aid
= child
.id
.replace("RROW-", "");
1279 var cb
= $("RCHK-" + aid
);
1281 if (mode
== "all") {
1282 if (!child
.className
.match("Selected")) {
1283 child
.className
= child
.className
+ "Selected";
1286 } else if (mode
== "unread") {
1287 if (child
.className
.match("Unread") && !child
.className
.match("Selected")) {
1288 child
.className
= child
.className
+ "Selected";
1292 child
.className
= child
.className
.replace("Selected", "");
1299 function catchupPage() {
1301 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1303 var str
= __("Mark all visible articles in %s as read?");
1305 str
= str
.replace("%s", fn
);
1307 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1311 if ($("headlinesList")) {
1312 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
1313 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1314 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1316 cdmSelectArticles('all');
1317 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1318 cdmSelectArticles('none');
1322 function deleteSelection() {
1328 if ($("headlinesList")) {
1329 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1331 rows
= cdmGetSelectedArticles();
1334 if (rows
.length
== 0) {
1335 alert(__("No articles are selected."));
1340 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1344 if (getActiveFeedId() != 0) {
1345 str
= __("Delete %d selected articles in %s?");
1347 str
= __("Delete %d selected articles?");
1350 str
= str
.replace("%d", rows
.length
);
1351 str
= str
.replace("%s", fn
);
1353 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1357 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
1361 new Ajax
.Request("backend.php", {
1363 onComplete: function(transport
) {
1368 exception_error("deleteSelection", e
);
1372 function archiveSelection() {
1378 if ($("headlinesList")) {
1379 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1381 rows
= cdmGetSelectedArticles();
1384 if (rows
.length
== 0) {
1385 alert(__("No articles are selected."));
1390 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1394 if (getActiveFeedId() != 0) {
1395 str
= __("Archive %d selected articles in %s?");
1398 str
= __("Move %d archived articles back?");
1402 str
= str
.replace("%d", rows
.length
);
1403 str
= str
.replace("%s", fn
);
1405 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1409 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1413 for (var i
= 0; i
< rows
.length
; i
++) {
1414 cache_invalidate(rows
[i
]);
1417 new Ajax
.Request("backend.php", {
1419 onComplete: function(transport
) {
1424 exception_error("archiveSelection", e
);
1428 function catchupSelection() {
1434 if ($("headlinesList")) {
1435 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1437 rows
= cdmGetSelectedArticles();
1440 if (rows
.length
== 0) {
1441 alert(__("No articles are selected."));
1446 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1448 var str
= __("Mark %d selected articles in %s as read?");
1450 str
= str
.replace("%d", rows
.length
);
1451 str
= str
.replace("%s", fn
);
1453 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1457 if ($("headlinesList")) {
1458 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1459 // selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1461 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1462 // cdmSelectArticles('none');
1466 exception_error("catchupSelection", e
);
1470 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1471 displayDlg('editArticleTags', id
,
1473 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1474 "backend.php?op=rpc&subop=completeTags",
1475 { tokens
: ',', paramName
: "search" });
1480 function tag_saved_callback(transport
) {
1482 debug("in tag_saved_callback");
1487 if (tagsAreDisplayed()) {
1488 _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("tag_saved_callback", e
);
1512 function editTagsSave() {
1514 notify_progress("Saving article tags...");
1516 var form
= document
.forms
["tag_edit_form"];
1518 var query
= Form
.serialize("tag_edit_form");
1520 query
= "?op=rpc&subop=setArticleTags&" + query
;
1524 new Ajax
.Request("backend.php", {
1526 onComplete: function(transport
) {
1527 tag_saved_callback(transport
);
1532 function editTagsInsert() {
1535 var form
= document
.forms
["tag_edit_form"];
1537 var found_tags
= form
.found_tags
;
1538 var tags_str
= form
.tags_str
;
1540 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1542 if (tags_str
.value
.length
> 0 &&
1543 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1545 tags_str
.value
= tags_str
.value
+ ", ";
1548 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1550 found_tags
.selectedIndex
= 0;
1553 exception_error("editTagsInsert", e
);
1557 function cdmScrollViewport(where
) {
1558 debug("cdmScrollViewport: " + where
);
1560 var ctr
= $("headlinesInnerContainer");
1564 if (where
== "bottom") {
1565 ctr
.scrollTop
= ctr
.scrollHeight
;
1567 ctr
.scrollTop
= where
;
1571 function cdmArticleIsBelowViewport(id
) {
1573 var ctr
= $("headlinesInnerContainer");
1574 var e
= $("RROW-" + id
);
1576 if (!e
|| !ctr
) return;
1578 // article starts below viewport
1580 if (ctr
.scrollTop
< e
.offsetTop
) {
1587 exception_error("cdmArticleIsVisible", e
);
1591 function cdmArticleIsAboveViewport(id
) {
1593 var ctr
= $("headlinesInnerContainer");
1594 var e
= $("RROW-" + id
);
1596 if (!e
|| !ctr
) return;
1598 // article starts above viewport
1600 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1607 exception_error("cdmArticleIsVisible", e
);
1611 function cdmScrollToArticleId(id
) {
1613 var ctr
= $("headlinesInnerContainer");
1614 var e
= $("RROW-" + id
);
1616 if (!e
|| !ctr
) return;
1618 ctr
.scrollTop
= e
.offsetTop
;
1621 exception_error("cdmScrollToArticleId", e
);
1625 function cdmArticleIsActuallyVisible(id
) {
1627 var ctr
= $("headlinesInnerContainer");
1628 var e
= $("RROW-" + id
);
1630 if (!e
|| !ctr
) return;
1632 // article fits in viewport OR article is longer than viewport and
1633 // its bottom is visible
1635 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1636 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1640 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1641 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1642 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1651 exception_error("cdmArticleIsVisible", e
);
1655 function cdmWatchdog() {
1659 var ctr
= $("headlinesInnerContainer");
1663 var ids
= new Array();
1665 var e
= ctr
.firstChild
;
1668 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1669 e
.id
.match("RROW-")) {
1671 // article fits in viewport OR article is longer than viewport and
1672 // its bottom is visible
1674 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1675 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1677 // debug(e.id + " is visible " + e.offsetTop + "." +
1678 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1679 // (ctr.scrollTop + ctr.offsetHeight));
1681 ids
.push(e
.id
.replace("RROW-", ""));
1683 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1684 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1685 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1687 ids
.push(e
.id
.replace("RROW-", ""));
1691 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1693 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1694 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1696 ids.push(e.id.replace("RROW-", ""));
1705 debug("cdmWatchdog, ids= " + ids
.toString());
1707 if (ids
.length
> 0) {
1709 for (var i
= 0; i
< ids
.length
; i
++) {
1710 var e
= $("RROW-" + ids
[i
]);
1712 e
.className
= e
.className
.replace("Unread", "");
1716 var query
= "?op=rpc&subop=catchupSelected" +
1717 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1719 new Ajax
.Request("backend.php", {
1721 onComplete: function(transport
) {
1722 all_counters_callback2(transport
);
1727 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1730 exception_error("cdmWatchdog", e
);
1736 function cache_inject(id
, article
, param
) {
1738 if (!cache_check_param(id
, param
)) {
1739 debug("cache_article: miss: " + id
+ " [p=" + param
+ "]");
1744 var date
= new Date();
1745 var ts
= Math
.round(date
.getTime() / 1000);
1747 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1748 [id
, article
, param
, ts
]);
1751 var cache_obj
= new Array();
1753 cache_obj
["id"] = id
;
1754 cache_obj
["data"] = article
;
1755 cache_obj
["param"] = param
;
1757 article_cache
.push(cache_obj
);
1761 debug("cache_article: hit: " + id
+ " [p=" + param
+ "]");
1764 exception_error("cache_inject", e
);
1768 function cache_find(id
) {
1771 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1774 if (rs
.isValidRow()) {
1775 var a
= rs
.field(0);
1783 for (var i
= 0; i
< article_cache
.length
; i
++) {
1784 if (article_cache
[i
]["id"] == id
) {
1785 return article_cache
[i
]["data"];
1792 function cache_find_param(id
, param
) {
1795 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1799 if (rs
.isValidRow()) {
1808 for (var i
= 0; i
< article_cache
.length
; i
++) {
1809 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1810 return article_cache
[i
]["data"];
1817 function cache_check(id
) {
1820 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1824 if (rs
.isValidRow()) {
1825 a
= rs
.field(0) != "0";
1833 for (var i
= 0; i
< article_cache
.length
; i
++) {
1834 if (article_cache
[i
]["id"] == id
) {
1842 function cache_check_param(id
, param
) {
1845 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1849 if (rs
.isValidRow()) {
1850 a
= rs
.field(0) != "0";
1858 for (var i
= 0; i
< article_cache
.length
; i
++) {
1859 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1867 function cache_expire() {
1869 var date
= new Date();
1870 var ts
= Math
.round(date
.getTime() / 1000);
1872 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1873 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1874 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1878 while (article_cache
.length
> 25) {
1879 article_cache
.shift();
1884 function cache_empty() {
1885 article_cache
= new Array();
1888 function cache_invalidate(id
) {
1892 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1893 return rs
.rowsAffected
!= 0;
1898 while (i
< article_cache
.length
) {
1899 if (article_cache
[i
]["id"] == id
) {
1900 debug("cache_invalidate: removed id " + id
);
1901 article_cache
.splice(i
, 1);
1908 debug("cache_invalidate: id not found: " + id
);
1911 exception_error("cache_invalidate", e
);
1915 function getActiveArticleId() {
1916 return active_post_id
;
1919 function cdmClicked(id
) {
1921 var elem
= $("RROW-" + id
);
1924 var id
= elem
.id
.replace("RROW-", "");
1925 active_post_id
= id
;
1927 // cdmSelectArticles("none");
1928 toggleUnread(id
, 0, true);
1929 // toggleSelected(id);
1933 exception_error("cdmClicked", e
);
1937 function preload_article_callback(transport
) {
1939 if (transport
.responseXML
) {
1940 var articles
= transport
.responseXML
.getElementsByTagName("article");
1942 for (var i
= 0; i
< articles
.length
; i
++) {
1943 var id
= articles
[i
].getAttribute("id");
1944 if (!cache_check(id
)) {
1945 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1946 debug("preloaded article: " + id
);
1951 exception_error("preload_article_callback", e
);
1955 function preloadArticleUnderPointer(id
) {
1957 if (getInitParam("bw_limit") == "1") return;
1959 if (post_under_pointer
== id
&& !cache_check(id
)) {
1961 debug("trying to preload article " + id
);
1963 var neighbor_ids
= getRelativePostIds(id
, 1);
1965 /* only request uncached articles */
1967 var cids_to_request
= Array();
1969 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1970 if (!cache_check(neighbor_ids
[i
])) {
1971 cids_to_request
.push(neighbor_ids
[i
]);
1974 debug("additional ids: " + cids_to_request
.toString());
1976 cids_to_request
.push(id
);
1978 var query
= "?op=rpc&subop=getArticles&ids=" +
1979 cids_to_request
.toString();
1981 new Ajax
.Request("backend.php", {
1983 onComplete: function(transport
) {
1984 preload_article_callback(transport
);
1988 exception_error("preloadArticleUnderPointer", e
);
1992 function postMouseIn(id
) {
1994 if (post_under_pointer
!= id
) {
1995 post_under_pointer
= id
;
1997 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
2002 exception_error("postMouseIn", e
);
2006 function postMouseOut(id
) {
2008 post_under_pointer
= false;
2010 exception_error("postMouseOut", e
);
2014 function headlines_scroll_handler() {
2017 var e
= $("headlinesInnerContainer");
2019 var toolbar_form
= document
.forms
["main_toolbar_form"];
2021 debug((e
.scrollTop
+ e
.offsetHeight
) + " vs " + e
.scrollHeight
+ " dis? " +
2022 _infscroll_disable
);
2024 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
2025 if (!_infscroll_disable
) {
2026 debug("more cowbell!");
2032 exception_error("headlines_scroll_handler", e
);
2036 function catchupRelativeToArticle(below
) {
2041 if (!getActiveArticleId()) {
2042 alert(__("No article is selected."));
2048 if ($("headlinesList")) {
2049 visible_ids
= getVisibleHeadlineIds();
2051 visible_ids
= cdmGetVisibleArticles();
2054 var ids_to_mark
= new Array();
2057 for (var i
= 0; i
< visible_ids
.length
; i
++) {
2058 if (visible_ids
[i
] != getActiveArticleId()) {
2059 var e
= $("RROW-" + visible_ids
[i
]);
2061 if (e
&& e
.className
.match("Unread")) {
2062 ids_to_mark
.push(visible_ids
[i
]);
2069 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
2070 if (visible_ids
[i
] != getActiveArticleId()) {
2071 var e
= $("RROW-" + visible_ids
[i
]);
2073 if (e
&& e
.className
.match("Unread")) {
2074 ids_to_mark
.push(visible_ids
[i
]);
2082 if (ids_to_mark
.length
== 0) {
2083 alert(__("No articles found to mark"));
2085 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
2089 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
2090 var e
= $("RROW-" + ids_to_mark
[i
]);
2091 e
.className
= e
.className
.replace("Unread", "");
2094 var query
= "?op=rpc&subop=catchupSelected" +
2095 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
2097 new Ajax
.Request("backend.php", {
2099 onComplete: function(transport
) {
2100 catchup_callback2(transport
);
2107 exception_error("catchupRelativeToArticle", e
);
2111 function cdmExpandArticle(a_id
) {
2113 var id
= 'CICD-' + a_id
;
2116 Element
.hide("CEXC-" + a_id
);
2119 Effect
.Appear(id
, {duration
: 0.5,
2120 beforeStart: function(effect
) {
2121 var h_id
= 'CICH-' + a_id
;
2122 var h_elem
= $(h_id
);
2123 if (h_elem
) { h_elem
.style
.display
= "none"; }
2125 toggleUnread(a_id
, 0);
2130 exception_error("appearBlockElementF", e
);
2135 function fixHeadlinesOrder(ids
) {
2137 for (var i
= 0; i
< ids
.length
; i
++) {
2138 var e
= $("RROW-" + ids
[i
]);
2142 e
.className
= e
.className
.replace("even", "odd");
2144 e
.className
= e
.className
.replace("odd", "even");
2149 exception_error("fixHeadlinesOrder", e
);
2153 function hideReadHeadlines() {
2157 var vis_ids
= new Array();
2159 if ($("headlinesList")) {
2160 ids
= getVisibleHeadlineIds();
2162 ids
= cdmGetVisibleArticles();
2165 var read_headlines_visible
= true;
2167 for (var i
= 0; i
< ids
.length
; i
++) {
2168 var row
= $("RROW-" + ids
[i
]);
2170 if (row
&& row
.className
) {
2171 if (read_headlines_visible
) {
2172 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2174 vis_ids
.push(ids
[i
]);
2176 //Effect.Fade(row, {duration : 0.3});
2181 vis_ids
.push(ids
[i
]);
2186 fixHeadlinesOrder(vis_ids
);
2188 read_headlines_visible
= !read_headlines_visible
;
2191 exception_error("hideReadHeadlines", e
);
2195 function invertHeadlineSelection() {
2197 var rows
= new Array();
2201 r
= document
.getElementsByTagName("TR");
2203 r
= document
.getElementsByTagName("DIV");
2206 for (var i
= 0; i
< r
.length
; i
++) {
2207 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2212 for (var i
= 0; i
< rows
.length
; i
++) {
2213 var nc
= rows
[i
].className
;
2214 var id
= rows
[i
].id
.replace("RROW-", "");
2215 var cb
= $("RCHK-" + id
);
2217 if (!rows
[i
].className
.match("Selected")) {
2218 nc
= nc
+ "Selected";
2221 nc
= nc
.replace("Selected", "");
2225 rows
[i
].className
= nc
;
2230 exception_error("invertHeadlineSelection", e
);
2234 function getArticleUnderPointer() {
2235 return post_under_pointer
;
2238 function zoomToArticle(id
) {
2240 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2242 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2245 exception_error("zoomToArticle", e
);
2249 function showOriginalArticleInline(id
) {
2252 var query
= "?op=rpc&subop=getArticleLink&id=" + id
;
2254 notify_progress("Loading, please wait...", true);
2256 new Ajax
.Request("backend.php", {
2258 onComplete: function(transport
) {
2260 if (transport
.responseXML
) {
2262 var link
= transport
.responseXML
.getElementsByTagName("link")[0];
2263 var id
= transport
.responseXML
.getElementsByTagName("id")[0];
2268 link
= link
.firstChild
.nodeValue
;
2270 var ci
= $("content-insert");
2272 var tmp
= "<iframe id=\"inline_orig_article\" width=\""+ci
.offsetWidth
+"\" height=\""+ci
.offsetHeight
+"\" style=\"border-width : 0px;\" src=\""+link
+"\"></iframe>";
2274 render_article(tmp
);
2281 exception_error("showOriginalArticleInline", e
);
2286 function scrollArticle(offset
) {
2289 var ci
= $("content-insert");
2291 ci
.scrollTop
+= offset
;
2294 var hi
= $("headlinesInnerContainer");
2296 hi
.scrollTop
+= offset
;
2301 exception_error("scrollArticle", e
);
2305 function show_labels_in_headlines(transport
) {
2307 if (transport
.responseXML
) {
2308 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2310 var elems
= info
.getElementsByTagName("entry");
2312 for (var l
= 0; l
< elems
.length
; l
++) {
2313 var e_id
= elems
[l
].getAttribute("id");
2317 var ctr
= $("HLLCTR-" + e_id
);
2320 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2328 exception_error("show_labels_in_headlines", e
);
2333 function toggleHeadlineActions() {
2335 var e
= $("headlineActionsBody");
2336 var p
= $("headlineActionsDrop");
2338 if (!Element
.visible(e
)) {
2345 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2346 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2349 exception_error("toggleHeadlineActions", e
);
2353 function publishWithNote(id
, def_note
) {
2355 if (!def_note
) def_note
= '';
2357 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2359 if (note
!= undefined) {
2360 togglePub(id
, false, false, note
);
2364 exception_error("publishWithNote", e
);