]>
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));
369 var query
= "?op=view&id=" + param_escape(id
);
371 var neighbor_ids
= getRelativePostIds(active_post_id
);
373 /* only request uncached articles */
375 var cids_to_request
= Array();
377 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
378 if (!cache_check(neighbor_ids
[i
])) {
379 cids_to_request
.push(neighbor_ids
[i
]);
383 console
.log("additional ids: " + cids_to_request
.toString());
385 query
= query
+ "&cids=" + cids_to_request
.toString();
387 var crow
= $("RROW-" + id
);
388 var article_is_unread
= crow
.hasClassName("Unread");
391 showArticleInHeadlines(id
);
393 if (!cached_article
) {
395 var upic
= $('FUPDPIC-' + id
);
398 upic
.src
= getInitParam("sign_progress");
401 } else if (cached_article
&& article_is_unread
) {
403 query
= query
+ "&mode=prefetch";
405 render_article(cached_article
);
407 } else if (cached_article
) {
409 query
= query
+ "&mode=prefetch_old";
410 render_article(cached_article
);
416 last_requested_article
= id
;
418 new Ajax
.Request("backend.php", {
420 onComplete: function(transport
) {
421 article_callback2(transport
, id
);
427 exception_error("view", e
);
432 return toggleMark(id
);
436 return togglePub(id
);
439 function toggleMark(id
, client_only
) {
441 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
443 var img
= $("FMPIC-" + id
);
447 if (img
.src
.match("mark_unset")) {
448 img
.src
= img
.src
.replace("mark_unset", "mark_set");
449 img
.alt
= __("Unstar article");
450 query
= query
+ "&mark=1";
453 img
.src
= img
.src
.replace("mark_set", "mark_unset");
454 img
.alt
= __("Star article");
455 query
= query
+ "&mark=0";
459 new Ajax
.Request("backend.php", {
461 onComplete: function(transport
) {
462 handle_rpc_reply(transport
);
467 exception_error("toggleMark", e
);
471 function togglePub(id
, client_only
, no_effects
, note
) {
473 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
475 if (note
!= undefined) {
476 query
= query
+ "¬e=" + param_escape(note
);
478 query
= query
+ "¬e=undefined";
481 var img
= $("FPPIC-" + id
);
485 if (img
.src
.match("pub_unset") || note
!= undefined) {
486 img
.src
= img
.src
.replace("pub_unset", "pub_set");
487 img
.alt
= __("Unpublish article");
488 query
= query
+ "&pub=1";
491 img
.src
= img
.src
.replace("pub_set", "pub_unset");
492 img
.alt
= __("Publish article");
494 query
= query
+ "&pub=0";
498 new Ajax
.Request("backend.php", {
500 onComplete: function(transport
) {
501 handle_rpc_reply(transport
);
503 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
506 var note_id
= note
.getAttribute("id");
507 var note_size
= note
.getAttribute("size");
508 var note_content
= note
.firstChild
.nodeValue
;
510 var container
= $('POSTNOTE-' + note_id
);
512 cache_invalidate(note_id
);
515 if (note_size
== "0") {
516 Element
.hide(container
);
518 container
.innerHTML
= note_content
;
519 Element
.show(container
);
528 exception_error("togglePub", e
);
532 function moveToPost(mode
) {
536 var rows
= getVisibleArticleIds();
541 if (!$('RROW-' + active_post_id
)) {
542 active_post_id
= false;
545 if (active_post_id
== false) {
546 next_id
= getFirstVisibleHeadlineId();
547 prev_id
= getLastVisibleHeadlineId();
549 for (var i
= 0; i
< rows
.length
; i
++) {
550 if (rows
[i
] == active_post_id
) {
557 if (mode
== "next") {
561 cdmExpandArticle(next_id
);
562 cdmScrollToArticleId(next_id
);
565 correctHeadlinesOffset(next_id
);
566 view(next_id
, getActiveFeedId());
571 if (mode
== "prev") {
574 cdmExpandArticle(prev_id
);
575 cdmScrollToArticleId(prev_id
);
577 correctHeadlinesOffset(prev_id
);
578 view(prev_id
, getActiveFeedId());
584 exception_error("moveToPost", e
);
588 function toggleSelected(id
, force_on
) {
591 var cb
= $("RCHK-" + id
);
592 var row
= $("RROW-" + id
);
595 if (row
.hasClassName('Selected') && !force_on
) {
596 row
.removeClassName('Selected');
597 if (cb
) cb
.checked
= false;
599 row
.addClassName('Selected');
600 if (cb
) cb
.checked
= true;
604 exception_error("toggleSelected", e
);
608 function toggleUnread_afh(effect
) {
611 var elem
= effect
.element
;
612 elem
.style
.backgroundColor
= "";
615 exception_error("toggleUnread_afh", e
);
619 function toggleUnread(id
, cmode
, effect
) {
622 var row
= $("RROW-" + id
);
624 if (cmode
== undefined || cmode
== 2) {
625 if (row
.hasClassName("Unread")) {
626 row
.removeClassName("Unread");
629 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
630 afterFinish
: toggleUnread_afh
,
631 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
635 row
.addClassName("Unread");
638 } else if (cmode
== 0) {
640 row
.removeClassName("Unread");
643 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
644 afterFinish
: toggleUnread_afh
,
645 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
648 } else if (cmode
== 1) {
649 row
.addClassName("Unread");
652 if (cmode
== undefined) cmode
= 2;
654 var query
= "?op=rpc&subop=catchupSelected" +
655 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
657 // notify_progress("Loading, please wait...");
659 new Ajax
.Request("backend.php", {
661 onComplete: function(transport
) {
662 handle_rpc_reply(transport
);
668 exception_error("toggleUnread", e
);
672 function selectionRemoveLabel(id
, ids
) {
675 if (!ids
) var ids
= getSelectedArticleIds2();
677 if (ids
.length
== 0) {
678 alert(__("No articles are selected."));
682 // var ok = confirm(__("Remove selected articles from label?"));
686 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
687 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
691 // notify_progress("Loading, please wait...");
693 cache_invalidate("F:" + (-11 - id
));
695 new Ajax
.Request("backend.php", {
697 onComplete: function(transport
) {
698 show_labels_in_headlines(transport
);
699 handle_rpc_reply(transport
);
705 exception_error("selectionAssignLabel", e
);
710 function selectionAssignLabel(id
, ids
) {
713 if (!ids
) ids
= getSelectedArticleIds2();
715 if (ids
.length
== 0) {
716 alert(__("No articles are selected."));
720 // var ok = confirm(__("Assign selected articles to label?"));
724 cache_invalidate("F:" + (-11 - id
));
726 var query
= "?op=rpc&subop=assignToLabel&ids=" +
727 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
731 // notify_progress("Loading, please wait...");
733 new Ajax
.Request("backend.php", {
735 onComplete: function(transport
) {
736 show_labels_in_headlines(transport
);
737 handle_rpc_reply(transport
);
743 exception_error("selectionAssignLabel", e
);
748 function selectionToggleUnread(set_state
, callback_func
, no_error
) {
750 var rows
= getSelectedArticleIds2();
752 if (rows
.length
== 0 && !no_error
) {
753 alert(__("No articles are selected."));
757 for (i
= 0; i
< rows
.length
; i
++) {
758 var row
= $("RROW-" + rows
[i
]);
760 if (set_state
== undefined) {
761 if (row
.hasClassName("Unread")) {
762 row
.removeClassName("Unread");
764 row
.addClassName("Unread");
768 if (set_state
== false) {
769 row
.removeClassName("Unread");
772 if (set_state
== true) {
773 row
.addClassName("Unread");
778 if (rows
.length
> 0) {
782 if (set_state
== undefined) {
784 } else if (set_state
== true) {
786 } else if (set_state
== false) {
790 var query
= "?op=rpc&subop=catchupSelected" +
791 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
793 notify_progress("Loading, please wait...");
795 new Ajax
.Request("backend.php", {
797 onComplete: function(transport
) {
798 catchup_callback2(transport
, callback_func
);
804 exception_error("selectionToggleUnread", e
);
808 function selectionToggleMarked() {
811 var rows
= getSelectedArticleIds2();
813 if (rows
.length
== 0) {
814 alert(__("No articles are selected."));
818 for (i
= 0; i
< rows
.length
; i
++) {
819 toggleMark(rows
[i
], true, true);
822 if (rows
.length
> 0) {
824 var query
= "?op=rpc&subop=markSelected&ids=" +
825 param_escape(rows
.toString()) + "&cmode=2";
827 new Ajax
.Request("backend.php", {
829 onComplete: function(transport
) {
830 handle_rpc_reply(transport
);
836 exception_error("selectionToggleMarked", e
);
840 function selectionTogglePublished() {
843 var rows
= getSelectedArticleIds2();
845 if (rows
.length
== 0) {
846 alert(__("No articles are selected."));
850 for (i
= 0; i
< rows
.length
; i
++) {
851 togglePub(rows
[i
], true, true);
854 if (rows
.length
> 0) {
856 var query
= "?op=rpc&subop=publishSelected&ids=" +
857 param_escape(rows
.toString()) + "&cmode=2";
859 new Ajax
.Request("backend.php", {
861 onComplete: function(transport
) {
862 handle_rpc_reply(transport
);
868 exception_error("selectionToggleMarked", e
);
872 function getSelectedArticleIds2() {
876 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
878 rv
.push(child
.id
.replace("RROW-", ""));
884 function getLoadedArticleIds() {
887 var children
= $$("#headlines-frame > div[id*=RROW-]");
889 children
.each(function(child
) {
890 rv
.push(child
.id
.replace("RROW-", ""));
897 // mode = all,none,unread,invert
898 function selectArticles(mode
) {
901 var children
= $$("#headlines-frame > div[id*=RROW]");
903 children
.each(function(child
) {
904 var id
= child
.id
.replace("RROW-", "");
905 var cb
= $("RCHK-" + id
);
908 child
.addClassName("Selected");
910 } else if (mode
== "unread") {
911 if (child
.hasClassName("Unread")) {
912 child
.addClassName("Selected");
915 child
.removeClassName("Selected");
918 } else if (mode
== "invert") {
919 if (child
.hasClassName("Selected")) {
920 child
.removeClassName("Selected");
923 child
.addClassName("Selected");
928 child
.removeClassName("Selected");
934 exception_error("selectArticles", e
);
938 function catchupPage() {
940 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
942 var str
= __("Mark all visible articles in %s as read?");
944 str
= str
.replace("%s", fn
);
946 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
950 selectArticles('all');
951 selectionToggleUnread(false, 'viewCurrentFeed()', true)
952 selectArticles('none');
955 function deleteSelection() {
959 var rows
= getSelectedArticleIds2();
961 if (rows
.length
== 0) {
962 alert(__("No articles are selected."));
966 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
970 if (getActiveFeedId() != 0) {
971 str
= __("Delete %d selected articles in %s?");
973 str
= __("Delete %d selected articles?");
976 str
= str
.replace("%d", rows
.length
);
977 str
= str
.replace("%s", fn
);
979 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
983 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
987 new Ajax
.Request("backend.php", {
989 onComplete: function(transport
) {
994 exception_error("deleteSelection", e
);
998 function archiveSelection() {
1002 var rows
= getSelectedArticleIds2();
1004 if (rows
.length
== 0) {
1005 alert(__("No articles are selected."));
1009 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1013 if (getActiveFeedId() != 0) {
1014 str
= __("Archive %d selected articles in %s?");
1017 str
= __("Move %d archived articles back?");
1021 str
= str
.replace("%d", rows
.length
);
1022 str
= str
.replace("%s", fn
);
1024 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1028 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1032 for (var i
= 0; i
< rows
.length
; i
++) {
1033 cache_invalidate(rows
[i
]);
1036 new Ajax
.Request("backend.php", {
1038 onComplete: function(transport
) {
1043 exception_error("archiveSelection", e
);
1047 function catchupSelection() {
1051 var rows
= getSelectedArticleIds2();
1053 if (rows
.length
== 0) {
1054 alert(__("No articles are selected."));
1058 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1060 var str
= __("Mark %d selected articles in %s as read?");
1062 str
= str
.replace("%d", rows
.length
);
1063 str
= str
.replace("%s", fn
);
1065 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1069 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1072 exception_error("catchupSelection", e
);
1076 function editArticleTags(id
, feed_id
, cdm_enabled
) {
1077 displayDlg('editArticleTags', id
,
1079 $("tags_str").focus();
1081 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1082 "backend.php?op=rpc&subop=completeTags",
1083 { tokens
: ',', paramName
: "search" });
1087 function editTagsSave() {
1089 notify_progress("Saving article tags...");
1091 var form
= document
.forms
["tag_edit_form"];
1093 var query
= Form
.serialize("tag_edit_form");
1095 query
= "?op=rpc&subop=setArticleTags&" + query
;
1099 new Ajax
.Request("backend.php", {
1101 onComplete: function(transport
) {
1103 //console.log("tags saved...");
1108 if (transport
.responseXML
) {
1109 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1112 var id
= tags_str
.getAttribute("id");
1115 var tags
= $("ATSTR-" + id
);
1117 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1120 cache_invalidate(id
);
1126 exception_error("editTagsSave", e
);
1131 function editTagsInsert() {
1134 var form
= document
.forms
["tag_edit_form"];
1136 var found_tags
= form
.found_tags
;
1137 var tags_str
= form
.tags_str
;
1139 var tag
= found_tags
[found_tags
.selectedIndex
].value
;
1141 if (tags_str
.value
.length
> 0 &&
1142 tags_str
.value
.lastIndexOf(", ") != tags_str
.value
.length
- 2) {
1144 tags_str
.value
= tags_str
.value
+ ", ";
1147 tags_str
.value
= tags_str
.value
+ tag
+ ", ";
1149 found_tags
.selectedIndex
= 0;
1152 exception_error("editTagsInsert", e
);
1156 function cdmScrollToArticleId(id
) {
1158 var ctr
= $("headlines-frame");
1159 var e
= $("RROW-" + id
);
1161 if (!e
|| !ctr
) return;
1163 ctr
.scrollTop
= e
.offsetTop
;
1166 exception_error("cdmScrollToArticleId", e
);
1170 function cdmWatchdog() {
1174 var ctr
= $("headlines-frame");
1178 var ids
= new Array();
1180 var e
= ctr
.firstChild
;
1183 if (e
.className
&& e
.hasClassName("Unread") && e
.id
&&
1184 e
.id
.match("RROW-")) {
1186 // article fits in viewport OR article is longer than viewport and
1187 // its bottom is visible
1189 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1190 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1192 // console.log(e.id + " is visible " + e.offsetTop + "." +
1193 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1194 // (ctr.scrollTop + ctr.offsetHeight));
1196 ids
.push(e
.id
.replace("RROW-", ""));
1198 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1199 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1200 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1202 ids
.push(e
.id
.replace("RROW-", ""));
1206 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1208 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1209 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1211 ids.push(e.id.replace("RROW-", ""));
1220 console
.log("cdmWatchdog, ids= " + ids
.toString());
1222 if (ids
.length
> 0) {
1224 for (var i
= 0; i
< ids
.length
; i
++) {
1225 var e
= $("RROW-" + ids
[i
]);
1227 e
.removeClassName("Unread");
1231 var query
= "?op=rpc&subop=catchupSelected" +
1232 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1234 new Ajax
.Request("backend.php", {
1236 onComplete: function(transport
) {
1237 handle_rpc_reply(transport
);
1242 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1245 exception_error("cdmWatchdog", e
);
1251 function cache_inject(id
, article
, param
) {
1254 if (!cache_check_param(id
, param
)) {
1255 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1257 var date
= new Date();
1258 var ts
= Math
.round(date
.getTime() / 1000);
1262 cache_obj
["id"] = id
;
1263 cache_obj
["data"] = article
;
1264 cache_obj
["param"] = param
;
1266 if (param
) id
= id
+ ":" + param
;
1268 cache_added
["TS:" + id
] = ts
;
1270 if (has_local_storage())
1271 localStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1273 article_cache
.push(cache_obj
);
1276 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1279 exception_error("cache_inject", e
);
1283 function cache_find(id
) {
1285 if (has_local_storage()) {
1286 var cache_obj
= localStorage
.getItem(id
);
1289 cache_obj
= JSON
.parse(cache_obj
);
1292 return cache_obj
['data'];
1296 for (var i
= 0; i
< article_cache
.length
; i
++) {
1297 if (article_cache
[i
]["id"] == id
) {
1298 return article_cache
[i
]["data"];
1305 function cache_find_param(id
, param
) {
1307 if (has_local_storage()) {
1309 if (param
) id
= id
+ ":" + param
;
1311 var cache_obj
= localStorage
.getItem(id
);
1314 cache_obj
= JSON
.parse(cache_obj
);
1317 return cache_obj
['data'];
1321 for (var i
= 0; i
< article_cache
.length
; i
++) {
1322 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1323 return article_cache
[i
]["data"];
1331 function cache_check(id
) {
1332 if (has_local_storage()) {
1333 if (localStorage
.getItem(id
))
1336 for (var i
= 0; i
< article_cache
.length
; i
++) {
1337 if (article_cache
[i
]["id"] == id
) {
1345 function cache_check_param(id
, param
) {
1346 if (has_local_storage()) {
1348 if (param
) id
= id
+ ":" + param
;
1350 if (localStorage
.getItem(id
))
1354 for (var i
= 0; i
< article_cache
.length
; i
++) {
1355 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1363 function cache_expire() {
1364 if (has_local_storage()) {
1366 var date
= new Date();
1367 var timestamp
= Math
.round(date
.getTime() / 1000);
1369 for (var i
= 0; i
< localStorage
.length
; i
++) {
1371 var id
= localStorage
.key(i
);
1373 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1374 localStorage
.removeItem(id
);
1379 while (article_cache
.length
> 25) {
1380 article_cache
.shift();
1385 function cache_flush() {
1386 if (has_local_storage()) {
1387 localStorage
.clear();
1389 article_cache
= new Array();
1393 function cache_invalidate(id
) {
1395 if (has_local_storage()) {
1399 for (var i
= 0; i
< localStorage
.length
; i
++) {
1400 var key
= localStorage
.key(i
);
1402 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1404 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1405 localStorage
.removeItem(key
);
1416 while (i
< article_cache
.length
) {
1417 if (article_cache
[i
]["id"] == id
) {
1418 //console.log("cache_invalidate: removed id " + id);
1419 article_cache
.splice(i
, 1);
1426 //console.log("cache_invalidate: id not found: " + id);
1429 exception_error("cache_invalidate", e
);
1433 function getActiveArticleId() {
1434 return active_post_id
;
1437 function preloadBatchedArticles() {
1440 var query
= "?op=rpc&subop=getArticles&ids=" +
1441 preload_id_batch
.toString();
1443 new Ajax
.Request("backend.php", {
1445 onComplete: function(transport
) {
1447 preload_id_batch
= [];
1449 var articles
= transport
.responseXML
.getElementsByTagName("article");
1451 for (var i
= 0; i
< articles
.length
; i
++) {
1452 var id
= articles
[i
].getAttribute("id");
1453 if (!cache_check(id
)) {
1454 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1455 console
.log("preloaded article: " + id
);
1461 exception_error("preloadBatchedArticles", e
);
1465 function preloadArticleUnderPointer(id
) {
1467 if (getInitParam("bw_limit") == "1") return;
1469 if (post_under_pointer
== id
&& !cache_check(id
)) {
1471 console
.log("trying to preload article " + id
);
1473 var neighbor_ids
= getRelativePostIds(id
, 1);
1475 /* only request uncached articles */
1477 if (preload_id_batch
.indexOf(id
) == -1) {
1478 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1479 if (!cache_check(neighbor_ids
[i
])) {
1480 preload_id_batch
.push(neighbor_ids
[i
]);
1485 if (preload_id_batch
.indexOf(id
) == -1)
1486 preload_id_batch
.push(id
);
1488 //console.log("preload ids batch: " + preload_id_batch.toString());
1490 window
.clearTimeout(preload_timeout_id
);
1491 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1495 exception_error("preloadArticleUnderPointer", e
);
1499 function postMouseIn(id
) {
1501 if (post_under_pointer
!= id
) {
1502 post_under_pointer
= id
;
1504 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1509 exception_error("postMouseIn", e
);
1513 function postMouseOut(id
) {
1515 post_under_pointer
= false;
1517 exception_error("postMouseOut", e
);
1521 function headlines_scroll_handler(e
) {
1524 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1525 if (!_infscroll_disable
) {
1531 exception_error("headlines_scroll_handler", e
);
1535 function catchupRelativeToArticle(below
) {
1540 if (!getActiveArticleId()) {
1541 alert(__("No article is selected."));
1545 var visible_ids
= getVisibleArticleIds();
1547 var ids_to_mark
= new Array();
1550 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1551 if (visible_ids
[i
] != getActiveArticleId()) {
1552 var e
= $("RROW-" + visible_ids
[i
]);
1554 if (e
&& e
.hasClassName("Unread")) {
1555 ids_to_mark
.push(visible_ids
[i
]);
1562 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1563 if (visible_ids
[i
] != getActiveArticleId()) {
1564 var e
= $("RROW-" + visible_ids
[i
]);
1566 if (e
&& e
.hasClassName("Unread")) {
1567 ids_to_mark
.push(visible_ids
[i
]);
1575 if (ids_to_mark
.length
== 0) {
1576 alert(__("No articles found to mark"));
1578 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1580 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1582 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1583 var e
= $("RROW-" + ids_to_mark
[i
]);
1584 e
.removeClassName("Unread");
1587 var query
= "?op=rpc&subop=catchupSelected" +
1588 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1590 new Ajax
.Request("backend.php", {
1592 onComplete: function(transport
) {
1593 catchup_callback2(transport
);
1600 exception_error("catchupRelativeToArticle", e
);
1604 function cdmExpandArticle(id
) {
1609 var elem
= $("CICD-" + active_post_id
);
1611 var upd_img_pic
= $("FUPDPIC-" + id
);
1613 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1614 upd_img_pic
.src
.match("fresh_sign.png"))) {
1616 upd_img_pic
.src
= "images/blank_icon.gif";
1619 if (id
== active_post_id
&& Element
.visible(elem
))
1622 selectArticles("none");
1624 var old_offset
= $("RROW-" + id
).offsetTop
;
1626 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1628 Element
.show("CEXC-" + active_post_id
);
1631 active_post_id
= id
;
1633 elem
= $("CICD-" + id
);
1635 if (!Element
.visible(elem
)) {
1637 Element
.hide("CEXC-" + id
);
1639 if ($("CWRAP-" + id
).innerHTML
== "") {
1641 $("FUPDPIC-" + id
).src
= "images/indicator_tiny.gif";
1643 $("CWRAP-" + id
).innerHTML
= "<div class=\"insensitive\">" +
1644 __("Loading, please wait...") + "</div>";
1646 var query
= "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id
);
1648 //console.log(query);
1650 new Ajax
.Request("backend.php", {
1652 onComplete: function(transport
) {
1653 $("FUPDPIC-" + id
).src
= 'images/blank_icon.gif';
1655 if (transport
.responseXML
) {
1656 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1657 var recv_id
= article
.getAttribute("id");
1660 $("CWRAP-" + id
).innerHTML
= article
.firstChild
.nodeValue
;
1663 $("CWRAP-" + id
).innerHTML
= __("Unable to load article.");
1671 var new_offset
= $("RROW-" + id
).offsetTop
;
1673 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1675 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1676 $("headlines-frame").scrollTop
= new_offset
;
1678 toggleUnread(id
, 0, true);
1682 exception_error("cdmExpandArticle", e
);
1688 function fixHeadlinesOrder(ids
) {
1690 for (var i
= 0; i
< ids
.length
; i
++) {
1691 var e
= $("RROW-" + ids
[i
]);
1695 e
.removeClassName("even");
1696 e
.addClassName("odd");
1698 e
.removeClassName("odd");
1699 e
.addClassName("even");
1704 exception_error("fixHeadlinesOrder", e
);
1708 function getArticleUnderPointer() {
1709 return post_under_pointer
;
1712 function zoomToArticle(event
, id
) {
1714 var cached_article
= cache_find(id
);
1716 if (dijit
.byId("ATAB-" + id
))
1717 if (!event
|| !event
.shiftKey
)
1718 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1720 if (cached_article
) {
1721 //closeArticlePanel();
1723 var article_pane
= new dijit
.layout
.ContentPane({
1724 title
: __("Loading...") , content
: cached_article
,
1725 style
: 'padding : 0px;',
1729 dijit
.byId("content-tabs").addChild(article_pane
);
1731 if (!event
|| !event
.shiftKey
)
1732 dijit
.byId("content-tabs").selectChild(article_pane
);
1734 if ($("PTITLE-" + id
))
1735 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1739 var query
= "?op=rpc&subop=getArticles&ids=" + param_escape(id
);
1741 notify_progress("Loading, please wait...", true);
1743 new Ajax
.Request("backend.php", {
1745 onComplete: function(transport
) {
1748 if (transport
.responseXML
) {
1749 //closeArticlePanel();
1751 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1752 var content
= article
.firstChild
.nodeValue
;
1754 var article_pane
= new dijit
.layout
.ContentPane({
1755 title
: "article-" + id
, content
: content
,
1756 style
: 'padding : 0px;',
1760 dijit
.byId("content-tabs").addChild(article_pane
);
1762 if (!event
|| !event
.shiftKey
)
1763 dijit
.byId("content-tabs").selectChild(article_pane
);
1765 if ($("PTITLE-" + id
))
1766 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1773 exception_error("zoomToArticle", e
);
1777 function scrollArticle(offset
) {
1780 var ci
= $("content-insert");
1782 ci
.scrollTop
+= offset
;
1785 var hi
= $("headlines-frame");
1787 hi
.scrollTop
+= offset
;
1792 exception_error("scrollArticle", e
);
1796 function show_labels_in_headlines(transport
) {
1798 if (transport
.responseXML
) {
1799 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
1801 var elems
= info
.getElementsByTagName("entry");
1803 for (var l
= 0; l
< elems
.length
; l
++) {
1804 var e_id
= elems
[l
].getAttribute("id");
1808 var ctr
= $("HLLCTR-" + e_id
);
1811 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
1819 exception_error("show_labels_in_headlines", e
);
1824 function toggleHeadlineActions() {
1826 var e
= $("headlineActionsBody");
1827 var p
= $("headlineActionsDrop");
1829 if (!Element
.visible(e
)) {
1836 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
1837 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
1840 exception_error("toggleHeadlineActions", e
);
1844 function publishWithNote(id
, def_note
) {
1846 if (!def_note
) def_note
= '';
1848 var note
= prompt(__("Please enter a note for this article:"), def_note
);
1850 if (note
!= undefined) {
1851 togglePub(id
, false, false, note
);
1855 exception_error("publishWithNote", e
);
1859 function emailArticle(id
) {
1862 var ids
= getSelectedArticleIds2();
1864 if (ids
.length
== 0) {
1865 alert(__("No articles are selected."));
1869 id
= ids
.toString();
1872 displayDlg('emailArticle', id
,
1874 document
.forms
['article_email_form'].destination
.focus();
1876 new Ajax
.Autocompleter('destination', 'destination_choices',
1877 "backend.php?op=rpc&subop=completeEmails",
1878 { tokens
: '', paramName
: "search" });
1883 exception_error("emailArticle", e
);
1887 function emailArticleDo() {
1889 var f
= document
.forms
['article_email_form'];
1891 if (f
.destination
.value
== "") {
1892 alert("Please fill in the destination email.");
1896 if (f
.subject
.value
== "") {
1897 alert("Please fill in the subject.");
1901 var query
= Form
.serialize("article_email_form");
1903 // console.log(query);
1905 new Ajax
.Request("backend.php", {
1907 onComplete: function(transport
) {
1910 var error
= transport
.responseXML
.getElementsByTagName('error')[0];
1913 alert(__('Error sending email:') + ' ' + error
.firstChild
.nodeValue
);
1915 notify_info('Your message has been sent.');
1920 exception_error("sendEmailDo", e
);
1926 exception_error("emailArticleDo", e
);
1930 function dismissArticle(id
) {
1932 var elem
= $("RROW-" + id
);
1934 toggleUnread(id
, 0, true);
1936 new Effect
.Fade(elem
, {duration
: 0.5});
1938 active_post_id
= false;
1941 exception_error("dismissArticle", e
);
1945 function dismissSelectedArticles() {
1948 var ids
= getVisibleArticleIds();
1952 for (var i
= 0; i
< ids
.length
; i
++) {
1953 var elem
= $("RROW-" + ids
[i
]);
1955 if (elem
.className
&& elem
.hasClassName("Selected") &&
1956 ids
[i
] != active_post_id
) {
1957 new Effect
.Fade(elem
, {duration
: 0.5});
1965 selectionToggleUnread(false);
1967 fixHeadlinesOrder(tmp
);
1970 exception_error("dismissSelectedArticles", e
);
1974 function dismissReadArticles() {
1977 var ids
= getVisibleArticleIds();
1980 for (var i
= 0; i
< ids
.length
; i
++) {
1981 var elem
= $("RROW-" + ids
[i
]);
1983 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1984 !elem
.hasClassName("Selected")) {
1986 new Effect
.Fade(elem
, {duration
: 0.5});
1992 fixHeadlinesOrder(tmp
);
1995 exception_error("dismissSelectedArticles", e
);
1999 function getVisibleArticleIds() {
2004 getLoadedArticleIds().each(function(id
) {
2005 var elem
= $("RROW-" + id
);
2006 if (elem
&& Element
.visible(elem
))
2011 exception_error("getVisibleArticleIds", e
);
2017 function cdmClicked(event
, id
) {
2019 var shift_key
= event
.shiftKey
;
2023 if (!event
.ctrlKey
) {
2025 if (!getInitParam("cdm_expanded")) {
2026 return cdmExpandArticle(id
);
2029 selectArticles("none");
2032 var elem
= $("RROW-" + id
);
2035 elem
.removeClassName("Unread");
2037 var upd_img_pic
= $("FUPDPIC-" + id
);
2039 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
2040 upd_img_pic
.src
.match("fresh_sign.png"))) {
2042 upd_img_pic
.src
= "images/blank_icon.gif";
2045 active_post_id
= id
;
2047 var query
= "?op=rpc&subop=catchupSelected" +
2048 "&cmode=0&ids=" + param_escape(id
);
2050 new Ajax
.Request("backend.php", {
2052 onComplete: function(transport
) {
2053 handle_rpc_reply(transport
);
2058 toggleSelected(id
, true);
2059 toggleUnread(id
, 0, false);
2060 zoomToArticle(event
, id
);
2064 exception_error("cdmClicked");
2070 function postClicked(event
, id
) {
2073 if (!event
.ctrlKey
) {
2076 postOpenInNewTab(event
, id
);
2081 exception_error("postClicked");
2085 function hlOpenInNewTab(event
, id
) {
2086 toggleUnread(id
, 0, false);
2087 zoomToArticle(event
, id
);
2090 function postOpenInNewTab(event
, id
) {
2091 closeArticlePanel(id
);
2092 zoomToArticle(event
, id
);
2095 function hlClicked(event
, id
) {
2098 if (!event
.ctrlKey
) {
2103 toggleUnread(id
, 0, false);
2104 zoomToArticle(event
, id
);
2109 exception_error("hlClicked");
2113 function getFirstVisibleHeadlineId() {
2114 var rows
= getVisibleArticleIds();
2119 function getLastVisibleHeadlineId() {
2120 var rows
= getVisibleArticleIds();
2121 return rows
[rows
.length
-1];
2124 function openArticleInNewWindow(id
) {
2125 toggleUnread(id
, 0, false);
2126 window
.open("backend.php?op=la&id=" + id
);
2129 function isCdmMode() {
2130 return getInitParam("combined_display_mode");
2133 function markHeadline(id
) {
2134 var row
= $("RROW-" + id
);
2136 var check
= $("RCHK-" + id
);
2139 check
.checked
= true;
2142 row
.addClassName("Selected");
2146 function getRelativePostIds(id
, limit
) {
2152 if (!limit
) limit
= 3;
2154 var ids
= getVisibleArticleIds();
2156 for (var i
= 0; i
< ids
.length
; i
++) {
2158 for (var k
= 1; k
<= limit
; k
++) {
2159 if (i
> k
-1) tmp
.push(ids
[i
-k
]);
2160 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
2167 exception_error("getRelativePostIds", e
);
2173 function correctHeadlinesOffset(id
) {
2177 var container
= $("headlines-frame");
2178 var row
= $("RROW-" + id
);
2180 var viewport
= container
.offsetHeight
;
2182 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
2183 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
2185 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
2186 //console.log("Vport: " + viewport);
2188 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
2189 container
.scrollTop
= row
.offsetTop
;
2190 } else if (rel_offset_bottom
> viewport
) {
2192 /* doesn't properly work with Opera in some cases because
2193 Opera fucks up element scrolling */
2195 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
2199 exception_error("correctHeadlinesOffset", e
);
2204 function headlineActionsChange(elem
) {
2207 elem
.selectedIndex
= 0;
2209 exception_error("headlineActionsChange", e
);
2213 function closeArticlePanel() {
2215 var tabs
= dijit
.byId("content-tabs");
2216 var child
= tabs
.selectedChildWidget
;
2218 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
2219 tabs
.removeChild(child
);
2222 if (dijit
.byId("content-insert"))
2223 dijit
.byId("headlines-wrap-inner").removeChild(
2224 dijit
.byId("content-insert"));
2228 function initHeadlinesMenu() {
2230 if (dijit
.byId("headlinesMenu"))
2231 dijit
.byId("headlinesMenu").destroyRecursive();
2236 nodes
= $$("#headlines-frame > div[id*=RROW]");
2238 nodes
= $$("#headlines-frame span[id*=RTITLE]");
2241 nodes
.each(function(node
) {
2245 var menu
= new dijit
.Menu({
2246 id
: "headlinesMenu",
2250 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
2251 var callerNode
= event
.target
, match
= null, tries
= 0;
2253 while (match
== null && callerNode
&& tries
<= 3) {
2254 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
2255 callerNode
= callerNode
.parentNode
;
2259 if (match
) this.callerRowId
= parseInt(match
[1]);
2264 menu
.addChild(new dijit
.MenuItem({
2265 label
: __("View article"),
2266 onClick: function(event
) {
2267 view(this.getParent().callerRowId
);
2270 menu
.addChild(new dijit
.MenuItem({
2271 label
: __("View in a new tab"),
2272 onClick: function(event
) {
2273 hlOpenInNewTab(event
, this.getParent().callerRowId
);
2276 menu
.addChild(new dijit
.MenuSeparator());
2278 menu
.addChild(new dijit
.MenuItem({
2279 label
: __("Open original article"),
2280 onClick: function(event
) {
2281 openArticleInNewWindow(this.getParent().callerRowId
);
2284 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2288 menu
.addChild(new dijit
.MenuSeparator());
2290 var labelsMenu
= new dijit
.Menu({ownerMenu
: menu
});
2292 labels
.each(function(label
) {
2293 var id
= label
.id
[0];
2294 var bare_id
= id
.substr(id
.indexOf(":")+1);
2295 var name
= label
.name
[0];
2297 bare_id
= -11-bare_id
;
2299 labelsMenu
.addChild(new dijit
.MenuItem({
2302 onClick: function(event
) {
2303 //console.log(this.labelId);
2304 //console.log(this.getParent().ownerMenu.callerRowId);
2305 selectionAssignLabel(this.labelId
,
2306 [this.getParent().ownerMenu
.callerRowId
]);
2310 menu
.addChild(new dijit
.PopupMenuItem({
2311 label
: __("Labels"),
2319 exception_error("initHeadlinesMenu", e
);