]>
git.wh0rd.org - tt-rss.git/blob - viewfeed.js
1 var active_post_id
= false;
2 var last_article_view
= false;
3 var active_real_feed_id
= false;
5 var _cdm_wd_timeout
= false;
6 var _cdm_wd_vishist
= new Array();
8 var article_cache
= new Array();
10 var vgroup_last_feed
= false;
11 var post_under_pointer
= false;
13 var last_requested_article
= false;
15 var preload_id_batch
= [];
16 var preload_timeout_id
= false;
20 function catchup_callback2(transport
, callback
) {
22 console
.log("catchup_callback2 " + transport
+ ", " + callback
);
24 handle_rpc_reply(transport
);
26 setTimeout(callback
, 10);
29 exception_error("catchup_callback2", e
, transport
);
33 function headlines_callback2(transport
, feed_cur_page
) {
36 if (!handle_rpc_reply(transport
)) return;
38 loading_set_progress(25);
40 console
.log("headlines_callback2 [page=" + feed_cur_page
+ "]");
42 if (!transport_error_check(transport
)) return;
47 if (transport
.responseXML
) {
48 var headlines
= transport
.responseXML
.getElementsByTagName("headlines")[0];
50 is_cat
= headlines
.getAttribute("is_cat");
51 feed_id
= headlines
.getAttribute("id");
52 setActiveFeedId(feed_id
, is_cat
);
56 var update_btn
= document
.forms
["main_toolbar_form"].update
;
58 update_btn
.disabled
= !(feed_id
>= 0 && !is_cat
);
61 if (feed_cur_page
== 0) {
62 $("headlines-frame").scrollTop
= 0;
66 if (transport
.responseXML
) {
67 var response
= transport
.responseXML
;
69 var headlines
= response
.getElementsByTagName("headlines")[0];
71 var headlines_content
= headlines
.getElementsByTagName("content")[0];
72 var headlines_toolbar
= headlines
.getElementsByTagName("toolbar")[0];
74 var headlines_info
= response
.getElementsByTagName("headlines-info")[0];
77 headlines_info
= JSON
.parse(headlines_info
.firstChild
.nodeValue
);
79 console
.error("didn't find headlines-info object in response");
83 var headlines_count
= headlines_info
.count
;
84 var headlines_unread
= headlines_info
.unread
;
85 var disable_cache
= headlines_info
.disable_cache
;
87 vgroup_last_feed
= headlines_info
.vgroup_last_feed
;
89 if (parseInt(headlines_count
) < getInitParam("default_article_limit")) {
90 _infscroll_disable
= 1;
92 _infscroll_disable
= 0;
95 var counters
= response
.getElementsByTagName("counters")[0];
96 var articles
= response
.getElementsByTagName("article");
97 var runtime_info
= response
.getElementsByTagName("runtime-info");
99 if (feed_cur_page
== 0) {
101 dijit
.byId("headlines-frame").attr('content',
102 headlines_content
.firstChild
.nodeValue
);
104 dijit
.byId("headlines-toolbar").attr('content',
105 headlines_toolbar
.firstChild
.nodeValue
);
109 var cache_prefix
= "";
117 cache_invalidate(cache_prefix
+ feed_id
);
119 if (!disable_cache
) {
120 cache_inject(cache_prefix
+ feed_id
,
121 $("headlines-frame").innerHTML
, headlines_unread
);
125 console
.warn("headlines_callback: returned no data");
126 dijit
.byId("headlines-frame").attr('content',
127 "<div class='whiteBox'>" +
128 __('Could not update headlines (missing XML data)') + "</div>");
133 if (headlines_count
> 0) {
134 console
.log("adding some more headlines...");
136 var c
= dijit
.byId("headlines-frame");
137 var ids
= getSelectedArticleIds2();
139 c
.attr('content', c
.attr('content') +
140 headlines_content
.firstChild
.nodeValue
);
142 console
.log("restore selected ids: " + ids
);
144 for (var i
= 0; i
< ids
.length
; i
++) {
145 markHeadline(ids
[i
]);
151 console
.log("no new headlines received");
154 console
.warn("headlines_callback: returned no data");
155 notify_error("Error while trying to load more headlines");
161 for (var i
= 0; i
< articles
.length
; i
++) {
162 var a_id
= articles
[i
].getAttribute("id");
163 //console.log("found id: " + a_id);
164 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
167 console
.log("no cached articles received");
171 parse_counters(counters
);
176 parse_runtime_info(runtime_info
[0]);
180 console
.warn("headlines_callback: returned no XML object");
181 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
182 __('Could not update headlines (missing XML object)') + "</div>");
186 if (_cdm_wd_timeout
) window
.clearTimeout(_cdm_wd_timeout
);
189 getActiveFeedId() != -3 &&
190 getInitParam("cdm_auto_catchup") == 1) {
191 console
.log("starting CDM watchdog");
192 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 5000);
193 _cdm_wd_vishist
= new Array();
195 console
.log("not in CDM mode or watchdog disabled");
198 _feed_cur_page
= feed_cur_page
;
199 _infscroll_request_sent
= 0;
204 exception_error("headlines_callback2", e
, transport
);
208 function render_article(article
) {
210 dijit
.byId("headlines-wrap-inner").addChild(
211 dijit
.byId("content-insert"));
213 var c
= dijit
.byId("content-insert");
216 c
.domNode
.scrollTop
= 0;
219 c
.attr('content', article
);
221 correctHeadlinesOffset(getActiveArticleId());
224 exception_error("render_article", e
);
228 function showArticleInHeadlines(id
) {
232 selectArticles("none");
234 var crow
= $("RROW-" + id
);
238 var article_is_unread
= crow
.hasClassName("Unread");
240 crow
.removeClassName("Unread");
242 selectArticles('none');
244 var upd_img_pic
= $("FUPDPIC-" + id
);
246 var cache_prefix
= "";
248 if (activeFeedIsCat()) {
254 var view_mode
= false;
257 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
258 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
263 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
264 upd_img_pic
.src
.match("fresh_sign.png"))) {
266 upd_img_pic
.src
= "images/blank_icon.gif";
268 cache_invalidate(cache_prefix
+ getActiveFeedId());
270 cache_inject(cache_prefix
+ getActiveFeedId(),
271 $("headlines-frame").innerHTML
,
272 getFeedUnread(getActiveFeedId()));
274 } else if (article_is_unread
&& view_mode
== "all_articles") {
276 cache_invalidate(cache_prefix
+ getActiveFeedId());
278 cache_inject(cache_prefix
+ getActiveFeedId(),
279 $("headlines-frame").innerHTML
,
280 getFeedUnread(getActiveFeedId())-1);
282 } else if (article_is_unread
) {
283 cache_invalidate(cache_prefix
+ getActiveFeedId());
288 if (article_is_unread
)
289 _force_scheduled_update
= true;
292 exception_error("showArticleInHeadlines", e
);
296 function article_callback2(transport
, id
) {
298 console
.log("article_callback2 " + id
);
300 if (!handle_rpc_reply(transport
)) return;
302 if (transport
.responseXML
) {
304 if (!transport_error_check(transport
)) return;
306 var upic
= $('FUPDPIC-' + id
);
309 upic
.src
= 'images/blank_icon.gif';
312 if (id
!= last_requested_article
) {
313 console
.log("requested article id is out of sequence, aborting");
317 // active_post_id = id;
319 //console.log("looking for articles to cache...");
321 var articles
= transport
.responseXML
.getElementsByTagName("article");
323 for (var i
= 0; i
< articles
.length
; i
++) {
324 var a_id
= articles
[i
].getAttribute("id");
326 //console.log("found id: " + a_id);
328 if (a_id
== active_post_id
) {
329 //console.log("active article, rendering...");
330 render_article(articles
[i
].firstChild
.nodeValue
);
333 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
337 // showArticleInHeadlines(id);
339 var reply
= transport
.responseXML
.firstChild
.firstChild
;
342 console
.warn("article_callback: returned no XML object");
343 //var f = $("content-frame");
344 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
347 var date
= new Date();
348 last_article_view
= date
.getTime() / 1000;
354 exception_error("article_callback2", e
, transport
);
360 console
.log("loading article: " + id
);
362 var cached_article
= cache_find(id
);
364 console
.log("cache check result: " + (cached_article
!= false));
368 var query
= "?op=view&id=" + param_escape(id
);
370 var neighbor_ids
= getRelativePostIds(active_post_id
);
372 /* only request uncached articles */
374 var cids_to_request
= Array();
376 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
377 if (!cache_check(neighbor_ids
[i
])) {
378 cids_to_request
.push(neighbor_ids
[i
]);
382 console
.log("additional ids: " + cids_to_request
.toString());
384 query
= query
+ "&cids=" + cids_to_request
.toString();
386 var crow
= $("RROW-" + id
);
387 var article_is_unread
= crow
.hasClassName("Unread");
390 showArticleInHeadlines(id
);
392 if (!cached_article
) {
394 var upic
= $('FUPDPIC-' + id
);
397 upic
.src
= getInitParam("sign_progress");
400 } else if (cached_article
&& article_is_unread
) {
402 query
= query
+ "&mode=prefetch";
404 render_article(cached_article
);
406 } else if (cached_article
) {
408 query
= query
+ "&mode=prefetch_old";
409 render_article(cached_article
);
415 last_requested_article
= id
;
417 new Ajax
.Request("backend.php", {
419 onComplete: function(transport
) {
420 article_callback2(transport
, id
);
426 exception_error("view", e
);
431 return toggleMark(id
);
435 return togglePub(id
);
438 function toggleMark(id
, client_only
) {
440 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
442 var img
= $("FMPIC-" + id
);
446 if (img
.src
.match("mark_unset")) {
447 img
.src
= img
.src
.replace("mark_unset", "mark_set");
448 img
.alt
= __("Unstar article");
449 query
= query
+ "&mark=1";
452 img
.src
= img
.src
.replace("mark_set", "mark_unset");
453 img
.alt
= __("Star article");
454 query
= query
+ "&mark=0";
458 new Ajax
.Request("backend.php", {
460 onComplete: function(transport
) {
461 handle_rpc_reply(transport
);
466 exception_error("toggleMark", e
);
470 function togglePub(id
, client_only
, no_effects
, note
) {
472 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
474 if (note
!= undefined) {
475 query
= query
+ "¬e=" + param_escape(note
);
477 query
= query
+ "¬e=undefined";
480 var img
= $("FPPIC-" + id
);
484 if (img
.src
.match("pub_unset") || note
!= undefined) {
485 img
.src
= img
.src
.replace("pub_unset", "pub_set");
486 img
.alt
= __("Unpublish article");
487 query
= query
+ "&pub=1";
490 img
.src
= img
.src
.replace("pub_set", "pub_unset");
491 img
.alt
= __("Publish article");
493 query
= query
+ "&pub=0";
497 new Ajax
.Request("backend.php", {
499 onComplete: function(transport
) {
500 handle_rpc_reply(transport
);
502 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
505 var note_id
= note
.getAttribute("id");
506 var note_size
= note
.getAttribute("size");
507 var note_content
= note
.firstChild
.nodeValue
;
509 var container
= $('POSTNOTE-' + note_id
);
511 cache_invalidate(note_id
);
514 if (note_size
== "0") {
515 Element
.hide(container
);
517 container
.innerHTML
= note_content
;
518 Element
.show(container
);
527 exception_error("togglePub", e
);
531 function moveToPost(mode
) {
535 var rows
= getVisibleArticleIds();
540 if (!$('RROW-' + active_post_id
)) {
541 active_post_id
= false;
544 if (active_post_id
== false) {
545 next_id
= getFirstVisibleHeadlineId();
546 prev_id
= getLastVisibleHeadlineId();
548 for (var i
= 0; i
< rows
.length
; i
++) {
549 if (rows
[i
] == active_post_id
) {
556 if (mode
== "next") {
560 cdmExpandArticle(next_id
);
561 cdmScrollToArticleId(next_id
);
564 correctHeadlinesOffset(next_id
);
565 view(next_id
, getActiveFeedId());
570 if (mode
== "prev") {
573 cdmExpandArticle(prev_id
);
574 cdmScrollToArticleId(prev_id
);
576 correctHeadlinesOffset(prev_id
);
577 view(prev_id
, getActiveFeedId());
583 exception_error("moveToPost", e
);
587 function toggleSelected(id
, force_on
) {
590 var cb
= $("RCHK-" + id
);
591 var row
= $("RROW-" + id
);
594 if (row
.hasClassName('Selected') && !force_on
) {
595 row
.removeClassName('Selected');
596 if (cb
) cb
.checked
= false;
598 row
.addClassName('Selected');
599 if (cb
) cb
.checked
= true;
603 exception_error("toggleSelected", e
);
607 function toggleUnread_afh(effect
) {
610 var elem
= effect
.element
;
611 elem
.style
.backgroundColor
= "";
614 exception_error("toggleUnread_afh", e
);
618 function toggleUnread(id
, cmode
, effect
) {
621 var row
= $("RROW-" + id
);
623 if (cmode
== undefined || cmode
== 2) {
624 if (row
.hasClassName("Unread")) {
625 row
.removeClassName("Unread");
628 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
629 afterFinish
: toggleUnread_afh
,
630 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
634 row
.addClassName("Unread");
637 } else if (cmode
== 0) {
639 row
.removeClassName("Unread");
642 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
643 afterFinish
: toggleUnread_afh
,
644 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
647 } else if (cmode
== 1) {
648 row
.addClassName("Unread");
651 if (cmode
== undefined) cmode
= 2;
653 var query
= "?op=rpc&subop=catchupSelected" +
654 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
656 // notify_progress("Loading, please wait...");
658 new Ajax
.Request("backend.php", {
660 onComplete: function(transport
) {
661 handle_rpc_reply(transport
);
667 exception_error("toggleUnread", e
);
671 function selectionRemoveLabel(id
, ids
) {
674 if (!ids
) var ids
= getSelectedArticleIds2();
676 if (ids
.length
== 0) {
677 alert(__("No articles are selected."));
681 // var ok = confirm(__("Remove selected articles from label?"));
685 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
686 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
690 // notify_progress("Loading, please wait...");
692 cache_invalidate("F:" + (-11 - id
));
694 new Ajax
.Request("backend.php", {
696 onComplete: function(transport
) {
697 show_labels_in_headlines(transport
);
698 handle_rpc_reply(transport
);
704 exception_error("selectionAssignLabel", e
);
709 function selectionAssignLabel(id
, ids
) {
712 if (!ids
) ids
= getSelectedArticleIds2();
714 if (ids
.length
== 0) {
715 alert(__("No articles are selected."));
719 // var ok = confirm(__("Assign selected articles to label?"));
723 cache_invalidate("F:" + (-11 - id
));
725 var query
= "?op=rpc&subop=assignToLabel&ids=" +
726 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
730 // notify_progress("Loading, please wait...");
732 new Ajax
.Request("backend.php", {
734 onComplete: function(transport
) {
735 show_labels_in_headlines(transport
);
736 handle_rpc_reply(transport
);
742 exception_error("selectionAssignLabel", e
);
747 function selectionToggleUnread(set_state
, callback_func
, no_error
) {
749 var rows
= getSelectedArticleIds2();
751 if (rows
.length
== 0 && !no_error
) {
752 alert(__("No articles are selected."));
756 for (i
= 0; i
< rows
.length
; i
++) {
757 var row
= $("RROW-" + rows
[i
]);
759 if (set_state
== undefined) {
760 if (row
.hasClassName("Unread")) {
761 row
.removeClassName("Unread");
763 row
.addClassName("Unread");
767 if (set_state
== false) {
768 row
.removeClassName("Unread");
771 if (set_state
== true) {
772 row
.addClassName("Unread");
777 if (rows
.length
> 0) {
781 if (set_state
== undefined) {
783 } else if (set_state
== true) {
785 } else if (set_state
== false) {
789 var query
= "?op=rpc&subop=catchupSelected" +
790 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
792 notify_progress("Loading, please wait...");
794 new Ajax
.Request("backend.php", {
796 onComplete: function(transport
) {
797 catchup_callback2(transport
, callback_func
);
803 exception_error("selectionToggleUnread", e
);
807 function selectionToggleMarked() {
810 var rows
= getSelectedArticleIds2();
812 if (rows
.length
== 0) {
813 alert(__("No articles are selected."));
817 for (i
= 0; i
< rows
.length
; i
++) {
818 toggleMark(rows
[i
], true, true);
821 if (rows
.length
> 0) {
823 var query
= "?op=rpc&subop=markSelected&ids=" +
824 param_escape(rows
.toString()) + "&cmode=2";
826 new Ajax
.Request("backend.php", {
828 onComplete: function(transport
) {
829 handle_rpc_reply(transport
);
835 exception_error("selectionToggleMarked", e
);
839 function selectionTogglePublished() {
842 var rows
= getSelectedArticleIds2();
844 if (rows
.length
== 0) {
845 alert(__("No articles are selected."));
849 for (i
= 0; i
< rows
.length
; i
++) {
850 togglePub(rows
[i
], true, true);
853 if (rows
.length
> 0) {
855 var query
= "?op=rpc&subop=publishSelected&ids=" +
856 param_escape(rows
.toString()) + "&cmode=2";
858 new Ajax
.Request("backend.php", {
860 onComplete: function(transport
) {
861 handle_rpc_reply(transport
);
867 exception_error("selectionToggleMarked", e
);
871 function getSelectedArticleIds2() {
875 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
877 rv
.push(child
.id
.replace("RROW-", ""));
883 function getLoadedArticleIds() {
886 var children
= $$("#headlines-frame > div[id*=RROW-]");
888 children
.each(function(child
) {
889 rv
.push(child
.id
.replace("RROW-", ""));
896 // mode = all,none,unread,invert
897 function selectArticles(mode
) {
900 var children
= $$("#headlines-frame > div[id*=RROW]");
902 children
.each(function(child
) {
903 var id
= child
.id
.replace("RROW-", "");
904 var cb
= $("RCHK-" + id
);
907 child
.addClassName("Selected");
909 } else if (mode
== "unread") {
910 if (child
.hasClassName("Unread")) {
911 child
.addClassName("Selected");
914 child
.removeClassName("Selected");
917 } else if (mode
== "invert") {
918 if (child
.hasClassName("Selected")) {
919 child
.removeClassName("Selected");
922 child
.addClassName("Selected");
927 child
.removeClassName("Selected");
933 exception_error("selectArticles", e
);
937 function catchupPage() {
939 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
941 var str
= __("Mark all visible articles in %s as read?");
943 str
= str
.replace("%s", fn
);
945 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
949 selectArticles('all');
950 selectionToggleUnread(false, 'viewCurrentFeed()', true)
951 selectArticles('none');
954 function deleteSelection() {
958 var rows
= getSelectedArticleIds2();
960 if (rows
.length
== 0) {
961 alert(__("No articles are selected."));
965 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
969 if (getActiveFeedId() != 0) {
970 str
= __("Delete %d selected articles in %s?");
972 str
= __("Delete %d selected articles?");
975 str
= str
.replace("%d", rows
.length
);
976 str
= str
.replace("%s", fn
);
978 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
982 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
986 new Ajax
.Request("backend.php", {
988 onComplete: function(transport
) {
993 exception_error("deleteSelection", e
);
997 function archiveSelection() {
1001 var rows
= getSelectedArticleIds2();
1003 if (rows
.length
== 0) {
1004 alert(__("No articles are selected."));
1008 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1012 if (getActiveFeedId() != 0) {
1013 str
= __("Archive %d selected articles in %s?");
1016 str
= __("Move %d archived articles back?");
1020 str
= str
.replace("%d", rows
.length
);
1021 str
= str
.replace("%s", fn
);
1023 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1027 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1031 for (var i
= 0; i
< rows
.length
; i
++) {
1032 cache_invalidate(rows
[i
]);
1035 new Ajax
.Request("backend.php", {
1037 onComplete: function(transport
) {
1042 exception_error("archiveSelection", e
);
1046 function catchupSelection() {
1050 var rows
= getSelectedArticleIds2();
1052 if (rows
.length
== 0) {
1053 alert(__("No articles are selected."));
1057 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1059 var str
= __("Mark %d selected articles in %s as read?");
1061 str
= str
.replace("%d", rows
.length
);
1062 str
= str
.replace("%s", fn
);
1064 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1068 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1071 exception_error("catchupSelection", e
);
1075 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1076 displayDlg('editArticleTags', id
,
1078 $("tags_str").focus();
1080 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1081 "backend.php?op=rpc&subop=completeTags",
1082 { tokens
: ',', paramName
: "search" });
1086 function editTagsSave() {
1088 notify_progress("Saving article tags...");
1090 var form
= document
.forms
["tag_edit_form"];
1092 var query
= Form
.serialize("tag_edit_form");
1094 query
= "?op=rpc&subop=setArticleTags&" + query
;
1098 new Ajax
.Request("backend.php", {
1100 onComplete: function(transport
) {
1102 //console.log("tags saved...");
1107 if (transport
.responseXML
) {
1108 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1111 var id
= tags_str
.getAttribute("id");
1114 var tags
= $("ATSTR-" + id
);
1116 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1119 cache_invalidate(id
);
1125 exception_error("editTagsSave", e
);
1130 function editTagsInsert() {
1133 var form
= document
.forms
["tag_edit_form"];
1135 var found_tags
= form
.found_tags
;
1136 var tags_str
= form
.tags_str
;
1138 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1140 if (tags_str
.value
.length
> 0 &&
1141 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1143 tags_str
.value
= tags_str
.value
+ ", ";
1146 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1148 found_tags
.selectedIndex
= 0;
1151 exception_error("editTagsInsert", e
);
1155 function cdmScrollToArticleId(id
) {
1157 var ctr
= $("headlines-frame");
1158 var e
= $("RROW-" + id
);
1160 if (!e
|| !ctr
) return;
1162 ctr
.scrollTop
= e
.offsetTop
;
1165 exception_error("cdmScrollToArticleId", e
);
1169 function cdmWatchdog() {
1173 var ctr
= $("headlines-frame");
1177 var ids
= new Array();
1179 var e
= ctr
.firstChild
;
1182 if (e
.className
&& e
.hasClassName("Unread") && e
.id
&&
1183 e
.id
.match("RROW-")) {
1185 // article fits in viewport OR article is longer than viewport and
1186 // its bottom is visible
1188 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1189 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1191 // console.log(e.id + " is visible " + e.offsetTop + "." +
1192 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1193 // (ctr.scrollTop + ctr.offsetHeight));
1195 ids
.push(e
.id
.replace("RROW-", ""));
1197 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1198 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1199 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1201 ids
.push(e
.id
.replace("RROW-", ""));
1205 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1207 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1208 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1210 ids.push(e.id.replace("RROW-", ""));
1219 console
.log("cdmWatchdog, ids= " + ids
.toString());
1221 if (ids
.length
> 0) {
1223 for (var i
= 0; i
< ids
.length
; i
++) {
1224 var e
= $("RROW-" + ids
[i
]);
1226 e
.removeClassName("Unread");
1230 var query
= "?op=rpc&subop=catchupSelected" +
1231 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1233 new Ajax
.Request("backend.php", {
1235 onComplete: function(transport
) {
1236 handle_rpc_reply(transport
);
1241 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1244 exception_error("cdmWatchdog", e
);
1250 function cache_inject(id
, article
, param
) {
1253 if (!cache_check_param(id
, param
)) {
1254 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1256 var date
= new Date();
1257 var ts
= Math
.round(date
.getTime() / 1000);
1261 cache_obj
["id"] = id
;
1262 cache_obj
["data"] = article
;
1263 cache_obj
["param"] = param
;
1265 if (param
) id
= id
+ ":" + param
;
1267 cache_added
["TS:" + id
] = ts
;
1269 if (has_local_storage())
1270 sessionStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1272 article_cache
.push(cache_obj
);
1275 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1278 exception_error("cache_inject", e
);
1282 function cache_find(id
) {
1284 if (has_local_storage()) {
1285 var cache_obj
= sessionStorage
.getItem(id
);
1288 cache_obj
= JSON
.parse(cache_obj
);
1291 return cache_obj
['data'];
1295 for (var i
= 0; i
< article_cache
.length
; i
++) {
1296 if (article_cache
[i
]["id"] == id
) {
1297 return article_cache
[i
]["data"];
1304 function cache_find_param(id
, param
) {
1306 if (has_local_storage()) {
1308 if (param
) id
= id
+ ":" + param
;
1310 var cache_obj
= sessionStorage
.getItem(id
);
1313 cache_obj
= JSON
.parse(cache_obj
);
1316 return cache_obj
['data'];
1320 for (var i
= 0; i
< article_cache
.length
; i
++) {
1321 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1322 return article_cache
[i
]["data"];
1330 function cache_check(id
) {
1331 if (has_local_storage()) {
1332 if (sessionStorage
.getItem(id
))
1335 for (var i
= 0; i
< article_cache
.length
; i
++) {
1336 if (article_cache
[i
]["id"] == id
) {
1344 function cache_check_param(id
, param
) {
1345 if (has_local_storage()) {
1347 if (param
) id
= id
+ ":" + param
;
1349 if (sessionStorage
.getItem(id
))
1353 for (var i
= 0; i
< article_cache
.length
; i
++) {
1354 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1362 function cache_expire() {
1363 if (has_local_storage()) {
1365 var date
= new Date();
1366 var timestamp
= Math
.round(date
.getTime() / 1000);
1368 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1370 var id
= sessionStorage
.key(i
);
1372 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1373 sessionStorage
.removeItem(id
);
1378 while (article_cache
.length
> 25) {
1379 article_cache
.shift();
1384 function cache_flush() {
1385 if (has_local_storage()) {
1386 sessionStorage
.clear();
1388 article_cache
= new Array();
1392 function cache_invalidate(id
) {
1394 if (has_local_storage()) {
1398 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1399 var key
= sessionStorage
.key(i
);
1401 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1403 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1404 sessionStorage
.removeItem(key
);
1415 while (i
< article_cache
.length
) {
1416 if (article_cache
[i
]["id"] == id
) {
1417 //console.log("cache_invalidate: removed id " + id);
1418 article_cache
.splice(i
, 1);
1425 //console.log("cache_invalidate: id not found: " + id);
1428 exception_error("cache_invalidate", e
);
1432 function getActiveArticleId() {
1433 return active_post_id
;
1436 function preloadBatchedArticles() {
1439 var query
= "?op=rpc&subop=getArticles&ids=" +
1440 preload_id_batch
.toString();
1442 new Ajax
.Request("backend.php", {
1444 onComplete: function(transport
) {
1446 preload_id_batch
= [];
1448 var articles
= transport
.responseXML
.getElementsByTagName("article");
1450 for (var i
= 0; i
< articles
.length
; i
++) {
1451 var id
= articles
[i
].getAttribute("id");
1452 if (!cache_check(id
)) {
1453 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1454 console
.log("preloaded article: " + id
);
1460 exception_error("preloadBatchedArticles", e
);
1464 function preloadArticleUnderPointer(id
) {
1466 if (getInitParam("bw_limit") == "1") return;
1468 if (post_under_pointer
== id
&& !cache_check(id
)) {
1470 console
.log("trying to preload article " + id
);
1472 var neighbor_ids
= getRelativePostIds(id
, 1);
1474 /* only request uncached articles */
1476 if (preload_id_batch
.indexOf(id
) == -1) {
1477 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1478 if (!cache_check(neighbor_ids
[i
])) {
1479 preload_id_batch
.push(neighbor_ids
[i
]);
1484 if (preload_id_batch
.indexOf(id
) == -1)
1485 preload_id_batch
.push(id
);
1487 //console.log("preload ids batch: " + preload_id_batch.toString());
1489 window
.clearTimeout(preload_timeout_id
);
1490 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1494 exception_error("preloadArticleUnderPointer", e
);
1498 function postMouseIn(id
) {
1500 if (post_under_pointer
!= id
) {
1501 post_under_pointer
= id
;
1503 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1508 exception_error("postMouseIn", e
);
1512 function postMouseOut(id
) {
1514 post_under_pointer
= false;
1516 exception_error("postMouseOut", e
);
1520 function headlines_scroll_handler(e
) {
1523 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1524 if (!_infscroll_disable
) {
1530 exception_error("headlines_scroll_handler", e
);
1534 function catchupRelativeToArticle(below
) {
1539 if (!getActiveArticleId()) {
1540 alert(__("No article is selected."));
1544 var visible_ids
= getVisibleArticleIds();
1546 var ids_to_mark
= new Array();
1549 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1550 if (visible_ids
[i
] != getActiveArticleId()) {
1551 var e
= $("RROW-" + visible_ids
[i
]);
1553 if (e
&& e
.hasClassName("Unread")) {
1554 ids_to_mark
.push(visible_ids
[i
]);
1561 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1562 if (visible_ids
[i
] != getActiveArticleId()) {
1563 var e
= $("RROW-" + visible_ids
[i
]);
1565 if (e
&& e
.hasClassName("Unread")) {
1566 ids_to_mark
.push(visible_ids
[i
]);
1574 if (ids_to_mark
.length
== 0) {
1575 alert(__("No articles found to mark"));
1577 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1579 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1581 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1582 var e
= $("RROW-" + ids_to_mark
[i
]);
1583 e
.removeClassName("Unread");
1586 var query
= "?op=rpc&subop=catchupSelected" +
1587 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1589 new Ajax
.Request("backend.php", {
1591 onComplete: function(transport
) {
1592 catchup_callback2(transport
);
1599 exception_error("catchupRelativeToArticle", e
);
1603 function cdmExpandArticle(id
) {
1608 var elem
= $("CICD-" + active_post_id
);
1610 var upd_img_pic
= $("FUPDPIC-" + id
);
1612 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1613 upd_img_pic
.src
.match("fresh_sign.png"))) {
1615 upd_img_pic
.src
= "images/blank_icon.gif";
1618 if (id
== active_post_id
&& Element
.visible(elem
))
1621 selectArticles("none");
1623 var old_offset
= $("RROW-" + id
).offsetTop
;
1625 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1627 Element
.show("CEXC-" + active_post_id
);
1630 active_post_id
= id
;
1632 elem
= $("CICD-" + id
);
1634 if (!Element
.visible(elem
)) {
1636 Element
.hide("CEXC-" + id
);
1638 if ($("CWRAP-" + id
).innerHTML
== "") {
1640 $("FUPDPIC-" + id
).src
= "images/indicator_tiny.gif";
1642 $("CWRAP-" + id
).innerHTML
= "<div class=\"insensitive\">" +
1643 __("Loading, please wait...") + "</div>";
1645 var query
= "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id
);
1647 //console.log(query);
1649 new Ajax
.Request("backend.php", {
1651 onComplete: function(transport
) {
1652 $("FUPDPIC-" + id
).src
= 'images/blank_icon.gif';
1654 if (transport
.responseXML
) {
1655 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1656 var recv_id
= article
.getAttribute("id");
1659 $("CWRAP-" + id
).innerHTML
= article
.firstChild
.nodeValue
;
1662 $("CWRAP-" + id
).innerHTML
= __("Unable to load article.");
1670 var new_offset
= $("RROW-" + id
).offsetTop
;
1672 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1674 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1675 $("headlines-frame").scrollTop
= new_offset
;
1677 toggleUnread(id
, 0, true);
1681 exception_error("cdmExpandArticle", e
);
1687 function fixHeadlinesOrder(ids
) {
1689 for (var i
= 0; i
< ids
.length
; i
++) {
1690 var e
= $("RROW-" + ids
[i
]);
1694 e
.removeClassName("even");
1695 e
.addClassName("odd");
1697 e
.removeClassName("odd");
1698 e
.addClassName("even");
1703 exception_error("fixHeadlinesOrder", e
);
1707 function getArticleUnderPointer() {
1708 return post_under_pointer
;
1711 function zoomToArticle(event
, id
) {
1713 var cached_article
= cache_find(id
);
1715 if (dijit
.byId("ATAB-" + id
))
1716 if (!event
|| !event
.shiftKey
)
1717 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1719 if (cached_article
) {
1720 //closeArticlePanel();
1722 var article_pane
= new dijit
.layout
.ContentPane({
1723 title
: __("Loading...") , content
: cached_article
,
1724 style
: 'padding : 0px;',
1728 dijit
.byId("content-tabs").addChild(article_pane
);
1730 if (!event
|| !event
.shiftKey
)
1731 dijit
.byId("content-tabs").selectChild(article_pane
);
1733 if ($("PTITLE-" + id
))
1734 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1738 var query
= "?op=rpc&subop=getArticles&ids=" + param_escape(id
);
1740 notify_progress("Loading, please wait...", true);
1742 new Ajax
.Request("backend.php", {
1744 onComplete: function(transport
) {
1747 if (transport
.responseXML
) {
1748 //closeArticlePanel();
1750 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1751 var content
= article
.firstChild
.nodeValue
;
1753 var article_pane
= new dijit
.layout
.ContentPane({
1754 title
: "article-" + id
, content
: content
,
1755 style
: 'padding : 0px;',
1759 dijit
.byId("content-tabs").addChild(article_pane
);
1761 if (!event
|| !event
.shiftKey
)
1762 dijit
.byId("content-tabs").selectChild(article_pane
);
1764 if ($("PTITLE-" + id
))
1765 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1772 exception_error("zoomToArticle", e
);
1776 function scrollArticle(offset
) {
1779 var ci
= $("content-insert");
1781 ci
.scrollTop
+= offset
;
1784 var hi
= $("headlines-frame");
1786 hi
.scrollTop
+= offset
;
1791 exception_error("scrollArticle", e
);
1795 function show_labels_in_headlines(transport
) {
1797 if (transport
.responseXML
) {
1798 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
1800 var elems
= info
.getElementsByTagName("entry");
1802 for (var l
= 0; l
< elems
.length
; l
++) {
1803 var e_id
= elems
[l
].getAttribute("id");
1807 var ctr
= $("HLLCTR-" + e_id
);
1810 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
1818 exception_error("show_labels_in_headlines", e
);
1823 function toggleHeadlineActions() {
1825 var e
= $("headlineActionsBody");
1826 var p
= $("headlineActionsDrop");
1828 if (!Element
.visible(e
)) {
1835 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
1836 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
1839 exception_error("toggleHeadlineActions", e
);
1843 function publishWithNote(id
, def_note
) {
1845 if (!def_note
) def_note
= '';
1847 var note
= prompt(__("Please enter a note for this article:"), def_note
);
1849 if (note
!= undefined) {
1850 togglePub(id
, false, false, note
);
1854 exception_error("publishWithNote", e
);
1858 function emailArticle(id
) {
1861 var ids
= getSelectedArticleIds2();
1863 if (ids
.length
== 0) {
1864 alert(__("No articles are selected."));
1868 id
= ids
.toString();
1871 if (dijit
.byId("emailArticleDlg"))
1872 dijit
.byId("emailArticleDlg").destroyRecursive();
1874 var query
= "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id
);
1876 dialog
= new dijit
.Dialog({
1877 id
: "emailArticleDlg",
1878 title
: __("Forward article by email"),
1879 style
: "width: 600px",
1880 execute: function() {
1881 if (this.validate()) {
1883 new Ajax
.Request("backend.php", {
1884 parameters
: dojo
.objectToQuery(this.attr('value')),
1885 onComplete: function(transport
) {
1887 var error
= transport
.responseXML
.getElementsByTagName('error')[0];
1890 alert(__('Error sending email:') + ' ' + error
.firstChild
.nodeValue
);
1892 notify_info('Your message has been sent.');
1901 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1902 dojo
.disconnect(tmph
);
1904 new Ajax
.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
1905 "backend.php?op=rpc&subop=completeEmails",
1906 { tokens
: '', paramName
: "search" });
1911 /* displayDlg('emailArticle', id,
1913 document.forms['article_email_form'].destination.focus();
1915 new Ajax.Autocompleter('destination', 'destination_choices',
1916 "backend.php?op=rpc&subop=completeEmails",
1917 { tokens: '', paramName: "search" });
1922 exception_error("emailArticle", e
);
1926 function dismissArticle(id
) {
1928 var elem
= $("RROW-" + id
);
1930 toggleUnread(id
, 0, true);
1932 new Effect
.Fade(elem
, {duration
: 0.5});
1934 active_post_id
= false;
1937 exception_error("dismissArticle", e
);
1941 function dismissSelectedArticles() {
1944 var ids
= getVisibleArticleIds();
1948 for (var i
= 0; i
< ids
.length
; i
++) {
1949 var elem
= $("RROW-" + ids
[i
]);
1951 if (elem
.className
&& elem
.hasClassName("Selected") &&
1952 ids
[i
] != active_post_id
) {
1953 new Effect
.Fade(elem
, {duration
: 0.5});
1961 selectionToggleUnread(false);
1963 fixHeadlinesOrder(tmp
);
1966 exception_error("dismissSelectedArticles", e
);
1970 function dismissReadArticles() {
1973 var ids
= getVisibleArticleIds();
1976 for (var i
= 0; i
< ids
.length
; i
++) {
1977 var elem
= $("RROW-" + ids
[i
]);
1979 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1980 !elem
.hasClassName("Selected")) {
1982 new Effect
.Fade(elem
, {duration
: 0.5});
1988 fixHeadlinesOrder(tmp
);
1991 exception_error("dismissSelectedArticles", e
);
1995 function getVisibleArticleIds() {
2000 getLoadedArticleIds().each(function(id
) {
2001 var elem
= $("RROW-" + id
);
2002 if (elem
&& Element
.visible(elem
))
2007 exception_error("getVisibleArticleIds", e
);
2013 function cdmClicked(event
, id
) {
2015 var shift_key
= event
.shiftKey
;
2019 if (!event
.ctrlKey
) {
2021 if (!getInitParam("cdm_expanded")) {
2022 return cdmExpandArticle(id
);
2025 selectArticles("none");
2028 var elem
= $("RROW-" + id
);
2031 elem
.removeClassName("Unread");
2033 var upd_img_pic
= $("FUPDPIC-" + id
);
2035 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
2036 upd_img_pic
.src
.match("fresh_sign.png"))) {
2038 upd_img_pic
.src
= "images/blank_icon.gif";
2041 active_post_id
= id
;
2043 var query
= "?op=rpc&subop=catchupSelected" +
2044 "&cmode=0&ids=" + param_escape(id
);
2046 new Ajax
.Request("backend.php", {
2048 onComplete: function(transport
) {
2049 handle_rpc_reply(transport
);
2054 toggleSelected(id
, true);
2055 toggleUnread(id
, 0, false);
2056 zoomToArticle(event
, id
);
2060 exception_error("cdmClicked");
2066 function postClicked(event
, id
) {
2069 if (!event
.ctrlKey
) {
2072 postOpenInNewTab(event
, id
);
2077 exception_error("postClicked");
2081 function hlOpenInNewTab(event
, id
) {
2082 toggleUnread(id
, 0, false);
2083 zoomToArticle(event
, id
);
2086 function postOpenInNewTab(event
, id
) {
2087 closeArticlePanel(id
);
2088 zoomToArticle(event
, id
);
2091 function hlClicked(event
, id
) {
2094 openArticleInNewWindow(id
);
2095 } else if (!event
.ctrlKey
) {
2100 toggleUnread(id
, 0, false);
2101 zoomToArticle(event
, id
);
2106 exception_error("hlClicked");
2110 function getFirstVisibleHeadlineId() {
2111 var rows
= getVisibleArticleIds();
2116 function getLastVisibleHeadlineId() {
2117 var rows
= getVisibleArticleIds();
2118 return rows
[rows
.length
-1];
2121 function openArticleInNewWindow(id
) {
2122 toggleUnread(id
, 0, false);
2123 window
.open("backend.php?op=la&id=" + id
);
2126 function isCdmMode() {
2127 return getInitParam("combined_display_mode");
2130 function markHeadline(id
) {
2131 var row
= $("RROW-" + id
);
2133 var check
= $("RCHK-" + id
);
2136 check
.checked
= true;
2139 row
.addClassName("Selected");
2143 function getRelativePostIds(id
, limit
) {
2149 if (!limit
) limit
= 3;
2151 var ids
= getVisibleArticleIds();
2153 for (var i
= 0; i
< ids
.length
; i
++) {
2155 for (var k
= 1; k
<= limit
; k
++) {
2156 if (i
> k
-1) tmp
.push(ids
[i
-k
]);
2157 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
2164 exception_error("getRelativePostIds", e
);
2170 function correctHeadlinesOffset(id
) {
2174 var container
= $("headlines-frame");
2175 var row
= $("RROW-" + id
);
2177 var viewport
= container
.offsetHeight
;
2179 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
2180 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
2182 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
2183 //console.log("Vport: " + viewport);
2185 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
2186 container
.scrollTop
= row
.offsetTop
;
2187 } else if (rel_offset_bottom
> viewport
) {
2189 /* doesn't properly work with Opera in some cases because
2190 Opera fucks up element scrolling */
2192 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
2196 exception_error("correctHeadlinesOffset", e
);
2201 function headlineActionsChange(elem
) {
2204 elem
.attr('value', 'false');
2206 exception_error("headlineActionsChange", e
);
2210 function closeArticlePanel() {
2212 var tabs
= dijit
.byId("content-tabs");
2213 var child
= tabs
.selectedChildWidget
;
2215 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
2216 tabs
.removeChild(child
);
2219 if (dijit
.byId("content-insert"))
2220 dijit
.byId("headlines-wrap-inner").removeChild(
2221 dijit
.byId("content-insert"));
2225 function initHeadlinesMenu() {
2227 if (dijit
.byId("headlinesMenu"))
2228 dijit
.byId("headlinesMenu").destroyRecursive();
2233 nodes
= $$("#headlines-frame > div[id*=RROW]");
2235 nodes
= $$("#headlines-frame span[id*=RTITLE]");
2238 nodes
.each(function(node
) {
2242 var menu
= new dijit
.Menu({
2243 id
: "headlinesMenu",
2247 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
2248 var callerNode
= event
.target
, match
= null, tries
= 0;
2250 while (match
== null && callerNode
&& tries
<= 3) {
2251 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
2252 callerNode
= callerNode
.parentNode
;
2256 if (match
) this.callerRowId
= parseInt(match
[1]);
2261 menu
.addChild(new dijit
.MenuItem({
2262 label
: __("View article"),
2263 onClick: function(event
) {
2264 view(this.getParent().callerRowId
);
2267 menu
.addChild(new dijit
.MenuItem({
2268 label
: __("View in a new tab"),
2269 onClick: function(event
) {
2270 hlOpenInNewTab(event
, this.getParent().callerRowId
);
2273 menu
.addChild(new dijit
.MenuSeparator());
2275 menu
.addChild(new dijit
.MenuItem({
2276 label
: __("Open original article"),
2277 onClick: function(event
) {
2278 openArticleInNewWindow(this.getParent().callerRowId
);
2281 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2285 menu
.addChild(new dijit
.MenuSeparator());
2287 var labelsMenu
= new dijit
.Menu({ownerMenu
: menu
});
2289 labels
.each(function(label
) {
2290 var id
= label
.id
[0];
2291 var bare_id
= id
.substr(id
.indexOf(":")+1);
2292 var name
= label
.name
[0];
2294 bare_id
= -11-bare_id
;
2296 labelsMenu
.addChild(new dijit
.MenuItem({
2299 onClick: function(event
) {
2300 //console.log(this.labelId);
2301 //console.log(this.getParent().ownerMenu.callerRowId);
2302 selectionAssignLabel(this.labelId
,
2303 [this.getParent().ownerMenu
.callerRowId
]);
2307 menu
.addChild(new dijit
.PopupMenuItem({
2308 label
: __("Labels"),
2316 exception_error("initHeadlinesMenu", e
);