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
) {
462 if (!feed_id
) feed_id
= 0;
464 debug("loading article: " + id
+ "/" + feed_id
);
466 if (offline_mode
) return view_offline(id
, feed_id
);
468 var cached_article
= cache_find(id
);
470 debug("cache check result: " + (cached_article
!= false));
475 //setActiveFeedId(feed_id);
477 var query
= "?op=view&id=" + param_escape(id
) +
478 "&feed=" + param_escape(feed_id
);
480 var date
= new Date();
482 var neighbor_ids
= getRelativePostIds(active_post_id
);
484 /* only request uncached articles */
486 var cids_to_request
= Array();
488 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
489 if (!cache_check(neighbor_ids
[i
])) {
490 cids_to_request
.push(neighbor_ids
[i
]);
494 debug("additional ids: " + cids_to_request
.toString());
496 /* additional info for piggyback counters */
498 if (tagsAreDisplayed()) {
499 query
= query
+ "&omode=lt";
501 query
= query
+ "&omode=flc";
504 var date
= new Date();
505 var timestamp
= Math
.round(date
.getTime() / 1000);
506 query
= query
+ "&ts=" + timestamp
;
508 query
= query
+ "&cids=" + cids_to_request
.toString();
510 var crow
= $("RROW-" + id
);
511 var article_is_unread
= crow
.className
.match("Unread");
513 if (!async_counters_work
) {
514 query
= query
+ "&csync=true";
517 showArticleInHeadlines(id
);
519 if (!cached_article
) {
521 // notify_progress("Loading, please wait...", true);
523 /* var content = $('HLC-' + id);
525 if (content && !$('LL-' + id)) {
526 var ll = document.createElement('img');
528 ll.src = 'images/indicator_tiny.gif';
529 ll.className = 'hlLoading';
532 content.appendChild(ll);
536 var upic
= $('FUPDPIC-' + id
);
539 upic
.src
= 'images/indicator_white.gif';
542 } else if (cached_article
&& article_is_unread
) {
544 query
= query
+ "&mode=prefetch";
546 render_article(cached_article
);
548 } else if (cached_article
) {
550 query
= query
+ "&mode=prefetch_old";
551 render_article(cached_article
);
557 last_requested_article
= id
;
559 new Ajax
.Request("backend.php", {
561 onComplete: function(transport
) {
562 article_callback2(transport
, id
, feed_id
);
568 exception_error("view", e
);
573 return toggleMark(id
);
577 return togglePub(id
);
580 function tMark_afh_off(effect
) {
582 var elem
= effect
.effects
[0].element
;
584 debug("tMark_afh_off : " + elem
.id
);
587 elem
.src
= elem
.src
.replace("mark_set", "mark_unset");
588 elem
.alt
= __("Star article");
593 exception_error("tMark_afh_off", e
);
597 function tPub_afh_off(effect
) {
599 var elem
= effect
.effects
[0].element
;
601 debug("tPub_afh_off : " + elem
.id
);
604 elem
.src
= elem
.src
.replace("pub_set", "pub_unset");
605 elem
.alt
= __("Publish article");
610 exception_error("tPub_afh_off", e
);
614 function toggleMark(id
, client_only
, no_effects
) {
618 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
620 query
= query
+ "&afid=" + getActiveFeedId();
622 if (tagsAreDisplayed()) {
623 query
= query
+ "&omode=tl";
625 query
= query
+ "&omode=flc";
628 var mark_img
= $("FMPIC-" + id
);
630 if (!mark_img
) return;
632 var vfeedu
= $("FEEDU--1");
633 var crow
= $("RROW-" + id
);
635 if (mark_img
.src
.match("mark_unset")) {
636 mark_img
.src
= mark_img
.src
.replace("mark_unset", "mark_set");
637 mark_img
.alt
= __("Unstar article");
638 query
= query
+ "&mark=1";
641 db
.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id
]);
645 //mark_img.src = "images/mark_unset.png";
646 mark_img
.alt
= __("Please wait...");
647 query
= query
+ "&mark=0";
649 if ($("headlinesList") && !no_effects
) {
650 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tMark_afh_off
});
652 mark_img
.src
= mark_img
.src
.replace("mark_set", "mark_unset");
653 mark_img
.alt
= __("Star article");
657 db
.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id
]);
662 if (!no_effects
) update_local_feedlist_counters();
667 new Ajax
.Request("backend.php", {
669 onComplete: function(transport
) {
670 all_counters_callback2(transport
);
676 exception_error("toggleMark", e
);
680 function togglePub(id
, client_only
, no_effects
, note
) {
684 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
686 query
= query
+ "&afid=" + getActiveFeedId();
688 if (note
!= undefined) {
689 query
= query
+ "¬e=" + param_escape(note
);
691 query
= query
+ "¬e=undefined";
694 if (tagsAreDisplayed()) {
695 query
= query
+ "&omode=tl";
697 query
= query
+ "&omode=flc";
700 var mark_img
= $("FPPIC-" + id
);
702 if (!mark_img
) return;
704 var vfeedu
= $("FEEDU--2");
705 var crow
= $("RROW-" + id
);
707 if (mark_img
.src
.match("pub_unset") || note
!= undefined) {
708 mark_img
.src
= mark_img
.src
.replace("pub_unset", "pub_set");
709 mark_img
.alt
= __("Unpublish article");
710 query
= query
+ "&pub=1";
713 //mark_img.src = "images/pub_unset.png";
714 mark_img
.alt
= __("Please wait...");
715 query
= query
+ "&pub=0";
717 if ($("headlinesList") && !no_effects
) {
718 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tPub_afh_off
});
720 mark_img
.src
= mark_img
.src
.replace("pub_set", "pub_unset");
721 mark_img
.alt
= __("Publish article");
726 new Ajax
.Request("backend.php", {
728 onComplete: function(transport
) {
729 toggle_published_callback(transport
);
735 exception_error("togglePub", e
);
739 function correctHeadlinesOffset(id
) {
743 var hlist
= $("headlinesList");
744 var container
= $("headlinesInnerContainer");
745 var row
= $("RROW-" + id
);
747 var viewport
= container
.offsetHeight
;
749 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
750 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
752 debug("Rtop: " + rel_offset_top
+ " Rbtm: " + rel_offset_bottom
);
753 debug("Vport: " + viewport
);
755 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
756 container
.scrollTop
= row
.offsetTop
;
757 } else if (rel_offset_bottom
> viewport
) {
759 /* doesn't properly work with Opera in some cases because
760 Opera fucks up element scrolling */
762 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
766 exception_error("correctHeadlinesOffset", e
);
771 function moveToPost(mode
) {
778 rows
= cdmGetVisibleArticles();
780 rows
= getVisibleHeadlineIds();
786 if (!$('RROW-' + active_post_id
)) {
787 active_post_id
= false;
790 if (active_post_id
== false) {
791 next_id
= getFirstVisibleHeadlineId();
792 prev_id
= getLastVisibleHeadlineId();
794 for (var i
= 0; i
< rows
.length
; i
++) {
795 if (rows
[i
] == active_post_id
) {
802 if (mode
== "next") {
806 if (!cdmArticleIsActuallyVisible(next_id
)) {
807 cdmScrollToArticleId(next_id
);
809 cdmSelectArticles("none");
810 toggleUnread(next_id
, 0, true);
811 toggleSelected(next_id
);
814 correctHeadlinesOffset(next_id
);
815 view(next_id
, getActiveFeedId());
820 if (mode
== "prev") {
823 cdmScrollToArticleId(prev_id
);
824 cdmSelectArticles("none");
825 toggleUnread(prev_id
, 0, true);
826 toggleSelected(prev_id
);
828 correctHeadlinesOffset(prev_id
);
829 view(prev_id
, getActiveFeedId());
835 exception_error("moveToPost", e
);
839 function toggleSelected(id
) {
842 var cb
= $("RCHK-" + id
);
844 var row
= $("RROW-" + id
);
846 var nc
= row
.className
;
848 if (!nc
.match("Selected")) {
849 nc
= nc
+ "Selected";
854 // In CDM basically last selected article == active article
855 if (isCdmMode()) active_post_id
= id
;
857 nc
= nc
.replace("Selected", "");
867 exception_error("toggleSelected", e
);
871 function toggleUnread_afh(effect
) {
874 var elem
= effect
.element
;
875 elem
.style
.backgroundColor
= "";
878 exception_error("toggleUnread_afh", e
);
882 function toggleUnread(id
, cmode
, effect
) {
885 var row
= $("RROW-" + id
);
887 var nc
= row
.className
;
888 var is_selected
= row
.className
.match("Selected");
889 nc
= nc
.replace("Unread", "");
890 nc
= nc
.replace("Selected", "");
892 // since we are removing selection from the object, uncheck
893 // corresponding checkbox
895 var cb
= $("RCHK-" + id
);
900 // NOTE: I'm not sure that resetting selection here is a feature -fox
902 if (cmode
== undefined || cmode
== 2) {
903 if (row
.className
.match("Unread")) {
907 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
908 afterFinish
: toggleUnread_afh
,
909 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
913 row
.className
= nc
+ "Unread";
917 db
.execute("UPDATE articles SET unread = not unread "+
918 "WHERE id = ?", [id
]);
921 } else if (cmode
== 0) {
925 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
926 afterFinish
: toggleUnread_afh
,
927 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
931 db
.execute("UPDATE articles SET unread = 0 "+
932 "WHERE id = ?", [id
]);
935 } else if (cmode
== 1) {
936 row
.className
= nc
+ "Unread";
939 db
.execute("UPDATE articles SET unread = 1 "+
940 "WHERE id = ?", [id
]);
945 update_local_feedlist_counters();
947 // Disable unmarking as selected for the time being (16.05.08) -fox
948 if (is_selected
) row
.className
= row
.className
+ "Selected";
950 if (cmode
== undefined) cmode
= 2;
952 var query
= "?op=rpc&subop=catchupSelected" +
953 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
955 // notify_progress("Loading, please wait...");
957 new Ajax
.Request("backend.php", {
959 onComplete: function(transport
) {
960 all_counters_callback2(transport
);
966 exception_error("toggleUnread", e
);
970 function selectionRemoveLabel(id
) {
973 var ids
= getSelectedArticleIds2();
975 if (ids
.length
== 0) {
976 alert(__("No articles are selected."));
980 // var ok = confirm(__("Remove selected articles from label?"));
984 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
985 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
987 // notify_progress("Loading, please wait...");
989 cache_invalidate("F:" + (-11 - id
));
991 new Ajax
.Request("backend.php", {
993 onComplete: function(transport
) {
994 show_labels_in_headlines(transport
);
995 all_counters_callback2(transport
);
1001 exception_error("selectionAssignLabel", e
);
1006 function selectionAssignLabel(id
) {
1009 var ids
= getSelectedArticleIds2();
1011 if (ids
.length
== 0) {
1012 alert(__("No articles are selected."));
1016 // var ok = confirm(__("Assign selected articles to label?"));
1020 cache_invalidate("F:" + (-11 - id
));
1022 var query
= "?op=rpc&subop=assignToLabel&ids=" +
1023 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
1025 // notify_progress("Loading, please wait...");
1027 new Ajax
.Request("backend.php", {
1029 onComplete: function(transport
) {
1030 show_labels_in_headlines(transport
);
1031 all_counters_callback2(transport
);
1037 exception_error("selectionAssignLabel", e
);
1042 function selectionToggleUnread(cdm_mode
, set_state
, callback_func
, no_error
) {
1047 rows
= cdmGetSelectedArticles();
1049 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1052 if (rows
.length
== 0 && !no_error
) {
1053 alert(__("No articles are selected."));
1057 for (i
= 0; i
< rows
.length
; i
++) {
1058 var row
= $("RROW-" + rows
[i
]);
1060 var nc
= row
.className
;
1061 nc
= nc
.replace("Unread", "");
1062 nc
= nc
.replace("Selected", "");
1064 if (set_state
== undefined) {
1065 if (row
.className
.match("Unread")) {
1066 row
.className
= nc
+ "Selected";
1068 row
.className
= nc
+ "UnreadSelected";
1071 db
.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
1076 if (set_state
== false) {
1077 row
.className
= nc
+ "Selected";
1079 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?",
1084 if (set_state
== true) {
1085 row
.className
= nc
+ "UnreadSelected";
1087 db
.execute("UPDATE articles SET unread = 1 WHERE id = ?",
1094 if (rows
.length
> 0) {
1096 update_local_feedlist_counters();
1100 if (set_state
== undefined) {
1102 } else if (set_state
== true) {
1104 } else if (set_state
== false) {
1108 var query
= "?op=rpc&subop=catchupSelected" +
1109 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
1111 notify_progress("Loading, please wait...");
1113 new Ajax
.Request("backend.php", {
1115 onComplete: function(transport
) {
1116 catchup_callback2(transport
, callback_func
);
1122 exception_error("selectionToggleUnread", e
);
1126 function selectionToggleMarked(cdm_mode
) {
1132 rows
= cdmGetSelectedArticles();
1134 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1137 if (rows
.length
== 0) {
1138 alert(__("No articles are selected."));
1142 for (i
= 0; i
< rows
.length
; i
++) {
1143 toggleMark(rows
[i
], true, true);
1146 update_local_feedlist_counters();
1148 if (rows
.length
> 0) {
1150 var query
= "?op=rpc&subop=markSelected&ids=" +
1151 param_escape(rows
.toString()) + "&cmode=2";
1153 query
= query
+ "&afid=" + getActiveFeedId();
1155 /* if (tagsAreDisplayed()) {
1156 query = query + "&omode=tl";
1158 query = query + "&omode=flc";
1161 query
= query
+ "&omode=lc";
1163 new Ajax
.Request("backend.php", {
1165 onComplete: function(transport
) {
1166 all_counters_callback2(transport
);
1172 exception_error("selectionToggleMarked", e
);
1176 function selectionTogglePublished(cdm_mode
) {
1182 rows
= cdmGetSelectedArticles();
1184 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1187 if (rows
.length
== 0) {
1188 alert(__("No articles are selected."));
1192 for (i
= 0; i
< rows
.length
; i
++) {
1193 togglePub(rows
[i
], true, true);
1196 if (rows
.length
> 0) {
1198 var query
= "?op=rpc&subop=publishSelected&ids=" +
1199 param_escape(rows
.toString()) + "&cmode=2";
1201 query
= query
+ "&afid=" + getActiveFeedId();
1203 /* if (tagsAreDisplayed()) {
1204 query = query + "&omode=tl";
1206 query = query + "&omode=flc";
1209 query
= query
+ "&omode=lc";
1211 new Ajax
.Request("backend.php", {
1213 onComplete: function(transport
) {
1214 all_counters_callback2(transport
);
1220 exception_error("selectionToggleMarked", e
);
1224 function cdmGetSelectedArticles() {
1225 var sel_articles
= new Array();
1226 var container
= $("headlinesInnerContainer");
1228 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1229 var child
= container
.childNodes
[i
];
1231 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Selected")) {
1232 var c_id
= child
.id
.replace("RROW-", "");
1233 sel_articles
.push(c_id
);
1237 return sel_articles
;
1240 function cdmGetVisibleArticles() {
1241 var sel_articles
= new Array();
1242 var container
= $("headlinesInnerContainer");
1244 if (!container
) return sel_articles
;
1246 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1247 var child
= container
.childNodes
[i
];
1249 if (child
.id
&& child
.id
.match("RROW-")) {
1250 var c_id
= child
.id
.replace("RROW-", "");
1251 sel_articles
.push(c_id
);
1255 return sel_articles
;
1258 function cdmGetUnreadArticles() {
1259 var sel_articles
= new Array();
1260 var container
= $("headlinesInnerContainer");
1262 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1263 var child
= container
.childNodes
[i
];
1265 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Unread")) {
1266 var c_id
= child
.id
.replace("RROW-", "");
1267 sel_articles
.push(c_id
);
1271 return sel_articles
;
1275 // mode = all,none,unread
1276 function cdmSelectArticles(mode
) {
1277 var container
= $("headlinesInnerContainer");
1279 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1280 var child
= container
.childNodes
[i
];
1282 if (child
.id
&& child
.id
.match("RROW-")) {
1283 var aid
= child
.id
.replace("RROW-", "");
1285 var cb
= $("RCHK-" + aid
);
1287 if (mode
== "all") {
1288 if (!child
.className
.match("Selected")) {
1289 child
.className
= child
.className
+ "Selected";
1292 } else if (mode
== "unread") {
1293 if (child
.className
.match("Unread") && !child
.className
.match("Selected")) {
1294 child
.className
= child
.className
+ "Selected";
1298 child
.className
= child
.className
.replace("Selected", "");
1305 function catchupPage() {
1307 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1309 var str
= __("Mark all visible articles in %s as read?");
1311 str
= str
.replace("%s", fn
);
1313 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1317 if ($("headlinesList")) {
1318 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
1319 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1320 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1322 cdmSelectArticles('all');
1323 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1324 cdmSelectArticles('none');
1328 function deleteSelection() {
1334 if ($("headlinesList")) {
1335 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1337 rows
= cdmGetSelectedArticles();
1340 if (rows
.length
== 0) {
1341 alert(__("No articles are selected."));
1346 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1350 if (getActiveFeedId() != 0) {
1351 str
= __("Delete %d selected articles in %s?");
1353 str
= __("Delete %d selected articles?");
1356 str
= str
.replace("%d", rows
.length
);
1357 str
= str
.replace("%s", fn
);
1359 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1363 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
1367 new Ajax
.Request("backend.php", {
1369 onComplete: function(transport
) {
1374 exception_error("deleteSelection", e
);
1378 function archiveSelection() {
1384 if ($("headlinesList")) {
1385 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1387 rows
= cdmGetSelectedArticles();
1390 if (rows
.length
== 0) {
1391 alert(__("No articles are selected."));
1396 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1400 if (getActiveFeedId() != 0) {
1401 str
= __("Archive %d selected articles in %s?");
1404 str
= __("Move %d archived articles back?");
1408 str
= str
.replace("%d", rows
.length
);
1409 str
= str
.replace("%s", fn
);
1411 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1415 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1419 for (var i
= 0; i
< rows
.length
; i
++) {
1420 cache_invalidate(rows
[i
]);
1423 new Ajax
.Request("backend.php", {
1425 onComplete: function(transport
) {
1430 exception_error("archiveSelection", e
);
1434 function catchupSelection() {
1440 if ($("headlinesList")) {
1441 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1443 rows
= cdmGetSelectedArticles();
1446 if (rows
.length
== 0) {
1447 alert(__("No articles are selected."));
1452 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1454 var str
= __("Mark %d selected articles in %s as read?");
1456 str
= str
.replace("%d", rows
.length
);
1457 str
= str
.replace("%s", fn
);
1459 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1463 if ($("headlinesList")) {
1464 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
1465 // selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1467 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
1468 // cdmSelectArticles('none');
1472 exception_error("catchupSelection", e
);
1476 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1477 displayDlg('editArticleTags', id
);
1481 function tag_saved_callback(transport
) {
1483 debug("in tag_saved_callback");
1488 if (tagsAreDisplayed()) {
1489 _reload_feedlist_after_view
= true;
1493 if (transport
.responseXML
) {
1494 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1497 var id
= tags_str
.getAttribute("id");
1500 var tags
= $("ATSTR-" + id
);
1502 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1509 exception_error("tag_saved_callback", e
);
1513 function editTagsSave() {
1515 notify_progress("Saving article tags...");
1517 var form
= document
.forms
["tag_edit_form"];
1519 var query
= Form
.serialize("tag_edit_form");
1521 query
= "?op=rpc&subop=setArticleTags&" + query
;
1525 new Ajax
.Request("backend.php", {
1527 onComplete: function(transport
) {
1528 tag_saved_callback(transport
);
1533 function editTagsInsert() {
1536 var form
= document
.forms
["tag_edit_form"];
1538 var found_tags
= form
.found_tags
;
1539 var tags_str
= form
.tags_str
;
1541 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1543 if (tags_str
.value
.length
> 0 &&
1544 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1546 tags_str
.value
= tags_str
.value
+ ", ";
1549 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1551 found_tags
.selectedIndex
= 0;
1554 exception_error("editTagsInsert", e
);
1558 function cdmScrollViewport(where
) {
1559 debug("cdmScrollViewport: " + where
);
1561 var ctr
= $("headlinesInnerContainer");
1565 if (where
== "bottom") {
1566 ctr
.scrollTop
= ctr
.scrollHeight
;
1568 ctr
.scrollTop
= where
;
1572 function cdmArticleIsBelowViewport(id
) {
1574 var ctr
= $("headlinesInnerContainer");
1575 var e
= $("RROW-" + id
);
1577 if (!e
|| !ctr
) return;
1579 // article starts below viewport
1581 if (ctr
.scrollTop
< e
.offsetTop
) {
1588 exception_error("cdmArticleIsVisible", e
);
1592 function cdmArticleIsAboveViewport(id
) {
1594 var ctr
= $("headlinesInnerContainer");
1595 var e
= $("RROW-" + id
);
1597 if (!e
|| !ctr
) return;
1599 // article starts above viewport
1601 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1608 exception_error("cdmArticleIsVisible", e
);
1612 function cdmScrollToArticleId(id
) {
1614 var ctr
= $("headlinesInnerContainer");
1615 var e
= $("RROW-" + id
);
1617 if (!e
|| !ctr
) return;
1619 ctr
.scrollTop
= e
.offsetTop
;
1622 exception_error("cdmScrollToArticleId", e
);
1626 function cdmArticleIsActuallyVisible(id
) {
1628 var ctr
= $("headlinesInnerContainer");
1629 var e
= $("RROW-" + id
);
1631 if (!e
|| !ctr
) return;
1633 // article fits in viewport OR article is longer than viewport and
1634 // its bottom is visible
1636 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1637 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1641 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1642 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1643 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1652 exception_error("cdmArticleIsVisible", e
);
1656 function cdmWatchdog() {
1660 var ctr
= $("headlinesInnerContainer");
1664 var ids
= new Array();
1666 var e
= ctr
.firstChild
;
1669 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1670 e
.id
.match("RROW-")) {
1672 // article fits in viewport OR article is longer than viewport and
1673 // its bottom is visible
1675 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1676 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1678 // debug(e.id + " is visible " + e.offsetTop + "." +
1679 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1680 // (ctr.scrollTop + ctr.offsetHeight));
1682 ids
.push(e
.id
.replace("RROW-", ""));
1684 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1685 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1686 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1688 ids
.push(e
.id
.replace("RROW-", ""));
1692 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1694 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1695 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1697 ids.push(e.id.replace("RROW-", ""));
1706 debug("cdmWatchdog, ids= " + ids
.toString());
1708 if (ids
.length
> 0) {
1710 for (var i
= 0; i
< ids
.length
; i
++) {
1711 var e
= $("RROW-" + ids
[i
]);
1713 e
.className
= e
.className
.replace("Unread", "");
1717 var query
= "?op=rpc&subop=catchupSelected" +
1718 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1720 new Ajax
.Request("backend.php", {
1722 onComplete: function(transport
) {
1723 all_counters_callback2(transport
);
1728 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1731 exception_error("cdmWatchdog", e
);
1737 function cache_inject(id
, article
, param
) {
1739 if (!cache_check_param(id
, param
)) {
1740 debug("cache_article: miss: " + id
+ " [p=" + param
+ "]");
1745 var date
= new Date();
1746 var ts
= Math
.round(date
.getTime() / 1000);
1748 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1749 [id
, article
, param
, ts
]);
1752 var cache_obj
= new Array();
1754 cache_obj
["id"] = id
;
1755 cache_obj
["data"] = article
;
1756 cache_obj
["param"] = param
;
1758 article_cache
.push(cache_obj
);
1762 debug("cache_article: hit: " + id
+ " [p=" + param
+ "]");
1765 exception_error("cache_inject", e
);
1769 function cache_find(id
) {
1772 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1775 if (rs
.isValidRow()) {
1776 var a
= rs
.field(0);
1784 for (var i
= 0; i
< article_cache
.length
; i
++) {
1785 if (article_cache
[i
]["id"] == id
) {
1786 return article_cache
[i
]["data"];
1793 function cache_find_param(id
, param
) {
1796 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1800 if (rs
.isValidRow()) {
1809 for (var i
= 0; i
< article_cache
.length
; i
++) {
1810 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1811 return article_cache
[i
]["data"];
1818 function cache_check(id
) {
1821 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1825 if (rs
.isValidRow()) {
1826 a
= rs
.field(0) != "0";
1834 for (var i
= 0; i
< article_cache
.length
; i
++) {
1835 if (article_cache
[i
]["id"] == id
) {
1843 function cache_check_param(id
, param
) {
1846 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1850 if (rs
.isValidRow()) {
1851 a
= rs
.field(0) != "0";
1859 for (var i
= 0; i
< article_cache
.length
; i
++) {
1860 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1868 function cache_expire() {
1870 var date
= new Date();
1871 var ts
= Math
.round(date
.getTime() / 1000);
1873 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1874 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1875 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1879 while (article_cache
.length
> 25) {
1880 article_cache
.shift();
1885 function cache_empty() {
1886 article_cache
= new Array();
1889 function cache_invalidate(id
) {
1893 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1894 return rs
.rowsAffected
!= 0;
1899 while (i
< article_cache
.length
) {
1900 if (article_cache
[i
]["id"] == id
) {
1901 debug("cache_invalidate: removed id " + id
);
1902 article_cache
.splice(i
, 1);
1909 debug("cache_invalidate: id not found: " + id
);
1912 exception_error("cache_invalidate", e
);
1916 function getActiveArticleId() {
1917 return active_post_id
;
1920 function cdmClicked(id
) {
1922 var elem
= $("RROW-" + id
);
1925 var id
= elem
.id
.replace("RROW-", "");
1926 active_post_id
= id
;
1928 // cdmSelectArticles("none");
1929 toggleUnread(id
, 0, true);
1930 // toggleSelected(id);
1934 exception_error("cdmClicked", e
);
1938 function preload_article_callback(transport
) {
1940 if (transport
.responseXML
) {
1941 var articles
= transport
.responseXML
.getElementsByTagName("article");
1943 for (var i
= 0; i
< articles
.length
; i
++) {
1944 var id
= articles
[i
].getAttribute("id");
1945 if (!cache_check(id
)) {
1946 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1947 debug("preloaded article: " + id
);
1952 exception_error("preload_article_callback", e
);
1956 function preloadArticleUnderPointer(id
) {
1958 if (getInitParam("bw_limit") == "1") return;
1960 if (post_under_pointer
== id
&& !cache_check(id
)) {
1962 debug("trying to preload article " + id
);
1964 var neighbor_ids
= getRelativePostIds(id
, 1);
1966 /* only request uncached articles */
1968 var cids_to_request
= Array();
1970 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1971 if (!cache_check(neighbor_ids
[i
])) {
1972 cids_to_request
.push(neighbor_ids
[i
]);
1975 debug("additional ids: " + cids_to_request
.toString());
1977 cids_to_request
.push(id
);
1979 var query
= "?op=rpc&subop=getArticles&ids=" +
1980 cids_to_request
.toString();
1982 new Ajax
.Request("backend.php", {
1984 onComplete: function(transport
) {
1985 preload_article_callback(transport
);
1989 exception_error("preloadArticleUnderPointer", e
);
1993 function postMouseIn(id
) {
1995 if (post_under_pointer
!= id
) {
1996 post_under_pointer
= id
;
1998 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
2003 exception_error("postMouseIn", e
);
2007 function postMouseOut(id
) {
2009 post_under_pointer
= false;
2011 exception_error("postMouseOut", e
);
2015 function headlines_scroll_handler() {
2018 var e
= $("headlinesInnerContainer");
2020 // don't do infinite scrolling when Limit == All
2022 var toolbar_form
= document
.forms
["main_toolbar_form"];
2024 var limit
= toolbar_form
.limit
[toolbar_form
.limit
.selectedIndex
];
2025 if (limit
.value
!= 0) {
2027 debug((e
.scrollTop
+ e
.offsetHeight
) + " vs " + e
.scrollHeight
+ " dis? " +
2028 _infscroll_disable
);
2030 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
2031 if (!_infscroll_disable
) {
2032 debug("more cowbell!");
2039 exception_error("headlines_scroll_handler", e
);
2043 function catchupRelativeToArticle(below
) {
2048 if (!getActiveArticleId()) {
2049 alert(__("No article is selected."));
2055 if ($("headlinesList")) {
2056 visible_ids
= getVisibleHeadlineIds();
2058 visible_ids
= cdmGetVisibleArticles();
2061 var ids_to_mark
= new Array();
2064 for (var i
= 0; i
< visible_ids
.length
; i
++) {
2065 if (visible_ids
[i
] != getActiveArticleId()) {
2066 var e
= $("RROW-" + visible_ids
[i
]);
2068 if (e
&& e
.className
.match("Unread")) {
2069 ids_to_mark
.push(visible_ids
[i
]);
2076 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
2077 if (visible_ids
[i
] != getActiveArticleId()) {
2078 var e
= $("RROW-" + visible_ids
[i
]);
2080 if (e
&& e
.className
.match("Unread")) {
2081 ids_to_mark
.push(visible_ids
[i
]);
2089 if (ids_to_mark
.length
== 0) {
2090 alert(__("No articles found to mark"));
2092 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
2096 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
2097 var e
= $("RROW-" + ids_to_mark
[i
]);
2098 e
.className
= e
.className
.replace("Unread", "");
2101 var query
= "?op=rpc&subop=catchupSelected" +
2102 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
2104 new Ajax
.Request("backend.php", {
2106 onComplete: function(transport
) {
2107 catchup_callback2(transport
);
2114 exception_error("catchupRelativeToArticle", e
);
2118 function cdmExpandArticle(a_id
) {
2120 var id
= 'CICD-' + a_id
;
2123 Element
.hide("CEXC-" + a_id
);
2126 Effect
.Appear(id
, {duration
: 0.5,
2127 beforeStart: function(effect
) {
2128 var h_id
= 'CICH-' + a_id
;
2129 var h_elem
= $(h_id
);
2130 if (h_elem
) { h_elem
.style
.display
= "none"; }
2132 toggleUnread(a_id
, 0);
2137 exception_error("appearBlockElementF", e
);
2142 function fixHeadlinesOrder(ids
) {
2144 for (var i
= 0; i
< ids
.length
; i
++) {
2145 var e
= $("RROW-" + ids
[i
]);
2149 e
.className
= e
.className
.replace("even", "odd");
2151 e
.className
= e
.className
.replace("odd", "even");
2156 exception_error("fixHeadlinesOrder", e
);
2160 function hideReadHeadlines() {
2164 var vis_ids
= new Array();
2166 if ($("headlinesList")) {
2167 ids
= getVisibleHeadlineIds();
2169 ids
= cdmGetVisibleArticles();
2172 var read_headlines_visible
= true;
2174 for (var i
= 0; i
< ids
.length
; i
++) {
2175 var row
= $("RROW-" + ids
[i
]);
2177 if (row
&& row
.className
) {
2178 if (read_headlines_visible
) {
2179 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2181 vis_ids
.push(ids
[i
]);
2183 //Effect.Fade(row, {duration : 0.3});
2188 vis_ids
.push(ids
[i
]);
2193 fixHeadlinesOrder(vis_ids
);
2195 read_headlines_visible
= !read_headlines_visible
;
2198 exception_error("hideReadHeadlines", e
);
2202 function invertHeadlineSelection() {
2204 var rows
= new Array();
2208 r
= document
.getElementsByTagName("TR");
2210 r
= document
.getElementsByTagName("DIV");
2213 for (var i
= 0; i
< r
.length
; i
++) {
2214 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2219 for (var i
= 0; i
< rows
.length
; i
++) {
2220 var nc
= rows
[i
].className
;
2221 var id
= rows
[i
].id
.replace("RROW-", "");
2222 var cb
= $("RCHK-" + id
);
2224 if (!rows
[i
].className
.match("Selected")) {
2225 nc
= nc
+ "Selected";
2228 nc
= nc
.replace("Selected", "");
2232 rows
[i
].className
= nc
;
2237 exception_error("invertHeadlineSelection", e
);
2241 function getArticleUnderPointer() {
2242 return post_under_pointer
;
2245 function zoomToArticle(id
) {
2247 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2249 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2252 exception_error("zoomToArticle", e
);
2256 function showOriginalArticleInline(id
) {
2259 var query
= "?op=rpc&subop=getArticleLink&id=" + id
;
2261 notify_progress("Loading, please wait...", true);
2263 new Ajax
.Request("backend.php", {
2265 onComplete: function(transport
) {
2267 if (transport
.responseXML
) {
2269 var link
= transport
.responseXML
.getElementsByTagName("link")[0];
2270 var id
= transport
.responseXML
.getElementsByTagName("id")[0];
2275 link
= link
.firstChild
.nodeValue
;
2277 var ci
= $("content-insert");
2279 var tmp
= "<iframe id=\"inline_orig_article\" width=\""+ci
.offsetWidth
+"\" height=\""+ci
.offsetHeight
+"\" style=\"border-width : 0px;\" src=\""+link
+"\"></iframe>";
2281 render_article(tmp
);
2288 exception_error("showOriginalArticleInline", e
);
2293 function scrollArticle(offset
) {
2296 var ci
= $("content-insert");
2298 ci
.scrollTop
+= offset
;
2301 var hi
= $("headlinesInnerContainer");
2303 hi
.scrollTop
+= offset
;
2308 exception_error("scrollArticle", e
);
2312 function show_labels_in_headlines(transport
) {
2314 if (transport
.responseXML
) {
2315 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2317 var elems
= info
.getElementsByTagName("entry");
2319 for (var l
= 0; l
< elems
.length
; l
++) {
2320 var e_id
= elems
[l
].getAttribute("id");
2324 var ctr
= $("HLLCTR-" + e_id
);
2327 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2335 exception_error("show_labels_in_headlines", e
);
2340 function toggleHeadlineActions() {
2342 var e
= $("headlineActionsBody");
2343 var p
= $("headlineActionsDrop");
2345 if (!Element
.visible(e
)) {
2352 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2353 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2356 exception_error("toggleHeadlineActions", e
);
2360 function publishWithNote(id
, def_note
) {
2362 if (!def_note
) def_note
= '';
2364 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2366 if (note
!= undefined) {
2367 togglePub(id
, false, false, note
);
2371 exception_error("publishWithNote", e
);