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;
59 Element
.hide("floatingTitle");
60 $("floatingTitle").setAttribute("rowid", 0);
61 $("floatingTitle").innerHTML
= "";
65 $("headlines-frame").removeClassName("cdm");
66 $("headlines-frame").removeClassName("normal");
68 $("headlines-frame").addClassName(isCdmMode() ? "cdm" : "normal");
70 var headlines_count
= reply
['headlines-info']['count'];
72 vgroup_last_feed
= reply
['headlines-info']['vgroup_last_feed'];
74 if (parseInt(headlines_count
) < 30) {
75 _infscroll_disable
= 1;
77 _infscroll_disable
= 0;
80 var counters
= reply
['counters'];
81 var articles
= reply
['articles'];
82 //var runtime_info = reply['runtime-info'];
84 if (infscroll_req
== false) {
85 loaded_article_ids
= [];
87 dijit
.byId("headlines-frame").attr('content',
88 reply
['headlines']['content']);
90 dijit
.byId("headlines-toolbar").attr('content',
91 reply
['headlines']['toolbar']);
93 $$("#headlines-frame > div[id*=RROW]").each(function(row
) {
94 if (loaded_article_ids
.indexOf(row
.id
) != -1) {
95 row
.parentNode
.removeChild(row
);
97 loaded_article_ids
.push(row
.id
);
101 var hsp
= $("headlines-spacer");
102 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
103 dijit
.byId('headlines-frame').domNode
.appendChild(hsp
);
108 $("feed_title").innerHTML
+= "<span id='cancel_search'>" +
109 " (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" +
115 if (headlines_count
> 0 && feed_id
== getActiveFeedId() && is_cat
== activeFeedIsCat()) {
116 console
.log("adding some more headlines: " + headlines_count
);
118 var c
= dijit
.byId("headlines-frame");
119 var ids
= getSelectedArticleIds2();
122 $("headlines-tmp").innerHTML
= reply
['headlines']['content'];
124 var hsp
= $("headlines-spacer");
127 c
.domNode
.removeChild(hsp
);
129 $$("#headlines-tmp > div").each(function(row
) {
130 if (row
.className
== 'cdmFeedTitle') {
131 row
.style
.display
= 'none';
132 c
.domNode
.appendChild(row
);
134 } else if (loaded_article_ids
.indexOf(row
.id
) == -1) {
135 row
.style
.display
= 'none';
136 c
.domNode
.appendChild(row
);
138 loaded_article_ids
.push(row
.id
);
140 row
.parentNode
.removeChild(row
);
144 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
146 if (getInitParam("cdm_auto_catchup") == 1) {
147 c
.domNode
.appendChild(hsp
);
150 console
.log("added " + new_elems
.size() + " headlines");
152 if (new_elems
.size() == 0)
153 _infscroll_disable
= true;
155 console
.log("restore selected ids: " + ids
);
157 for (var i
= 0; i
< ids
.length
; i
++) {
158 markHeadline(ids
[i
]);
163 new_elems
.each(function(child
) {
164 dojo
.parser
.parse(child
);
166 if (!Element
.visible(child
))
167 new Effect
.Appear(child
, { duration
: 0.5 });
171 console
.log("no new headlines received");
173 var hsp
= $("headlines-spacer");
175 if (hsp
) hsp
.innerHTML
= "";
180 for (var i
= 0; i
< articles
.length
; i
++) {
181 var a_id
= articles
[i
]['id'];
182 cache_set("article:" + a_id
, articles
[i
]['content']);
185 console
.log("no cached articles received");
189 parse_counters(counters
);
191 request_counters(true);
193 } else if (transport
.responseText
) {
194 console
.error("Invalid object received: " + transport
.responseText
);
195 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
196 __('Could not update headlines (invalid object received - see error console for details)') +
199 //notify_error("Error communicating with server.");
200 Element
.show(dijit
.byId("net-alert").domNode
);
203 _infscroll_request_sent
= 0;
204 _last_headlines_update
= new Date().getTime();
206 unpackVisibleHeadlines();
208 // if we have some more space in the buffer, why not try to fill it
210 if (!_infscroll_disable
&& $("headlines-spacer") &&
211 $("headlines-spacer").offsetTop
< $("headlines-frame").offsetHeight
) {
213 window
.setTimeout(function() {
221 exception_error("headlines_callback2", e
, transport
);
225 function render_article(article
) {
227 dijit
.byId("headlines-wrap-inner").addChild(
228 dijit
.byId("content-insert"));
230 var c
= dijit
.byId("content-insert");
233 c
.domNode
.scrollTop
= 0;
236 PluginHost
.run(PluginHost
.HOOK_ARTICLE_RENDERED
, article
);
238 c
.attr('content', article
);
240 correctHeadlinesOffset(getActiveArticleId());
247 exception_error("render_article", e
);
251 function showArticleInHeadlines(id
, noexpand
) {
254 selectArticles("none");
256 var crow
= $("RROW-" + id
);
260 var article_is_unread
= crow
.hasClassName("Unread");
263 crow
.removeClassName("Unread");
264 crow
.addClassName("active");
266 selectArticles('none');
268 var view_mode
= false;
271 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
272 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
279 if (article_is_unread
&& !noexpand
)
280 _force_scheduled_update
= true;
283 exception_error("showArticleInHeadlines", e
);
287 function article_callback2(transport
, id
) {
289 console
.log("article_callback2 " + id
);
291 handle_rpc_json(transport
);
296 reply
= JSON
.parse(transport
.responseText
);
303 reply
.each(function(article
) {
304 if (getActiveArticleId() == article
['id']) {
305 render_article(article
['content']);
307 cids_requested
.remove(article
['id']);
309 cache_set("article:" + article
['id'], article
['content']);
312 // if (id != last_requested_article) {
313 // console.log("requested article id is out of sequence, aborting");
317 } else if (transport
.responseText
) {
318 console
.error("Invalid object received: " + transport
.responseText
);
320 render_article("<div class='whiteBox'>" +
321 __('Could not display article (invalid object received - see error console for details)') + "</div>");
323 Element
.show(dijit
.byId("net-alert").domNode
);
326 var unread_in_buffer
= $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
327 request_counters(unread_in_buffer
== 0);
329 //headlines_scroll_handler($("headlines-frame"));
332 if (!_infscroll_disable &&
333 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
343 exception_error("article_callback2", e
, transport
);
347 function view(id
, activefeed
, noexpand
) {
349 var oldrow
= $("RROW-" + getActiveArticleId());
350 if (oldrow
) oldrow
.removeClassName("active");
352 var crow
= $("RROW-" + id
);
356 setActiveArticleId(id
);
357 showArticleInHeadlines(id
, noexpand
);
361 console
.log("loading article: " + id
);
363 var cached_article
= cache_get("article:" + id
);
365 console
.log("cache check result: " + (cached_article
!= false));
367 var query
= "?op=article&method=view&id=" + param_escape(id
);
369 var neighbor_ids
= getRelativePostIds(id
);
371 /* only request uncached articles */
373 var cids_to_request
= [];
375 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
376 if (cids_requested
.indexOf(neighbor_ids
[i
]) == -1)
377 if (!cache_get("article:" + neighbor_ids
[i
])) {
378 cids_to_request
.push(neighbor_ids
[i
]);
379 cids_requested
.push(neighbor_ids
[i
]);
383 console
.log("additional ids: " + cids_to_request
.toString());
385 query
= query
+ "&cids=" + cids_to_request
.toString();
387 var article_is_unread
= crow
.hasClassName("Unread");
389 setActiveArticleId(id
);
390 showArticleInHeadlines(id
);
392 if (cached_article
&& article_is_unread
) {
394 query
= query
+ "&mode=prefetch";
396 render_article(cached_article
);
398 } else if (cached_article
) {
400 query
= query
+ "&mode=prefetch_old";
401 render_article(cached_article
);
403 // if we don't need to request any relative ids, we might as well skip
404 // the server roundtrip altogether
405 if (cids_to_request
.length
== 0) {
408 if (!_infscroll_disable &&
409 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
417 //headlines_scroll_handler($("headlines-frame"));
423 last_requested_article
= id
;
427 if (article_is_unread
) {
428 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
431 new Ajax
.Request("backend.php", {
433 onComplete: function(transport
) {
434 article_callback2(transport
, id
);
440 exception_error("view", e
);
444 function toggleMark(id
, client_only
) {
446 var query
= "?op=rpc&id=" + id
+ "&method=mark";
448 var row
= $("RROW-" + id
);
453 var row_imgs
= row
.getElementsByClassName("markedPic");
455 for (var i
= 0; i
< row_imgs
.length
; i
++)
456 imgs
.push(row_imgs
[i
]);
458 var ft
= $("floatingTitle");
460 if (ft
&& ft
.getAttribute("rowid") == "RROW-" + id
) {
461 var fte
= ft
.getElementsByClassName("markedPic");
463 for (var i
= 0; i
< fte
.length
; i
++)
467 for (i
= 0; i
< imgs
.length
; i
++) {
470 if (!row
.hasClassName("marked")) {
471 img
.src
= img
.src
.replace("mark_unset", "mark_set");
472 img
.alt
= __("Unstar article");
473 query
= query
+ "&mark=1";
475 img
.src
= img
.src
.replace("mark_set", "mark_unset");
476 img
.alt
= __("Star article");
477 query
= query
+ "&mark=0";
481 row
.toggleClassName("marked");
484 new Ajax
.Request("backend.php", {
486 onComplete: function(transport
) {
487 handle_rpc_json(transport
);
492 exception_error("toggleMark", e
);
496 function togglePub(id
, client_only
, no_effects
, note
) {
498 var query
= "?op=rpc&id=" + id
+ "&method=publ";
500 if (note
!= undefined) {
501 query
= query
+ "¬e=" + param_escape(note
);
503 query
= query
+ "¬e=undefined";
506 var row
= $("RROW-" + id
);
511 var row_imgs
= row
.getElementsByClassName("pubPic");
513 for (var i
= 0; i
< row_imgs
.length
; i
++)
514 imgs
.push(row_imgs
[i
]);
516 var ft
= $("floatingTitle");
518 if (ft
&& ft
.getAttribute("rowid") == "RROW-" + id
) {
519 var fte
= ft
.getElementsByClassName("pubPic");
521 for (var i
= 0; i
< fte
.length
; i
++)
525 for (i
= 0; i
< imgs
.length
; i
++) {
528 if (!row
.hasClassName("published") || note
!= undefined) {
529 img
.src
= img
.src
.replace("pub_unset", "pub_set");
530 img
.alt
= __("Unpublish article");
531 query
= query
+ "&pub=1";
533 img
.src
= img
.src
.replace("pub_set", "pub_unset");
534 img
.alt
= __("Publish article");
535 query
= query
+ "&pub=0";
539 if (note
!= undefined)
540 row
.addClassName("published");
542 row
.toggleClassName("published");
545 new Ajax
.Request("backend.php", {
547 onComplete: function(transport
) {
548 handle_rpc_json(transport
);
553 exception_error("togglePub", e
);
557 function moveToPost(mode
, noscroll
, noexpand
) {
561 var rows
= getVisibleArticleIds();
566 if (!$('RROW-' + getActiveArticleId())) {
567 setActiveArticleId(0);
570 if (!getActiveArticleId()) {
572 prev_id
= rows
[rows
.length
-1]
574 for (var i
= 0; i
< rows
.length
; i
++) {
575 if (rows
[i
] == getActiveArticleId()) {
577 // Account for adjacent identical article ids.
578 if (i
> 0) prev_id
= rows
[i
-1];
580 for (var j
= i
+1; j
< rows
.length
; j
++) {
581 if (rows
[j
] != getActiveArticleId()) {
591 if (mode
== "next") {
592 if (next_id
|| getActiveArticleId()) {
595 var article
= $("RROW-" + getActiveArticleId());
596 var ctr
= $("headlines-frame");
598 if (!noscroll
&& article
&& article
.offsetTop
+ article
.offsetHeight
>
599 ctr
.scrollTop
+ ctr
.offsetHeight
) {
601 scrollArticle(ctr
.offsetHeight
/4);
603 } else if (next_id
) {
604 cdmExpandArticle(next_id
, noexpand
);
605 cdmScrollToArticleId(next_id
, true);
608 } else if (next_id
) {
609 correctHeadlinesOffset(next_id
);
610 view(next_id
, getActiveFeedId(), noexpand
);
615 if (mode
== "prev") {
616 if (prev_id
|| getActiveArticleId()) {
619 var article
= $("RROW-" + getActiveArticleId());
620 var prev_article
= $("RROW-" + prev_id
);
621 var ctr
= $("headlines-frame");
623 if (!getInitParam("cdm_expanded")) {
625 if (!noscroll
&& article
&& article
.offsetTop
< ctr
.scrollTop
) {
626 scrollArticle(-ctr
.offsetHeight
/4);
628 cdmExpandArticle(prev_id
, noexpand
);
629 cdmScrollToArticleId(prev_id
, true);
633 if (!noscroll
&& article
&& article
.offsetTop
< ctr
.scrollTop
) {
634 scrollArticle(-ctr
.offsetHeight
/3);
635 } else if (!noscroll
&& prev_article
&&
636 prev_article
.offsetTop
< ctr
.scrollTop
) {
637 cdmExpandArticle(prev_id
, noexpand
);
638 scrollArticle(-ctr
.offsetHeight
/4);
639 } else if (prev_id
) {
640 cdmExpandArticle(prev_id
, noexpand
);
641 cdmScrollToArticleId(prev_id
, noscroll
);
645 } else if (prev_id
) {
646 correctHeadlinesOffset(prev_id
);
647 view(prev_id
, getActiveFeedId(), noexpand
);
653 exception_error("moveToPost", e
);
657 function toggleSelected(id
, force_on
) {
659 var row
= $("RROW-" + id
);
662 var cb
= dijit
.getEnclosingWidget(
663 row
.getElementsByClassName("rchk")[0]);
665 if (row
.hasClassName('Selected') && !force_on
) {
666 row
.removeClassName('Selected');
667 if (cb
) cb
.attr("checked", false);
669 row
.addClassName('Selected');
670 if (cb
) cb
.attr("checked", true);
674 updateSelectedPrompt();
676 exception_error("toggleSelected", e
);
680 function updateSelectedPrompt() {
682 var count
= getSelectedArticleIds2().size();
683 var elem
= $("selected_prompt");
686 elem
.innerHTML
= ngettext("%d article selected",
687 "%d articles selected", count
).replace("%d", count
);
696 exception_error("updateSelectedPrompt", e
);
700 function toggleUnread_afh(effect
) {
703 var elem
= effect
.element
;
704 elem
.style
.backgroundColor
= "";
707 exception_error("toggleUnread_afh", e
);
711 function toggleUnread(id
, cmode
, effect
) {
714 var row
= $("RROW-" + id
);
716 if (cmode
== undefined || cmode
== 2) {
717 if (row
.hasClassName("Unread")) {
718 row
.removeClassName("Unread");
721 row
.addClassName("Unread");
724 } else if (cmode
== 0) {
726 row
.removeClassName("Unread");
728 } else if (cmode
== 1) {
729 row
.addClassName("Unread");
732 if (cmode
== undefined) cmode
= 2;
734 var query
= "?op=rpc&method=catchupSelected" +
735 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
737 // notify_progress("Loading, please wait...");
739 new Ajax
.Request("backend.php", {
741 onComplete: function(transport
) {
742 handle_rpc_json(transport
);
748 exception_error("toggleUnread", e
);
752 function selectionRemoveLabel(id
, ids
) {
755 if (!ids
) ids
= getSelectedArticleIds2();
757 if (ids
.length
== 0) {
758 alert(__("No articles are selected."));
762 var query
= "?op=article&method=removeFromLabel&ids=" +
763 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
767 new Ajax
.Request("backend.php", {
769 onComplete: function(transport
) {
770 handle_rpc_json(transport
);
771 show_labels_in_headlines(transport
);
775 exception_error("selectionAssignLabel", e
);
780 function selectionAssignLabel(id
, ids
) {
783 if (!ids
) ids
= getSelectedArticleIds2();
785 if (ids
.length
== 0) {
786 alert(__("No articles are selected."));
790 var query
= "?op=article&method=assignToLabel&ids=" +
791 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
795 new Ajax
.Request("backend.php", {
797 onComplete: function(transport
) {
798 handle_rpc_json(transport
);
799 show_labels_in_headlines(transport
);
803 exception_error("selectionAssignLabel", e
);
808 function selectionToggleUnread(set_state
, callback
, no_error
, ids
) {
810 var rows
= ids
? ids
: getSelectedArticleIds2();
812 if (rows
.length
== 0 && !no_error
) {
813 alert(__("No articles are selected."));
817 for (var i
= 0; i
< rows
.length
; i
++) {
818 var row
= $("RROW-" + rows
[i
]);
820 if (set_state
== undefined) {
821 if (row
.hasClassName("Unread")) {
822 row
.removeClassName("Unread");
824 row
.addClassName("Unread");
828 if (set_state
== false) {
829 row
.removeClassName("Unread");
832 if (set_state
== true) {
833 row
.addClassName("Unread");
838 if (rows
.length
> 0) {
842 if (set_state
== undefined) {
844 } else if (set_state
== true) {
846 } else if (set_state
== false) {
850 var query
= "?op=rpc&method=catchupSelected" +
851 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
853 notify_progress("Loading, please wait...");
855 new Ajax
.Request("backend.php", {
857 onComplete: function(transport
) {
858 handle_rpc_json(transport
);
859 if (callback
) callback(transport
);
865 exception_error("selectionToggleUnread", e
);
870 function selectionToggleMarked(sel_state
, callback
, no_error
, ids
) {
873 var rows
= ids
? ids
: getSelectedArticleIds2();
875 if (rows
.length
== 0 && !no_error
) {
876 alert(__("No articles are selected."));
880 for (var i
= 0; i
< rows
.length
; i
++) {
881 toggleMark(rows
[i
], true, true);
884 if (rows
.length
> 0) {
886 var query
= "?op=rpc&method=markSelected&ids=" +
887 param_escape(rows
.toString()) + "&cmode=2";
889 new Ajax
.Request("backend.php", {
891 onComplete: function(transport
) {
892 handle_rpc_json(transport
);
893 if (callback
) callback(transport
);
899 exception_error("selectionToggleMarked", e
);
904 function selectionTogglePublished(sel_state
, callback
, no_error
, ids
) {
907 var rows
= ids
? ids
: getSelectedArticleIds2();
909 if (rows
.length
== 0 && !no_error
) {
910 alert(__("No articles are selected."));
914 for (var i
= 0; i
< rows
.length
; i
++) {
915 togglePub(rows
[i
], true, true);
918 if (rows
.length
> 0) {
920 var query
= "?op=rpc&method=publishSelected&ids=" +
921 param_escape(rows
.toString()) + "&cmode=2";
923 new Ajax
.Request("backend.php", {
925 onComplete: function(transport
) {
926 handle_rpc_json(transport
);
932 exception_error("selectionToggleMarked", e
);
936 function getSelectedArticleIds2() {
940 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
942 rv
.push(child
.id
.replace("RROW-", ""));
948 function getLoadedArticleIds() {
951 var children
= $$("#headlines-frame > div[id*=RROW-]");
953 children
.each(function(child
) {
954 rv
.push(child
.id
.replace("RROW-", ""));
961 // mode = all,none,unread,invert,marked,published
962 function selectArticles(mode
) {
965 var children
= $$("#headlines-frame > div[id*=RROW]");
967 children
.each(function(child
) {
968 var id
= child
.id
.replace("RROW-", "");
970 var cb
= dijit
.getEnclosingWidget(
971 child
.getElementsByClassName("rchk")[0]);
974 child
.addClassName("Selected");
975 if (cb
) cb
.attr("checked", true);
976 } else if (mode
== "unread") {
977 if (child
.hasClassName("Unread")) {
978 child
.addClassName("Selected");
979 if (cb
) cb
.attr("checked", true);
981 child
.removeClassName("Selected");
982 if (cb
) cb
.attr("checked", false);
984 } else if (mode
== "marked") {
985 if (child
.hasClassName("marked")) {
986 child
.addClassName("Selected");
987 if (cb
) cb
.attr("checked", true);
989 child
.removeClassName("Selected");
990 if (cb
) cb
.attr("checked", false);
992 } else if (mode
== "published") {
993 if (child
.hasClassName("published")) {
994 child
.addClassName("Selected");
995 if (cb
) cb
.attr("checked", true);
997 child
.removeClassName("Selected");
998 if (cb
) cb
.attr("checked", false);
1001 } else if (mode
== "invert") {
1002 if (child
.hasClassName("Selected")) {
1003 child
.removeClassName("Selected");
1004 if (cb
) cb
.attr("checked", false);
1006 child
.addClassName("Selected");
1007 if (cb
) cb
.attr("checked", true);
1011 child
.removeClassName("Selected");
1012 if (cb
) cb
.attr("checked", false);
1016 updateSelectedPrompt();
1019 exception_error("selectArticles", e
);
1023 function deleteSelection() {
1027 var rows
= getSelectedArticleIds2();
1029 if (rows
.length
== 0) {
1030 alert(__("No articles are selected."));
1034 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1037 if (getActiveFeedId() != 0) {
1038 str
= ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?" , rows
.length
);
1040 str
= ngettext("Delete %d selected article?", "Delete %d selected articles?", rows
.length
);
1043 str
= str
.replace("%d", rows
.length
);
1044 str
= str
.replace("%s", fn
);
1046 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1050 query
= "?op=rpc&method=delete&ids=" + param_escape(rows
);
1054 new Ajax
.Request("backend.php", {
1056 onComplete: function(transport
) {
1057 handle_rpc_json(transport
);
1062 exception_error("deleteSelection", e
);
1066 function archiveSelection() {
1070 var rows
= getSelectedArticleIds2();
1072 if (rows
.length
== 0) {
1073 alert(__("No articles are selected."));
1077 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1081 if (getActiveFeedId() != 0) {
1082 str
= ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows
.length
);
1085 str
= ngettext("Move %d archived article back?", "Move %d archived articles back?", rows
.length
);
1087 str
+= " " + __("Please note that unstarred articles might get purged on next feed update.");
1092 str
= str
.replace("%d", rows
.length
);
1093 str
= str
.replace("%s", fn
);
1095 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1099 query
= "?op=rpc&method="+op
+"&ids=" + param_escape(rows
);
1103 for (var i
= 0; i
< rows
.length
; i
++) {
1104 cache_delete("article:" + rows
[i
]);
1107 new Ajax
.Request("backend.php", {
1109 onComplete: function(transport
) {
1110 handle_rpc_json(transport
);
1115 exception_error("archiveSelection", e
);
1119 function catchupSelection() {
1123 var rows
= getSelectedArticleIds2();
1125 if (rows
.length
== 0) {
1126 alert(__("No articles are selected."));
1130 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1132 var str
= ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows
.length
);
1134 str
= str
.replace("%d", rows
.length
);
1135 str
= str
.replace("%s", fn
);
1137 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1141 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1144 exception_error("catchupSelection", e
);
1148 function editArticleTags(id
) {
1149 var query
= "backend.php?op=article&method=editArticleTags¶m=" + param_escape(id
);
1151 if (dijit
.byId("editTagsDlg"))
1152 dijit
.byId("editTagsDlg").destroyRecursive();
1154 dialog
= new dijit
.Dialog({
1156 title
: __("Edit article Tags"),
1157 style
: "width: 600px",
1158 execute: function() {
1159 if (this.validate()) {
1160 var query
= dojo
.objectToQuery(this.attr('value'));
1162 notify_progress("Saving article tags...", true);
1164 new Ajax
.Request("backend.php", {
1166 onComplete: function(transport
) {
1171 var data
= JSON
.parse(transport
.responseText
);
1178 var tags
= $("ATSTR-" + id
);
1179 var tooltip
= dijit
.byId("ATSTRTIP-" + id
);
1181 if (tags
) tags
.innerHTML
= data
.content
;
1182 if (tooltip
) tooltip
.attr('label', data
.content_full
);
1185 exception_error("editArticleTags/inner", e
);
1194 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1195 dojo
.disconnect(tmph
);
1197 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1198 "backend.php?op=article&method=completeTags",
1199 { tokens
: ',', paramName
: "search" });
1206 function cdmScrollToArticleId(id
, force
) {
1208 var ctr
= $("headlines-frame");
1209 var e
= $("RROW-" + id
);
1211 if (!e
|| !ctr
) return;
1213 if (force
|| e
.offsetTop
+e
.offsetHeight
> (ctr
.scrollTop
+ctr
.offsetHeight
) ||
1214 e
.offsetTop
< ctr
.scrollTop
) {
1216 // expanded cdm has a 4px margin now
1217 ctr
.scrollTop
= parseInt(e
.offsetTop
) - 4;
1221 exception_error("cdmScrollToArticleId", e
);
1225 function setActiveArticleId(id
) {
1226 _active_article_id
= id
;
1227 PluginHost
.run(PluginHost
.HOOK_ARTICLE_SET_ACTIVE
, _active_article_id
);
1230 function getActiveArticleId() {
1231 return _active_article_id
;
1234 function postMouseIn(e
, id
) {
1235 post_under_pointer
= id
;
1238 function postMouseOut(id
) {
1239 post_under_pointer
= false;
1242 function unpackVisibleHeadlines() {
1244 if (!isCdmMode()) return;
1246 $$("#headlines-frame > div[id*=RROW]").each(
1248 if (child
.offsetTop
<= $("headlines-frame").scrollTop
+
1249 $("headlines-frame").offsetHeight
) {
1251 var cencw
= $("CENCW-" + child
.id
.replace("RROW-", ""));
1254 PluginHost
.run(PluginHost
.HOOK_ARTICLE_RENDERED_CDM
, child
);
1256 cencw
.innerHTML
= htmlspecialchars_decode(cencw
.innerHTML
);
1257 cencw
.setAttribute('id', '');
1258 Element
.show(cencw
);
1265 exception_error("unpackVisibleHeadlines", e
);
1269 function headlines_scroll_handler(e
) {
1271 var hsp
= $("headlines-spacer");
1273 unpackVisibleHeadlines();
1275 // set topmost child in the buffer as active
1276 if (getInitParam("cdm_auto_catchup") == 1 &&
1277 (!isCdmMode() || getInitParam("cdm_expanded"))) {
1278 var rows
= $$("#headlines-frame > div[id*=RROW]");
1280 for (var i
= 0; i
< rows
.length
; i
++) {
1281 var child
= rows
[i
];
1283 if ($("headlines-frame").scrollTop
< child
.offsetTop
&&
1284 child
.offsetTop
- $("headlines-frame").scrollTop
< 100 &&
1285 child
.id
.replace("RROW-", "") != _active_article_id
) {
1287 if (_active_article_id
) {
1288 var row
= $("RROW-" + _active_article_id
);
1289 if (row
) row
.removeClassName("active");
1292 _active_article_id
= child
.id
.replace("RROW-", "");
1293 showArticleInHeadlines(_active_article_id
, true);
1294 updateSelectedPrompt();
1300 if (!_infscroll_disable
) {
1301 if ((hsp
&& e
.scrollTop
+ e
.offsetHeight
>= hsp
.offsetTop
- hsp
.offsetHeight
) ||
1302 (e
.scrollHeight
!= 0 &&
1303 ((e
.scrollTop
+ e
.offsetHeight
) / e
.scrollHeight
>= 0.7))) {
1306 hsp
.innerHTML
= "<img src='images/indicator_tiny.gif'> " +
1307 __("Loading, please wait...");
1309 loadMoreHeadlines();
1314 if (hsp
) hsp
.innerHTML
= "";
1317 if (getInitParam("cdm_expanded") && isCdmMode()) {
1318 updateFloatingTitle();
1321 if (getInitParam("cdm_auto_catchup") == 1) {
1323 // let's get DOM some time to settle down
1324 var ts
= new Date().getTime();
1325 if (ts
- _last_headlines_update
< 100) return;
1327 $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
1329 if (child
.hasClassName("Unread") && $("headlines-frame").scrollTop
>
1330 (child
.offsetTop
+ child
.offsetHeight
/2)) {
1332 var id
= child
.id
.replace("RROW-", "");
1334 if (catchup_id_batch
.indexOf(id
) == -1)
1335 catchup_id_batch
.push(id
);
1337 //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
1342 if (catchup_id_batch
.length
> 0) {
1343 window
.clearTimeout(catchup_timeout_id
);
1345 if (!_infscroll_request_sent
) {
1346 catchup_timeout_id
= window
.setTimeout('catchupBatchedArticles()',
1353 console
.warn("headlines_scroll_handler: " + e
);
1357 function catchupBatchedArticles() {
1359 if (catchup_id_batch
.length
> 0 && !_infscroll_request_sent
) {
1361 // make a copy of the array
1362 var batch
= catchup_id_batch
.slice();
1363 var query
= "?op=rpc&method=catchupSelected" +
1364 "&cmode=0&ids=" + param_escape(batch
.toString());
1368 new Ajax
.Request("backend.php", {
1370 onComplete: function(transport
) {
1371 handle_rpc_json(transport
);
1373 reply
= JSON
.parse(transport
.responseText
);
1374 var batch
= reply
.ids
;
1376 batch
.each(function(id
) {
1378 var elem
= $("RROW-" + id
);
1379 if (elem
) elem
.removeClassName("Unread");
1380 catchup_id_batch
.remove(id
);
1387 exception_error("catchupBatchedArticles", e
);
1391 function catchupRelativeToArticle(below
, id
) {
1395 if (!id
) id
= getActiveArticleId();
1398 alert(__("No article is selected."));
1402 var visible_ids
= getVisibleArticleIds();
1404 var ids_to_mark
= new Array();
1407 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1408 if (visible_ids
[i
] != id
) {
1409 var e
= $("RROW-" + visible_ids
[i
]);
1411 if (e
&& e
.hasClassName("Unread")) {
1412 ids_to_mark
.push(visible_ids
[i
]);
1419 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1420 if (visible_ids
[i
] != id
) {
1421 var e
= $("RROW-" + visible_ids
[i
]);
1423 if (e
&& e
.hasClassName("Unread")) {
1424 ids_to_mark
.push(visible_ids
[i
]);
1432 if (ids_to_mark
.length
== 0) {
1433 alert(__("No articles found to mark"));
1435 var msg
= ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark
.length
).replace("%d", ids_to_mark
.length
);
1437 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1439 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1440 var e
= $("RROW-" + ids_to_mark
[i
]);
1441 e
.removeClassName("Unread");
1444 var query
= "?op=rpc&method=catchupSelected" +
1445 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1447 new Ajax
.Request("backend.php", {
1449 onComplete: function(transport
) {
1450 handle_rpc_json(transport
);
1457 exception_error("catchupRelativeToArticle", e
);
1461 function cdmCollapseArticle(event
, id
, unmark
) {
1463 if (unmark
== undefined) unmark
= true;
1465 var row
= $("RROW-" + id
);
1466 var elem
= $("CICD-" + id
);
1469 var collapse
= $$("div#RROW-" + id
+
1470 " span[class='collapseBtn']")[0];
1473 Element
.show("CEXC-" + id
);
1474 Element
.hide(collapse
);
1477 row
.removeClassName("active");
1479 markHeadline(id
, false);
1481 if (id
== getActiveArticleId()) {
1482 setActiveArticleId(0);
1485 updateSelectedPrompt();
1488 if (event
) Event
.stop(event
);
1490 PluginHost
.run(PluginHost
.HOOK_ARTICLE_COLLAPSED
, id
);
1494 exception_error("cdmCollapseArticle", e
);
1498 function cdmExpandArticle(id
, noexpand
) {
1500 console
.log("cdmExpandArticle " + id
);
1502 if (!$("RROW-" + id
)) return false;
1504 var oldrow
= $("RROW-" + getActiveArticleId());
1506 var elem
= $("CICD-" + getActiveArticleId());
1508 if (id
== getActiveArticleId() && Element
.visible(elem
))
1511 selectArticles("none");
1513 var old_offset
= $("RROW-" + id
).offsetTop
;
1515 if (getActiveArticleId() && elem
&& !getInitParam("cdm_expanded")) {
1516 var collapse
= $$("div#RROW-" + getActiveArticleId() +
1517 " span[class='collapseBtn']")[0];
1520 Element
.show("CEXC-" + getActiveArticleId());
1521 Element
.hide(collapse
);
1524 if (oldrow
) oldrow
.removeClassName("active");
1526 setActiveArticleId(id
);
1528 elem
= $("CICD-" + id
);
1530 var collapse
= $$("div#RROW-" + id
+
1531 " span[class='collapseBtn']")[0];
1533 var cencw
= $("CENCW-" + id
);
1535 if (!Element
.visible(elem
) && !noexpand
) {
1537 cencw
.innerHTML
= htmlspecialchars_decode(cencw
.innerHTML
);
1538 cencw
.setAttribute('id', '');
1539 Element
.show(cencw
);
1543 Element
.hide("CEXC-" + id
);
1544 Element
.show(collapse
);
1547 var new_offset
= $("RROW-" + id
).offsetTop
;
1549 if (old_offset
> new_offset
)
1550 $("headlines-frame").scrollTop
-= (old_offset
-new_offset
);
1553 toggleUnread(id
, 0, true);
1555 $("RROW-" + id
).addClassName("active");
1557 PluginHost
.run(PluginHost
.HOOK_ARTICLE_EXPANDED
, id
);
1560 exception_error("cdmExpandArticle", e
);
1566 function getArticleUnderPointer() {
1567 return post_under_pointer
;
1570 function scrollArticle(offset
) {
1573 var ci
= $("content-insert");
1575 ci
.scrollTop
+= offset
;
1578 var hi
= $("headlines-frame");
1580 hi
.scrollTop
+= offset
;
1585 exception_error("scrollArticle", e
);
1589 function show_labels_in_headlines(transport
) {
1591 var data
= JSON
.parse(transport
.responseText
);
1594 data
['info-for-headlines'].each(function(elem
) {
1595 var ctr
= $("HLLCTR-" + elem
.id
);
1597 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1601 exception_error("show_labels_in_headlines", e
);
1605 function dismissArticle(id
) {
1607 var elem
= $("RROW-" + id
);
1611 toggleUnread(id
, 0, true);
1613 new Effect
.Fade(elem
, {duration
: 0.5});
1615 // Remove the content, too
1616 var elem_content
= $("CICD-" + id
);
1618 Element
.remove(elem_content
);
1621 if (id
== getActiveArticleId()) {
1622 setActiveArticleId(0);
1626 exception_error("dismissArticle", e
);
1630 function dismissSelectedArticles() {
1633 var ids
= getVisibleArticleIds();
1637 for (var i
= 0; i
< ids
.length
; i
++) {
1638 var elem
= $("RROW-" + ids
[i
]);
1640 if (elem
.className
&& elem
.hasClassName("Selected") &&
1641 ids
[i
] != getActiveArticleId()) {
1642 new Effect
.Fade(elem
, {duration
: 0.5});
1645 // Remove the content, too
1646 var elem_content
= $("CICD-" + ids
[i
]);
1648 Element
.remove(elem_content
);
1656 selectionToggleUnread(false);
1660 exception_error("dismissSelectedArticles", e
);
1664 function dismissReadArticles() {
1667 var ids
= getVisibleArticleIds();
1670 for (var i
= 0; i
< ids
.length
; i
++) {
1671 var elem
= $("RROW-" + ids
[i
]);
1673 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1674 !elem
.hasClassName("Selected")) {
1676 new Effect
.Fade(elem
, {duration
: 0.5});
1678 // Remove the content, too
1679 var elem_content
= $("CICD-" + ids
[i
]);
1681 Element
.remove(elem_content
);
1689 exception_error("dismissReadArticles", e
);
1693 function getVisibleArticleIds() {
1698 getLoadedArticleIds().each(function(id
) {
1699 var elem
= $("RROW-" + id
);
1700 if (elem
&& Element
.visible(elem
))
1705 exception_error("getVisibleArticleIds", e
);
1711 function cdmClicked(event
, id
) {
1713 //var shift_key = event.shiftKey;
1715 if (!event
.ctrlKey
) {
1717 if (!getInitParam("cdm_expanded")) {
1718 return cdmExpandArticle(id
);
1721 var elem
= $("RROW-" + getActiveArticleId());
1723 if (elem
) elem
.removeClassName("active");
1725 selectArticles("none");
1728 var elem
= $("RROW-" + id
);
1729 var article_is_unread
= elem
.hasClassName("Unread");
1731 elem
.removeClassName("Unread");
1732 elem
.addClassName("active");
1734 setActiveArticleId(id
);
1736 if (article_is_unread
) {
1737 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1740 var query
= "?op=rpc&method=catchupSelected" +
1741 "&cmode=0&ids=" + param_escape(id
);
1743 new Ajax
.Request("backend.php", {
1745 onComplete: function(transport
) {
1746 handle_rpc_json(transport
);
1749 return !event
.shiftKey
;
1753 toggleSelected(id
, true);
1755 var elem
= $("RROW-" + id
);
1756 var article_is_unread
= elem
.hasClassName("Unread");
1758 if (article_is_unread
) {
1759 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1762 toggleUnread(id
, 0, false);
1764 openArticleInNewWindow(id
);
1767 var unread_in_buffer
= $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
1768 request_counters(unread_in_buffer
== 0);
1771 exception_error("cdmClicked");
1777 function hlClicked(event
, id
) {
1779 if (event
.which
== 2) {
1782 } else if (event
.ctrlKey
) {
1783 toggleSelected(id
, true);
1784 toggleUnread(id
, 0, false);
1785 openArticleInNewWindow(id
);
1793 exception_error("hlClicked");
1797 function getFirstVisibleHeadlineId() {
1798 var rows
= getVisibleArticleIds();
1803 function getLastVisibleHeadlineId() {
1804 var rows
= getVisibleArticleIds();
1805 return rows
[rows
.length
-1];
1808 function openArticleInNewWindow(id
) {
1809 toggleUnread(id
, 0, false);
1810 window
.open("backend.php?op=article&method=redirect&id=" + id
);
1813 function isCdmMode() {
1814 return getInitParam("combined_display_mode");
1817 function markHeadline(id
, marked
) {
1818 if (marked
== undefined) marked
= true;
1820 var row
= $("RROW-" + id
);
1822 var check
= dijit
.getEnclosingWidget(
1823 row
.getElementsByClassName("rchk")[0]);
1826 check
.attr("checked", marked
);
1830 row
.addClassName("Selected");
1832 row
.removeClassName("Selected");
1836 function getRelativePostIds(id
, limit
) {
1842 if (!limit
) limit
= 6; //3
1844 var ids
= getVisibleArticleIds();
1846 for (var i
= 0; i
< ids
.length
; i
++) {
1848 for (var k
= 1; k
<= limit
; k
++) {
1849 //if (i > k-1) tmp.push(ids[i-k]);
1850 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
1857 exception_error("getRelativePostIds", e
);
1863 function correctHeadlinesOffset(id
) {
1867 var container
= $("headlines-frame");
1868 var row
= $("RROW-" + id
);
1870 if (!container
|| !row
) return;
1872 var viewport
= container
.offsetHeight
;
1874 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
1875 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
1877 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
1878 //console.log("Vport: " + viewport);
1880 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
1881 container
.scrollTop
= row
.offsetTop
;
1882 } else if (rel_offset_bottom
> viewport
) {
1884 /* doesn't properly work with Opera in some cases because
1885 Opera fucks up element scrolling */
1887 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
1891 exception_error("correctHeadlinesOffset", e
);
1896 function headlineActionsChange(elem
) {
1899 elem
.attr('value', 'false');
1901 exception_error("headlineActionsChange", e
);
1905 function closeArticlePanel() {
1907 if (dijit
.byId("content-insert"))
1908 dijit
.byId("headlines-wrap-inner").removeChild(
1909 dijit
.byId("content-insert"));
1912 function initHeadlinesMenu() {
1914 if (dijit
.byId("headlinesMenu"))
1915 dijit
.byId("headlinesMenu").destroyRecursive();
1920 nodes
= $$("#headlines-frame > div[id*=RROW]");
1922 nodes
= $$("#headlines-frame span[id*=RTITLE]");
1925 nodes
.each(function(node
) {
1929 var menu
= new dijit
.Menu({
1930 id
: "headlinesMenu",
1934 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
1935 var callerNode
= event
.target
, match
= null, tries
= 0;
1937 while (match
== null && callerNode
&& tries
<= 3) {
1938 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
1939 callerNode
= callerNode
.parentNode
;
1943 if (match
) this.callerRowId
= parseInt(match
[1]);
1947 /* if (!isCdmMode())
1948 menu.addChild(new dijit.MenuItem({
1949 label: __("View article"),
1950 onClick: function(event) {
1951 view(this.getParent().callerRowId);
1954 menu
.addChild(new dijit
.MenuItem({
1955 label
: __("Open original article"),
1956 onClick: function(event
) {
1957 openArticleInNewWindow(this.getParent().callerRowId
);
1960 menu
.addChild(new dijit
.MenuItem({
1961 label
: __("Display article URL"),
1962 onClick: function(event
) {
1963 displayArticleUrl(this.getParent().callerRowId
);
1966 menu
.addChild(new dijit
.MenuSeparator());
1968 menu
.addChild(new dijit
.MenuItem({
1969 label
: __("Toggle unread"),
1970 onClick: function(event
) {
1971 var ids
= getSelectedArticleIds2();
1973 var id
= this.getParent().callerRowId
+ "";
1974 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1976 selectionToggleUnread(undefined, false, true, ids
);
1979 menu
.addChild(new dijit
.MenuItem({
1980 label
: __("Toggle starred"),
1981 onClick: function(event
) {
1982 var ids
= getSelectedArticleIds2();
1984 var id
= this.getParent().callerRowId
+ "";
1985 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1987 selectionToggleMarked(undefined, false, true, ids
);
1990 menu
.addChild(new dijit
.MenuItem({
1991 label
: __("Toggle published"),
1992 onClick: function(event
) {
1993 var ids
= getSelectedArticleIds2();
1995 var id
= this.getParent().callerRowId
+ "";
1996 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1998 selectionTogglePublished(undefined, false, true, ids
);
2001 menu
.addChild(new dijit
.MenuSeparator());
2003 menu
.addChild(new dijit
.MenuItem({
2004 label
: __("Mark above as read"),
2005 onClick: function(event
) {
2006 catchupRelativeToArticle(0, this.getParent().callerRowId
);
2009 menu
.addChild(new dijit
.MenuItem({
2010 label
: __("Mark below as read"),
2011 onClick: function(event
) {
2012 catchupRelativeToArticle(1, this.getParent().callerRowId
);
2016 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2020 menu
.addChild(new dijit
.MenuSeparator());
2022 var labelAddMenu
= new dijit
.Menu({ownerMenu
: menu
});
2023 var labelDelMenu
= new dijit
.Menu({ownerMenu
: menu
});
2025 labels
.each(function(label
) {
2026 var id
= label
.id
[0];
2027 var bare_id
= id
.substr(id
.indexOf(":")+1);
2028 var name
= label
.name
[0];
2030 bare_id
= feed_to_label_id(bare_id
);
2032 labelAddMenu
.addChild(new dijit
.MenuItem({
2035 onClick: function(event
) {
2036 var ids
= getSelectedArticleIds2();
2038 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
2040 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
2042 selectionAssignLabel(this.labelId
, ids
);
2045 labelDelMenu
.addChild(new dijit
.MenuItem({
2048 onClick: function(event
) {
2049 var ids
= getSelectedArticleIds2();
2051 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
2053 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
2055 selectionRemoveLabel(this.labelId
, ids
);
2060 menu
.addChild(new dijit
.PopupMenuItem({
2061 label
: __("Assign label"),
2062 popup
: labelAddMenu
,
2065 menu
.addChild(new dijit
.PopupMenuItem({
2066 label
: __("Remove label"),
2067 popup
: labelDelMenu
,
2075 exception_error("initHeadlinesMenu", e
);
2079 function cache_set(id
, obj
) {
2080 //console.log("cache_set: " + id);
2083 sessionStorage
[id
] = obj
;
2085 sessionStorage
.clear();
2089 function cache_get(id
) {
2091 return sessionStorage
[id
];
2094 function cache_clear() {
2096 sessionStorage
.clear();
2099 function cache_delete(id
) {
2101 sessionStorage
.removeItem(id
);
2104 function cancelSearch() {
2109 exception_error("cancelSearch", e
);
2113 function setSelectionScore() {
2115 var ids
= getSelectedArticleIds2();
2117 if (ids
.length
> 0) {
2120 var score
= prompt(__("Please enter new score for selected articles:"), score
);
2122 if (score
!= undefined) {
2123 var query
= "op=article&method=setScore&id=" + param_escape(ids
.toString()) +
2124 "&score=" + param_escape(score
);
2126 new Ajax
.Request("backend.php", {
2128 onComplete: function(transport
) {
2129 var reply
= JSON
.parse(transport
.responseText
);
2133 ids
.each(function(id
) {
2134 var row
= $("RROW-" + id
);
2137 var pic
= row
.getElementsByClassName("hlScorePic")[0];
2140 pic
.src
= pic
.src
.replace(/score_.*?\.png/,
2141 reply
["score_pic"]);
2142 pic
.setAttribute("score", score
);
2151 alert(__("No articles are selected."));
2154 exception_error("setSelectionScore", e
);
2158 function changeScore(id
, pic
) {
2160 var score
= pic
.getAttribute("score");
2162 var new_score
= prompt(__("Please enter new score for this article:"), score
);
2164 if (new_score
!= undefined) {
2166 var query
= "op=article&method=setScore&id=" + param_escape(id
) +
2167 "&score=" + param_escape(new_score
);
2169 new Ajax
.Request("backend.php", {
2171 onComplete: function(transport
) {
2172 var reply
= JSON
.parse(transport
.responseText
);
2175 pic
.src
= pic
.src
.replace(/score_.*?\.png/, reply
["score_pic"]);
2176 pic
.setAttribute("score", new_score
);
2181 exception_error("changeScore", e
);
2185 function displayArticleUrl(id
) {
2187 var query
= "op=rpc&method=getlinktitlebyid&id=" + param_escape(id
);
2189 new Ajax
.Request("backend.php", {
2191 onComplete: function(transport
) {
2192 var reply
= JSON
.parse(transport
.responseText
);
2194 if (reply
&& reply
.link
) {
2195 prompt(__("Article URL:"), reply
.link
);
2199 exception_error("changeScore", e
);
2203 function openSelectedAttachment(elem
) {
2205 var url
= elem
[elem
.selectedIndex
].value
;
2209 elem
.selectedIndex
= 0;
2213 exception_error("openSelectedAttachment", e
);
2217 function updateFloatingTitle() {
2219 var hf
= $("headlines-frame");
2220 var child
= $("RROW-" + _active_article_id
);
2222 if (child
&& child
.offsetTop
+ child
.offsetHeight
> hf
.scrollTop
) {
2224 var header
= child
.getElementsByClassName("cdmHeader")[0];
2226 if (child
.id
!= $("floatingTitle").getAttribute("rowid")) {
2227 $("floatingTitle").setAttribute("rowid", child
.id
);
2228 $("floatingTitle").innerHTML
= header
.innerHTML
;
2230 PluginHost
.run(PluginHost
.HOOK_FLOATING_TITLE
, child
);
2233 if (child
.offsetTop
< hf
.scrollTop
- header
.offsetHeight
- 100 &&
2234 child
.offsetTop
+ child
.offsetHeight
- hf
.scrollTop
> 100)
2235 Element
.show("floatingTitle");
2237 Element
.hide("floatingTitle");
2241 exception_error("updateFloatingTitle", e
);