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 console
.log("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 console
.log("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 console
.log("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 console
.log("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 console
.log("adding some more headlines...");
162 var c
= $("headlinesList");
165 c
= $("headlinesInnerContainer");
168 var ids
= getSelectedArticleIds2();
170 c
.innerHTML
= c
.innerHTML
+ headlines
.firstChild
.nodeValue
;
172 console
.log("restore selected ids: " + ids
);
174 for (var i
= 0; i
< ids
.length
; i
++) {
175 markHeadline(ids
[i
]);
179 console
.log("no new headlines received");
182 console
.log("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 console
.log("found id: " + a_id
);
192 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
195 console
.log("no cached articles received");
199 console
.log("parsing piggybacked counters: " + counters
);
200 parse_counters(counters
, false);
202 console
.log("counters container not found in reply, requesting...");
207 console
.log("parsing runtime info: " + runtime_info
[0]);
208 parse_runtime_info(runtime_info
[0]);
210 console
.log("counters container not found in reply");
214 console
.log("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 console
.log("starting CDM watchdog");
228 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 5000);
229 _cdm_wd_vishist
= new Array();
231 console
.log("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 console
.log("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 console
.log("requested article id is out of sequence, aborting");
364 console
.log("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 console
.log("found id: " + a_id
);
373 if (a_id
== active_post_id
) {
374 console
.log("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 console
.log("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 console
.log("parsing piggybacked counters: " + counters
);
412 parse_counters(counters
, false);
414 console
.log("counters container not found in reply, requesting...");
422 exception_error("article_callback2", e
, transport
);
428 console
.log("loading article: " + id
);
430 if (offline_mode
) return view_offline(id
);
432 var cached_article
= cache_find(id
);
434 console
.log("cache check result: " + (cached_article
!= false));
439 var query
= "?op=view&id=" + param_escape(id
);
441 var neighbor_ids
= getRelativePostIds(active_post_id
);
443 /* only request uncached articles */
445 var cids_to_request
= Array();
447 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
448 if (!cache_check(neighbor_ids
[i
])) {
449 cids_to_request
.push(neighbor_ids
[i
]);
453 console
.log("additional ids: " + cids_to_request
.toString());
455 /* additional info for piggyback counters */
457 if (tagsAreDisplayed()) {
458 query
= query
+ "&omode=lt";
460 query
= query
+ "&omode=flc";
463 query
= query
+ "&cids=" + cids_to_request
.toString();
465 var crow
= $("RROW-" + id
);
466 var article_is_unread
= crow
.className
.match("Unread");
468 if (!async_counters_work
) {
469 query
= query
+ "&csync=true";
472 showArticleInHeadlines(id
);
474 if (!cached_article
) {
476 var upic
= $('FUPDPIC-' + id
);
479 upic
.src
= getInitParam("sign_progress");
482 } else if (cached_article
&& article_is_unread
) {
484 query
= query
+ "&mode=prefetch";
486 render_article(cached_article
);
488 } else if (cached_article
) {
490 query
= query
+ "&mode=prefetch_old";
491 render_article(cached_article
);
497 last_requested_article
= id
;
499 new Ajax
.Request("backend.php", {
501 onComplete: function(transport
) {
502 article_callback2(transport
, id
);
508 exception_error("view", e
);
513 return toggleMark(id
);
517 return togglePub(id
);
520 function tMark_afh_off(effect
) {
522 var elem
= effect
.effects
[0].element
;
524 console
.log("tMark_afh_off : " + elem
.id
);
527 elem
.src
= elem
.src
.replace("mark_set", "mark_unset");
528 elem
.alt
= __("Star article");
533 exception_error("tMark_afh_off", e
);
537 function tPub_afh_off(effect
) {
539 var elem
= effect
.effects
[0].element
;
541 console
.log("tPub_afh_off : " + elem
.id
);
544 elem
.src
= elem
.src
.replace("pub_set", "pub_unset");
545 elem
.alt
= __("Publish article");
550 exception_error("tPub_afh_off", e
);
554 function toggleMark(id
, client_only
, no_effects
) {
558 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
560 query
= query
+ "&afid=" + getActiveFeedId();
562 if (tagsAreDisplayed()) {
563 query
= query
+ "&omode=tl";
565 query
= query
+ "&omode=flc";
568 var mark_img
= $("FMPIC-" + id
);
570 if (!mark_img
) return;
572 var vfeedu
= $("FEEDU--1");
573 var crow
= $("RROW-" + id
);
575 if (mark_img
.src
.match("mark_unset")) {
576 mark_img
.src
= mark_img
.src
.replace("mark_unset", "mark_set");
577 mark_img
.alt
= __("Unstar article");
578 query
= query
+ "&mark=1";
581 db
.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id
]);
585 mark_img
.alt
= __("Please wait...");
586 query
= query
+ "&mark=0";
588 if ($("headlinesList") && !no_effects
) {
589 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tMark_afh_off
});
591 mark_img
.src
= mark_img
.src
.replace("mark_set", "mark_unset");
592 mark_img
.alt
= __("Star article");
596 db
.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id
]);
601 if (!no_effects
) update_local_feedlist_counters();
606 new Ajax
.Request("backend.php", {
608 onComplete: function(transport
) {
609 all_counters_callback2(transport
);
615 exception_error("toggleMark", e
);
619 function togglePub(id
, client_only
, no_effects
, note
) {
623 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
625 query
= query
+ "&afid=" + getActiveFeedId();
627 if (note
!= undefined) {
628 query
= query
+ "¬e=" + param_escape(note
);
630 query
= query
+ "¬e=undefined";
633 if (tagsAreDisplayed()) {
634 query
= query
+ "&omode=tl";
636 query
= query
+ "&omode=flc";
639 var mark_img
= $("FPPIC-" + id
);
641 if (!mark_img
) return;
643 var vfeedu
= $("FEEDU--2");
644 var crow
= $("RROW-" + id
);
646 if (mark_img
.src
.match("pub_unset") || note
!= undefined) {
647 mark_img
.src
= mark_img
.src
.replace("pub_unset", "pub_set");
648 mark_img
.alt
= __("Unpublish article");
649 query
= query
+ "&pub=1";
652 mark_img
.alt
= __("Please wait...");
653 query
= query
+ "&pub=0";
655 if ($("headlinesList") && !no_effects
) {
656 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tPub_afh_off
});
658 mark_img
.src
= mark_img
.src
.replace("pub_set", "pub_unset");
659 mark_img
.alt
= __("Publish article");
664 new Ajax
.Request("backend.php", {
666 onComplete: function(transport
) {
667 all_counters_callback2(transport
);
669 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
672 var note_id
= note
.getAttribute("id");
673 var note_size
= note
.getAttribute("size");
674 var note_content
= note
.firstChild
.nodeValue
;
676 var container
= $('POSTNOTE-' + note_id
);
678 cache_invalidate(note_id
);
681 if (note_size
== "0") {
682 Element
.hide(container
);
684 container
.innerHTML
= note_content
;
685 Element
.show(container
);
694 exception_error("togglePub", e
);
698 function correctHeadlinesOffset(id
) {
702 var hlist
= $("headlinesList");
703 var container
= $("headlinesInnerContainer");
704 var row
= $("RROW-" + id
);
706 var viewport
= container
.offsetHeight
;
708 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
709 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
711 console
.log("Rtop: " + rel_offset_top
+ " Rbtm: " + rel_offset_bottom
);
712 console
.log("Vport: " + viewport
);
714 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
715 container
.scrollTop
= row
.offsetTop
;
716 } else if (rel_offset_bottom
> viewport
) {
718 /* doesn't properly work with Opera in some cases because
719 Opera fucks up element scrolling */
721 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
725 exception_error("correctHeadlinesOffset", e
);
730 function moveToPost(mode
) {
737 rows
= cdmGetVisibleArticles();
739 rows
= getVisibleHeadlineIds();
745 if (!$('RROW-' + active_post_id
)) {
746 active_post_id
= false;
749 if (active_post_id
== false) {
750 next_id
= getFirstVisibleHeadlineId();
751 prev_id
= getLastVisibleHeadlineId();
753 for (var i
= 0; i
< rows
.length
; i
++) {
754 if (rows
[i
] == active_post_id
) {
761 if (mode
== "next") {
765 if (!cdmArticleIsActuallyVisible(next_id
)) {
766 cdmScrollToArticleId(next_id
);
768 cdmSelectArticles("none");
769 toggleUnread(next_id
, 0, true);
770 toggleSelected(next_id
);
773 correctHeadlinesOffset(next_id
);
774 view(next_id
, getActiveFeedId());
779 if (mode
== "prev") {
782 cdmScrollToArticleId(prev_id
);
783 cdmSelectArticles("none");
784 toggleUnread(prev_id
, 0, true);
785 toggleSelected(prev_id
);
787 correctHeadlinesOffset(prev_id
);
788 view(prev_id
, getActiveFeedId());
794 exception_error("moveToPost", e
);
798 function toggleSelected(id
) {
801 var cb
= $("RCHK-" + id
);
803 var row
= $("RROW-" + id
);
805 var nc
= row
.className
;
807 if (!nc
.match("Selected")) {
808 nc
= nc
+ "Selected";
813 // In CDM basically last selected article == active article
814 if (isCdmMode()) active_post_id
= id
;
816 nc
= nc
.replace("Selected", "");
826 exception_error("toggleSelected", e
);
830 function toggleUnread_afh(effect
) {
833 var elem
= effect
.element
;
834 elem
.style
.backgroundColor
= "";
837 exception_error("toggleUnread_afh", e
);
841 function toggleUnread(id
, cmode
, effect
) {
844 var row
= $("RROW-" + id
);
846 var nc
= row
.className
;
847 var is_selected
= row
.className
.match("Selected");
848 nc
= nc
.replace("Unread", "");
849 nc
= nc
.replace("Selected", "");
851 // since we are removing selection from the object, uncheck
852 // corresponding checkbox
854 var cb
= $("RCHK-" + id
);
859 // NOTE: I'm not sure that resetting selection here is a feature -fox
861 if (cmode
== undefined || cmode
== 2) {
862 if (row
.className
.match("Unread")) {
866 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
867 afterFinish
: toggleUnread_afh
,
868 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
872 row
.className
= nc
+ "Unread";
876 db
.execute("UPDATE articles SET unread = not unread "+
877 "WHERE id = ?", [id
]);
880 } else if (cmode
== 0) {
884 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
885 afterFinish
: toggleUnread_afh
,
886 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
890 db
.execute("UPDATE articles SET unread = 0 "+
891 "WHERE id = ?", [id
]);
894 } else if (cmode
== 1) {
895 row
.className
= nc
+ "Unread";
898 db
.execute("UPDATE articles SET unread = 1 "+
899 "WHERE id = ?", [id
]);
904 update_local_feedlist_counters();
906 // Disable unmarking as selected for the time being (16.05.08) -fox
907 if (is_selected
) row
.className
= row
.className
+ "Selected";
909 if (cmode
== undefined) cmode
= 2;
911 var query
= "?op=rpc&subop=catchupSelected" +
912 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
914 // notify_progress("Loading, please wait...");
916 new Ajax
.Request("backend.php", {
918 onComplete: function(transport
) {
919 all_counters_callback2(transport
);
925 exception_error("toggleUnread", e
);
929 function selectionRemoveLabel(id
) {
932 var ids
= getSelectedArticleIds2();
934 if (ids
.length
== 0) {
935 alert(__("No articles are selected."));
939 // var ok = confirm(__("Remove selected articles from label?"));
943 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
944 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
946 // notify_progress("Loading, please wait...");
948 cache_invalidate("F:" + (-11 - id
));
950 new Ajax
.Request("backend.php", {
952 onComplete: function(transport
) {
953 show_labels_in_headlines(transport
);
954 all_counters_callback2(transport
);
960 exception_error("selectionAssignLabel", e
);
965 function selectionAssignLabel(id
) {
968 var ids
= getSelectedArticleIds2();
970 if (ids
.length
== 0) {
971 alert(__("No articles are selected."));
975 // var ok = confirm(__("Assign selected articles to label?"));
979 cache_invalidate("F:" + (-11 - id
));
981 var query
= "?op=rpc&subop=assignToLabel&ids=" +
982 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
984 // notify_progress("Loading, please wait...");
986 new Ajax
.Request("backend.php", {
988 onComplete: function(transport
) {
989 show_labels_in_headlines(transport
);
990 all_counters_callback2(transport
);
996 exception_error("selectionAssignLabel", e
);
1001 function selectionToggleUnread(cdm_mode
, set_state
, callback_func
, no_error
) {
1006 rows
= cdmGetSelectedArticles();
1008 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1011 if (rows
.length
== 0 && !no_error
) {
1012 alert(__("No articles are selected."));
1016 for (i
= 0; i
< rows
.length
; i
++) {
1017 var row
= $("RROW-" + rows
[i
]);
1019 var nc
= row
.className
;
1020 nc
= nc
.replace("Unread", "");
1021 nc
= nc
.replace("Selected", "");
1023 if (set_state
== undefined) {
1024 if (row
.className
.match("Unread")) {
1025 row
.className
= nc
+ "Selected";
1027 row
.className
= nc
+ "UnreadSelected";
1030 db
.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
1035 if (set_state
== false) {
1036 row
.className
= nc
+ "Selected";
1038 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?",
1043 if (set_state
== true) {
1044 row
.className
= nc
+ "UnreadSelected";
1046 db
.execute("UPDATE articles SET unread = 1 WHERE id = ?",
1053 if (rows
.length
> 0) {
1055 update_local_feedlist_counters();
1059 if (set_state
== undefined) {
1061 } else if (set_state
== true) {
1063 } else if (set_state
== false) {
1067 var query
= "?op=rpc&subop=catchupSelected" +
1068 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
1070 notify_progress("Loading, please wait...");
1072 new Ajax
.Request("backend.php", {
1074 onComplete: function(transport
) {
1075 catchup_callback2(transport
, callback_func
);
1081 exception_error("selectionToggleUnread", e
);
1085 function selectionToggleMarked(cdm_mode
) {
1091 rows
= cdmGetSelectedArticles();
1093 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1096 if (rows
.length
== 0) {
1097 alert(__("No articles are selected."));
1101 for (i
= 0; i
< rows
.length
; i
++) {
1102 toggleMark(rows
[i
], true, true);
1105 update_local_feedlist_counters();
1107 if (rows
.length
> 0) {
1109 var query
= "?op=rpc&subop=markSelected&ids=" +
1110 param_escape(rows
.toString()) + "&cmode=2";
1112 query
= query
+ "&afid=" + getActiveFeedId();
1114 query
= query
+ "&omode=lc";
1116 new Ajax
.Request("backend.php", {
1118 onComplete: function(transport
) {
1119 all_counters_callback2(transport
);
1125 exception_error("selectionToggleMarked", e
);
1129 function selectionTogglePublished(cdm_mode
) {
1135 rows
= cdmGetSelectedArticles();
1137 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1140 if (rows
.length
== 0) {
1141 alert(__("No articles are selected."));
1145 for (i
= 0; i
< rows
.length
; i
++) {
1146 togglePub(rows
[i
], true, true);
1149 if (rows
.length
> 0) {
1151 var query
= "?op=rpc&subop=publishSelected&ids=" +
1152 param_escape(rows
.toString()) + "&cmode=2";
1154 query
= query
+ "&afid=" + getActiveFeedId();
1156 query
= query
+ "&omode=lc";
1158 new Ajax
.Request("backend.php", {
1160 onComplete: function(transport
) {
1161 all_counters_callback2(transport
);
1167 exception_error("selectionToggleMarked", e
);
1171 function cdmGetSelectedArticles() {
1172 var sel_articles
= new Array();
1173 var container
= $("headlinesInnerContainer");
1175 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1176 var child
= container
.childNodes
[i
];
1178 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Selected")) {
1179 var c_id
= child
.id
.replace("RROW-", "");
1180 sel_articles
.push(c_id
);
1184 return sel_articles
;
1187 function cdmGetVisibleArticles() {
1188 var sel_articles
= new Array();
1189 var container
= $("headlinesInnerContainer");
1191 if (!container
) return sel_articles
;
1193 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1194 var child
= container
.childNodes
[i
];
1196 if (child
.id
&& child
.id
.match("RROW-")) {
1197 var c_id
= child
.id
.replace("RROW-", "");
1198 sel_articles
.push(c_id
);
1202 return sel_articles
;
1205 function cdmGetUnreadArticles() {
1206 var sel_articles
= new Array();
1207 var container
= $("headlinesInnerContainer");
1209 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1210 var child
= container
.childNodes
[i
];
1212 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Unread")) {
1213 var c_id
= child
.id
.replace("RROW-", "");
1214 sel_articles
.push(c_id
);
1218 return sel_articles
;
1222 // mode = all,none,unread
1223 function cdmSelectArticles(mode
) {
1224 var container
= $("headlinesInnerContainer");
1226 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1227 var child
= container
.childNodes
[i
];
1229 if (child
.id
&& child
.id
.match("RROW-")) {
1230 var aid
= child
.id
.replace("RROW-", "");
1232 var cb
= $("RCHK-" + aid
);
1234 if (mode
== "all") {
1235 if (!child
.className
.match("Selected")) {
1236 child
.className
= child
.className
+ "Selected";
1239 } else if (mode
== "unread") {
1240 if (child
.className
.match("Unread") && !child
.className
.match("Selected")) {
1241 child
.className
= child
.className
+ "Selected";
1245 child
.className
= child
.className
.replace("Selected", "");
1252 function catchupPage() {
1254 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1256 var str
= __("Mark all visible articles in %s as read?");
1258 str
= str
.replace("%s", fn
);
1260 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1264 if ($("headlinesList")) {
1265 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
1266 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1267 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1269 cdmSelectArticles('all');
1270 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1271 cdmSelectArticles('none');
1275 function deleteSelection() {
1281 if ($("headlinesList")) {
1282 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1284 rows
= cdmGetSelectedArticles();
1287 if (rows
.length
== 0) {
1288 alert(__("No articles are selected."));
1293 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1297 if (getActiveFeedId() != 0) {
1298 str
= __("Delete %d selected articles in %s?");
1300 str
= __("Delete %d selected articles?");
1303 str
= str
.replace("%d", rows
.length
);
1304 str
= str
.replace("%s", fn
);
1306 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1310 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
1314 new Ajax
.Request("backend.php", {
1316 onComplete: function(transport
) {
1321 exception_error("deleteSelection", e
);
1325 function archiveSelection() {
1331 if ($("headlinesList")) {
1332 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1334 rows
= cdmGetSelectedArticles();
1337 if (rows
.length
== 0) {
1338 alert(__("No articles are selected."));
1343 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1347 if (getActiveFeedId() != 0) {
1348 str
= __("Archive %d selected articles in %s?");
1351 str
= __("Move %d archived articles back?");
1355 str
= str
.replace("%d", rows
.length
);
1356 str
= str
.replace("%s", fn
);
1358 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1362 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1366 for (var i
= 0; i
< rows
.length
; i
++) {
1367 cache_invalidate(rows
[i
]);
1370 new Ajax
.Request("backend.php", {
1372 onComplete: function(transport
) {
1377 exception_error("archiveSelection", e
);
1381 function catchupSelection() {
1387 if ($("headlinesList")) {
1388 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1390 rows
= cdmGetSelectedArticles();
1393 if (rows
.length
== 0) {
1394 alert(__("No articles are selected."));
1399 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1401 var str
= __("Mark %d selected articles in %s as read?");
1403 str
= str
.replace("%d", rows
.length
);
1404 str
= str
.replace("%s", fn
);
1406 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1410 if ($("headlinesList")) {
1411 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1413 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1417 exception_error("catchupSelection", e
);
1421 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1422 displayDlg('editArticleTags', id
,
1424 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1425 "backend.php?op=rpc&subop=completeTags",
1426 { tokens
: ',', paramName
: "search" });
1430 function editTagsSave() {
1432 notify_progress("Saving article tags...");
1434 var form
= document
.forms
["tag_edit_form"];
1436 var query
= Form
.serialize("tag_edit_form");
1438 query
= "?op=rpc&subop=setArticleTags&" + query
;
1442 new Ajax
.Request("backend.php", {
1444 onComplete: function(transport
) {
1446 console
.log("tags saved...");
1451 if (tagsAreDisplayed()) {
1452 _reload_feedlist_after_view
= true;
1455 if (transport
.responseXML
) {
1456 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1459 var id
= tags_str
.getAttribute("id");
1462 var tags
= $("ATSTR-" + id
);
1464 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1467 cache_invalidate(id
);
1473 exception_error("editTagsSave", e
);
1478 function editTagsInsert() {
1481 var form
= document
.forms
["tag_edit_form"];
1483 var found_tags
= form
.found_tags
;
1484 var tags_str
= form
.tags_str
;
1486 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1488 if (tags_str
.value
.length
> 0 &&
1489 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1491 tags_str
.value
= tags_str
.value
+ ", ";
1494 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1496 found_tags
.selectedIndex
= 0;
1499 exception_error("editTagsInsert", e
);
1503 function cdmScrollViewport(where
) {
1504 console
.log("cdmScrollViewport: " + where
);
1506 var ctr
= $("headlinesInnerContainer");
1510 if (where
== "bottom") {
1511 ctr
.scrollTop
= ctr
.scrollHeight
;
1513 ctr
.scrollTop
= where
;
1517 function cdmArticleIsBelowViewport(id
) {
1519 var ctr
= $("headlinesInnerContainer");
1520 var e
= $("RROW-" + id
);
1522 if (!e
|| !ctr
) return;
1524 // article starts below viewport
1526 if (ctr
.scrollTop
< e
.offsetTop
) {
1533 exception_error("cdmArticleIsVisible", e
);
1537 function cdmArticleIsAboveViewport(id
) {
1539 var ctr
= $("headlinesInnerContainer");
1540 var e
= $("RROW-" + id
);
1542 if (!e
|| !ctr
) return;
1544 // article starts above viewport
1546 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1553 exception_error("cdmArticleIsVisible", e
);
1557 function cdmScrollToArticleId(id
) {
1559 var ctr
= $("headlinesInnerContainer");
1560 var e
= $("RROW-" + id
);
1562 if (!e
|| !ctr
) return;
1564 ctr
.scrollTop
= e
.offsetTop
;
1567 exception_error("cdmScrollToArticleId", e
);
1571 function cdmArticleIsActuallyVisible(id
) {
1573 var ctr
= $("headlinesInnerContainer");
1574 var e
= $("RROW-" + id
);
1576 if (!e
|| !ctr
) return;
1578 // article fits in viewport OR article is longer than viewport and
1579 // its bottom is visible
1581 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1582 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1586 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1587 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1588 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1597 exception_error("cdmArticleIsVisible", e
);
1601 function cdmWatchdog() {
1605 var ctr
= $("headlinesInnerContainer");
1609 var ids
= new Array();
1611 var e
= ctr
.firstChild
;
1614 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1615 e
.id
.match("RROW-")) {
1617 // article fits in viewport OR article is longer than viewport and
1618 // its bottom is visible
1620 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1621 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1623 // console.log(e.id + " is visible " + e.offsetTop + "." +
1624 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1625 // (ctr.scrollTop + ctr.offsetHeight));
1627 ids
.push(e
.id
.replace("RROW-", ""));
1629 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1630 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1631 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1633 ids
.push(e
.id
.replace("RROW-", ""));
1637 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1639 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1640 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1642 ids.push(e.id.replace("RROW-", ""));
1651 console
.log("cdmWatchdog, ids= " + ids
.toString());
1653 if (ids
.length
> 0) {
1655 for (var i
= 0; i
< ids
.length
; i
++) {
1656 var e
= $("RROW-" + ids
[i
]);
1658 e
.className
= e
.className
.replace("Unread", "");
1662 var query
= "?op=rpc&subop=catchupSelected" +
1663 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1665 new Ajax
.Request("backend.php", {
1667 onComplete: function(transport
) {
1668 all_counters_callback2(transport
);
1673 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1676 exception_error("cdmWatchdog", e
);
1682 function cache_inject(id
, article
, param
) {
1684 if (!cache_check_param(id
, param
)) {
1685 console
.log("cache_article: miss: " + id
+ " [p=" + param
+ "]");
1689 var date
= new Date();
1690 var ts
= Math
.round(date
.getTime() / 1000);
1692 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1693 [id
, article
, param
, ts
]);
1696 var cache_obj
= new Array();
1698 cache_obj
["id"] = id
;
1699 cache_obj
["data"] = article
;
1700 cache_obj
["param"] = param
;
1702 article_cache
.push(cache_obj
);
1706 console
.log("cache_article: hit: " + id
+ " [p=" + param
+ "]");
1709 exception_error("cache_inject", e
);
1713 function cache_find(id
) {
1716 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1719 if (rs
.isValidRow()) {
1720 var a
= rs
.field(0);
1728 for (var i
= 0; i
< article_cache
.length
; i
++) {
1729 if (article_cache
[i
]["id"] == id
) {
1730 return article_cache
[i
]["data"];
1737 function cache_find_param(id
, param
) {
1740 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1744 if (rs
.isValidRow()) {
1753 for (var i
= 0; i
< article_cache
.length
; i
++) {
1754 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1755 return article_cache
[i
]["data"];
1762 function cache_check(id
) {
1765 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1769 if (rs
.isValidRow()) {
1770 a
= rs
.field(0) != "0";
1778 for (var i
= 0; i
< article_cache
.length
; i
++) {
1779 if (article_cache
[i
]["id"] == id
) {
1787 function cache_check_param(id
, param
) {
1790 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1794 if (rs
.isValidRow()) {
1795 a
= rs
.field(0) != "0";
1803 for (var i
= 0; i
< article_cache
.length
; i
++) {
1804 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1812 function cache_expire() {
1814 var date
= new Date();
1815 var ts
= Math
.round(date
.getTime() / 1000);
1817 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1818 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1819 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1823 while (article_cache
.length
> 25) {
1824 article_cache
.shift();
1829 function cache_flush() {
1830 article_cache
= new Array();
1833 function cache_invalidate(id
) {
1837 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1838 return rs
.rowsAffected
!= 0;
1843 while (i
< article_cache
.length
) {
1844 if (article_cache
[i
]["id"] == id
) {
1845 console
.log("cache_invalidate: removed id " + id
);
1846 article_cache
.splice(i
, 1);
1853 console
.log("cache_invalidate: id not found: " + id
);
1856 exception_error("cache_invalidate", e
);
1860 function getActiveArticleId() {
1861 return active_post_id
;
1864 function cdmClicked(id
) {
1866 var elem
= $("RROW-" + id
);
1869 var id
= elem
.id
.replace("RROW-", "");
1870 active_post_id
= id
;
1872 // cdmSelectArticles("none");
1873 toggleUnread(id
, 0, true);
1874 // toggleSelected(id);
1878 exception_error("cdmClicked", e
);
1882 function preloadArticleUnderPointer(id
) {
1884 if (getInitParam("bw_limit") == "1") return;
1886 if (post_under_pointer
== id
&& !cache_check(id
)) {
1888 console
.log("trying to preload article " + id
);
1890 var neighbor_ids
= getRelativePostIds(id
, 1);
1892 /* only request uncached articles */
1894 var cids_to_request
= Array();
1896 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1897 if (!cache_check(neighbor_ids
[i
])) {
1898 cids_to_request
.push(neighbor_ids
[i
]);
1901 console
.log("additional ids: " + cids_to_request
.toString());
1903 cids_to_request
.push(id
);
1905 var query
= "?op=rpc&subop=getArticles&ids=" +
1906 cids_to_request
.toString();
1908 new Ajax
.Request("backend.php", {
1910 onComplete: function(transport
) {
1911 var articles
= transport
.responseXML
.getElementsByTagName("article");
1913 for (var i
= 0; i
< articles
.length
; i
++) {
1914 var id
= articles
[i
].getAttribute("id");
1915 if (!cache_check(id
)) {
1916 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1917 console
.log("preloaded article: " + id
);
1923 exception_error("preloadArticleUnderPointer", e
);
1927 function postMouseIn(id
) {
1929 if (post_under_pointer
!= id
) {
1930 post_under_pointer
= id
;
1932 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1937 exception_error("postMouseIn", e
);
1941 function postMouseOut(id
) {
1943 post_under_pointer
= false;
1945 exception_error("postMouseOut", e
);
1949 function headlines_scroll_handler() {
1952 var e
= $("headlinesInnerContainer");
1954 var toolbar_form
= document
.forms
["main_toolbar_form"];
1956 console
.log((e
.scrollTop
+ e
.offsetHeight
) + " vs " + e
.scrollHeight
+ " dis? " +
1957 _infscroll_disable
);
1959 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1960 if (!_infscroll_disable
) {
1961 console
.log("more cowbell!");
1967 exception_error("headlines_scroll_handler", e
);
1971 function catchupRelativeToArticle(below
) {
1976 if (!getActiveArticleId()) {
1977 alert(__("No article is selected."));
1983 if ($("headlinesList")) {
1984 visible_ids
= getVisibleHeadlineIds();
1986 visible_ids
= cdmGetVisibleArticles();
1989 var ids_to_mark
= new Array();
1992 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1993 if (visible_ids
[i
] != getActiveArticleId()) {
1994 var e
= $("RROW-" + visible_ids
[i
]);
1996 if (e
&& e
.className
.match("Unread")) {
1997 ids_to_mark
.push(visible_ids
[i
]);
2004 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
2005 if (visible_ids
[i
] != getActiveArticleId()) {
2006 var e
= $("RROW-" + visible_ids
[i
]);
2008 if (e
&& e
.className
.match("Unread")) {
2009 ids_to_mark
.push(visible_ids
[i
]);
2017 if (ids_to_mark
.length
== 0) {
2018 alert(__("No articles found to mark"));
2020 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
2024 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
2025 var e
= $("RROW-" + ids_to_mark
[i
]);
2026 e
.className
= e
.className
.replace("Unread", "");
2029 var query
= "?op=rpc&subop=catchupSelected" +
2030 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
2032 new Ajax
.Request("backend.php", {
2034 onComplete: function(transport
) {
2035 catchup_callback2(transport
);
2042 exception_error("catchupRelativeToArticle", e
);
2046 function cdmExpandArticle(a_id
) {
2048 var id
= 'CICD-' + a_id
;
2051 Element
.hide("CEXC-" + a_id
);
2054 Effect
.Appear(id
, {duration
: 0.5,
2055 beforeStart: function(effect
) {
2056 var h_id
= 'CICH-' + a_id
;
2057 var h_elem
= $(h_id
);
2058 if (h_elem
) { h_elem
.style
.display
= "none"; }
2060 toggleUnread(a_id
, 0);
2065 exception_error("appearBlockElementF", e
);
2070 function fixHeadlinesOrder(ids
) {
2072 for (var i
= 0; i
< ids
.length
; i
++) {
2073 var e
= $("RROW-" + ids
[i
]);
2077 e
.className
= e
.className
.replace("even", "odd");
2079 e
.className
= e
.className
.replace("odd", "even");
2084 exception_error("fixHeadlinesOrder", e
);
2088 function hideReadHeadlines() {
2092 var vis_ids
= new Array();
2094 if ($("headlinesList")) {
2095 ids
= getVisibleHeadlineIds();
2097 ids
= cdmGetVisibleArticles();
2100 var read_headlines_visible
= true;
2102 for (var i
= 0; i
< ids
.length
; i
++) {
2103 var row
= $("RROW-" + ids
[i
]);
2105 if (row
&& row
.className
) {
2106 if (read_headlines_visible
) {
2107 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2109 vis_ids
.push(ids
[i
]);
2111 //Effect.Fade(row, {duration : 0.3});
2116 vis_ids
.push(ids
[i
]);
2121 fixHeadlinesOrder(vis_ids
);
2123 read_headlines_visible
= !read_headlines_visible
;
2126 exception_error("hideReadHeadlines", e
);
2130 function invertHeadlineSelection() {
2132 var rows
= new Array();
2136 r
= document
.getElementsByTagName("TR");
2138 r
= document
.getElementsByTagName("DIV");
2141 for (var i
= 0; i
< r
.length
; i
++) {
2142 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2147 for (var i
= 0; i
< rows
.length
; i
++) {
2148 var nc
= rows
[i
].className
;
2149 var id
= rows
[i
].id
.replace("RROW-", "");
2150 var cb
= $("RCHK-" + id
);
2152 if (!rows
[i
].className
.match("Selected")) {
2153 nc
= nc
+ "Selected";
2156 nc
= nc
.replace("Selected", "");
2160 rows
[i
].className
= nc
;
2165 exception_error("invertHeadlineSelection", e
);
2169 function getArticleUnderPointer() {
2170 return post_under_pointer
;
2173 function zoomToArticle(id
) {
2175 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2177 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2180 exception_error("zoomToArticle", e
);
2184 function scrollArticle(offset
) {
2187 var ci
= $("content-insert");
2189 ci
.scrollTop
+= offset
;
2192 var hi
= $("headlinesInnerContainer");
2194 hi
.scrollTop
+= offset
;
2199 exception_error("scrollArticle", e
);
2203 function show_labels_in_headlines(transport
) {
2205 if (transport
.responseXML
) {
2206 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2208 var elems
= info
.getElementsByTagName("entry");
2210 for (var l
= 0; l
< elems
.length
; l
++) {
2211 var e_id
= elems
[l
].getAttribute("id");
2215 var ctr
= $("HLLCTR-" + e_id
);
2218 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2226 exception_error("show_labels_in_headlines", e
);
2231 function toggleHeadlineActions() {
2233 var e
= $("headlineActionsBody");
2234 var p
= $("headlineActionsDrop");
2236 if (!Element
.visible(e
)) {
2243 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2244 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2247 exception_error("toggleHeadlineActions", e
);
2251 function publishWithNote(id
, def_note
) {
2253 if (!def_note
) def_note
= '';
2255 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2257 if (note
!= undefined) {
2258 togglePub(id
, false, false, note
);
2262 exception_error("publishWithNote", e
);