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 response
= transport
.responseXML
;
112 var headlines
= response
.getElementsByTagName("headlines")[0];
113 var headlines_info
= response
.getElementsByTagName("headlines-info")[0];
116 headlines_info
= JSON
.parse(headlines_info
.firstChild
.nodeValue
);
118 console
.log("didn't find headlines-info object in response");
120 var headlines_count
= headlines_info
.count
;
121 var headlines_unread
= headlines_info
.unread
;
122 var disable_cache
= headlines_info
.disable_cache
;
124 vgroup_last_feed
= headlines_info
.vgroup_last_feed
;
126 if (headlines_count
== 0) {
127 _infscroll_disable
= 1;
129 _infscroll_disable
= 0;
132 var counters
= response
.getElementsByTagName("counters")[0];
133 var articles
= response
.getElementsByTagName("article");
134 var runtime_info
= response
.getElementsByTagName("runtime-info");
136 if (feed_cur_page
== 0) {
138 f
.innerHTML
= headlines
.firstChild
.nodeValue
;
140 var cache_prefix
= "";
148 cache_invalidate(cache_prefix
+ feed_id
);
150 if (!disable_cache
) {
151 cache_inject(cache_prefix
+ feed_id
,
152 headlines
.firstChild
.nodeValue
, headlines_unread
);
156 console
.log("headlines_callback: returned no data");
157 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
162 if (headlines_count
> 0) {
163 console
.log("adding some more headlines...");
165 var c
= $("headlinesList");
168 c
= $("headlinesInnerContainer");
171 var ids
= getSelectedArticleIds2();
173 c
.innerHTML
= c
.innerHTML
+ headlines
.firstChild
.nodeValue
;
175 console
.log("restore selected ids: " + ids
);
177 for (var i
= 0; i
< ids
.length
; i
++) {
178 markHeadline(ids
[i
]);
182 console
.log("no new headlines received");
185 console
.log("headlines_callback: returned no data");
186 notify_error("Error while trying to load more headlines");
192 for (var i
= 0; i
< articles
.length
; i
++) {
193 var a_id
= articles
[i
].getAttribute("id");
194 console
.log("found id: " + a_id
);
195 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
198 console
.log("no cached articles received");
202 console
.log("parsing piggybacked counters: " + counters
);
203 parse_counters(counters
, false);
205 console
.log("counters container not found in reply, requesting...");
210 console
.log("parsing runtime info: " + runtime_info
[0]);
211 parse_runtime_info(runtime_info
[0]);
213 console
.log("counters container not found in reply");
217 console
.log("headlines_callback: returned no XML object");
218 f
.innerHTML
= "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
221 if (typeof correctPNG
!= 'undefined') {
225 if (_cdm_wd_timeout
) window
.clearTimeout(_cdm_wd_timeout
);
227 if (!$("headlinesList") &&
228 getActiveFeedId() != -3 &&
229 getInitParam("cdm_auto_catchup") == 1) {
230 console
.log("starting CDM watchdog");
231 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 5000);
232 _cdm_wd_vishist
= new Array();
234 console
.log("not in CDM mode or watchdog disabled");
237 _feed_cur_page
= feed_cur_page
;
238 _infscroll_request_sent
= 0;
245 exception_error("headlines_callback2", e
, transport
);
249 function render_article(article
) {
251 var f
= $("content-frame");
256 var fi
= $("content-insert");
262 fi
.innerHTML
= article
;
264 // article.evalScripts();
267 exception_error("render_article", e
);
271 function showArticleInHeadlines(id
) {
275 cleanSelected("headlinesList");
277 var crow
= $("RROW-" + id
);
281 var article_is_unread
= crow
.className
.match("Unread");
283 crow
.className
= crow
.className
.replace("Unread", "");
285 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
287 var upd_img_pic
= $("FUPDPIC-" + id
);
289 var cache_prefix
= "";
291 if (activeFeedIsCat()) {
297 var view_mode
= false;
300 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
301 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
306 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
307 upd_img_pic
.src
.match("fresh_sign.png"))) {
309 upd_img_pic
.src
= "images/blank_icon.gif";
311 cache_invalidate(cache_prefix
+ getActiveFeedId());
313 cache_inject(cache_prefix
+ getActiveFeedId(),
314 $("headlines-frame").innerHTML
,
315 get_feed_unread(getActiveFeedId()));
317 } else if (article_is_unread
&& view_mode
== "all_articles") {
319 cache_invalidate(cache_prefix
+ getActiveFeedId());
321 cache_inject(cache_prefix
+ getActiveFeedId(),
322 $("headlines-frame").innerHTML
,
323 get_feed_unread(getActiveFeedId())-1);
325 } else if (article_is_unread
) {
326 cache_invalidate(cache_prefix
+ getActiveFeedId());
332 exception_error("showArticleInHeadlines", e
);
336 function article_callback2(transport
, id
) {
338 console
.log("article_callback2 " + id
);
340 if (!transport
.responseText
&& db
) {
341 offlineConfirmModeChange();
345 if (transport
.responseXML
) {
347 if (!transport_error_check(transport
)) return;
349 /* var ll = $('LL-' + id);
350 var content = $('HLC-' + id);
352 if (ll && content) content.removeChild(ll); */
354 var upic
= $('FUPDPIC-' + id
);
357 upic
.src
= 'images/blank_icon.gif';
360 if (id
!= last_requested_article
) {
361 console
.log("requested article id is out of sequence, aborting");
367 console
.log("looking for articles to cache...");
369 var articles
= transport
.responseXML
.getElementsByTagName("article");
371 for (var i
= 0; i
< articles
.length
; i
++) {
372 var a_id
= articles
[i
].getAttribute("id");
374 console
.log("found id: " + a_id
);
376 if (a_id
== active_post_id
) {
377 console
.log("active article, rendering...");
378 render_article(articles
[i
].firstChild
.nodeValue
);
381 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
385 showArticleInHeadlines(id
);
388 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?", [id
]);
391 var reply
= transport
.responseXML
.firstChild
.firstChild
;
394 console
.log("article_callback: returned no XML object");
395 //var f = $("content-frame");
396 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
399 var date
= new Date();
400 last_article_view
= date
.getTime() / 1000;
402 if (typeof correctPNG
!= 'undefined') {
406 if (_reload_feedlist_after_view
) {
407 setTimeout('updateFeedList(false, false)', 50);
408 _reload_feedlist_after_view
= false;
410 if (transport
.responseXML
) {
411 var counters
= transport
.responseXML
.getElementsByTagName("counters")[0];
414 console
.log("parsing piggybacked counters: " + counters
);
415 parse_counters(counters
, false);
417 console
.log("counters container not found in reply, requesting...");
425 exception_error("article_callback2", e
, transport
);
431 console
.log("loading article: " + id
);
433 if (offline_mode
) return view_offline(id
);
435 var cached_article
= cache_find(id
);
437 console
.log("cache check result: " + (cached_article
!= false));
442 var query
= "?op=view&id=" + param_escape(id
);
444 var neighbor_ids
= getRelativePostIds(active_post_id
);
446 /* only request uncached articles */
448 var cids_to_request
= Array();
450 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
451 if (!cache_check(neighbor_ids
[i
])) {
452 cids_to_request
.push(neighbor_ids
[i
]);
456 console
.log("additional ids: " + cids_to_request
.toString());
458 /* additional info for piggyback counters */
460 if (tagsAreDisplayed()) {
461 query
= query
+ "&omode=lt";
463 query
= query
+ "&omode=flc";
466 query
= query
+ "&cids=" + cids_to_request
.toString();
468 var crow
= $("RROW-" + id
);
469 var article_is_unread
= crow
.className
.match("Unread");
471 if (!async_counters_work
) {
472 query
= query
+ "&csync=true";
475 showArticleInHeadlines(id
);
477 if (!cached_article
) {
479 var upic
= $('FUPDPIC-' + id
);
482 upic
.src
= getInitParam("sign_progress");
485 } else if (cached_article
&& article_is_unread
) {
487 query
= query
+ "&mode=prefetch";
489 render_article(cached_article
);
491 } else if (cached_article
) {
493 query
= query
+ "&mode=prefetch_old";
494 render_article(cached_article
);
500 last_requested_article
= id
;
502 new Ajax
.Request("backend.php", {
504 onComplete: function(transport
) {
505 article_callback2(transport
, id
);
511 exception_error("view", e
);
516 return toggleMark(id
);
520 return togglePub(id
);
523 function tMark_afh_off(effect
) {
525 var elem
= effect
.effects
[0].element
;
527 console
.log("tMark_afh_off : " + elem
.id
);
530 elem
.src
= elem
.src
.replace("mark_set", "mark_unset");
531 elem
.alt
= __("Star article");
536 exception_error("tMark_afh_off", e
);
540 function tPub_afh_off(effect
) {
542 var elem
= effect
.effects
[0].element
;
544 console
.log("tPub_afh_off : " + elem
.id
);
547 elem
.src
= elem
.src
.replace("pub_set", "pub_unset");
548 elem
.alt
= __("Publish article");
553 exception_error("tPub_afh_off", e
);
557 function toggleMark(id
, client_only
, no_effects
) {
561 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
563 query
= query
+ "&afid=" + getActiveFeedId();
565 if (tagsAreDisplayed()) {
566 query
= query
+ "&omode=tl";
568 query
= query
+ "&omode=flc";
571 var mark_img
= $("FMPIC-" + id
);
573 if (!mark_img
) return;
575 var vfeedu
= $("FEEDU--1");
576 var crow
= $("RROW-" + id
);
578 if (mark_img
.src
.match("mark_unset")) {
579 mark_img
.src
= mark_img
.src
.replace("mark_unset", "mark_set");
580 mark_img
.alt
= __("Unstar article");
581 query
= query
+ "&mark=1";
584 db
.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id
]);
588 mark_img
.alt
= __("Please wait...");
589 query
= query
+ "&mark=0";
591 if ($("headlinesList") && !no_effects
) {
592 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tMark_afh_off
});
594 mark_img
.src
= mark_img
.src
.replace("mark_set", "mark_unset");
595 mark_img
.alt
= __("Star article");
599 db
.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id
]);
604 if (!no_effects
) update_local_feedlist_counters();
609 new Ajax
.Request("backend.php", {
611 onComplete: function(transport
) {
612 all_counters_callback2(transport
);
618 exception_error("toggleMark", e
);
622 function togglePub(id
, client_only
, no_effects
, note
) {
626 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
628 query
= query
+ "&afid=" + getActiveFeedId();
630 if (note
!= undefined) {
631 query
= query
+ "¬e=" + param_escape(note
);
633 query
= query
+ "¬e=undefined";
636 if (tagsAreDisplayed()) {
637 query
= query
+ "&omode=tl";
639 query
= query
+ "&omode=flc";
642 var mark_img
= $("FPPIC-" + id
);
644 if (!mark_img
) return;
646 var vfeedu
= $("FEEDU--2");
647 var crow
= $("RROW-" + id
);
649 if (mark_img
.src
.match("pub_unset") || note
!= undefined) {
650 mark_img
.src
= mark_img
.src
.replace("pub_unset", "pub_set");
651 mark_img
.alt
= __("Unpublish article");
652 query
= query
+ "&pub=1";
655 mark_img
.alt
= __("Please wait...");
656 query
= query
+ "&pub=0";
658 if ($("headlinesList") && !no_effects
) {
659 Effect
.Puff(mark_img
, {duration
: 0.25, afterFinish
: tPub_afh_off
});
661 mark_img
.src
= mark_img
.src
.replace("pub_set", "pub_unset");
662 mark_img
.alt
= __("Publish article");
667 new Ajax
.Request("backend.php", {
669 onComplete: function(transport
) {
670 all_counters_callback2(transport
);
672 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
675 var note_id
= note
.getAttribute("id");
676 var note_size
= note
.getAttribute("size");
677 var note_content
= note
.firstChild
.nodeValue
;
679 var container
= $('POSTNOTE-' + note_id
);
681 cache_invalidate(note_id
);
684 if (note_size
== "0") {
685 Element
.hide(container
);
687 container
.innerHTML
= note_content
;
688 Element
.show(container
);
697 exception_error("togglePub", e
);
701 function correctHeadlinesOffset(id
) {
705 var hlist
= $("headlinesList");
706 var container
= $("headlinesInnerContainer");
707 var row
= $("RROW-" + id
);
709 var viewport
= container
.offsetHeight
;
711 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
712 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
714 console
.log("Rtop: " + rel_offset_top
+ " Rbtm: " + rel_offset_bottom
);
715 console
.log("Vport: " + viewport
);
717 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
718 container
.scrollTop
= row
.offsetTop
;
719 } else if (rel_offset_bottom
> viewport
) {
721 /* doesn't properly work with Opera in some cases because
722 Opera fucks up element scrolling */
724 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
728 exception_error("correctHeadlinesOffset", e
);
733 function moveToPost(mode
) {
740 rows
= cdmGetVisibleArticles();
742 rows
= getVisibleHeadlineIds();
748 if (!$('RROW-' + active_post_id
)) {
749 active_post_id
= false;
752 if (active_post_id
== false) {
753 next_id
= getFirstVisibleHeadlineId();
754 prev_id
= getLastVisibleHeadlineId();
756 for (var i
= 0; i
< rows
.length
; i
++) {
757 if (rows
[i
] == active_post_id
) {
764 if (mode
== "next") {
768 if (!cdmArticleIsActuallyVisible(next_id
)) {
769 cdmScrollToArticleId(next_id
);
771 cdmSelectArticles("none");
772 toggleUnread(next_id
, 0, true);
773 toggleSelected(next_id
);
776 correctHeadlinesOffset(next_id
);
777 view(next_id
, getActiveFeedId());
782 if (mode
== "prev") {
785 cdmScrollToArticleId(prev_id
);
786 cdmSelectArticles("none");
787 toggleUnread(prev_id
, 0, true);
788 toggleSelected(prev_id
);
790 correctHeadlinesOffset(prev_id
);
791 view(prev_id
, getActiveFeedId());
797 exception_error("moveToPost", e
);
801 function toggleSelected(id
) {
804 var cb
= $("RCHK-" + id
);
806 var row
= $("RROW-" + id
);
808 var nc
= row
.className
;
810 if (!nc
.match("Selected")) {
811 nc
= nc
+ "Selected";
816 // In CDM basically last selected article == active article
817 if (isCdmMode()) active_post_id
= id
;
819 nc
= nc
.replace("Selected", "");
829 exception_error("toggleSelected", e
);
833 function toggleUnread_afh(effect
) {
836 var elem
= effect
.element
;
837 elem
.style
.backgroundColor
= "";
840 exception_error("toggleUnread_afh", e
);
844 function toggleUnread(id
, cmode
, effect
) {
847 var row
= $("RROW-" + id
);
849 var nc
= row
.className
;
850 var is_selected
= row
.className
.match("Selected");
851 nc
= nc
.replace("Unread", "");
852 nc
= nc
.replace("Selected", "");
854 // since we are removing selection from the object, uncheck
855 // corresponding checkbox
857 var cb
= $("RCHK-" + id
);
862 // NOTE: I'm not sure that resetting selection here is a feature -fox
864 if (cmode
== undefined || cmode
== 2) {
865 if (row
.className
.match("Unread")) {
869 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
870 afterFinish
: toggleUnread_afh
,
871 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
875 row
.className
= nc
+ "Unread";
879 db
.execute("UPDATE articles SET unread = not unread "+
880 "WHERE id = ?", [id
]);
883 } else if (cmode
== 0) {
887 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
888 afterFinish
: toggleUnread_afh
,
889 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
893 db
.execute("UPDATE articles SET unread = 0 "+
894 "WHERE id = ?", [id
]);
897 } else if (cmode
== 1) {
898 row
.className
= nc
+ "Unread";
901 db
.execute("UPDATE articles SET unread = 1 "+
902 "WHERE id = ?", [id
]);
907 update_local_feedlist_counters();
909 // Disable unmarking as selected for the time being (16.05.08) -fox
910 if (is_selected
) row
.className
= row
.className
+ "Selected";
912 if (cmode
== undefined) cmode
= 2;
914 var query
= "?op=rpc&subop=catchupSelected" +
915 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
917 // notify_progress("Loading, please wait...");
919 new Ajax
.Request("backend.php", {
921 onComplete: function(transport
) {
922 all_counters_callback2(transport
);
928 exception_error("toggleUnread", e
);
932 function selectionRemoveLabel(id
) {
935 var ids
= getSelectedArticleIds2();
937 if (ids
.length
== 0) {
938 alert(__("No articles are selected."));
942 // var ok = confirm(__("Remove selected articles from label?"));
946 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
947 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
949 // notify_progress("Loading, please wait...");
951 cache_invalidate("F:" + (-11 - id
));
953 new Ajax
.Request("backend.php", {
955 onComplete: function(transport
) {
956 show_labels_in_headlines(transport
);
957 all_counters_callback2(transport
);
963 exception_error("selectionAssignLabel", e
);
968 function selectionAssignLabel(id
) {
971 var ids
= getSelectedArticleIds2();
973 if (ids
.length
== 0) {
974 alert(__("No articles are selected."));
978 // var ok = confirm(__("Assign selected articles to label?"));
982 cache_invalidate("F:" + (-11 - id
));
984 var query
= "?op=rpc&subop=assignToLabel&ids=" +
985 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
987 // notify_progress("Loading, please wait...");
989 new Ajax
.Request("backend.php", {
991 onComplete: function(transport
) {
992 show_labels_in_headlines(transport
);
993 all_counters_callback2(transport
);
999 exception_error("selectionAssignLabel", e
);
1004 function selectionToggleUnread(set_state
, callback_func
, no_error
) {
1006 var rows
= getSelectedArticleIds2();
1008 if (rows
.length
== 0 && !no_error
) {
1009 alert(__("No articles are selected."));
1013 for (i
= 0; i
< rows
.length
; i
++) {
1014 var row
= $("RROW-" + rows
[i
]);
1016 var nc
= row
.className
;
1017 nc
= nc
.replace("Unread", "");
1018 nc
= nc
.replace("Selected", "");
1020 if (set_state
== undefined) {
1021 if (row
.className
.match("Unread")) {
1022 row
.className
= nc
+ "Selected";
1024 row
.className
= nc
+ "UnreadSelected";
1027 db
.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
1032 if (set_state
== false) {
1033 row
.className
= nc
+ "Selected";
1035 db
.execute("UPDATE articles SET unread = 0 WHERE id = ?",
1040 if (set_state
== true) {
1041 row
.className
= nc
+ "UnreadSelected";
1043 db
.execute("UPDATE articles SET unread = 1 WHERE id = ?",
1050 if (rows
.length
> 0) {
1052 update_local_feedlist_counters();
1056 if (set_state
== undefined) {
1058 } else if (set_state
== true) {
1060 } else if (set_state
== false) {
1064 var query
= "?op=rpc&subop=catchupSelected" +
1065 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
1067 notify_progress("Loading, please wait...");
1069 new Ajax
.Request("backend.php", {
1071 onComplete: function(transport
) {
1072 catchup_callback2(transport
, callback_func
);
1078 exception_error("selectionToggleUnread", e
);
1082 function selectionToggleMarked() {
1085 var rows
= getSelectedArticleIds2();
1087 if (rows
.length
== 0) {
1088 alert(__("No articles are selected."));
1092 for (i
= 0; i
< rows
.length
; i
++) {
1093 toggleMark(rows
[i
], true, true);
1096 update_local_feedlist_counters();
1098 if (rows
.length
> 0) {
1100 var query
= "?op=rpc&subop=markSelected&ids=" +
1101 param_escape(rows
.toString()) + "&cmode=2";
1103 query
= query
+ "&afid=" + getActiveFeedId();
1105 query
= query
+ "&omode=lc";
1107 new Ajax
.Request("backend.php", {
1109 onComplete: function(transport
) {
1110 all_counters_callback2(transport
);
1116 exception_error("selectionToggleMarked", e
);
1120 function selectionTogglePublished() {
1123 var rows
= getSelectedArticleIds2();
1125 if (rows
.length
== 0) {
1126 alert(__("No articles are selected."));
1130 for (i
= 0; i
< rows
.length
; i
++) {
1131 togglePub(rows
[i
], true, true);
1134 if (rows
.length
> 0) {
1136 var query
= "?op=rpc&subop=publishSelected&ids=" +
1137 param_escape(rows
.toString()) + "&cmode=2";
1139 query
= query
+ "&afid=" + getActiveFeedId();
1141 query
= query
+ "&omode=lc";
1143 new Ajax
.Request("backend.php", {
1145 onComplete: function(transport
) {
1146 all_counters_callback2(transport
);
1152 exception_error("selectionToggleMarked", e
);
1156 function cdmGetSelectedArticles() {
1157 var sel_articles
= new Array();
1158 var container
= $("headlinesInnerContainer");
1160 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1161 var child
= container
.childNodes
[i
];
1163 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Selected")) {
1164 var c_id
= child
.id
.replace("RROW-", "");
1165 sel_articles
.push(c_id
);
1169 return sel_articles
;
1172 function cdmGetVisibleArticles() {
1173 var sel_articles
= new Array();
1174 var container
= $("headlinesInnerContainer");
1176 if (!container
) return sel_articles
;
1178 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1179 var child
= container
.childNodes
[i
];
1181 if (child
.id
&& child
.id
.match("RROW-")) {
1182 var c_id
= child
.id
.replace("RROW-", "");
1183 sel_articles
.push(c_id
);
1187 return sel_articles
;
1190 function cdmGetUnreadArticles() {
1191 var sel_articles
= new Array();
1192 var container
= $("headlinesInnerContainer");
1194 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1195 var child
= container
.childNodes
[i
];
1197 if (child
.id
&& child
.id
.match("RROW-") && child
.className
.match("Unread")) {
1198 var c_id
= child
.id
.replace("RROW-", "");
1199 sel_articles
.push(c_id
);
1203 return sel_articles
;
1207 // mode = all,none,unread
1208 function cdmSelectArticles(mode
) {
1209 var container
= $("headlinesInnerContainer");
1211 for (i
= 0; i
< container
.childNodes
.length
; i
++) {
1212 var child
= container
.childNodes
[i
];
1214 if (child
.id
&& child
.id
.match("RROW-")) {
1215 var aid
= child
.id
.replace("RROW-", "");
1217 var cb
= $("RCHK-" + aid
);
1219 if (mode
== "all") {
1220 if (!child
.className
.match("Selected")) {
1221 child
.className
= child
.className
+ "Selected";
1224 } else if (mode
== "unread") {
1225 if (child
.className
.match("Unread") && !child
.className
.match("Selected")) {
1226 child
.className
= child
.className
+ "Selected";
1230 child
.className
= child
.className
.replace("Selected", "");
1237 function catchupPage() {
1239 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1241 var str
= __("Mark all visible articles in %s as read?");
1243 str
= str
.replace("%s", fn
);
1245 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1249 if ($("headlinesList")) {
1250 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
1251 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1252 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
1254 cdmSelectArticles('all');
1255 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1256 cdmSelectArticles('none');
1260 function deleteSelection() {
1264 var rows
= getSelectedArticleIds2();
1266 if (rows
.length
== 0) {
1267 alert(__("No articles are selected."));
1271 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1275 if (getActiveFeedId() != 0) {
1276 str
= __("Delete %d selected articles in %s?");
1278 str
= __("Delete %d selected articles?");
1281 str
= str
.replace("%d", rows
.length
);
1282 str
= str
.replace("%s", fn
);
1284 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1288 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
1292 new Ajax
.Request("backend.php", {
1294 onComplete: function(transport
) {
1299 exception_error("deleteSelection", e
);
1303 function archiveSelection() {
1307 var rows
= getSelectedArticleIds2();
1309 if (rows
.length
== 0) {
1310 alert(__("No articles are selected."));
1314 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1318 if (getActiveFeedId() != 0) {
1319 str
= __("Archive %d selected articles in %s?");
1322 str
= __("Move %d archived articles back?");
1326 str
= str
.replace("%d", rows
.length
);
1327 str
= str
.replace("%s", fn
);
1329 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1333 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1337 for (var i
= 0; i
< rows
.length
; i
++) {
1338 cache_invalidate(rows
[i
]);
1341 new Ajax
.Request("backend.php", {
1343 onComplete: function(transport
) {
1348 exception_error("archiveSelection", e
);
1352 function catchupSelection() {
1356 var rows
= getSelectedArticleIds2();
1358 if (rows
.length
== 0) {
1359 alert(__("No articles are selected."));
1363 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1365 var str
= __("Mark %d selected articles in %s as read?");
1367 str
= str
.replace("%d", rows
.length
);
1368 str
= str
.replace("%s", fn
);
1370 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1374 if ($("headlinesList")) {
1375 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1377 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1381 exception_error("catchupSelection", e
);
1385 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1386 displayDlg('editArticleTags', id
,
1388 $("tags_str").focus();
1390 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1391 "backend.php?op=rpc&subop=completeTags",
1392 { tokens
: ',', paramName
: "search" });
1396 function editTagsSave() {
1398 notify_progress("Saving article tags...");
1400 var form
= document
.forms
["tag_edit_form"];
1402 var query
= Form
.serialize("tag_edit_form");
1404 query
= "?op=rpc&subop=setArticleTags&" + query
;
1408 new Ajax
.Request("backend.php", {
1410 onComplete: function(transport
) {
1412 console
.log("tags saved...");
1417 if (tagsAreDisplayed()) {
1418 _reload_feedlist_after_view
= true;
1421 if (transport
.responseXML
) {
1422 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1425 var id
= tags_str
.getAttribute("id");
1428 var tags
= $("ATSTR-" + id
);
1430 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1433 cache_invalidate(id
);
1439 exception_error("editTagsSave", e
);
1444 function editTagsInsert() {
1447 var form
= document
.forms
["tag_edit_form"];
1449 var found_tags
= form
.found_tags
;
1450 var tags_str
= form
.tags_str
;
1452 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1454 if (tags_str
.value
.length
> 0 &&
1455 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1457 tags_str
.value
= tags_str
.value
+ ", ";
1460 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1462 found_tags
.selectedIndex
= 0;
1465 exception_error("editTagsInsert", e
);
1469 function cdmScrollViewport(where
) {
1470 console
.log("cdmScrollViewport: " + where
);
1472 var ctr
= $("headlinesInnerContainer");
1476 if (where
== "bottom") {
1477 ctr
.scrollTop
= ctr
.scrollHeight
;
1479 ctr
.scrollTop
= where
;
1483 function cdmArticleIsBelowViewport(id
) {
1485 var ctr
= $("headlinesInnerContainer");
1486 var e
= $("RROW-" + id
);
1488 if (!e
|| !ctr
) return;
1490 // article starts below viewport
1492 if (ctr
.scrollTop
< e
.offsetTop
) {
1499 exception_error("cdmArticleIsVisible", e
);
1503 function cdmArticleIsAboveViewport(id
) {
1505 var ctr
= $("headlinesInnerContainer");
1506 var e
= $("RROW-" + id
);
1508 if (!e
|| !ctr
) return;
1510 // article starts above viewport
1512 if (ctr
.scrollTop
> e
.offsetTop
+ e
.offsetHeight
) {
1519 exception_error("cdmArticleIsVisible", e
);
1523 function cdmScrollToArticleId(id
) {
1525 var ctr
= $("headlinesInnerContainer");
1526 var e
= $("RROW-" + id
);
1528 if (!e
|| !ctr
) return;
1530 ctr
.scrollTop
= e
.offsetTop
;
1533 exception_error("cdmScrollToArticleId", e
);
1537 function cdmArticleIsActuallyVisible(id
) {
1539 var ctr
= $("headlinesInnerContainer");
1540 var e
= $("RROW-" + id
);
1542 if (!e
|| !ctr
) return;
1544 // article fits in viewport OR article is longer than viewport and
1545 // its bottom is visible
1547 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1548 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1552 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1553 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1554 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1563 exception_error("cdmArticleIsVisible", e
);
1567 function cdmWatchdog() {
1571 var ctr
= $("headlinesInnerContainer");
1575 var ids
= new Array();
1577 var e
= ctr
.firstChild
;
1580 if (e
.className
&& e
.className
== "cdmArticleUnread" && e
.id
&&
1581 e
.id
.match("RROW-")) {
1583 // article fits in viewport OR article is longer than viewport and
1584 // its bottom is visible
1586 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1587 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1589 // console.log(e.id + " is visible " + e.offsetTop + "." +
1590 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1591 // (ctr.scrollTop + ctr.offsetHeight));
1593 ids
.push(e
.id
.replace("RROW-", ""));
1595 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1596 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1597 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1599 ids
.push(e
.id
.replace("RROW-", ""));
1603 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1605 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1606 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1608 ids.push(e.id.replace("RROW-", ""));
1617 console
.log("cdmWatchdog, ids= " + ids
.toString());
1619 if (ids
.length
> 0) {
1621 for (var i
= 0; i
< ids
.length
; i
++) {
1622 var e
= $("RROW-" + ids
[i
]);
1624 e
.className
= e
.className
.replace("Unread", "");
1628 var query
= "?op=rpc&subop=catchupSelected" +
1629 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1631 new Ajax
.Request("backend.php", {
1633 onComplete: function(transport
) {
1634 all_counters_callback2(transport
);
1639 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1642 exception_error("cdmWatchdog", e
);
1648 function cache_inject(id
, article
, param
) {
1650 if (!cache_check_param(id
, param
)) {
1651 console
.log("cache_article: miss: " + id
+ " [p=" + param
+ "]");
1655 var date
= new Date();
1656 var ts
= Math
.round(date
.getTime() / 1000);
1658 db
.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
1659 [id
, article
, param
, ts
]);
1664 cache_obj
["id"] = id
;
1665 cache_obj
["data"] = article
;
1666 cache_obj
["param"] = param
;
1667 cache_obj
["added"] = new Date();
1669 if (param
) id
= id
+ ":" + param
;
1671 if (has_local_storage())
1672 localStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1674 article_cache
.push(cache_obj
);
1678 console
.log("cache_article: hit: " + id
+ " [p=" + param
+ "]");
1681 exception_error("cache_inject", e
);
1685 function cache_find(id
) {
1688 var rs
= db
.execute("SELECT article FROM cache WHERE id = ?", [id
]);
1691 if (rs
.isValidRow()) {
1692 var a
= rs
.field(0);
1701 if (has_local_storage()) {
1702 var cache_obj
= localStorage
.getItem(id
);
1705 cache_obj
= JSON
.parse(cache_obj
);
1708 return cache_obj
['data'];
1712 for (var i
= 0; i
< article_cache
.length
; i
++) {
1713 if (article_cache
[i
]["id"] == id
) {
1714 return article_cache
[i
]["data"];
1722 function cache_find_param(id
, param
) {
1725 var rs
= db
.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
1729 if (rs
.isValidRow()) {
1739 if (has_local_storage()) {
1740 var cache_obj
= localStorage
.getItem(id
+ ":" + param
);
1743 cache_obj
= JSON
.parse(cache_obj
);
1746 return cache_obj
['data'];
1750 for (var i
= 0; i
< article_cache
.length
; i
++) {
1751 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1752 return article_cache
[i
]["data"];
1760 function cache_check(id
) {
1763 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
1767 if (rs
.isValidRow()) {
1768 a
= rs
.field(0) != "0";
1776 if (has_local_storage
) {
1777 if (localStorage
.getItem(id
))
1780 for (var i
= 0; i
< article_cache
.length
; i
++) {
1781 if (article_cache
[i
]["id"] == id
) {
1790 function cache_check_param(id
, param
) {
1793 var rs
= db
.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
1797 if (rs
.isValidRow()) {
1798 a
= rs
.field(0) != "0";
1807 if (has_local_storage
) {
1808 if (localStorage
.getItem(id
+ ':' + param
))
1811 for (var i
= 0; i
< article_cache
.length
; i
++) {
1812 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1821 function cache_expire() {
1823 var date
= new Date();
1824 var ts
= Math
.round(date
.getTime() / 1000);
1826 db
.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts
]);
1827 db
.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts
]);
1828 db
.execute("DELETE FROM cache WHERE added < ? - 86400", [ts
]);
1832 if (has_local_storage()) {
1833 while (localStorage
.length
> 25) {
1834 localStorage
.removeItem(localStorage
.key(0));
1837 while (article_cache
.length
> 25) {
1838 article_cache
.shift();
1844 function cache_flush() {
1845 article_cache
= new Array();
1848 function cache_invalidate(id
) {
1852 rs
= db
.execute("DELETE FROM cache WHERE id = ?", [id
]);
1853 return rs
.rowsAffected
!= 0;
1856 if (has_local_storage()) {
1857 for (var i
= 0; i
< localStorage
.length
; i
++) {
1858 var key
= localStorage
.key(i
);
1860 if (key
== id
|| key
.indexOf(id
+ ":") == 0)
1861 localStorage
.removeItem(key
);
1867 while (i
< article_cache
.length
) {
1868 if (article_cache
[i
]["id"] == id
) {
1869 console
.log("cache_invalidate: removed id " + id
);
1870 article_cache
.splice(i
, 1);
1878 console
.log("cache_invalidate: id not found: " + id
);
1881 exception_error("cache_invalidate", e
);
1885 function getActiveArticleId() {
1886 return active_post_id
;
1889 function cdmClicked(id
) {
1891 var elem
= $("RROW-" + id
);
1894 var id
= elem
.id
.replace("RROW-", "");
1895 active_post_id
= id
;
1897 // cdmSelectArticles("none");
1898 toggleUnread(id
, 0, true);
1899 // toggleSelected(id);
1903 exception_error("cdmClicked", e
);
1907 function preloadArticleUnderPointer(id
) {
1909 if (getInitParam("bw_limit") == "1") return;
1911 if (post_under_pointer
== id
&& !cache_check(id
)) {
1913 console
.log("trying to preload article " + id
);
1915 var neighbor_ids
= getRelativePostIds(id
, 1);
1917 /* only request uncached articles */
1919 var cids_to_request
= Array();
1921 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1922 if (!cache_check(neighbor_ids
[i
])) {
1923 cids_to_request
.push(neighbor_ids
[i
]);
1926 console
.log("additional ids: " + cids_to_request
.toString());
1928 cids_to_request
.push(id
);
1930 var query
= "?op=rpc&subop=getArticles&ids=" +
1931 cids_to_request
.toString();
1933 new Ajax
.Request("backend.php", {
1935 onComplete: function(transport
) {
1936 var articles
= transport
.responseXML
.getElementsByTagName("article");
1938 for (var i
= 0; i
< articles
.length
; i
++) {
1939 var id
= articles
[i
].getAttribute("id");
1940 if (!cache_check(id
)) {
1941 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1942 console
.log("preloaded article: " + id
);
1948 exception_error("preloadArticleUnderPointer", e
);
1952 function postMouseIn(id
) {
1954 if (post_under_pointer
!= id
) {
1955 post_under_pointer
= id
;
1957 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1962 exception_error("postMouseIn", e
);
1966 function postMouseOut(id
) {
1968 post_under_pointer
= false;
1970 exception_error("postMouseOut", e
);
1974 function headlines_scroll_handler() {
1977 var e
= $("headlinesInnerContainer");
1979 var toolbar_form
= document
.forms
["main_toolbar_form"];
1981 console
.log((e
.scrollTop
+ e
.offsetHeight
) + " vs " + e
.scrollHeight
+ " dis? " +
1982 _infscroll_disable
);
1984 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1985 if (!_infscroll_disable
) {
1986 console
.log("more cowbell!");
1992 exception_error("headlines_scroll_handler", e
);
1996 function catchupRelativeToArticle(below
) {
2001 if (!getActiveArticleId()) {
2002 alert(__("No article is selected."));
2008 if ($("headlinesList")) {
2009 visible_ids
= getVisibleHeadlineIds();
2011 visible_ids
= cdmGetVisibleArticles();
2014 var ids_to_mark
= new Array();
2017 for (var i
= 0; i
< visible_ids
.length
; i
++) {
2018 if (visible_ids
[i
] != getActiveArticleId()) {
2019 var e
= $("RROW-" + visible_ids
[i
]);
2021 if (e
&& e
.className
.match("Unread")) {
2022 ids_to_mark
.push(visible_ids
[i
]);
2029 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
2030 if (visible_ids
[i
] != getActiveArticleId()) {
2031 var e
= $("RROW-" + visible_ids
[i
]);
2033 if (e
&& e
.className
.match("Unread")) {
2034 ids_to_mark
.push(visible_ids
[i
]);
2042 if (ids_to_mark
.length
== 0) {
2043 alert(__("No articles found to mark"));
2045 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
2047 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
2049 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
2050 var e
= $("RROW-" + ids_to_mark
[i
]);
2051 e
.className
= e
.className
.replace("Unread", "");
2054 var query
= "?op=rpc&subop=catchupSelected" +
2055 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
2057 new Ajax
.Request("backend.php", {
2059 onComplete: function(transport
) {
2060 catchup_callback2(transport
);
2067 exception_error("catchupRelativeToArticle", e
);
2071 function cdmExpandArticle(a_id
) {
2073 var id
= 'CICD-' + a_id
;
2076 Element
.hide("CEXC-" + a_id
);
2079 Effect
.Appear(id
, {duration
: 0.5,
2080 beforeStart: function(effect
) {
2081 var h_id
= 'CICH-' + a_id
;
2082 var h_elem
= $(h_id
);
2083 if (h_elem
) { h_elem
.style
.display
= "none"; }
2085 toggleUnread(a_id
, 0);
2090 exception_error("cdmExpandArticle", e
);
2095 function fixHeadlinesOrder(ids
) {
2097 for (var i
= 0; i
< ids
.length
; i
++) {
2098 var e
= $("RROW-" + ids
[i
]);
2102 e
.className
= e
.className
.replace("even", "odd");
2104 e
.className
= e
.className
.replace("odd", "even");
2109 exception_error("fixHeadlinesOrder", e
);
2113 function hideReadHeadlines() {
2117 var vis_ids
= new Array();
2119 if ($("headlinesList")) {
2120 ids
= getVisibleHeadlineIds();
2122 ids
= cdmGetVisibleArticles();
2125 var read_headlines_visible
= true;
2127 for (var i
= 0; i
< ids
.length
; i
++) {
2128 var row
= $("RROW-" + ids
[i
]);
2130 if (row
&& row
.className
) {
2131 if (read_headlines_visible
) {
2132 if (row
.className
.match("Unread") || row
.className
.match("Selected")) {
2134 vis_ids
.push(ids
[i
]);
2136 //Effect.Fade(row, {duration : 0.3});
2141 vis_ids
.push(ids
[i
]);
2146 fixHeadlinesOrder(vis_ids
);
2148 read_headlines_visible
= !read_headlines_visible
;
2151 exception_error("hideReadHeadlines", e
);
2155 function invertHeadlineSelection() {
2157 var rows
= new Array();
2161 r
= document
.getElementsByTagName("TR");
2163 r
= document
.getElementsByTagName("DIV");
2166 for (var i
= 0; i
< r
.length
; i
++) {
2167 if (r
[i
].id
&& r
[i
].id
.match("RROW-")) {
2172 for (var i
= 0; i
< rows
.length
; i
++) {
2173 var nc
= rows
[i
].className
;
2174 var id
= rows
[i
].id
.replace("RROW-", "");
2175 var cb
= $("RCHK-" + id
);
2177 if (!rows
[i
].className
.match("Selected")) {
2178 nc
= nc
+ "Selected";
2181 nc
= nc
.replace("Selected", "");
2185 rows
[i
].className
= nc
;
2190 exception_error("invertHeadlineSelection", e
);
2194 function getArticleUnderPointer() {
2195 return post_under_pointer
;
2198 function zoomToArticle(id
) {
2200 var w
= window
.open("backend.php?op=view&mode=zoom&id=" + param_escape(id
),
2202 "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0");
2205 exception_error("zoomToArticle", e
);
2209 function scrollArticle(offset
) {
2212 var ci
= $("content-insert");
2214 ci
.scrollTop
+= offset
;
2217 var hi
= $("headlinesInnerContainer");
2219 hi
.scrollTop
+= offset
;
2224 exception_error("scrollArticle", e
);
2228 function show_labels_in_headlines(transport
) {
2230 if (transport
.responseXML
) {
2231 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
2233 var elems
= info
.getElementsByTagName("entry");
2235 for (var l
= 0; l
< elems
.length
; l
++) {
2236 var e_id
= elems
[l
].getAttribute("id");
2240 var ctr
= $("HLLCTR-" + e_id
);
2243 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
2251 exception_error("show_labels_in_headlines", e
);
2256 function toggleHeadlineActions() {
2258 var e
= $("headlineActionsBody");
2259 var p
= $("headlineActionsDrop");
2261 if (!Element
.visible(e
)) {
2268 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
2269 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
2272 exception_error("toggleHeadlineActions", e
);
2276 function publishWithNote(id
, def_note
) {
2278 if (!def_note
) def_note
= '';
2280 var note
= prompt(__("Please enter a note for this article:"), def_note
);
2282 if (note
!= undefined) {
2283 togglePub(id
, false, false, note
);
2287 exception_error("publishWithNote", e
);
2291 function emailArticle(id
) {
2294 var ids
= getSelectedArticleIds2();
2296 if (ids
.length
== 0) {
2297 alert(__("No articles are selected."));
2301 id
= ids
.toString();
2304 displayDlg('emailArticle', id
,
2306 document
.forms
['article_email_form'].destination
.focus();
2308 new Ajax
.Autocompleter('destination', 'destination_choices',
2309 "backend.php?op=rpc&subop=completeEmails",
2310 { tokens
: '', paramName
: "search" });
2315 exception_error("emailArticle", e
);
2319 function emailArticleDo() {
2321 var f
= document
.forms
['article_email_form'];
2323 if (f
.destination
.value
== "") {
2324 alert("Please fill in the destination email.");
2328 if (f
.subject
.value
== "") {
2329 alert("Please fill in the subject.");
2333 var query
= Form
.serialize("article_email_form");
2335 // console.log(query);
2337 new Ajax
.Request("backend.php", {
2339 onComplete: function(transport
) {
2342 var error
= transport
.responseXML
.getElementsByTagName('error')[0];
2345 alert(__('Error sending email:') + ' ' + error
.firstChild
.nodeValue
);
2347 notify_info('Your message has been sent.');
2352 exception_error("sendEmailDo", e
);
2358 exception_error("emailArticleDo", e
);