1 var article_cache
= new Array();
3 var _active_article_id
= 0;
5 var vgroup_last_feed
= false;
6 var post_under_pointer
= false;
8 var last_requested_article
= false;
10 var catchup_id_batch
= [];
11 var catchup_timeout_id
= false;
13 var cids_requested
= [];
14 var loaded_article_ids
= [];
15 var _last_headlines_update
= 0;
17 var has_storage
= 'sessionStorage' in window
&& window
['sessionStorage'] !== null;
19 function headlines_callback2(transport
, offset
, background
, infscroll_req
) {
21 handle_rpc_json(transport
);
23 console
.log("headlines_callback2 [offset=" + offset
+ "] B:" + background
+ " I:" + infscroll_req
);
31 reply
= JSON
.parse(transport
.responseText
);
38 is_cat
= reply
['headlines']['is_cat'];
39 feed_id
= reply
['headlines']['id'];
42 var content
= reply
['headlines']['content'];
44 content
= content
+ "<div id='headlines-spacer'></div>";
48 if (feed_id
!= getActiveFeedId() || is_cat
!= activeFeedIsCat())
51 /* dijit.getEnclosingWidget(
52 document.forms["main_toolbar_form"].update).attr('disabled',
53 is_cat || feed_id <= 0); */
56 if (infscroll_req
== false) {
57 $("headlines-frame").scrollTop
= 0;
61 $("headlines-frame").removeClassName("cdm");
62 $("headlines-frame").removeClassName("normal");
64 $("headlines-frame").addClassName(isCdmMode() ? "cdm" : "normal");
66 var headlines_count
= reply
['headlines-info']['count'];
68 vgroup_last_feed
= reply
['headlines-info']['vgroup_last_feed'];
70 if (parseInt(headlines_count
) < 30) {
71 _infscroll_disable
= 1;
73 _infscroll_disable
= 0;
76 var counters
= reply
['counters'];
77 var articles
= reply
['articles'];
78 //var runtime_info = reply['runtime-info'];
80 if (infscroll_req
== false) {
81 loaded_article_ids
= [];
83 dijit
.byId("headlines-frame").attr('content',
84 reply
['headlines']['content']);
86 dijit
.byId("headlines-toolbar").attr('content',
87 reply
['headlines']['toolbar']);
89 $$("#headlines-frame > div[id*=RROW]").each(function(row
) {
90 if (loaded_article_ids
.indexOf(row
.id
) != -1) {
91 row
.parentNode
.removeChild(row
);
93 loaded_article_ids
.push(row
.id
);
97 var hsp
= $("headlines-spacer");
98 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
99 dijit
.byId('headlines-frame').domNode
.appendChild(hsp
);
104 $("feed_title").innerHTML
+= "<span id='cancel_search'>" +
105 " (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" +
111 if (headlines_count
> 0 && feed_id
== getActiveFeedId() && is_cat
== activeFeedIsCat()) {
112 console
.log("adding some more headlines: " + headlines_count
);
114 var c
= dijit
.byId("headlines-frame");
115 var ids
= getSelectedArticleIds2();
118 $("headlines-tmp").innerHTML
= reply
['headlines']['content'];
120 var hsp
= $("headlines-spacer");
123 c
.domNode
.removeChild(hsp
);
125 $$("#headlines-tmp > div").each(function(row
) {
126 if (row
.className
== 'cdmFeedTitle') {
127 row
.style
.display
= 'none';
128 c
.domNode
.appendChild(row
);
130 } else if (loaded_article_ids
.indexOf(row
.id
) == -1) {
131 row
.style
.display
= 'none';
132 c
.domNode
.appendChild(row
);
134 loaded_article_ids
.push(row
.id
);
136 row
.parentNode
.removeChild(row
);
140 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
142 if (getInitParam("cdm_auto_catchup") == 1) {
143 c
.domNode
.appendChild(hsp
);
146 console
.log("added " + new_elems
.size() + " headlines");
148 if (new_elems
.size() == 0)
149 _infscroll_disable
= true;
151 console
.log("restore selected ids: " + ids
);
153 for (var i
= 0; i
< ids
.length
; i
++) {
154 markHeadline(ids
[i
]);
159 new_elems
.each(function(child
) {
160 dojo
.parser
.parse(child
);
162 if (!Element
.visible(child
))
163 new Effect
.Appear(child
, { duration
: 0.5 });
167 console
.log("no new headlines received");
169 var hsp
= $("headlines-spacer");
171 if (hsp
) hsp
.innerHTML
= "";
176 for (var i
= 0; i
< articles
.length
; i
++) {
177 var a_id
= articles
[i
]['id'];
178 cache_set("article:" + a_id
, articles
[i
]['content']);
181 console
.log("no cached articles received");
185 parse_counters(counters
);
187 request_counters(true);
189 } else if (transport
.responseText
) {
190 console
.error("Invalid object received: " + transport
.responseText
);
191 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
192 __('Could not update headlines (invalid object received - see error console for details)') +
195 //notify_error("Error communicating with server.");
196 Element
.show(dijit
.byId("net-alert").domNode
);
199 _infscroll_request_sent
= 0;
200 _last_headlines_update
= new Date().getTime();
202 unpackVisibleHeadlines();
204 // if we have some more space in the buffer, why not try to fill it
206 if (!_infscroll_disable
&& $("headlines-spacer") &&
207 $("headlines-spacer").offsetTop
< $("headlines-frame").offsetHeight
) {
209 window
.setTimeout(function() {
217 exception_error("headlines_callback2", e
, transport
);
221 function render_article(article
) {
223 dijit
.byId("headlines-wrap-inner").addChild(
224 dijit
.byId("content-insert"));
226 var c
= dijit
.byId("content-insert");
229 c
.domNode
.scrollTop
= 0;
232 PluginHost
.run(PluginHost
.HOOK_ARTICLE_RENDERED
, article
);
234 c
.attr('content', article
);
236 correctHeadlinesOffset(getActiveArticleId());
243 exception_error("render_article", e
);
247 function showArticleInHeadlines(id
, noexpand
) {
250 selectArticles("none");
252 var crow
= $("RROW-" + id
);
256 var article_is_unread
= crow
.hasClassName("Unread");
259 crow
.removeClassName("Unread");
260 crow
.addClassName("active");
262 selectArticles('none');
264 var view_mode
= false;
267 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
268 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
275 if (article_is_unread
&& !noexpand
)
276 _force_scheduled_update
= true;
279 exception_error("showArticleInHeadlines", e
);
283 function article_callback2(transport
, id
) {
285 console
.log("article_callback2 " + id
);
287 handle_rpc_json(transport
);
292 reply
= JSON
.parse(transport
.responseText
);
299 reply
.each(function(article
) {
300 if (getActiveArticleId() == article
['id']) {
301 render_article(article
['content']);
303 cids_requested
.remove(article
['id']);
305 cache_set("article:" + article
['id'], article
['content']);
308 // if (id != last_requested_article) {
309 // console.log("requested article id is out of sequence, aborting");
313 } else if (transport
.responseText
) {
314 console
.error("Invalid object received: " + transport
.responseText
);
316 render_article("<div class='whiteBox'>" +
317 __('Could not display article (invalid object received - see error console for details)') + "</div>");
319 Element
.show(dijit
.byId("net-alert").domNode
);
322 var unread_in_buffer
= $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
323 request_counters(unread_in_buffer
== 0);
325 //headlines_scroll_handler($("headlines-frame"));
328 if (!_infscroll_disable &&
329 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
339 exception_error("article_callback2", e
, transport
);
343 function view(id
, activefeed
, noexpand
) {
345 var oldrow
= $("RROW-" + getActiveArticleId());
346 if (oldrow
) oldrow
.removeClassName("active");
348 var crow
= $("RROW-" + id
);
352 setActiveArticleId(id
);
353 showArticleInHeadlines(id
, noexpand
);
357 console
.log("loading article: " + id
);
359 var cached_article
= cache_get("article:" + id
);
361 console
.log("cache check result: " + (cached_article
!= false));
363 var query
= "?op=article&method=view&id=" + param_escape(id
);
365 var neighbor_ids
= getRelativePostIds(id
);
367 /* only request uncached articles */
369 var cids_to_request
= [];
371 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
372 if (cids_requested
.indexOf(neighbor_ids
[i
]) == -1)
373 if (!cache_get("article:" + neighbor_ids
[i
])) {
374 cids_to_request
.push(neighbor_ids
[i
]);
375 cids_requested
.push(neighbor_ids
[i
]);
379 console
.log("additional ids: " + cids_to_request
.toString());
381 query
= query
+ "&cids=" + cids_to_request
.toString();
383 var article_is_unread
= crow
.hasClassName("Unread");
385 setActiveArticleId(id
);
386 showArticleInHeadlines(id
);
388 if (cached_article
&& article_is_unread
) {
390 query
= query
+ "&mode=prefetch";
392 render_article(cached_article
);
394 } else if (cached_article
) {
396 query
= query
+ "&mode=prefetch_old";
397 render_article(cached_article
);
399 // if we don't need to request any relative ids, we might as well skip
400 // the server roundtrip altogether
401 if (cids_to_request
.length
== 0) {
404 if (!_infscroll_disable &&
405 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
413 //headlines_scroll_handler($("headlines-frame"));
419 last_requested_article
= id
;
423 if (article_is_unread
) {
424 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
427 new Ajax
.Request("backend.php", {
429 onComplete: function(transport
) {
430 article_callback2(transport
, id
);
436 exception_error("view", e
);
440 function toggleMark(id
, client_only
) {
442 var query
= "?op=rpc&id=" + id
+ "&method=mark";
444 var row
= $("RROW-" + id
);
449 var row_imgs
= row
.getElementsByClassName("markedPic");
451 for (var i
= 0; i
< row_imgs
.length
; i
++)
452 imgs
.push(row_imgs
[i
]);
454 var ft
= $("floatingTitle");
456 if (ft
&& ft
.getAttribute("rowid") == "RROW-" + id
) {
457 var fte
= ft
.getElementsByClassName("markedPic");
459 for (var i
= 0; i
< fte
.length
; i
++)
463 for (i
= 0; i
< imgs
.length
; i
++) {
466 if (!row
.hasClassName("marked")) {
467 img
.src
= img
.src
.replace("mark_unset", "mark_set");
468 img
.alt
= __("Unstar article");
469 query
= query
+ "&mark=1";
471 img
.src
= img
.src
.replace("mark_set", "mark_unset");
472 img
.alt
= __("Star article");
473 query
= query
+ "&mark=0";
477 row
.toggleClassName("marked");
480 new Ajax
.Request("backend.php", {
482 onComplete: function(transport
) {
483 handle_rpc_json(transport
);
488 exception_error("toggleMark", e
);
492 function togglePub(id
, client_only
, no_effects
, note
) {
494 var query
= "?op=rpc&id=" + id
+ "&method=publ";
496 if (note
!= undefined) {
497 query
= query
+ "¬e=" + param_escape(note
);
499 query
= query
+ "¬e=undefined";
502 var row
= $("RROW-" + id
);
507 var row_imgs
= row
.getElementsByClassName("pubPic");
509 for (var i
= 0; i
< row_imgs
.length
; i
++)
510 imgs
.push(row_imgs
[i
]);
512 var ft
= $("floatingTitle");
514 if (ft
&& ft
.getAttribute("rowid") == "RROW-" + id
) {
515 var fte
= ft
.getElementsByClassName("pubPic");
517 for (var i
= 0; i
< fte
.length
; i
++)
521 for (i
= 0; i
< imgs
.length
; i
++) {
524 if (!row
.hasClassName("published") || note
!= undefined) {
525 img
.src
= img
.src
.replace("pub_unset", "pub_set");
526 img
.alt
= __("Unpublish article");
527 query
= query
+ "&pub=1";
529 img
.src
= img
.src
.replace("pub_set", "pub_unset");
530 img
.alt
= __("Publish article");
531 query
= query
+ "&pub=0";
535 if (note
!= undefined)
536 row
.addClassName("published");
538 row
.toggleClassName("published");
541 new Ajax
.Request("backend.php", {
543 onComplete: function(transport
) {
544 handle_rpc_json(transport
);
549 exception_error("togglePub", e
);
553 function moveToPost(mode
, noscroll
, noexpand
) {
557 var rows
= getVisibleArticleIds();
562 if (!$('RROW-' + getActiveArticleId())) {
563 setActiveArticleId(0);
566 if (!getActiveArticleId()) {
568 prev_id
= rows
[rows
.length
-1]
570 for (var i
= 0; i
< rows
.length
; i
++) {
571 if (rows
[i
] == getActiveArticleId()) {
573 // Account for adjacent identical article ids.
574 if (i
> 0) prev_id
= rows
[i
-1];
576 for (var j
= i
+1; j
< rows
.length
; j
++) {
577 if (rows
[j
] != getActiveArticleId()) {
587 if (mode
== "next") {
588 if (next_id
|| getActiveArticleId()) {
591 var article
= $("RROW-" + getActiveArticleId());
592 var ctr
= $("headlines-frame");
594 if (!noscroll
&& article
&& article
.offsetTop
+ article
.offsetHeight
>
595 ctr
.scrollTop
+ ctr
.offsetHeight
) {
597 scrollArticle(ctr
.offsetHeight
/4);
599 } else if (next_id
) {
600 cdmExpandArticle(next_id
, noexpand
);
601 cdmScrollToArticleId(next_id
, true);
604 } else if (next_id
) {
605 correctHeadlinesOffset(next_id
);
606 view(next_id
, getActiveFeedId(), noexpand
);
611 if (mode
== "prev") {
612 if (prev_id
|| getActiveArticleId()) {
615 var article
= $("RROW-" + getActiveArticleId());
616 var prev_article
= $("RROW-" + prev_id
);
617 var ctr
= $("headlines-frame");
619 if (!getInitParam("cdm_expanded")) {
621 if (!noscroll
&& article
&& article
.offsetTop
< ctr
.scrollTop
) {
622 scrollArticle(-ctr
.offsetHeight
/4);
624 cdmExpandArticle(prev_id
, noexpand
);
625 cdmScrollToArticleId(prev_id
, true);
629 if (!noscroll
&& article
&& article
.offsetTop
< ctr
.scrollTop
) {
630 scrollArticle(-ctr
.offsetHeight
/3);
631 } else if (!noscroll
&& prev_article
&&
632 prev_article
.offsetTop
< ctr
.scrollTop
) {
633 cdmExpandArticle(prev_id
, noexpand
);
634 scrollArticle(-ctr
.offsetHeight
/4);
635 } else if (prev_id
) {
636 cdmExpandArticle(prev_id
, noexpand
);
637 cdmScrollToArticleId(prev_id
, noscroll
);
641 } else if (prev_id
) {
642 correctHeadlinesOffset(prev_id
);
643 view(prev_id
, getActiveFeedId(), noexpand
);
649 exception_error("moveToPost", e
);
653 function toggleSelected(id
, force_on
) {
655 var row
= $("RROW-" + id
);
658 var cb
= dijit
.getEnclosingWidget(
659 row
.getElementsByClassName("rchk")[0]);
661 if (row
.hasClassName('Selected') && !force_on
) {
662 row
.removeClassName('Selected');
663 if (cb
) cb
.attr("checked", false);
665 row
.addClassName('Selected');
666 if (cb
) cb
.attr("checked", true);
670 updateSelectedPrompt();
672 exception_error("toggleSelected", e
);
676 function updateSelectedPrompt() {
678 var count
= getSelectedArticleIds2().size();
679 var elem
= $("selected_prompt");
682 elem
.innerHTML
= ngettext("%d article selected",
683 "%d articles selected", count
).replace("%d", count
);
692 exception_error("updateSelectedPrompt", e
);
696 function toggleUnread_afh(effect
) {
699 var elem
= effect
.element
;
700 elem
.style
.backgroundColor
= "";
703 exception_error("toggleUnread_afh", e
);
707 function toggleUnread(id
, cmode
, effect
) {
710 var row
= $("RROW-" + id
);
712 if (cmode
== undefined || cmode
== 2) {
713 if (row
.hasClassName("Unread")) {
714 row
.removeClassName("Unread");
717 row
.addClassName("Unread");
720 } else if (cmode
== 0) {
722 row
.removeClassName("Unread");
724 } else if (cmode
== 1) {
725 row
.addClassName("Unread");
728 if (cmode
== undefined) cmode
= 2;
730 var query
= "?op=rpc&method=catchupSelected" +
731 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
733 // notify_progress("Loading, please wait...");
735 new Ajax
.Request("backend.php", {
737 onComplete: function(transport
) {
738 handle_rpc_json(transport
);
744 exception_error("toggleUnread", e
);
748 function selectionRemoveLabel(id
, ids
) {
751 if (!ids
) ids
= getSelectedArticleIds2();
753 if (ids
.length
== 0) {
754 alert(__("No articles are selected."));
758 var query
= "?op=article&method=removeFromLabel&ids=" +
759 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
763 new Ajax
.Request("backend.php", {
765 onComplete: function(transport
) {
766 handle_rpc_json(transport
);
767 show_labels_in_headlines(transport
);
771 exception_error("selectionAssignLabel", e
);
776 function selectionAssignLabel(id
, ids
) {
779 if (!ids
) ids
= getSelectedArticleIds2();
781 if (ids
.length
== 0) {
782 alert(__("No articles are selected."));
786 var query
= "?op=article&method=assignToLabel&ids=" +
787 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
791 new Ajax
.Request("backend.php", {
793 onComplete: function(transport
) {
794 handle_rpc_json(transport
);
795 show_labels_in_headlines(transport
);
799 exception_error("selectionAssignLabel", e
);
804 function selectionToggleUnread(set_state
, callback
, no_error
, ids
) {
806 var rows
= ids
? ids
: getSelectedArticleIds2();
808 if (rows
.length
== 0 && !no_error
) {
809 alert(__("No articles are selected."));
813 for (var i
= 0; i
< rows
.length
; i
++) {
814 var row
= $("RROW-" + rows
[i
]);
816 if (set_state
== undefined) {
817 if (row
.hasClassName("Unread")) {
818 row
.removeClassName("Unread");
820 row
.addClassName("Unread");
824 if (set_state
== false) {
825 row
.removeClassName("Unread");
828 if (set_state
== true) {
829 row
.addClassName("Unread");
834 if (rows
.length
> 0) {
838 if (set_state
== undefined) {
840 } else if (set_state
== true) {
842 } else if (set_state
== false) {
846 var query
= "?op=rpc&method=catchupSelected" +
847 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
849 notify_progress("Loading, please wait...");
851 new Ajax
.Request("backend.php", {
853 onComplete: function(transport
) {
854 handle_rpc_json(transport
);
855 if (callback
) callback(transport
);
861 exception_error("selectionToggleUnread", e
);
866 function selectionToggleMarked(sel_state
, callback
, no_error
, ids
) {
869 var rows
= ids
? ids
: getSelectedArticleIds2();
871 if (rows
.length
== 0 && !no_error
) {
872 alert(__("No articles are selected."));
876 for (var i
= 0; i
< rows
.length
; i
++) {
877 toggleMark(rows
[i
], true, true);
880 if (rows
.length
> 0) {
882 var query
= "?op=rpc&method=markSelected&ids=" +
883 param_escape(rows
.toString()) + "&cmode=2";
885 new Ajax
.Request("backend.php", {
887 onComplete: function(transport
) {
888 handle_rpc_json(transport
);
889 if (callback
) callback(transport
);
895 exception_error("selectionToggleMarked", e
);
900 function selectionTogglePublished(sel_state
, callback
, no_error
, ids
) {
903 var rows
= ids
? ids
: getSelectedArticleIds2();
905 if (rows
.length
== 0 && !no_error
) {
906 alert(__("No articles are selected."));
910 for (var i
= 0; i
< rows
.length
; i
++) {
911 togglePub(rows
[i
], true, true);
914 if (rows
.length
> 0) {
916 var query
= "?op=rpc&method=publishSelected&ids=" +
917 param_escape(rows
.toString()) + "&cmode=2";
919 new Ajax
.Request("backend.php", {
921 onComplete: function(transport
) {
922 handle_rpc_json(transport
);
928 exception_error("selectionToggleMarked", e
);
932 function getSelectedArticleIds2() {
936 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
938 rv
.push(child
.id
.replace("RROW-", ""));
944 function getLoadedArticleIds() {
947 var children
= $$("#headlines-frame > div[id*=RROW-]");
949 children
.each(function(child
) {
950 rv
.push(child
.id
.replace("RROW-", ""));
957 // mode = all,none,unread,invert,marked,published
958 function selectArticles(mode
) {
961 var children
= $$("#headlines-frame > div[id*=RROW]");
963 children
.each(function(child
) {
964 var id
= child
.id
.replace("RROW-", "");
966 var cb
= dijit
.getEnclosingWidget(
967 child
.getElementsByClassName("rchk")[0]);
970 child
.addClassName("Selected");
971 if (cb
) cb
.attr("checked", true);
972 } else if (mode
== "unread") {
973 if (child
.hasClassName("Unread")) {
974 child
.addClassName("Selected");
975 if (cb
) cb
.attr("checked", true);
977 child
.removeClassName("Selected");
978 if (cb
) cb
.attr("checked", false);
980 } else if (mode
== "marked") {
981 if (child
.hasClassName("marked")) {
982 child
.addClassName("Selected");
983 if (cb
) cb
.attr("checked", true);
985 child
.removeClassName("Selected");
986 if (cb
) cb
.attr("checked", false);
988 } else if (mode
== "published") {
989 if (child
.hasClassName("published")) {
990 child
.addClassName("Selected");
991 if (cb
) cb
.attr("checked", true);
993 child
.removeClassName("Selected");
994 if (cb
) cb
.attr("checked", false);
997 } else if (mode
== "invert") {
998 if (child
.hasClassName("Selected")) {
999 child
.removeClassName("Selected");
1000 if (cb
) cb
.attr("checked", false);
1002 child
.addClassName("Selected");
1003 if (cb
) cb
.attr("checked", true);
1007 child
.removeClassName("Selected");
1008 if (cb
) cb
.attr("checked", false);
1012 updateSelectedPrompt();
1015 exception_error("selectArticles", e
);
1019 function deleteSelection() {
1023 var rows
= getSelectedArticleIds2();
1025 if (rows
.length
== 0) {
1026 alert(__("No articles are selected."));
1030 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1033 if (getActiveFeedId() != 0) {
1034 str
= ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?" , rows
.length
);
1036 str
= ngettext("Delete %d selected article?", "Delete %d selected articles?", rows
.length
);
1039 str
= str
.replace("%d", rows
.length
);
1040 str
= str
.replace("%s", fn
);
1042 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1046 query
= "?op=rpc&method=delete&ids=" + param_escape(rows
);
1050 new Ajax
.Request("backend.php", {
1052 onComplete: function(transport
) {
1053 handle_rpc_json(transport
);
1058 exception_error("deleteSelection", e
);
1062 function archiveSelection() {
1066 var rows
= getSelectedArticleIds2();
1068 if (rows
.length
== 0) {
1069 alert(__("No articles are selected."));
1073 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1077 if (getActiveFeedId() != 0) {
1078 str
= ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows
.length
);
1081 str
= ngettext("Move %d archived article back?", "Move %d archived articles back?", rows
.length
);
1083 str
+= " " + __("Please note that unstarred articles might get purged on next feed update.");
1088 str
= str
.replace("%d", rows
.length
);
1089 str
= str
.replace("%s", fn
);
1091 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1095 query
= "?op=rpc&method="+op
+"&ids=" + param_escape(rows
);
1099 for (var i
= 0; i
< rows
.length
; i
++) {
1100 cache_delete("article:" + rows
[i
]);
1103 new Ajax
.Request("backend.php", {
1105 onComplete: function(transport
) {
1106 handle_rpc_json(transport
);
1111 exception_error("archiveSelection", e
);
1115 function catchupSelection() {
1119 var rows
= getSelectedArticleIds2();
1121 if (rows
.length
== 0) {
1122 alert(__("No articles are selected."));
1126 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1128 var str
= ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows
.length
);
1130 str
= str
.replace("%d", rows
.length
);
1131 str
= str
.replace("%s", fn
);
1133 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1137 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1140 exception_error("catchupSelection", e
);
1144 function editArticleTags(id
) {
1145 var query
= "backend.php?op=article&method=editArticleTags¶m=" + param_escape(id
);
1147 if (dijit
.byId("editTagsDlg"))
1148 dijit
.byId("editTagsDlg").destroyRecursive();
1150 dialog
= new dijit
.Dialog({
1152 title
: __("Edit article Tags"),
1153 style
: "width: 600px",
1154 execute: function() {
1155 if (this.validate()) {
1156 var query
= dojo
.objectToQuery(this.attr('value'));
1158 notify_progress("Saving article tags...", true);
1160 new Ajax
.Request("backend.php", {
1162 onComplete: function(transport
) {
1167 var data
= JSON
.parse(transport
.responseText
);
1174 var tags
= $("ATSTR-" + id
);
1175 var tooltip
= dijit
.byId("ATSTRTIP-" + id
);
1177 if (tags
) tags
.innerHTML
= data
.content
;
1178 if (tooltip
) tooltip
.attr('label', data
.content_full
);
1181 exception_error("editArticleTags/inner", e
);
1190 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1191 dojo
.disconnect(tmph
);
1193 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1194 "backend.php?op=article&method=completeTags",
1195 { tokens
: ',', paramName
: "search" });
1202 function cdmScrollToArticleId(id
, force
) {
1204 var ctr
= $("headlines-frame");
1205 var e
= $("RROW-" + id
);
1207 if (!e
|| !ctr
) return;
1209 if (force
|| e
.offsetTop
+e
.offsetHeight
> (ctr
.scrollTop
+ctr
.offsetHeight
) ||
1210 e
.offsetTop
< ctr
.scrollTop
) {
1212 // expanded cdm has a 4px margin now
1213 ctr
.scrollTop
= parseInt(e
.offsetTop
) - 4;
1217 exception_error("cdmScrollToArticleId", e
);
1221 function setActiveArticleId(id
) {
1222 _active_article_id
= id
;
1223 PluginHost
.run(PluginHost
.HOOK_ARTICLE_SET_ACTIVE
, _active_article_id
);
1226 function getActiveArticleId() {
1227 return _active_article_id
;
1230 function postMouseIn(e
, id
) {
1231 post_under_pointer
= id
;
1234 function postMouseOut(id
) {
1235 post_under_pointer
= false;
1238 function unpackVisibleHeadlines() {
1240 if (!isCdmMode()) return;
1242 $$("#headlines-frame > div[id*=RROW]").each(
1244 if (child
.offsetTop
<= $("headlines-frame").scrollTop
+
1245 $("headlines-frame").offsetHeight
) {
1247 var cencw
= $("CENCW-" + child
.id
.replace("RROW-", ""));
1250 PluginHost
.run(PluginHost
.HOOK_ARTICLE_RENDERED_CDM
, child
);
1252 cencw
.innerHTML
= htmlspecialchars_decode(cencw
.innerHTML
);
1253 cencw
.setAttribute('id', '');
1254 Element
.show(cencw
);
1261 exception_error("unpackVisibleHeadlines", e
);
1265 function headlines_scroll_handler(e
) {
1267 var hsp
= $("headlines-spacer");
1269 unpackVisibleHeadlines();
1271 // set topmost child in the buffer as active
1272 if (getInitParam("cdm_auto_catchup") == 1) {
1273 var rows
= $$("#headlines-frame > div[id*=RROW]");
1275 for (var i
= 0; i
< rows
.length
; i
++) {
1276 var child
= rows
[i
];
1278 if ($("headlines-frame").scrollTop
< child
.offsetTop
&&
1279 child
.offsetTop
- $("headlines-frame").scrollTop
< 100) {
1281 if (_active_article_id
) {
1282 var row
= $("RROW-" + _active_article_id
);
1283 if (row
) row
.removeClassName("active");
1286 _active_article_id
= child
.id
.replace("RROW-", "");
1287 showArticleInHeadlines(_active_article_id
, true);
1288 updateSelectedPrompt();
1294 if (!_infscroll_disable
) {
1295 if ((hsp
&& e
.scrollTop
+ e
.offsetHeight
>= hsp
.offsetTop
- hsp
.offsetHeight
) ||
1296 (e
.scrollHeight
!= 0 &&
1297 ((e
.scrollTop
+ e
.offsetHeight
) / e
.scrollHeight
>= 0.7))) {
1300 hsp
.innerHTML
= "<img src='images/indicator_tiny.gif'> " +
1301 __("Loading, please wait...");
1303 loadMoreHeadlines();
1308 if (hsp
) hsp
.innerHTML
= "";
1311 if (getInitParam("cdm_expanded") && isCdmMode()) {
1312 updateFloatingTitle();
1315 if (getInitParam("cdm_auto_catchup") == 1) {
1317 // let's get DOM some time to settle down
1318 var ts
= new Date().getTime();
1319 if (ts
- _last_headlines_update
< 100) return;
1321 $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
1323 if (child
.hasClassName("Unread") && $("headlines-frame").scrollTop
>
1324 (child
.offsetTop
+ child
.offsetHeight
/2)) {
1326 var id
= child
.id
.replace("RROW-", "");
1328 if (catchup_id_batch
.indexOf(id
) == -1)
1329 catchup_id_batch
.push(id
);
1331 //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
1336 if (catchup_id_batch
.length
> 0) {
1337 window
.clearTimeout(catchup_timeout_id
);
1339 if (!_infscroll_request_sent
) {
1340 catchup_timeout_id
= window
.setTimeout('catchupBatchedArticles()',
1347 console
.warn("headlines_scroll_handler: " + e
);
1351 function catchupBatchedArticles() {
1353 if (catchup_id_batch
.length
> 0 && !_infscroll_request_sent
) {
1355 // make a copy of the array
1356 var batch
= catchup_id_batch
.slice();
1357 var query
= "?op=rpc&method=catchupSelected" +
1358 "&cmode=0&ids=" + param_escape(batch
.toString());
1362 new Ajax
.Request("backend.php", {
1364 onComplete: function(transport
) {
1365 handle_rpc_json(transport
);
1367 reply
= JSON
.parse(transport
.responseText
);
1368 var batch
= reply
.ids
;
1370 batch
.each(function(id
) {
1372 var elem
= $("RROW-" + id
);
1373 if (elem
) elem
.removeClassName("Unread");
1374 catchup_id_batch
.remove(id
);
1381 exception_error("catchupBatchedArticles", e
);
1385 function catchupRelativeToArticle(below
, id
) {
1389 if (!id
) id
= getActiveArticleId();
1392 alert(__("No article is selected."));
1396 var visible_ids
= getVisibleArticleIds();
1398 var ids_to_mark
= new Array();
1401 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1402 if (visible_ids
[i
] != id
) {
1403 var e
= $("RROW-" + visible_ids
[i
]);
1405 if (e
&& e
.hasClassName("Unread")) {
1406 ids_to_mark
.push(visible_ids
[i
]);
1413 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1414 if (visible_ids
[i
] != id
) {
1415 var e
= $("RROW-" + visible_ids
[i
]);
1417 if (e
&& e
.hasClassName("Unread")) {
1418 ids_to_mark
.push(visible_ids
[i
]);
1426 if (ids_to_mark
.length
== 0) {
1427 alert(__("No articles found to mark"));
1429 var msg
= ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark
.length
).replace("%d", ids_to_mark
.length
);
1431 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1433 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1434 var e
= $("RROW-" + ids_to_mark
[i
]);
1435 e
.removeClassName("Unread");
1438 var query
= "?op=rpc&method=catchupSelected" +
1439 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1441 new Ajax
.Request("backend.php", {
1443 onComplete: function(transport
) {
1444 handle_rpc_json(transport
);
1451 exception_error("catchupRelativeToArticle", e
);
1455 function cdmCollapseArticle(event
, id
, unmark
) {
1457 if (unmark
== undefined) unmark
= true;
1459 var row
= $("RROW-" + id
);
1460 var elem
= $("CICD-" + id
);
1463 var collapse
= $$("div#RROW-" + id
+
1464 " span[class='collapseBtn']")[0];
1467 Element
.show("CEXC-" + id
);
1468 Element
.hide(collapse
);
1471 row
.removeClassName("active");
1473 markHeadline(id
, false);
1475 if (id
== getActiveArticleId()) {
1476 setActiveArticleId(0);
1479 updateSelectedPrompt();
1482 if (event
) Event
.stop(event
);
1484 PluginHost
.run(PluginHost
.HOOK_ARTICLE_COLLAPSED
, id
);
1488 exception_error("cdmCollapseArticle", e
);
1492 function cdmExpandArticle(id
, noexpand
) {
1494 console
.log("cdmExpandArticle " + id
);
1496 if (!$("RROW-" + id
)) return false;
1498 var oldrow
= $("RROW-" + getActiveArticleId());
1500 var elem
= $("CICD-" + getActiveArticleId());
1502 if (id
== getActiveArticleId() && Element
.visible(elem
))
1505 selectArticles("none");
1507 var old_offset
= $("RROW-" + id
).offsetTop
;
1509 if (getActiveArticleId() && elem
&& !getInitParam("cdm_expanded")) {
1510 var collapse
= $$("div#RROW-" + getActiveArticleId() +
1511 " span[class='collapseBtn']")[0];
1514 Element
.show("CEXC-" + getActiveArticleId());
1515 Element
.hide(collapse
);
1518 if (oldrow
) oldrow
.removeClassName("active");
1520 setActiveArticleId(id
);
1522 elem
= $("CICD-" + id
);
1524 var collapse
= $$("div#RROW-" + id
+
1525 " span[class='collapseBtn']")[0];
1527 var cencw
= $("CENCW-" + id
);
1529 if (!Element
.visible(elem
) && !noexpand
) {
1531 cencw
.innerHTML
= htmlspecialchars_decode(cencw
.innerHTML
);
1532 cencw
.setAttribute('id', '');
1533 Element
.show(cencw
);
1537 Element
.hide("CEXC-" + id
);
1538 Element
.show(collapse
);
1541 var new_offset
= $("RROW-" + id
).offsetTop
;
1543 if (old_offset
> new_offset
)
1544 $("headlines-frame").scrollTop
-= (old_offset
-new_offset
);
1547 toggleUnread(id
, 0, true);
1549 $("RROW-" + id
).addClassName("active");
1551 PluginHost
.run(PluginHost
.HOOK_ARTICLE_EXPANDED
, id
);
1554 exception_error("cdmExpandArticle", e
);
1560 function getArticleUnderPointer() {
1561 return post_under_pointer
;
1564 function scrollArticle(offset
) {
1567 var ci
= $("content-insert");
1569 ci
.scrollTop
+= offset
;
1572 var hi
= $("headlines-frame");
1574 hi
.scrollTop
+= offset
;
1579 exception_error("scrollArticle", e
);
1583 function show_labels_in_headlines(transport
) {
1585 var data
= JSON
.parse(transport
.responseText
);
1588 data
['info-for-headlines'].each(function(elem
) {
1589 var ctr
= $("HLLCTR-" + elem
.id
);
1591 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1595 exception_error("show_labels_in_headlines", e
);
1599 function dismissArticle(id
) {
1601 var elem
= $("RROW-" + id
);
1605 toggleUnread(id
, 0, true);
1607 new Effect
.Fade(elem
, {duration
: 0.5});
1609 if (id
== getActiveArticleId()) {
1610 setActiveArticleId(0);
1614 exception_error("dismissArticle", e
);
1618 function dismissSelectedArticles() {
1621 var ids
= getVisibleArticleIds();
1625 for (var i
= 0; i
< ids
.length
; i
++) {
1626 var elem
= $("RROW-" + ids
[i
]);
1628 if (elem
.className
&& elem
.hasClassName("Selected") &&
1629 ids
[i
] != getActiveArticleId()) {
1630 new Effect
.Fade(elem
, {duration
: 0.5});
1638 selectionToggleUnread(false);
1642 exception_error("dismissSelectedArticles", e
);
1646 function dismissReadArticles() {
1649 var ids
= getVisibleArticleIds();
1652 for (var i
= 0; i
< ids
.length
; i
++) {
1653 var elem
= $("RROW-" + ids
[i
]);
1655 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1656 !elem
.hasClassName("Selected")) {
1658 new Effect
.Fade(elem
, {duration
: 0.5});
1665 exception_error("dismissSelectedArticles", e
);
1669 function getVisibleArticleIds() {
1674 getLoadedArticleIds().each(function(id
) {
1675 var elem
= $("RROW-" + id
);
1676 if (elem
&& Element
.visible(elem
))
1681 exception_error("getVisibleArticleIds", e
);
1687 function cdmClicked(event
, id
) {
1689 //var shift_key = event.shiftKey;
1691 if (!event
.ctrlKey
) {
1693 if (!getInitParam("cdm_expanded")) {
1694 return cdmExpandArticle(id
);
1697 var elem
= $("RROW-" + getActiveArticleId());
1699 if (elem
) elem
.removeClassName("active");
1701 selectArticles("none");
1704 var elem
= $("RROW-" + id
);
1705 var article_is_unread
= elem
.hasClassName("Unread");
1707 elem
.removeClassName("Unread");
1708 elem
.addClassName("active");
1710 setActiveArticleId(id
);
1712 if (article_is_unread
) {
1713 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1716 var query
= "?op=rpc&method=catchupSelected" +
1717 "&cmode=0&ids=" + param_escape(id
);
1719 new Ajax
.Request("backend.php", {
1721 onComplete: function(transport
) {
1722 handle_rpc_json(transport
);
1725 return !event
.shiftKey
;
1729 toggleSelected(id
, true);
1731 var elem
= $("RROW-" + id
);
1732 var article_is_unread
= elem
.hasClassName("Unread");
1734 if (article_is_unread
) {
1735 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1738 toggleUnread(id
, 0, false);
1740 openArticleInNewWindow(id
);
1743 var unread_in_buffer
= $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
1744 request_counters(unread_in_buffer
== 0);
1747 exception_error("cdmClicked");
1753 function hlClicked(event
, id
) {
1755 if (event
.which
== 2) {
1758 } else if (event
.ctrlKey
) {
1759 toggleSelected(id
, true);
1760 toggleUnread(id
, 0, false);
1761 openArticleInNewWindow(id
);
1769 exception_error("hlClicked");
1773 function getFirstVisibleHeadlineId() {
1774 var rows
= getVisibleArticleIds();
1779 function getLastVisibleHeadlineId() {
1780 var rows
= getVisibleArticleIds();
1781 return rows
[rows
.length
-1];
1784 function openArticleInNewWindow(id
) {
1785 toggleUnread(id
, 0, false);
1786 window
.open("backend.php?op=article&method=redirect&id=" + id
);
1789 function isCdmMode() {
1790 return getInitParam("combined_display_mode");
1793 function markHeadline(id
, marked
) {
1794 if (marked
== undefined) marked
= true;
1796 var row
= $("RROW-" + id
);
1798 var check
= dijit
.getEnclosingWidget(
1799 row
.getElementsByClassName("rchk")[0]);
1802 check
.attr("checked", marked
);
1806 row
.addClassName("Selected");
1808 row
.removeClassName("Selected");
1812 function getRelativePostIds(id
, limit
) {
1818 if (!limit
) limit
= 6; //3
1820 var ids
= getVisibleArticleIds();
1822 for (var i
= 0; i
< ids
.length
; i
++) {
1824 for (var k
= 1; k
<= limit
; k
++) {
1825 //if (i > k-1) tmp.push(ids[i-k]);
1826 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
1833 exception_error("getRelativePostIds", e
);
1839 function correctHeadlinesOffset(id
) {
1843 var container
= $("headlines-frame");
1844 var row
= $("RROW-" + id
);
1846 if (!container
|| !row
) return;
1848 var viewport
= container
.offsetHeight
;
1850 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
1851 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
1853 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
1854 //console.log("Vport: " + viewport);
1856 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
1857 container
.scrollTop
= row
.offsetTop
;
1858 } else if (rel_offset_bottom
> viewport
) {
1860 /* doesn't properly work with Opera in some cases because
1861 Opera fucks up element scrolling */
1863 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
1867 exception_error("correctHeadlinesOffset", e
);
1872 function headlineActionsChange(elem
) {
1875 elem
.attr('value', 'false');
1877 exception_error("headlineActionsChange", e
);
1881 function closeArticlePanel() {
1883 if (dijit
.byId("content-insert"))
1884 dijit
.byId("headlines-wrap-inner").removeChild(
1885 dijit
.byId("content-insert"));
1888 function initHeadlinesMenu() {
1890 if (dijit
.byId("headlinesMenu"))
1891 dijit
.byId("headlinesMenu").destroyRecursive();
1896 nodes
= $$("#headlines-frame > div[id*=RROW]");
1898 nodes
= $$("#headlines-frame span[id*=RTITLE]");
1901 nodes
.each(function(node
) {
1905 var menu
= new dijit
.Menu({
1906 id
: "headlinesMenu",
1910 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
1911 var callerNode
= event
.target
, match
= null, tries
= 0;
1913 while (match
== null && callerNode
&& tries
<= 3) {
1914 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
1915 callerNode
= callerNode
.parentNode
;
1919 if (match
) this.callerRowId
= parseInt(match
[1]);
1923 /* if (!isCdmMode())
1924 menu.addChild(new dijit.MenuItem({
1925 label: __("View article"),
1926 onClick: function(event) {
1927 view(this.getParent().callerRowId);
1930 menu
.addChild(new dijit
.MenuItem({
1931 label
: __("Open original article"),
1932 onClick: function(event
) {
1933 openArticleInNewWindow(this.getParent().callerRowId
);
1936 menu
.addChild(new dijit
.MenuItem({
1937 label
: __("Display article URL"),
1938 onClick: function(event
) {
1939 displayArticleUrl(this.getParent().callerRowId
);
1942 menu
.addChild(new dijit
.MenuSeparator());
1944 menu
.addChild(new dijit
.MenuItem({
1945 label
: __("Toggle unread"),
1946 onClick: function(event
) {
1947 var ids
= getSelectedArticleIds2();
1949 var id
= this.getParent().callerRowId
+ "";
1950 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1952 selectionToggleUnread(undefined, false, true, ids
);
1955 menu
.addChild(new dijit
.MenuItem({
1956 label
: __("Toggle starred"),
1957 onClick: function(event
) {
1958 var ids
= getSelectedArticleIds2();
1960 var id
= this.getParent().callerRowId
+ "";
1961 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1963 selectionToggleMarked(undefined, false, true, ids
);
1966 menu
.addChild(new dijit
.MenuItem({
1967 label
: __("Toggle published"),
1968 onClick: function(event
) {
1969 var ids
= getSelectedArticleIds2();
1971 var id
= this.getParent().callerRowId
+ "";
1972 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1974 selectionTogglePublished(undefined, false, true, ids
);
1977 menu
.addChild(new dijit
.MenuSeparator());
1979 menu
.addChild(new dijit
.MenuItem({
1980 label
: __("Mark above as read"),
1981 onClick: function(event
) {
1982 catchupRelativeToArticle(0, this.getParent().callerRowId
);
1985 menu
.addChild(new dijit
.MenuItem({
1986 label
: __("Mark below as read"),
1987 onClick: function(event
) {
1988 catchupRelativeToArticle(1, this.getParent().callerRowId
);
1992 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
1996 menu
.addChild(new dijit
.MenuSeparator());
1998 var labelAddMenu
= new dijit
.Menu({ownerMenu
: menu
});
1999 var labelDelMenu
= new dijit
.Menu({ownerMenu
: menu
});
2001 labels
.each(function(label
) {
2002 var id
= label
.id
[0];
2003 var bare_id
= id
.substr(id
.indexOf(":")+1);
2004 var name
= label
.name
[0];
2006 bare_id
= feed_to_label_id(bare_id
);
2008 labelAddMenu
.addChild(new dijit
.MenuItem({
2011 onClick: function(event
) {
2012 var ids
= getSelectedArticleIds2();
2014 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
2016 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
2018 selectionAssignLabel(this.labelId
, ids
);
2021 labelDelMenu
.addChild(new dijit
.MenuItem({
2024 onClick: function(event
) {
2025 var ids
= getSelectedArticleIds2();
2027 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
2029 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
2031 selectionRemoveLabel(this.labelId
, ids
);
2036 menu
.addChild(new dijit
.PopupMenuItem({
2037 label
: __("Assign label"),
2038 popup
: labelAddMenu
,
2041 menu
.addChild(new dijit
.PopupMenuItem({
2042 label
: __("Remove label"),
2043 popup
: labelDelMenu
,
2051 exception_error("initHeadlinesMenu", e
);
2055 function cache_set(id
, obj
) {
2056 //console.log("cache_set: " + id);
2059 sessionStorage
[id
] = obj
;
2061 sessionStorage
.clear();
2065 function cache_get(id
) {
2067 return sessionStorage
[id
];
2070 function cache_clear() {
2072 sessionStorage
.clear();
2075 function cache_delete(id
) {
2077 sessionStorage
.removeItem(id
);
2080 function cancelSearch() {
2085 exception_error("cancelSearch", e
);
2089 function setSelectionScore() {
2091 var ids
= getSelectedArticleIds2();
2093 if (ids
.length
> 0) {
2096 var score
= prompt(__("Please enter new score for selected articles:"), score
);
2098 if (score
!= undefined) {
2099 var query
= "op=article&method=setScore&id=" + param_escape(ids
.toString()) +
2100 "&score=" + param_escape(score
);
2102 new Ajax
.Request("backend.php", {
2104 onComplete: function(transport
) {
2105 var reply
= JSON
.parse(transport
.responseText
);
2109 ids
.each(function(id
) {
2110 var row
= $("RROW-" + id
);
2113 var pic
= row
.getElementsByClassName("hlScorePic")[0];
2116 pic
.src
= pic
.src
.replace(/score_.*?\.png/,
2117 reply
["score_pic"]);
2118 pic
.setAttribute("score", score
);
2127 alert(__("No articles are selected."));
2130 exception_error("setSelectionScore", e
);
2134 function changeScore(id
, pic
) {
2136 var score
= pic
.getAttribute("score");
2138 var new_score
= prompt(__("Please enter new score for this article:"), score
);
2140 if (new_score
!= undefined) {
2142 var query
= "op=article&method=setScore&id=" + param_escape(id
) +
2143 "&score=" + param_escape(new_score
);
2145 new Ajax
.Request("backend.php", {
2147 onComplete: function(transport
) {
2148 var reply
= JSON
.parse(transport
.responseText
);
2151 pic
.src
= pic
.src
.replace(/score_.*?\.png/, reply
["score_pic"]);
2152 pic
.setAttribute("score", new_score
);
2157 exception_error("changeScore", e
);
2161 function displayArticleUrl(id
) {
2163 var query
= "op=rpc&method=getlinktitlebyid&id=" + param_escape(id
);
2165 new Ajax
.Request("backend.php", {
2167 onComplete: function(transport
) {
2168 var reply
= JSON
.parse(transport
.responseText
);
2170 if (reply
&& reply
.link
) {
2171 prompt(__("Article URL:"), reply
.link
);
2175 exception_error("changeScore", e
);
2179 function openSelectedAttachment(elem
) {
2181 var url
= elem
[elem
.selectedIndex
].value
;
2185 elem
.selectedIndex
= 0;
2189 exception_error("openSelectedAttachment", e
);
2193 function updateFloatingTitle() {
2195 var hf
= $("headlines-frame");
2197 var elems
= $$("#headlines-frame > div[id*=RROW]");
2199 for (var i
= 0; i
< elems
.length
; i
++) {
2200 var child
= elems
[i
];
2202 if (child
.offsetTop
+ child
.offsetHeight
> hf
.scrollTop
) {
2204 var header
= child
.getElementsByClassName("cdmHeader")[0];
2206 $("floatingTitle").setAttribute("rowid", child
.id
);
2207 $("floatingTitle").innerHTML
=
2210 if (child
.offsetTop
< hf
.scrollTop
- header
.offsetHeight
- 100 &&
2211 child
.offsetTop
+ child
.offsetHeight
- hf
.scrollTop
> 100)
2212 Element
.show("floatingTitle");
2214 Element
.hide("floatingTitle");
2220 exception_error("updateFloatingTitle", e
);