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
, feed_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");
395 active_real_feed_id
= feed_id
;
398 debug("looking for articles to cache...");
400 var articles
= transport
.responseXML
.getElementsByTagName("article");
402 for (var i
= 0; i
< articles
.length
; i
++) {
403 var a_id
= articles
[i
].getAttribute("id");
405 debug("found id: " + a_id
);
407 if (a_id
== active_post_id
) {
408 debug("active article, rendering...");
409 render_article(articles
[i
].firstChild
.nodeValue
);
412 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
416 showArticleInHeadlines(id
);
419 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?", [id
]);
422 var reply
= transport
.responseXML
.firstChild
.firstChild
;
425 debug("article_callback: returned no XML object");
426 //var f = $("content-frame");
427 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
430 var date
= new Date();
431 last_article_view
= date
.getTime() / 1000;
433 if (typeof correctPNG
!= 'undefined') {
437 if (_reload_feedlist_after_view
) {
438 setTimeout('updateFeedList(false, false)', 50);
439 _reload_feedlist_after_view
= false;
441 if (transport
.responseXML
) {
442 var counters
= transport
.responseXML
.getElementsByTagName("counters")[0];
445 debug("parsing piggybacked counters: " + counters
);
446 parse_counters(counters
, false);
448 debug("counters container not found in reply, requesting...");
456 exception_error("article_callback2", e
, transport
);
460 function view(id
, feed_id
, skip_history
) {
463 debug("loading article: " + id
+ "/" + feed_id
);
465 if (offline_mode
) return view_offline(id
, feed_id
);
467 var cached_article
= cache_find(id
);
469 debug("cache check result: " + (cached_article
!= false));
473 //setActiveFeedId(feed_id);
475 var query
= "backend.php?op=view&id=" + param_escape(id
) +
476 "&feed=" + param_escape(feed_id
);
478 var date
= new Date();
480 var neighbor_ids
= getRelativePostIds(active_post_id
);
482 /* only request uncached articles */
484 var cids_to_request
= Array();
486 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
487 if (!cache_check(neighbor_ids
[i
])) {
488 cids_to_request
.push(neighbor_ids
[i
]);
492 debug("additional ids: " + cids_to_request
.toString());
494 /* additional info for piggyback counters */
496 if (tagsAreDisplayed()) {
497 query
= query
+ "&omode=lt";
499 query
= query
+ "&omode=flc";
502 var date
= new Date();
503 var timestamp
= Math
.round(date
.getTime() / 1000);
504 query
= query
+ "&ts=" + timestamp
;
506 query
= query
+ "&cids=" + cids_to_request
.toString();
508 var crow
= $("RROW-" + id
);
509 var article_is_unread
= crow
.className
.match("Unread");
511 if (!async_counters_work
) {
512 query
= query
+ "&csync=true";
515 showArticleInHeadlines(id
);
517 if (!cached_article
) {
519 // notify_progress("Loading, please wait...", true);
521 /* var content = $('HLC-' + id);
523 if (content && !$('LL-' + id)) {
524 var ll = document.createElement('img');
526 ll.src = 'images/indicator_tiny.gif';
527 ll.className = 'hlLoading';
530 content.appendChild(ll);
534 var upic
= $('FUPDPIC-' + id
);
537 upic
.src
= 'images/indicator_white.gif';
540 } else if (cached_article
&& article_is_unread
) {
542 query
= query
+ "&mode=prefetch";
544 render_article(cached_article
);
546 } else if (cached_article
) {
548 query
= query
+ "&mode=prefetch_old";
549 render_article(cached_article
);
555 last_requested_article
= id
;
557 new Ajax
.Request(query
, {
558 onComplete: function(transport
) {
559 article_callback2(transport
, id
, feed_id
);
565 exception_error("view", e
);
570 return toggleMark(id
);
574 return togglePub(id
);
577 function tMark_afh_off(effect
) {
579 var elem
= effect
.effects
[0].element
;
581 debug("tMark_afh_off : " + elem
.id
);
584 elem
.src
= elem
.src
.replace("mark_set", "mark_unset");
585 elem
.alt
= __("Star article");
590 exception_error("tMark_afh_off", e
);
594 function tPub_afh_off(effect
) {
596 var elem
= effect
.effects
[0].element
;
598 debug("tPub_afh_off : " + elem
.id
);
601 elem
.src
= elem
.src
.replace("pub_set", "pub_unset");
602 elem
.alt
= __("Publish article");
607 exception_error("tPub_afh_off", e
);
611 function toggleMark(id
, client_only
, no_effects
) {
615 var query
= "backend.php?op=rpc&id=" + id
+ "&subop=mark";
617 query
= query
+ "&afid=" + getActiveFeedId();
619 if (tagsAreDisplayed()) {
620 query
= query
+ "&omode=tl";
622 query
= query
+ "&omode=flc";
625 var mark_img
= $("FMPIC-" + id
);
627 if (!mark_img
) return;
629 var vfeedu
= $("FEEDU--1");
630 var crow
= $("RROW-" + id
);
632 if (mark_img
.src
.match("mark_unset")) {
633 mark_img
.src
= mark_img
.src
.replace("mark_unset", "mark_set");
634 mark_img
.alt
= __("Unstar article");
635 query
= query
+ "&mark=1";
638 db
.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id
]);
642 //mark_img.src = "images/mark_unset.png";
643 mark_img
.alt
= __("Please wait...");
644 query
= query
+ "&mark=0";
646 if ($("headlinesList") && !no_effects
) {
647 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tMark_afh_off
});
649 mark_img
.src
= mark_img
.src
.replace("mark_set", "mark_unset");
650 mark_img
.alt
= __("Star article");
654 db
.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id
]);
659 if (!no_effects
) update_local_feedlist_counters();
664 new Ajax
.Request(query
, {
665 onComplete: function(transport
) {
666 all_counters_callback2(transport
);
672 exception_error("toggleMark", e
);
676 function togglePub(id
, client_only
, no_effects
, note
) {
680 var query
= "backend.php?op=rpc&id=" + id
+ "&subop=publ";
682 query
= query
+ "&afid=" + getActiveFeedId();
684 if (note
!= undefined) {
685 query
= query
+ "¬e=" + param_escape(note
);
687 query
= query
+ "¬e=undefined";
690 if (tagsAreDisplayed()) {
691 query
= query
+ "&omode=tl";
693 query
= query
+ "&omode=flc";
696 var mark_img
= $("FPPIC-" + id
);
698 if (!mark_img
) return;
700 var vfeedu
= $("FEEDU--2");
701 var crow
= $("RROW-" + id
);
703 if (mark_img
.src
.match("pub_unset") || note
!= undefined) {
704 mark_img
.src
= mark_img
.src
.replace("pub_unset", "pub_set");
705 mark_img
.alt
= __("Unpublish article");
706 query
= query
+ "&pub=1";
709 //mark_img.src = "images/pub_unset.png";
710 mark_img
.alt
= __("Please wait...");
711 query
= query
+ "&pub=0";
713 if ($("headlinesList") && !no_effects
) {
714 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tPub_afh_off
});
716 mark_img
.src
= mark_img
.src
.replace("pub_set", "pub_unset");
717 mark_img
.alt
= __("Publish article");
722 new Ajax
.Request(query
, {
723 onComplete: function(transport
) {
724 toggle_published_callback(transport
);
730 exception_error("togglePub", e
);
734 function correctHeadlinesOffset(id
) {
738 var hlist
= $("headlinesList");
739 var container
= $("headlinesInnerContainer");
740 var row
= $("RROW-" + id
);
742 var viewport
= container
.offsetHeight
;
744 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
745 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
747 debug("Rtop: " + rel_offset_top
+ " Rbtm: " + rel_offset_bottom
);
748 debug("Vport: " + viewport
);
750 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
751 container
.scrollTop
= row
.offsetTop
;
752 } else if (rel_offset_bottom
> viewport
) {
754 /* doesn't properly work with Opera in some cases because
755 Opera fucks up element scrolling */
757 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
761 exception_error("correctHeadlinesOffset", e
);
766 function moveToPost(mode
) {
773 rows
= cdmGetVisibleArticles();
775 rows
= getVisibleHeadlineIds();
781 if (!$('RROW-' + active_post_id
)) {
782 active_post_id
= false;
785 if (active_post_id
== false) {
786 next_id
= getFirstVisibleHeadlineId();
787 prev_id
= getLastVisibleHeadlineId();
789 for (var i
= 0; i
< rows
.length
; i
++) {
790 if (rows
[i
] == active_post_id
) {
797 if (mode
== "next") {
801 if (!cdmArticleIsActuallyVisible(next_id
)) {
802 cdmScrollToArticleId(next_id
);
804 cdmSelectArticles("none");
805 toggleUnread(next_id
, 0, true);
806 toggleSelected(next_id
);
809 correctHeadlinesOffset(next_id
);
810 view(next_id
, getActiveFeedId());
815 if (mode
== "prev") {
818 cdmScrollToArticleId(prev_id
);
819 cdmSelectArticles("none");
820 toggleUnread(prev_id
, 0, true);
821 toggleSelected(prev_id
);
823 correctHeadlinesOffset(prev_id
);
824 view(prev_id
, getActiveFeedId());
830 exception_error("moveToPost", e
);
834 function toggleSelected(id
) {
837 var cb
= $("RCHK-" + id
);
839 var row
= $("RROW-" + id
);
841 var nc
= row
.className
;
843 if (!nc
.match("Selected")) {
844 nc
= nc
+ "Selected";
849 // In CDM basically last selected article == active article
850 if (isCdmMode()) active_post_id
= id
;
852 nc
= nc
.replace("Selected", "");
862 exception_error("toggleSelected", e
);
866 function toggleUnread_afh(effect
) {
869 var elem
= effect
.element
;
870 elem
.style
.backgroundColor
= "";
873 exception_error("toggleUnread_afh", e
);
877 function toggleUnread(id
, cmode
, effect
) {
880 var row
= $("RROW-" + id
);
882 var nc
= row
.className
;
883 var is_selected
= row
.className
.match("Selected");
884 nc
= nc
.replace("Unread", "");
885 nc
= nc
.replace("Selected", "");
887 // since we are removing selection from the object, uncheck
888 // corresponding checkbox
890 var cb
= $("RCHK-" + id
);
895 // NOTE: I'm not sure that resetting selection here is a feature -fox
897 if (cmode
== undefined || cmode
== 2) {
898 if (row
.className
.match("Unread")) {
902 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
903 afterFinish
: toggleUnread_afh
,
904 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
908 row
.className
= nc
+ "Unread";
912 db
.execute("UPDATE articles SET unread = not unread "+
913 "WHERE id = ?", [id
]);
916 } else if (cmode
== 0) {
920 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
921 afterFinish
: toggleUnread_afh
,
922 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
926 db
.execute("UPDATE articles SET unread = 0 "+
927 "WHERE id = ?", [id
]);
930 } else if (cmode
== 1) {
931 row
.className
= nc
+ "Unread";
934 db
.execute("UPDATE articles SET unread = 1 "+
935 "WHERE id = ?", [id
]);
940 update_local_feedlist_counters();
942 // Disable unmarking as selected for the time being (16.05.08) -fox
943 if (is_selected
) row
.className
= row
.className
+ "Selected";
945 if (cmode
== undefined) cmode
= 2;
947 var query
= "backend.php?op=rpc&subop=catchupSelected" +
948 "&cmode=" + param_escape(cmode
);
950 var ids
= "?ids=" + param_escape(id
);
952 // notify_progress("Loading, please wait...");
954 new Ajax
.Request(query
, {
956 onComplete: function(transport
) {
957 all_counters_callback2(transport
);
963 exception_error("toggleUnread", e
);
967 function selectionRemoveLabel(id
) {
970 var ids
= getSelectedArticleIds2();
972 if (ids
.length
== 0) {
973 alert(__("No articles are selected."));
977 // var ok = confirm(__("Remove selected articles from label?"));
981 var query
= "backend.php?op=rpc&subop=removeFromLabel&ids=" +
982 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
984 // notify_progress("Loading, please wait...");
986 cache_invalidate("F:" + (-11 - id
));
988 new Ajax
.Request(query
, {
989 onComplete: function(transport
) {
990 show_labels_in_headlines(transport
);
991 all_counters_callback2(transport
);
997 exception_error("selectionAssignLabel", e
);
1002 function selectionAssignLabel(id
) {
1005 var ids
= getSelectedArticleIds2();
1007 if (ids
.length
== 0) {
1008 alert(__("No articles are selected."));
1012 // var ok = confirm(__("Assign selected articles to label?"));
1016 cache_invalidate("F:" + (-11 - id
));
1018 var query
= "backend.php?op=rpc&subop=assignToLabel&ids=" +
1019 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
1021 // notify_progress("Loading, please wait...");
1023 new Ajax
.Request(query
, {
1024 onComplete: function(transport
) {
1025 show_labels_in_headlines(transport
);
1026 all_counters_callback2(transport
);
1032 exception_error("selectionAssignLabel", e
);
1037 function selectionToggleUnread(cdm_mode
, set_state
, callback_func
, no_error
) {
1042 rows
= cdmGetSelectedArticles();
1044 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1047 if (rows
.length
== 0 && !no_error
) {
1048 alert(__("No articles are selected."));
1052 for (i
= 0; i
< rows
.length
; i
++) {
1053 var row
= $("RROW-" + rows
[i
]);
1055 var nc
= row
.className
;
1056 nc
= nc
.replace("Unread", "");
1057 nc
= nc
.replace("Selected", "");
1059 if (set_state
== undefined) {
1060 if (row
.className
.match("Unread")) {
1061 row
.className
= nc
+ "Selected";
1063 row
.className
= nc
+ "UnreadSelected";
1066 db
.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
1071 if (set_state
== false) {
1072 row
.className
= nc
+ "Selected";
1074 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?",
1079 if (set_state
== true) {
1080 row
.className
= nc
+ "UnreadSelected";
1082 db
.execute("UPDATE articles SET unread = 1 WHERE id = ?",
1089 if (rows
.length
> 0) {
1091 update_local_feedlist_counters();
1095 if (set_state
== undefined) {
1097 } else if (set_state
== true) {
1099 } else if (set_state
== false) {
1103 var query
= "backend.php?op=rpc&subop=catchupSelected" +
1106 var ids
= "?ids=" + param_escape(rows
.toString());
1108 notify_progress("Loading, please wait...");
1110 new Ajax
.Request(query
, {
1112 onComplete: function(transport
) {
1113 catchup_callback2(transport
, callback_func
);
1119 exception_error("selectionToggleUnread", e
);
1123 function selectionToggleMarked(cdm_mode
) {
1129 rows
= cdmGetSelectedArticles();
1131 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1134 if (rows
.length
== 0) {
1135 alert(__("No articles are selected."));
1139 for (i
= 0; i
< rows
.length
; i
++) {
1140 toggleMark(rows
[i
], true, true);
1143 update_local_feedlist_counters();
1145 if (rows
.length
> 0) {
1147 var query
= "backend.php?op=rpc&subop=markSelected&ids=" +
1148 param_escape(rows
.toString()) + "&cmode=2";
1150 query
= query
+ "&afid=" + getActiveFeedId();
1152 /* if (tagsAreDisplayed()) {
1153 query = query + "&omode=tl";
1155 query = query + "&omode=flc";
1158 query
= query
+ "&omode=lc";
1160 new Ajax
.Request(query
, {
1161 onComplete: function(transport
) {
1162 all_counters_callback2(transport
);
1168 exception_error("selectionToggleMarked", e
);
1172 function selectionTogglePublished(cdm_mode
) {
1178 rows
= cdmGetSelectedArticles();
1180 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1183 if (rows
.length
== 0) {
1184 alert(__("No articles are selected."));
1188 for (i
= 0; i
< rows
.length
; i
++) {
1189 togglePub(rows
[i
], true, true);
1192 if (rows
.length
> 0) {
1194 var query
= "backend.php?op=rpc&subop=publishSelected&ids=" +
1195 param_escape(rows
.toString()) + "&cmode=2";
1197 query
= query
+ "&afid=" + getActiveFeedId();
1199 /* if (tagsAreDisplayed()) {
1200 query = query + "&omode=tl";
1202 query = query + "&omode=flc";
1205 query
= query
+ "&omode=lc";
1207 new Ajax
.Request(query
, {
1208 onComplete: function(transport
) {
1209 all_counters_callback2(transport
);
1215 exception_error("selectionToggleMarked", e
);
1219 function cdmGetSelectedArticles() {
1220 var sel_articles
= new Array();
1221 var container
= $("headlinesInnerContainer");
1223 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1224 var child
= container
.childNodes
[i
];
1226 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Selected")) {
1227 var c_id
= child
.id
.replace("RROW-", "");
1228 sel_articles
.push(c_id
);
1232 return sel_articles
;
1235 function cdmGetVisibleArticles() {
1236 var sel_articles
= new Array();
1237 var container
= $("headlinesInnerContainer");
1239 if (!container
) return sel_articles
;
1241 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1242 var child
= container
.childNodes
[i
];
1244 if (child
.id
&& child
.id
.match("RROW-")) {
1245 var c_id
= child
.id
.replace("RROW-", "");
1246 sel_articles
.push(c_id
);
1250 return sel_articles
;
1253 function cdmGetUnreadArticles() {
1254 var sel_articles
= new Array();
1255 var container
= $("headlinesInnerContainer");
1257 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1258 var child
= container
.childNodes
[i
];
1260 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Unread")) {
1261 var c_id
= child
.id
.replace("RROW-", "");
1262 sel_articles
.push(c_id
);
1266 return sel_articles
;
1270 // mode = all,none,unread
1271 function cdmSelectArticles(mode
) {
1272 var container
= $("headlinesInnerContainer");
1274 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1275 var child
= container
.childNodes
[i
];
1277 if (child
.id
&& child
.id
.match("RROW-")) {
1278 var aid
= child
.id
.replace("RROW-", "");
1280 var cb
= $("RCHK-" + aid
);
1282 if (mode
== "all") {
1283 if (!child
.className
.match("Selected")) {
1284 child
.className
= child
.className
+ "Selected";
1287 } else if (mode
== "unread") {
1288 if (child
.className
.match("Unread") && !child
.className
.match("Selected")) {
1289 child
.className
= child
.className
+ "Selected";
1293 child
.className
= child
.className
.replace("Selected", "");
1300 function catchupPage() {
1302 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1304 var str
= __("Mark all visible articles in %s as read?");
1306 str
= str
.replace("%s", fn
);
1308 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1312 if ($("headlinesList")) {
1313 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
1314 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1315 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1317 cdmSelectArticles('all');
1318 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1319 cdmSelectArticles('none');
1323 function catchupSelection() {
1329 if ($("headlinesList")) {
1330 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1332 rows
= cdmGetSelectedArticles();
1335 if (rows
.length
== 0) {
1336 alert(__("No articles are selected."));
1341 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1343 var str
= __("Mark %d selected articles in %s as read?");
1345 str
= str
.replace("%d", rows
.length
);
1346 str
= str
.replace("%s", fn
);
1348 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1352 if ($("headlinesList")) {
1353 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1354 // selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1356 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1357 // cdmSelectArticles('none');
1361 exception_error("catchupSelection", e
);
1365 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1366 displayDlg('editArticleTags', id
);
1370 function tag_saved_callback(transport
) {
1372 debug("in tag_saved_callback");
1377 if (tagsAreDisplayed()) {
1378 _reload_feedlist_after_view
= true;
1382 if (transport
.responseXML
) {
1383 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1386 var id
= tags_str
.getAttribute("id");
1389 var tags
= $("ATSTR-" + id
);
1391 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1398 exception_error("tag_saved_callback", e
);
1402 function editTagsSave() {
1404 notify_progress("Saving article tags...");
1406 var form
= document
.forms
["tag_edit_form"];
1408 var query
= Form
.serialize("tag_edit_form");
1410 query
= "backend.php?op=rpc&subop=setArticleTags&" + query
;
1414 new Ajax
.Request(query
, {
1415 onComplete: function(transport
) {
1416 tag_saved_callback(transport
);
1421 function editTagsInsert() {
1424 var form
= document
.forms
["tag_edit_form"];
1426 var found_tags
= form
.found_tags
;
1427 var tags_str
= form
.tags_str
;
1429 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1431 if (tags_str
.value
.length
> 0 &&
1432 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1434 tags_str
.value
= tags_str
.value
+ ", ";
1437 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1439 found_tags
.selectedIndex
= 0;
1442 exception_error("editTagsInsert", e
);
1446 function cdmScrollViewport(where
) {
1447 debug("cdmScrollViewport: " + where
);
1449 var ctr
= $("headlinesInnerContainer");
1453 if (where
== "bottom") {
1454 ctr
.scrollTop
= ctr
.scrollHeight
;
1456 ctr
.scrollTop
= where
;
1460 function cdmArticleIsBelowViewport(id
) {
1462 var ctr
= $("headlinesInnerContainer");
1463 var e
= $("RROW-" + id
);
1465 if (!e
|| !ctr
) return;
1467 // article starts below viewport
1469 if (ctr
.scrollTop
< e
.offsetTop
) {
1476 exception_error("cdmArticleIsVisible", e
);
1480 function cdmArticleIsAboveViewport(id
) {
1482 var ctr
= $("headlinesInnerContainer");
1483 var e
= $("RROW-" + id
);
1485 if (!e
|| !ctr
) return;
1487 // article starts above viewport
1489 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1496 exception_error("cdmArticleIsVisible", e
);
1500 function cdmScrollToArticleId(id
) {
1502 var ctr
= $("headlinesInnerContainer");
1503 var e
= $("RROW-" + id
);
1505 if (!e
|| !ctr
) return;
1507 ctr
.scrollTop
= e
.offsetTop
;
1510 exception_error("cdmScrollToArticleId", e
);
1514 function cdmArticleIsActuallyVisible(id
) {
1516 var ctr
= $("headlinesInnerContainer");
1517 var e
= $("RROW-" + id
);
1519 if (!e
|| !ctr
) return;
1521 // article fits in viewport OR article is longer than viewport and
1522 // its bottom is visible
1524 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1525 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1529 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1530 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1531 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1540 exception_error("cdmArticleIsVisible", e
);
1544 function cdmWatchdog() {
1548 var ctr
= $("headlinesInnerContainer");
1552 var ids
= new Array();
1554 var e
= ctr
.firstChild
;
1557 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1558 e
.id
.match("RROW-")) {
1560 // article fits in viewport OR article is longer than viewport and
1561 // its bottom is visible
1563 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1564 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1566 // debug(e.id + " is visible " + e.offsetTop + "." +
1567 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1568 // (ctr.scrollTop + ctr.offsetHeight));
1570 ids
.push(e
.id
.replace("RROW-", ""));
1572 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1573 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1574 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1576 ids
.push(e
.id
.replace("RROW-", ""));
1580 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1582 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1583 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1585 ids.push(e.id.replace("RROW-", ""));
1594 debug("cdmWatchdog, ids= " + ids
.toString());
1596 if (ids
.length
> 0) {
1598 for (var i
= 0; i
< ids
.length
; i
++) {
1599 var e
= $("RROW-" + ids
[i
]);
1601 e
.className
= e
.className
.replace("Unread", "");
1605 var query
= "backend.php?op=rpc&subop=catchupSelected" +
1608 var ids
= "?ids=" + param_escape(ids
.toString());
1610 new Ajax
.Request(query
, {
1612 onComplete: function(transport
) {
1613 all_counters_callback2(transport
);
1618 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1621 exception_error("cdmWatchdog", e
);
1627 function cache_inject(id
, article
, param
) {
1629 if (!cache_check_param(id
, param
)) {
1630 debug("cache_article: miss: " + id
+ " [p=" + param
+ "]");
1635 var date
= new Date();
1636 var ts
= Math
.round(date
.getTime() / 1000);
1638 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1639 [id
, article
, param
, ts
]);
1642 var cache_obj
= new Array();
1644 cache_obj
["id"] = id
;
1645 cache_obj
["data"] = article
;
1646 cache_obj
["param"] = param
;
1648 article_cache
.push(cache_obj
);
1652 debug("cache_article: hit: " + id
+ " [p=" + param
+ "]");
1655 exception_error("cache_inject", e
);
1659 function cache_find(id
) {
1662 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1665 if (rs
.isValidRow()) {
1666 var a
= rs
.field(0);
1674 for (var i
= 0; i
< article_cache
.length
; i
++) {
1675 if (article_cache
[i
]["id"] == id
) {
1676 return article_cache
[i
]["data"];
1683 function cache_find_param(id
, param
) {
1686 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1690 if (rs
.isValidRow()) {
1699 for (var i
= 0; i
< article_cache
.length
; i
++) {
1700 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1701 return article_cache
[i
]["data"];
1708 function cache_check(id
) {
1711 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1715 if (rs
.isValidRow()) {
1716 a
= rs
.field(0) != "0";
1724 for (var i
= 0; i
< article_cache
.length
; i
++) {
1725 if (article_cache
[i
]["id"] == id
) {
1733 function cache_check_param(id
, param
) {
1736 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1740 if (rs
.isValidRow()) {
1741 a
= rs
.field(0) != "0";
1749 for (var i
= 0; i
< article_cache
.length
; i
++) {
1750 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1758 function cache_expire() {
1760 var date
= new Date();
1761 var ts
= Math
.round(date
.getTime() / 1000);
1763 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1764 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1765 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1769 while (article_cache
.length
> 25) {
1770 article_cache
.shift();
1775 function cache_empty() {
1776 article_cache
= new Array();
1779 function cache_invalidate(id
) {
1783 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1784 return rs
.rowsAffected
!= 0;
1789 while (i
< article_cache
.length
) {
1790 if (article_cache
[i
]["id"] == id
) {
1791 debug("cache_invalidate: removed id " + id
);
1792 article_cache
.splice(i
, 1);
1799 debug("cache_invalidate: id not found: " + id
);
1802 exception_error("cache_invalidate", e
);
1806 function getActiveArticleId() {
1807 return active_post_id
;
1810 function cdmClicked(id
) {
1812 var elem
= $("RROW-" + id
);
1815 var id
= elem
.id
.replace("RROW-", "");
1816 active_post_id
= id
;
1818 // cdmSelectArticles("none");
1819 toggleUnread(id
, 0, true);
1820 // toggleSelected(id);
1824 exception_error("cdmClicked", e
);
1828 function preload_article_callback(transport
) {
1830 if (transport
.responseXML
) {
1831 var articles
= transport
.responseXML
.getElementsByTagName("article");
1833 for (var i
= 0; i
< articles
.length
; i
++) {
1834 var id
= articles
[i
].getAttribute("id");
1835 if (!cache_check(id
)) {
1836 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1837 debug("preloaded article: " + id
);
1842 exception_error("preload_article_callback", e
);
1846 function preloadArticleUnderPointer(id
) {
1848 if (getInitParam("bw_limit") == "1") return;
1850 if (post_under_pointer
== id
&& !cache_check(id
)) {
1852 debug("trying to preload article " + id
);
1854 var neighbor_ids
= getRelativePostIds(id
, 1);
1856 /* only request uncached articles */
1858 var cids_to_request
= Array();
1860 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1861 if (!cache_check(neighbor_ids
[i
])) {
1862 cids_to_request
.push(neighbor_ids
[i
]);
1865 debug("additional ids: " + cids_to_request
.toString());
1867 cids_to_request
.push(id
);
1869 var query
= "backend.php?op=rpc&subop=getArticles&ids=" +
1870 cids_to_request
.toString();
1871 new Ajax
.Request(query
, {
1872 onComplete: function(transport
) {
1873 preload_article_callback(transport
);
1877 exception_error("preloadArticleUnderPointer", e
);
1881 function postMouseIn(id
) {
1883 if (post_under_pointer
!= id
) {
1884 post_under_pointer
= id
;
1886 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1891 exception_error("postMouseIn", e
);
1895 function postMouseOut(id
) {
1897 post_under_pointer
= false;
1899 exception_error("postMouseOut", e
);
1903 function headlines_scroll_handler() {
1906 var e
= $("headlinesInnerContainer");
1908 // don't do infinite scrolling when Limit == All
1910 var toolbar_form
= document
.forms
["main_toolbar_form"];
1912 var limit
= toolbar_form
.limit
[toolbar_form
.limit
.selectedIndex
];
1913 if (limit
.value
!= 0) {
1915 debug((e
.scrollTop
+ e
.offsetHeight
) + " vs " + e
.scrollHeight
+ " dis? " +
1916 _infscroll_disable
);
1918 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1919 if (!_infscroll_disable
) {
1920 debug("more cowbell!");
1927 exception_error("headlines_scroll_handler", e
);
1931 function catchupRelativeToArticle(below
) {
1936 if (!getActiveArticleId()) {
1937 alert(__("No article is selected."));
1943 if ($("headlinesList")) {
1944 visible_ids
= getVisibleHeadlineIds();
1946 visible_ids
= cdmGetVisibleArticles();
1949 var ids_to_mark
= new Array();
1952 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1953 if (visible_ids
[i
] != getActiveArticleId()) {
1954 var e
= $("RROW-" + visible_ids
[i
]);
1956 if (e
&& e
.className
.match("Unread")) {
1957 ids_to_mark
.push(visible_ids
[i
]);
1964 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1965 if (visible_ids
[i
] != getActiveArticleId()) {
1966 var e
= $("RROW-" + visible_ids
[i
]);
1968 if (e
&& e
.className
.match("Unread")) {
1969 ids_to_mark
.push(visible_ids
[i
]);
1977 if (ids_to_mark
.length
== 0) {
1978 alert(__("No articles found to mark"));
1980 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1984 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1985 var e
= $("RROW-" + ids_to_mark
[i
]);
1986 e
.className
= e
.className
.replace("Unread", "");
1989 var query
= "backend.php?op=rpc&subop=catchupSelected" +
1992 var ids
= "?ids=" + param_escape(ids_to_mark
.toString());
1994 new Ajax
.Request(query
, {
1996 onComplete: function(transport
) {
1997 catchup_callback2(transport
);
2004 exception_error("catchupRelativeToArticle", e
);
2008 function cdmExpandArticle(a_id
) {
2010 var id
= 'CICD-' + a_id
;
2013 Element
.hide("CEXC-" + a_id
);
2016 Effect
.Appear(id
, {duration
: 0.5,
2017 beforeStart: function(effect
) {
2018 var h_id
= 'CICH-' + a_id
;
2019 var h_elem
= $(h_id
);
2020 if (h_elem
) { h_elem
.style
.display
= "none"; }
2022 toggleUnread(a_id
, 0);
2027 exception_error("appearBlockElementF", e
);
2032 function fixHeadlinesOrder(ids
) {
2034 for (var i
= 0; i
< ids
.length
; i
++) {
2035 var e
= $("RROW-" + ids
[i
]);
2039 e
.className
= e
.className
.replace("even", "odd");
2041 e
.className
= e
.className
.replace("odd", "even");
2046 exception_error("fixHeadlinesOrder", e
);
2050 function hideReadHeadlines() {
2054 var vis_ids
= new Array();
2056 if ($("headlinesList")) {
2057 ids
= getVisibleHeadlineIds();
2059 ids
= cdmGetVisibleArticles();
2062 var read_headlines_visible
= true;
2064 for (var i
= 0; i
< ids
.length
; i
++) {
2065 var row
= $("RROW-" + ids
[i
]);
2067 if (row
&& row
.className
) {
2068 if (read_headlines_visible
) {
2069 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2071 vis_ids
.push(ids
[i
]);
2073 //Effect.Fade(row, {duration : 0.3});
2078 vis_ids
.push(ids
[i
]);
2083 fixHeadlinesOrder(vis_ids
);
2085 read_headlines_visible
= !read_headlines_visible
;
2088 exception_error("hideReadHeadlines", e
);
2092 function invertHeadlineSelection() {
2094 var rows
= new Array();
2098 r
= document
.getElementsByTagName("TR");
2100 r
= document
.getElementsByTagName("DIV");
2103 for (var i
= 0; i
< r
.length
; i
++) {
2104 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2109 for (var i
= 0; i
< rows
.length
; i
++) {
2110 var nc
= rows
[i
].className
;
2111 var id
= rows
[i
].id
.replace("RROW-", "");
2112 var cb
= $("RCHK-" + id
);
2114 if (!rows
[i
].className
.match("Selected")) {
2115 nc
= nc
+ "Selected";
2118 nc
= nc
.replace("Selected", "");
2122 rows
[i
].className
= nc
;
2127 exception_error("invertHeadlineSelection", e
);
2131 function getArticleUnderPointer() {
2132 return post_under_pointer
;
2135 function zoomToArticle(id
) {
2137 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2139 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2142 exception_error("zoomToArticle", e
);
2146 function showOriginalArticleInline(id
) {
2149 var query
= "backend.php?op=rpc&subop=getArticleLink&id=" + id
;
2151 notify_progress("Loading, please wait...", true);
2153 new Ajax
.Request(query
, {
2154 onComplete: function(transport
) {
2156 if (transport
.responseXML
) {
2158 var link
= transport
.responseXML
.getElementsByTagName("link")[0];
2159 var id
= transport
.responseXML
.getElementsByTagName("id")[0];
2164 link
= link
.firstChild
.nodeValue
;
2166 var ci
= $("content-insert");
2168 var tmp
= "<iframe id=\"inline_orig_article\" width=\""+ci
.offsetWidth
+"\" height=\""+ci
.offsetHeight
+"\" style=\"border-width : 0px;\" src=\""+link
+"\"></iframe>";
2170 render_article(tmp
);
2177 exception_error("showOriginalArticleInline", e
);
2182 function scrollArticle(offset
) {
2185 var ci
= $("content-insert");
2187 ci
.scrollTop
+= offset
;
2190 var hi
= $("headlinesInnerContainer");
2192 hi
.scrollTop
+= offset
;
2197 exception_error("scrollArticle", e
);
2201 function show_labels_in_headlines(transport
) {
2203 if (transport
.responseXML
) {
2204 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2206 var elems
= info
.getElementsByTagName("entry");
2208 for (var l
= 0; l
< elems
.length
; l
++) {
2209 var e_id
= elems
[l
].getAttribute("id");
2213 var ctr
= $("HLLCTR-" + e_id
);
2216 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2224 exception_error("show_labels_in_headlines", e
);
2229 function toggleHeadlineActions() {
2231 var e
= $("headlineActionsBody");
2232 var p
= $("headlineActionsDrop");
2234 if (!Element
.visible(e
)) {
2241 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2242 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2245 exception_error("toggleHeadlineActions", e
);
2249 function publishWithNote(id
, def_note
) {
2251 if (!def_note
) def_note
= '';
2253 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2255 if (note
!= undefined) {
2256 togglePub(id
, false, false, note
);
2260 exception_error("publishWithNote", e
);