]>
git.wh0rd.org - tt-rss.git/blob - viewfeed.js
4344398e3295bb839073d4def0201473e1af2791
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
) {
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" });
1085 var query
= "backend.php?op=dlg&id=editArticleTags¶m=" + param_escape(id
);
1087 if (dijit
.byId("editTagsDlg"))
1088 dijit
.byId("editTagsDlg").destroyRecursive();
1090 dialog
= new dijit
.Dialog({
1092 title
: __("Edit article Tags"),
1093 style
: "width: 600px",
1094 execute: function() {
1095 if (this.validate()) {
1096 var query
= dojo
.objectToQuery(this.attr('value'));
1098 notify_progress("Saving article tags...", true);
1100 new Ajax
.Request("backend.php", {
1102 onComplete: function(transport
) {
1106 if (transport
.responseXML
) {
1107 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1110 var id
= tags_str
.getAttribute("id");
1113 var tags
= $("ATSTR-" + id
);
1115 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1118 cache_invalidate(id
);
1129 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1130 dojo
.disconnect(tmph
);
1132 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1133 "backend.php?op=rpc&subop=completeTags",
1134 { tokens
: ',', paramName
: "search" });
1141 function cdmScrollToArticleId(id
) {
1143 var ctr
= $("headlines-frame");
1144 var e
= $("RROW-" + id
);
1146 if (!e
|| !ctr
) return;
1148 ctr
.scrollTop
= e
.offsetTop
;
1151 exception_error("cdmScrollToArticleId", e
);
1155 function cdmWatchdog() {
1159 var ctr
= $("headlines-frame");
1163 var ids
= new Array();
1165 var e
= ctr
.firstChild
;
1168 if (e
.className
&& e
.hasClassName("Unread") && e
.id
&&
1169 e
.id
.match("RROW-")) {
1171 // article fits in viewport OR article is longer than viewport and
1172 // its bottom is visible
1174 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1175 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1177 // console.log(e.id + " is visible " + e.offsetTop + "." +
1178 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1179 // (ctr.scrollTop + ctr.offsetHeight));
1181 ids
.push(e
.id
.replace("RROW-", ""));
1183 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1184 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1185 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1187 ids
.push(e
.id
.replace("RROW-", ""));
1191 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1193 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1194 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1196 ids.push(e.id.replace("RROW-", ""));
1205 console
.log("cdmWatchdog, ids= " + ids
.toString());
1207 if (ids
.length
> 0) {
1209 for (var i
= 0; i
< ids
.length
; i
++) {
1210 var e
= $("RROW-" + ids
[i
]);
1212 e
.removeClassName("Unread");
1216 var query
= "?op=rpc&subop=catchupSelected" +
1217 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1219 new Ajax
.Request("backend.php", {
1221 onComplete: function(transport
) {
1222 handle_rpc_reply(transport
);
1227 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1230 exception_error("cdmWatchdog", e
);
1236 function cache_inject(id
, article
, param
) {
1239 if (!cache_check_param(id
, param
)) {
1240 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1242 var date
= new Date();
1243 var ts
= Math
.round(date
.getTime() / 1000);
1247 cache_obj
["id"] = id
;
1248 cache_obj
["data"] = article
;
1249 cache_obj
["param"] = param
;
1251 if (param
) id
= id
+ ":" + param
;
1253 cache_added
["TS:" + id
] = ts
;
1255 if (has_local_storage())
1256 sessionStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1258 article_cache
.push(cache_obj
);
1261 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1264 exception_error("cache_inject", e
);
1268 function cache_find(id
) {
1270 if (has_local_storage()) {
1271 var cache_obj
= sessionStorage
.getItem(id
);
1274 cache_obj
= JSON
.parse(cache_obj
);
1277 return cache_obj
['data'];
1281 for (var i
= 0; i
< article_cache
.length
; i
++) {
1282 if (article_cache
[i
]["id"] == id
) {
1283 return article_cache
[i
]["data"];
1290 function cache_find_param(id
, param
) {
1292 if (has_local_storage()) {
1294 if (param
) id
= id
+ ":" + param
;
1296 var cache_obj
= sessionStorage
.getItem(id
);
1299 cache_obj
= JSON
.parse(cache_obj
);
1302 return cache_obj
['data'];
1306 for (var i
= 0; i
< article_cache
.length
; i
++) {
1307 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1308 return article_cache
[i
]["data"];
1316 function cache_check(id
) {
1317 if (has_local_storage()) {
1318 if (sessionStorage
.getItem(id
))
1321 for (var i
= 0; i
< article_cache
.length
; i
++) {
1322 if (article_cache
[i
]["id"] == id
) {
1330 function cache_check_param(id
, param
) {
1331 if (has_local_storage()) {
1333 if (param
) id
= id
+ ":" + param
;
1335 if (sessionStorage
.getItem(id
))
1339 for (var i
= 0; i
< article_cache
.length
; i
++) {
1340 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1348 function cache_expire() {
1349 if (has_local_storage()) {
1351 var date
= new Date();
1352 var timestamp
= Math
.round(date
.getTime() / 1000);
1354 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1356 var id
= sessionStorage
.key(i
);
1358 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1359 sessionStorage
.removeItem(id
);
1364 while (article_cache
.length
> 25) {
1365 article_cache
.shift();
1370 function cache_flush() {
1371 if (has_local_storage()) {
1372 sessionStorage
.clear();
1374 article_cache
= new Array();
1378 function cache_invalidate(id
) {
1380 if (has_local_storage()) {
1384 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1385 var key
= sessionStorage
.key(i
);
1387 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1389 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1390 sessionStorage
.removeItem(key
);
1401 while (i
< article_cache
.length
) {
1402 if (article_cache
[i
]["id"] == id
) {
1403 //console.log("cache_invalidate: removed id " + id);
1404 article_cache
.splice(i
, 1);
1411 //console.log("cache_invalidate: id not found: " + id);
1414 exception_error("cache_invalidate", e
);
1418 function getActiveArticleId() {
1419 return active_post_id
;
1422 function preloadBatchedArticles() {
1425 var query
= "?op=rpc&subop=getArticles&ids=" +
1426 preload_id_batch
.toString();
1428 new Ajax
.Request("backend.php", {
1430 onComplete: function(transport
) {
1432 preload_id_batch
= [];
1434 var articles
= transport
.responseXML
.getElementsByTagName("article");
1436 for (var i
= 0; i
< articles
.length
; i
++) {
1437 var id
= articles
[i
].getAttribute("id");
1438 if (!cache_check(id
)) {
1439 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1440 console
.log("preloaded article: " + id
);
1446 exception_error("preloadBatchedArticles", e
);
1450 function preloadArticleUnderPointer(id
) {
1452 if (getInitParam("bw_limit") == "1") return;
1454 if (post_under_pointer
== id
&& !cache_check(id
)) {
1456 console
.log("trying to preload article " + id
);
1458 var neighbor_ids
= getRelativePostIds(id
, 1);
1460 /* only request uncached articles */
1462 if (preload_id_batch
.indexOf(id
) == -1) {
1463 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1464 if (!cache_check(neighbor_ids
[i
])) {
1465 preload_id_batch
.push(neighbor_ids
[i
]);
1470 if (preload_id_batch
.indexOf(id
) == -1)
1471 preload_id_batch
.push(id
);
1473 //console.log("preload ids batch: " + preload_id_batch.toString());
1475 window
.clearTimeout(preload_timeout_id
);
1476 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1480 exception_error("preloadArticleUnderPointer", e
);
1484 function postMouseIn(id
) {
1486 if (post_under_pointer
!= id
) {
1487 post_under_pointer
= id
;
1489 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1494 exception_error("postMouseIn", e
);
1498 function postMouseOut(id
) {
1500 post_under_pointer
= false;
1502 exception_error("postMouseOut", e
);
1506 function headlines_scroll_handler(e
) {
1509 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1510 if (!_infscroll_disable
) {
1516 exception_error("headlines_scroll_handler", e
);
1520 function catchupRelativeToArticle(below
) {
1525 if (!getActiveArticleId()) {
1526 alert(__("No article is selected."));
1530 var visible_ids
= getVisibleArticleIds();
1532 var ids_to_mark
= new Array();
1535 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1536 if (visible_ids
[i
] != getActiveArticleId()) {
1537 var e
= $("RROW-" + visible_ids
[i
]);
1539 if (e
&& e
.hasClassName("Unread")) {
1540 ids_to_mark
.push(visible_ids
[i
]);
1547 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1548 if (visible_ids
[i
] != getActiveArticleId()) {
1549 var e
= $("RROW-" + visible_ids
[i
]);
1551 if (e
&& e
.hasClassName("Unread")) {
1552 ids_to_mark
.push(visible_ids
[i
]);
1560 if (ids_to_mark
.length
== 0) {
1561 alert(__("No articles found to mark"));
1563 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1565 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1567 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1568 var e
= $("RROW-" + ids_to_mark
[i
]);
1569 e
.removeClassName("Unread");
1572 var query
= "?op=rpc&subop=catchupSelected" +
1573 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1575 new Ajax
.Request("backend.php", {
1577 onComplete: function(transport
) {
1578 catchup_callback2(transport
);
1585 exception_error("catchupRelativeToArticle", e
);
1589 function cdmExpandArticle(id
) {
1594 var elem
= $("CICD-" + active_post_id
);
1596 var upd_img_pic
= $("FUPDPIC-" + id
);
1598 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1599 upd_img_pic
.src
.match("fresh_sign.png"))) {
1601 upd_img_pic
.src
= "images/blank_icon.gif";
1604 if (id
== active_post_id
&& Element
.visible(elem
))
1607 selectArticles("none");
1609 var old_offset
= $("RROW-" + id
).offsetTop
;
1611 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1613 Element
.show("CEXC-" + active_post_id
);
1616 active_post_id
= id
;
1618 elem
= $("CICD-" + id
);
1620 if (!Element
.visible(elem
)) {
1622 Element
.hide("CEXC-" + id
);
1624 if ($("CWRAP-" + id
).innerHTML
== "") {
1626 $("FUPDPIC-" + id
).src
= "images/indicator_tiny.gif";
1628 $("CWRAP-" + id
).innerHTML
= "<div class=\"insensitive\">" +
1629 __("Loading, please wait...") + "</div>";
1631 var query
= "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id
);
1633 //console.log(query);
1635 new Ajax
.Request("backend.php", {
1637 onComplete: function(transport
) {
1638 $("FUPDPIC-" + id
).src
= 'images/blank_icon.gif';
1640 if (transport
.responseXML
) {
1641 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1642 var recv_id
= article
.getAttribute("id");
1645 $("CWRAP-" + id
).innerHTML
= article
.firstChild
.nodeValue
;
1648 $("CWRAP-" + id
).innerHTML
= __("Unable to load article.");
1656 var new_offset
= $("RROW-" + id
).offsetTop
;
1658 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1660 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1661 $("headlines-frame").scrollTop
= new_offset
;
1663 toggleUnread(id
, 0, true);
1667 exception_error("cdmExpandArticle", e
);
1673 function fixHeadlinesOrder(ids
) {
1675 for (var i
= 0; i
< ids
.length
; i
++) {
1676 var e
= $("RROW-" + ids
[i
]);
1680 e
.removeClassName("even");
1681 e
.addClassName("odd");
1683 e
.removeClassName("odd");
1684 e
.addClassName("even");
1689 exception_error("fixHeadlinesOrder", e
);
1693 function getArticleUnderPointer() {
1694 return post_under_pointer
;
1697 function zoomToArticle(event
, id
) {
1699 var cached_article
= cache_find(id
);
1701 if (dijit
.byId("ATAB-" + id
))
1702 if (!event
|| !event
.shiftKey
)
1703 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1705 if (cached_article
) {
1706 //closeArticlePanel();
1708 var article_pane
= new dijit
.layout
.ContentPane({
1709 title
: __("Loading...") , content
: cached_article
,
1710 style
: 'padding : 0px;',
1714 dijit
.byId("content-tabs").addChild(article_pane
);
1716 if (!event
|| !event
.shiftKey
)
1717 dijit
.byId("content-tabs").selectChild(article_pane
);
1719 if ($("PTITLE-" + id
))
1720 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1724 var query
= "?op=rpc&subop=getArticles&ids=" + param_escape(id
);
1726 notify_progress("Loading, please wait...", true);
1728 new Ajax
.Request("backend.php", {
1730 onComplete: function(transport
) {
1733 if (transport
.responseXML
) {
1734 //closeArticlePanel();
1736 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1737 var content
= article
.firstChild
.nodeValue
;
1739 var article_pane
= new dijit
.layout
.ContentPane({
1740 title
: "article-" + id
, content
: content
,
1741 style
: 'padding : 0px;',
1745 dijit
.byId("content-tabs").addChild(article_pane
);
1747 if (!event
|| !event
.shiftKey
)
1748 dijit
.byId("content-tabs").selectChild(article_pane
);
1750 if ($("PTITLE-" + id
))
1751 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1758 exception_error("zoomToArticle", e
);
1762 function scrollArticle(offset
) {
1765 var ci
= $("content-insert");
1767 ci
.scrollTop
+= offset
;
1770 var hi
= $("headlines-frame");
1772 hi
.scrollTop
+= offset
;
1777 exception_error("scrollArticle", e
);
1781 function show_labels_in_headlines(transport
) {
1783 if (transport
.responseXML
) {
1784 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
1786 var elems
= info
.getElementsByTagName("entry");
1788 for (var l
= 0; l
< elems
.length
; l
++) {
1789 var e_id
= elems
[l
].getAttribute("id");
1793 var ctr
= $("HLLCTR-" + e_id
);
1796 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
1804 exception_error("show_labels_in_headlines", e
);
1809 function toggleHeadlineActions() {
1811 var e
= $("headlineActionsBody");
1812 var p
= $("headlineActionsDrop");
1814 if (!Element
.visible(e
)) {
1821 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
1822 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
1825 exception_error("toggleHeadlineActions", e
);
1829 function publishWithNote(id
, def_note
) {
1831 if (!def_note
) def_note
= '';
1833 var note
= prompt(__("Please enter a note for this article:"), def_note
);
1835 if (note
!= undefined) {
1836 togglePub(id
, false, false, note
);
1840 exception_error("publishWithNote", e
);
1844 function emailArticle(id
) {
1847 var ids
= getSelectedArticleIds2();
1849 if (ids
.length
== 0) {
1850 alert(__("No articles are selected."));
1854 id
= ids
.toString();
1857 if (dijit
.byId("emailArticleDlg"))
1858 dijit
.byId("emailArticleDlg").destroyRecursive();
1860 var query
= "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id
);
1862 dialog
= new dijit
.Dialog({
1863 id
: "emailArticleDlg",
1864 title
: __("Forward article by email"),
1865 style
: "width: 600px",
1866 execute: function() {
1867 if (this.validate()) {
1869 new Ajax
.Request("backend.php", {
1870 parameters
: dojo
.objectToQuery(this.attr('value')),
1871 onComplete: function(transport
) {
1873 var error
= transport
.responseXML
.getElementsByTagName('error')[0];
1876 alert(__('Error sending email:') + ' ' + error
.firstChild
.nodeValue
);
1878 notify_info('Your message has been sent.');
1887 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1888 dojo
.disconnect(tmph
);
1890 new Ajax
.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
1891 "backend.php?op=rpc&subop=completeEmails",
1892 { tokens
: '', paramName
: "search" });
1897 /* displayDlg('emailArticle', id,
1899 document.forms['article_email_form'].destination.focus();
1901 new Ajax.Autocompleter('destination', 'destination_choices',
1902 "backend.php?op=rpc&subop=completeEmails",
1903 { tokens: '', paramName: "search" });
1908 exception_error("emailArticle", e
);
1912 function dismissArticle(id
) {
1914 var elem
= $("RROW-" + id
);
1916 toggleUnread(id
, 0, true);
1918 new Effect
.Fade(elem
, {duration
: 0.5});
1920 active_post_id
= false;
1923 exception_error("dismissArticle", e
);
1927 function dismissSelectedArticles() {
1930 var ids
= getVisibleArticleIds();
1934 for (var i
= 0; i
< ids
.length
; i
++) {
1935 var elem
= $("RROW-" + ids
[i
]);
1937 if (elem
.className
&& elem
.hasClassName("Selected") &&
1938 ids
[i
] != active_post_id
) {
1939 new Effect
.Fade(elem
, {duration
: 0.5});
1947 selectionToggleUnread(false);
1949 fixHeadlinesOrder(tmp
);
1952 exception_error("dismissSelectedArticles", e
);
1956 function dismissReadArticles() {
1959 var ids
= getVisibleArticleIds();
1962 for (var i
= 0; i
< ids
.length
; i
++) {
1963 var elem
= $("RROW-" + ids
[i
]);
1965 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1966 !elem
.hasClassName("Selected")) {
1968 new Effect
.Fade(elem
, {duration
: 0.5});
1974 fixHeadlinesOrder(tmp
);
1977 exception_error("dismissSelectedArticles", e
);
1981 function getVisibleArticleIds() {
1986 getLoadedArticleIds().each(function(id
) {
1987 var elem
= $("RROW-" + id
);
1988 if (elem
&& Element
.visible(elem
))
1993 exception_error("getVisibleArticleIds", e
);
1999 function cdmClicked(event
, id
) {
2001 var shift_key
= event
.shiftKey
;
2005 if (!event
.ctrlKey
) {
2007 if (!getInitParam("cdm_expanded")) {
2008 return cdmExpandArticle(id
);
2011 selectArticles("none");
2014 var elem
= $("RROW-" + id
);
2017 elem
.removeClassName("Unread");
2019 var upd_img_pic
= $("FUPDPIC-" + id
);
2021 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
2022 upd_img_pic
.src
.match("fresh_sign.png"))) {
2024 upd_img_pic
.src
= "images/blank_icon.gif";
2027 active_post_id
= id
;
2029 var query
= "?op=rpc&subop=catchupSelected" +
2030 "&cmode=0&ids=" + param_escape(id
);
2032 new Ajax
.Request("backend.php", {
2034 onComplete: function(transport
) {
2035 handle_rpc_reply(transport
);
2040 toggleSelected(id
, true);
2041 toggleUnread(id
, 0, false);
2042 zoomToArticle(event
, id
);
2046 exception_error("cdmClicked");
2052 function postClicked(event
, id
) {
2055 if (!event
.ctrlKey
) {
2058 postOpenInNewTab(event
, id
);
2063 exception_error("postClicked");
2067 function hlOpenInNewTab(event
, id
) {
2068 toggleUnread(id
, 0, false);
2069 zoomToArticle(event
, id
);
2072 function postOpenInNewTab(event
, id
) {
2073 closeArticlePanel(id
);
2074 zoomToArticle(event
, id
);
2077 function hlClicked(event
, id
) {
2080 openArticleInNewWindow(id
);
2081 } else if (!event
.ctrlKey
) {
2086 toggleUnread(id
, 0, false);
2087 zoomToArticle(event
, id
);
2092 exception_error("hlClicked");
2096 function getFirstVisibleHeadlineId() {
2097 var rows
= getVisibleArticleIds();
2102 function getLastVisibleHeadlineId() {
2103 var rows
= getVisibleArticleIds();
2104 return rows
[rows
.length
-1];
2107 function openArticleInNewWindow(id
) {
2108 toggleUnread(id
, 0, false);
2109 window
.open("backend.php?op=la&id=" + id
);
2112 function isCdmMode() {
2113 return getInitParam("combined_display_mode");
2116 function markHeadline(id
) {
2117 var row
= $("RROW-" + id
);
2119 var check
= $("RCHK-" + id
);
2122 check
.checked
= true;
2125 row
.addClassName("Selected");
2129 function getRelativePostIds(id
, limit
) {
2135 if (!limit
) limit
= 3;
2137 var ids
= getVisibleArticleIds();
2139 for (var i
= 0; i
< ids
.length
; i
++) {
2141 for (var k
= 1; k
<= limit
; k
++) {
2142 if (i
> k
-1) tmp
.push(ids
[i
-k
]);
2143 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
2150 exception_error("getRelativePostIds", e
);
2156 function correctHeadlinesOffset(id
) {
2160 var container
= $("headlines-frame");
2161 var row
= $("RROW-" + id
);
2163 var viewport
= container
.offsetHeight
;
2165 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
2166 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
2168 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
2169 //console.log("Vport: " + viewport);
2171 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
2172 container
.scrollTop
= row
.offsetTop
;
2173 } else if (rel_offset_bottom
> viewport
) {
2175 /* doesn't properly work with Opera in some cases because
2176 Opera fucks up element scrolling */
2178 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
2182 exception_error("correctHeadlinesOffset", e
);
2187 function headlineActionsChange(elem
) {
2190 elem
.attr('value', 'false');
2192 exception_error("headlineActionsChange", e
);
2196 function closeArticlePanel() {
2198 var tabs
= dijit
.byId("content-tabs");
2199 var child
= tabs
.selectedChildWidget
;
2201 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
2202 tabs
.removeChild(child
);
2205 if (dijit
.byId("content-insert"))
2206 dijit
.byId("headlines-wrap-inner").removeChild(
2207 dijit
.byId("content-insert"));
2211 function initHeadlinesMenu() {
2213 if (dijit
.byId("headlinesMenu"))
2214 dijit
.byId("headlinesMenu").destroyRecursive();
2219 nodes
= $$("#headlines-frame > div[id*=RROW]");
2221 nodes
= $$("#headlines-frame span[id*=RTITLE]");
2224 nodes
.each(function(node
) {
2228 var menu
= new dijit
.Menu({
2229 id
: "headlinesMenu",
2233 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
2234 var callerNode
= event
.target
, match
= null, tries
= 0;
2236 while (match
== null && callerNode
&& tries
<= 3) {
2237 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
2238 callerNode
= callerNode
.parentNode
;
2242 if (match
) this.callerRowId
= parseInt(match
[1]);
2247 menu
.addChild(new dijit
.MenuItem({
2248 label
: __("View article"),
2249 onClick: function(event
) {
2250 view(this.getParent().callerRowId
);
2253 menu
.addChild(new dijit
.MenuItem({
2254 label
: __("View in a new tab"),
2255 onClick: function(event
) {
2256 hlOpenInNewTab(event
, this.getParent().callerRowId
);
2259 menu
.addChild(new dijit
.MenuSeparator());
2261 menu
.addChild(new dijit
.MenuItem({
2262 label
: __("Open original article"),
2263 onClick: function(event
) {
2264 openArticleInNewWindow(this.getParent().callerRowId
);
2267 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2271 menu
.addChild(new dijit
.MenuSeparator());
2273 var labelsMenu
= new dijit
.Menu({ownerMenu
: menu
});
2275 labels
.each(function(label
) {
2276 var id
= label
.id
[0];
2277 var bare_id
= id
.substr(id
.indexOf(":")+1);
2278 var name
= label
.name
[0];
2280 bare_id
= -11-bare_id
;
2282 labelsMenu
.addChild(new dijit
.MenuItem({
2285 onClick: function(event
) {
2286 //console.log(this.labelId);
2287 //console.log(this.getParent().ownerMenu.callerRowId);
2288 selectionAssignLabel(this.labelId
,
2289 [this.getParent().ownerMenu
.callerRowId
]);
2293 menu
.addChild(new dijit
.PopupMenuItem({
2294 label
: __("Labels"),
2302 exception_error("initHeadlinesMenu", e
);
2306 function tweetArticle(id
) {
2308 var query
= "?op=rpc&subop=getTweetInfo&id=" + param_escape(id
);
2313 var ts
= d
.getTime();
2315 var w
= window
.open('backend.php?op=loading', 'ttrss_tweet',
2316 "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
2318 new Ajax
.Request("backend.php", {
2320 onComplete: function(transport
) {
2321 var ti
= JSON
.parse(transport
.responseText
);
2323 var share_url
= "http://twitter.com/share?_=" + ts
+
2324 "&text=" + param_escape(ti
.title
) +
2325 "&url=" + param_escape(ti
.link
);
2327 w
.location
.href
= share_url
;
2333 exception_error("tweetArticle", e
);