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 (!isCdmMode() || getInitParam("cdm_expanded"))) {
1274 var rows
= $$("#headlines-frame > div[id*=RROW]");
1276 for (var i
= 0; i
< rows
.length
; i
++) {
1277 var child
= rows
[i
];
1279 if ($("headlines-frame").scrollTop
< child
.offsetTop
&&
1280 child
.offsetTop
- $("headlines-frame").scrollTop
< 100) {
1282 if (_active_article_id
) {
1283 var row
= $("RROW-" + _active_article_id
);
1284 if (row
) row
.removeClassName("active");
1287 _active_article_id
= child
.id
.replace("RROW-", "");
1288 showArticleInHeadlines(_active_article_id
, true);
1289 updateSelectedPrompt();
1295 if (!_infscroll_disable
) {
1296 if ((hsp
&& e
.scrollTop
+ e
.offsetHeight
>= hsp
.offsetTop
- hsp
.offsetHeight
) ||
1297 (e
.scrollHeight
!= 0 &&
1298 ((e
.scrollTop
+ e
.offsetHeight
) / e
.scrollHeight
>= 0.7))) {
1301 hsp
.innerHTML
= "<img src='images/indicator_tiny.gif'> " +
1302 __("Loading, please wait...");
1304 loadMoreHeadlines();
1309 if (hsp
) hsp
.innerHTML
= "";
1312 if (getInitParam("cdm_expanded") && isCdmMode()) {
1313 updateFloatingTitle();
1316 if (getInitParam("cdm_auto_catchup") == 1) {
1318 // let's get DOM some time to settle down
1319 var ts
= new Date().getTime();
1320 if (ts
- _last_headlines_update
< 100) return;
1322 $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
1324 if (child
.hasClassName("Unread") && $("headlines-frame").scrollTop
>
1325 (child
.offsetTop
+ child
.offsetHeight
/2)) {
1327 var id
= child
.id
.replace("RROW-", "");
1329 if (catchup_id_batch
.indexOf(id
) == -1)
1330 catchup_id_batch
.push(id
);
1332 //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
1337 if (catchup_id_batch
.length
> 0) {
1338 window
.clearTimeout(catchup_timeout_id
);
1340 if (!_infscroll_request_sent
) {
1341 catchup_timeout_id
= window
.setTimeout('catchupBatchedArticles()',
1348 console
.warn("headlines_scroll_handler: " + e
);
1352 function catchupBatchedArticles() {
1354 if (catchup_id_batch
.length
> 0 && !_infscroll_request_sent
) {
1356 // make a copy of the array
1357 var batch
= catchup_id_batch
.slice();
1358 var query
= "?op=rpc&method=catchupSelected" +
1359 "&cmode=0&ids=" + param_escape(batch
.toString());
1363 new Ajax
.Request("backend.php", {
1365 onComplete: function(transport
) {
1366 handle_rpc_json(transport
);
1368 reply
= JSON
.parse(transport
.responseText
);
1369 var batch
= reply
.ids
;
1371 batch
.each(function(id
) {
1373 var elem
= $("RROW-" + id
);
1374 if (elem
) elem
.removeClassName("Unread");
1375 catchup_id_batch
.remove(id
);
1382 exception_error("catchupBatchedArticles", e
);
1386 function catchupRelativeToArticle(below
, id
) {
1390 if (!id
) id
= getActiveArticleId();
1393 alert(__("No article is selected."));
1397 var visible_ids
= getVisibleArticleIds();
1399 var ids_to_mark
= new Array();
1402 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1403 if (visible_ids
[i
] != id
) {
1404 var e
= $("RROW-" + visible_ids
[i
]);
1406 if (e
&& e
.hasClassName("Unread")) {
1407 ids_to_mark
.push(visible_ids
[i
]);
1414 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1415 if (visible_ids
[i
] != id
) {
1416 var e
= $("RROW-" + visible_ids
[i
]);
1418 if (e
&& e
.hasClassName("Unread")) {
1419 ids_to_mark
.push(visible_ids
[i
]);
1427 if (ids_to_mark
.length
== 0) {
1428 alert(__("No articles found to mark"));
1430 var msg
= ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark
.length
).replace("%d", ids_to_mark
.length
);
1432 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1434 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1435 var e
= $("RROW-" + ids_to_mark
[i
]);
1436 e
.removeClassName("Unread");
1439 var query
= "?op=rpc&method=catchupSelected" +
1440 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1442 new Ajax
.Request("backend.php", {
1444 onComplete: function(transport
) {
1445 handle_rpc_json(transport
);
1452 exception_error("catchupRelativeToArticle", e
);
1456 function cdmCollapseArticle(event
, id
, unmark
) {
1458 if (unmark
== undefined) unmark
= true;
1460 var row
= $("RROW-" + id
);
1461 var elem
= $("CICD-" + id
);
1464 var collapse
= $$("div#RROW-" + id
+
1465 " span[class='collapseBtn']")[0];
1468 Element
.show("CEXC-" + id
);
1469 Element
.hide(collapse
);
1472 row
.removeClassName("active");
1474 markHeadline(id
, false);
1476 if (id
== getActiveArticleId()) {
1477 setActiveArticleId(0);
1480 updateSelectedPrompt();
1483 if (event
) Event
.stop(event
);
1485 PluginHost
.run(PluginHost
.HOOK_ARTICLE_COLLAPSED
, id
);
1489 exception_error("cdmCollapseArticle", e
);
1493 function cdmExpandArticle(id
, noexpand
) {
1495 console
.log("cdmExpandArticle " + id
);
1497 if (!$("RROW-" + id
)) return false;
1499 var oldrow
= $("RROW-" + getActiveArticleId());
1501 var elem
= $("CICD-" + getActiveArticleId());
1503 if (id
== getActiveArticleId() && Element
.visible(elem
))
1506 selectArticles("none");
1508 var old_offset
= $("RROW-" + id
).offsetTop
;
1510 if (getActiveArticleId() && elem
&& !getInitParam("cdm_expanded")) {
1511 var collapse
= $$("div#RROW-" + getActiveArticleId() +
1512 " span[class='collapseBtn']")[0];
1515 Element
.show("CEXC-" + getActiveArticleId());
1516 Element
.hide(collapse
);
1519 if (oldrow
) oldrow
.removeClassName("active");
1521 setActiveArticleId(id
);
1523 elem
= $("CICD-" + id
);
1525 var collapse
= $$("div#RROW-" + id
+
1526 " span[class='collapseBtn']")[0];
1528 var cencw
= $("CENCW-" + id
);
1530 if (!Element
.visible(elem
) && !noexpand
) {
1532 cencw
.innerHTML
= htmlspecialchars_decode(cencw
.innerHTML
);
1533 cencw
.setAttribute('id', '');
1534 Element
.show(cencw
);
1538 Element
.hide("CEXC-" + id
);
1539 Element
.show(collapse
);
1542 var new_offset
= $("RROW-" + id
).offsetTop
;
1544 if (old_offset
> new_offset
)
1545 $("headlines-frame").scrollTop
-= (old_offset
-new_offset
);
1548 toggleUnread(id
, 0, true);
1550 $("RROW-" + id
).addClassName("active");
1552 PluginHost
.run(PluginHost
.HOOK_ARTICLE_EXPANDED
, id
);
1555 exception_error("cdmExpandArticle", e
);
1561 function getArticleUnderPointer() {
1562 return post_under_pointer
;
1565 function scrollArticle(offset
) {
1568 var ci
= $("content-insert");
1570 ci
.scrollTop
+= offset
;
1573 var hi
= $("headlines-frame");
1575 hi
.scrollTop
+= offset
;
1580 exception_error("scrollArticle", e
);
1584 function show_labels_in_headlines(transport
) {
1586 var data
= JSON
.parse(transport
.responseText
);
1589 data
['info-for-headlines'].each(function(elem
) {
1590 var ctr
= $("HLLCTR-" + elem
.id
);
1592 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1596 exception_error("show_labels_in_headlines", e
);
1600 function dismissArticle(id
) {
1602 var elem
= $("RROW-" + id
);
1606 toggleUnread(id
, 0, true);
1608 new Effect
.Fade(elem
, {duration
: 0.5});
1610 if (id
== getActiveArticleId()) {
1611 setActiveArticleId(0);
1615 exception_error("dismissArticle", e
);
1619 function dismissSelectedArticles() {
1622 var ids
= getVisibleArticleIds();
1626 for (var i
= 0; i
< ids
.length
; i
++) {
1627 var elem
= $("RROW-" + ids
[i
]);
1629 if (elem
.className
&& elem
.hasClassName("Selected") &&
1630 ids
[i
] != getActiveArticleId()) {
1631 new Effect
.Fade(elem
, {duration
: 0.5});
1639 selectionToggleUnread(false);
1643 exception_error("dismissSelectedArticles", e
);
1647 function dismissReadArticles() {
1650 var ids
= getVisibleArticleIds();
1653 for (var i
= 0; i
< ids
.length
; i
++) {
1654 var elem
= $("RROW-" + ids
[i
]);
1656 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1657 !elem
.hasClassName("Selected")) {
1659 new Effect
.Fade(elem
, {duration
: 0.5});
1666 exception_error("dismissSelectedArticles", e
);
1670 function getVisibleArticleIds() {
1675 getLoadedArticleIds().each(function(id
) {
1676 var elem
= $("RROW-" + id
);
1677 if (elem
&& Element
.visible(elem
))
1682 exception_error("getVisibleArticleIds", e
);
1688 function cdmClicked(event
, id
) {
1690 //var shift_key = event.shiftKey;
1692 if (!event
.ctrlKey
) {
1694 if (!getInitParam("cdm_expanded")) {
1695 return cdmExpandArticle(id
);
1698 var elem
= $("RROW-" + getActiveArticleId());
1700 if (elem
) elem
.removeClassName("active");
1702 selectArticles("none");
1705 var elem
= $("RROW-" + id
);
1706 var article_is_unread
= elem
.hasClassName("Unread");
1708 elem
.removeClassName("Unread");
1709 elem
.addClassName("active");
1711 setActiveArticleId(id
);
1713 if (article_is_unread
) {
1714 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1717 var query
= "?op=rpc&method=catchupSelected" +
1718 "&cmode=0&ids=" + param_escape(id
);
1720 new Ajax
.Request("backend.php", {
1722 onComplete: function(transport
) {
1723 handle_rpc_json(transport
);
1726 return !event
.shiftKey
;
1730 toggleSelected(id
, true);
1732 var elem
= $("RROW-" + id
);
1733 var article_is_unread
= elem
.hasClassName("Unread");
1735 if (article_is_unread
) {
1736 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1739 toggleUnread(id
, 0, false);
1741 openArticleInNewWindow(id
);
1744 var unread_in_buffer
= $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
1745 request_counters(unread_in_buffer
== 0);
1748 exception_error("cdmClicked");
1754 function hlClicked(event
, id
) {
1756 if (event
.which
== 2) {
1759 } else if (event
.ctrlKey
) {
1760 toggleSelected(id
, true);
1761 toggleUnread(id
, 0, false);
1762 openArticleInNewWindow(id
);
1770 exception_error("hlClicked");
1774 function getFirstVisibleHeadlineId() {
1775 var rows
= getVisibleArticleIds();
1780 function getLastVisibleHeadlineId() {
1781 var rows
= getVisibleArticleIds();
1782 return rows
[rows
.length
-1];
1785 function openArticleInNewWindow(id
) {
1786 toggleUnread(id
, 0, false);
1787 window
.open("backend.php?op=article&method=redirect&id=" + id
);
1790 function isCdmMode() {
1791 return getInitParam("combined_display_mode");
1794 function markHeadline(id
, marked
) {
1795 if (marked
== undefined) marked
= true;
1797 var row
= $("RROW-" + id
);
1799 var check
= dijit
.getEnclosingWidget(
1800 row
.getElementsByClassName("rchk")[0]);
1803 check
.attr("checked", marked
);
1807 row
.addClassName("Selected");
1809 row
.removeClassName("Selected");
1813 function getRelativePostIds(id
, limit
) {
1819 if (!limit
) limit
= 6; //3
1821 var ids
= getVisibleArticleIds();
1823 for (var i
= 0; i
< ids
.length
; i
++) {
1825 for (var k
= 1; k
<= limit
; k
++) {
1826 //if (i > k-1) tmp.push(ids[i-k]);
1827 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
1834 exception_error("getRelativePostIds", e
);
1840 function correctHeadlinesOffset(id
) {
1844 var container
= $("headlines-frame");
1845 var row
= $("RROW-" + id
);
1847 if (!container
|| !row
) return;
1849 var viewport
= container
.offsetHeight
;
1851 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
1852 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
1854 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
1855 //console.log("Vport: " + viewport);
1857 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
1858 container
.scrollTop
= row
.offsetTop
;
1859 } else if (rel_offset_bottom
> viewport
) {
1861 /* doesn't properly work with Opera in some cases because
1862 Opera fucks up element scrolling */
1864 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
1868 exception_error("correctHeadlinesOffset", e
);
1873 function headlineActionsChange(elem
) {
1876 elem
.attr('value', 'false');
1878 exception_error("headlineActionsChange", e
);
1882 function closeArticlePanel() {
1884 if (dijit
.byId("content-insert"))
1885 dijit
.byId("headlines-wrap-inner").removeChild(
1886 dijit
.byId("content-insert"));
1889 function initHeadlinesMenu() {
1891 if (dijit
.byId("headlinesMenu"))
1892 dijit
.byId("headlinesMenu").destroyRecursive();
1897 nodes
= $$("#headlines-frame > div[id*=RROW]");
1899 nodes
= $$("#headlines-frame span[id*=RTITLE]");
1902 nodes
.each(function(node
) {
1906 var menu
= new dijit
.Menu({
1907 id
: "headlinesMenu",
1911 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
1912 var callerNode
= event
.target
, match
= null, tries
= 0;
1914 while (match
== null && callerNode
&& tries
<= 3) {
1915 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
1916 callerNode
= callerNode
.parentNode
;
1920 if (match
) this.callerRowId
= parseInt(match
[1]);
1924 /* if (!isCdmMode())
1925 menu.addChild(new dijit.MenuItem({
1926 label: __("View article"),
1927 onClick: function(event) {
1928 view(this.getParent().callerRowId);
1931 menu
.addChild(new dijit
.MenuItem({
1932 label
: __("Open original article"),
1933 onClick: function(event
) {
1934 openArticleInNewWindow(this.getParent().callerRowId
);
1937 menu
.addChild(new dijit
.MenuItem({
1938 label
: __("Display article URL"),
1939 onClick: function(event
) {
1940 displayArticleUrl(this.getParent().callerRowId
);
1943 menu
.addChild(new dijit
.MenuSeparator());
1945 menu
.addChild(new dijit
.MenuItem({
1946 label
: __("Toggle unread"),
1947 onClick: function(event
) {
1948 var ids
= getSelectedArticleIds2();
1950 var id
= this.getParent().callerRowId
+ "";
1951 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1953 selectionToggleUnread(undefined, false, true, ids
);
1956 menu
.addChild(new dijit
.MenuItem({
1957 label
: __("Toggle starred"),
1958 onClick: function(event
) {
1959 var ids
= getSelectedArticleIds2();
1961 var id
= this.getParent().callerRowId
+ "";
1962 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1964 selectionToggleMarked(undefined, false, true, ids
);
1967 menu
.addChild(new dijit
.MenuItem({
1968 label
: __("Toggle published"),
1969 onClick: function(event
) {
1970 var ids
= getSelectedArticleIds2();
1972 var id
= this.getParent().callerRowId
+ "";
1973 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1975 selectionTogglePublished(undefined, false, true, ids
);
1978 menu
.addChild(new dijit
.MenuSeparator());
1980 menu
.addChild(new dijit
.MenuItem({
1981 label
: __("Mark above as read"),
1982 onClick: function(event
) {
1983 catchupRelativeToArticle(0, this.getParent().callerRowId
);
1986 menu
.addChild(new dijit
.MenuItem({
1987 label
: __("Mark below as read"),
1988 onClick: function(event
) {
1989 catchupRelativeToArticle(1, this.getParent().callerRowId
);
1993 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
1997 menu
.addChild(new dijit
.MenuSeparator());
1999 var labelAddMenu
= new dijit
.Menu({ownerMenu
: menu
});
2000 var labelDelMenu
= new dijit
.Menu({ownerMenu
: menu
});
2002 labels
.each(function(label
) {
2003 var id
= label
.id
[0];
2004 var bare_id
= id
.substr(id
.indexOf(":")+1);
2005 var name
= label
.name
[0];
2007 bare_id
= feed_to_label_id(bare_id
);
2009 labelAddMenu
.addChild(new dijit
.MenuItem({
2012 onClick: function(event
) {
2013 var ids
= getSelectedArticleIds2();
2015 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
2017 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
2019 selectionAssignLabel(this.labelId
, ids
);
2022 labelDelMenu
.addChild(new dijit
.MenuItem({
2025 onClick: function(event
) {
2026 var ids
= getSelectedArticleIds2();
2028 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
2030 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
2032 selectionRemoveLabel(this.labelId
, ids
);
2037 menu
.addChild(new dijit
.PopupMenuItem({
2038 label
: __("Assign label"),
2039 popup
: labelAddMenu
,
2042 menu
.addChild(new dijit
.PopupMenuItem({
2043 label
: __("Remove label"),
2044 popup
: labelDelMenu
,
2052 exception_error("initHeadlinesMenu", e
);
2056 function cache_set(id
, obj
) {
2057 //console.log("cache_set: " + id);
2060 sessionStorage
[id
] = obj
;
2062 sessionStorage
.clear();
2066 function cache_get(id
) {
2068 return sessionStorage
[id
];
2071 function cache_clear() {
2073 sessionStorage
.clear();
2076 function cache_delete(id
) {
2078 sessionStorage
.removeItem(id
);
2081 function cancelSearch() {
2086 exception_error("cancelSearch", e
);
2090 function setSelectionScore() {
2092 var ids
= getSelectedArticleIds2();
2094 if (ids
.length
> 0) {
2097 var score
= prompt(__("Please enter new score for selected articles:"), score
);
2099 if (score
!= undefined) {
2100 var query
= "op=article&method=setScore&id=" + param_escape(ids
.toString()) +
2101 "&score=" + param_escape(score
);
2103 new Ajax
.Request("backend.php", {
2105 onComplete: function(transport
) {
2106 var reply
= JSON
.parse(transport
.responseText
);
2110 ids
.each(function(id
) {
2111 var row
= $("RROW-" + id
);
2114 var pic
= row
.getElementsByClassName("hlScorePic")[0];
2117 pic
.src
= pic
.src
.replace(/score_.*?\.png/,
2118 reply
["score_pic"]);
2119 pic
.setAttribute("score", score
);
2128 alert(__("No articles are selected."));
2131 exception_error("setSelectionScore", e
);
2135 function changeScore(id
, pic
) {
2137 var score
= pic
.getAttribute("score");
2139 var new_score
= prompt(__("Please enter new score for this article:"), score
);
2141 if (new_score
!= undefined) {
2143 var query
= "op=article&method=setScore&id=" + param_escape(id
) +
2144 "&score=" + param_escape(new_score
);
2146 new Ajax
.Request("backend.php", {
2148 onComplete: function(transport
) {
2149 var reply
= JSON
.parse(transport
.responseText
);
2152 pic
.src
= pic
.src
.replace(/score_.*?\.png/, reply
["score_pic"]);
2153 pic
.setAttribute("score", new_score
);
2158 exception_error("changeScore", e
);
2162 function displayArticleUrl(id
) {
2164 var query
= "op=rpc&method=getlinktitlebyid&id=" + param_escape(id
);
2166 new Ajax
.Request("backend.php", {
2168 onComplete: function(transport
) {
2169 var reply
= JSON
.parse(transport
.responseText
);
2171 if (reply
&& reply
.link
) {
2172 prompt(__("Article URL:"), reply
.link
);
2176 exception_error("changeScore", e
);
2180 function openSelectedAttachment(elem
) {
2182 var url
= elem
[elem
.selectedIndex
].value
;
2186 elem
.selectedIndex
= 0;
2190 exception_error("openSelectedAttachment", e
);
2194 function updateFloatingTitle() {
2196 var hf
= $("headlines-frame");
2198 var elems
= $$("#headlines-frame > div[id*=RROW]");
2200 for (var i
= 0; i
< elems
.length
; i
++) {
2201 var child
= elems
[i
];
2203 if (child
.offsetTop
+ child
.offsetHeight
> hf
.scrollTop
) {
2205 var header
= child
.getElementsByClassName("cdmHeader")[0];
2207 $("floatingTitle").setAttribute("rowid", child
.id
);
2208 $("floatingTitle").innerHTML
=
2211 if (child
.offsetTop
< hf
.scrollTop
- header
.offsetHeight
- 100 &&
2212 child
.offsetTop
+ child
.offsetHeight
- hf
.scrollTop
> 100)
2213 Element
.show("floatingTitle");
2215 Element
.hide("floatingTitle");
2221 exception_error("updateFloatingTitle", e
);