]>
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 headlines_callback2(transport
, feed_cur_page
) {
23 if (!handle_rpc_reply(transport
)) return;
25 loading_set_progress(25);
27 console
.log("headlines_callback2 [page=" + feed_cur_page
+ "]");
29 if (!transport_error_check(transport
)) return;
34 if (transport
.responseXML
) {
35 var headlines
= transport
.responseXML
.getElementsByTagName("headlines")[0];
37 is_cat
= headlines
.getAttribute("is_cat");
38 feed_id
= headlines
.getAttribute("id");
39 setActiveFeedId(feed_id
, is_cat
);
43 var update_btn
= document
.forms
["main_toolbar_form"].update
;
45 update_btn
.disabled
= !(feed_id
>= 0 && !is_cat
);
48 if (feed_cur_page
== 0) {
49 $("headlines-frame").scrollTop
= 0;
53 if (transport
.responseXML
) {
54 var response
= transport
.responseXML
;
56 var headlines
= response
.getElementsByTagName("headlines")[0];
58 var headlines_content
= headlines
.getElementsByTagName("content")[0];
59 var headlines_toolbar
= headlines
.getElementsByTagName("toolbar")[0];
61 var headlines_info
= response
.getElementsByTagName("headlines-info")[0];
64 headlines_info
= JSON
.parse(headlines_info
.firstChild
.nodeValue
);
66 console
.error("didn't find headlines-info object in response");
70 var headlines_count
= headlines_info
.count
;
71 var headlines_unread
= headlines_info
.unread
;
72 var disable_cache
= headlines_info
.disable_cache
;
74 vgroup_last_feed
= headlines_info
.vgroup_last_feed
;
76 if (parseInt(headlines_count
) < getInitParam("default_article_limit")) {
77 _infscroll_disable
= 1;
79 _infscroll_disable
= 0;
82 var counters
= response
.getElementsByTagName("counters")[0];
83 var articles
= response
.getElementsByTagName("article");
84 var runtime_info
= response
.getElementsByTagName("runtime-info");
86 if (feed_cur_page
== 0) {
88 dijit
.byId("headlines-frame").attr('content',
89 headlines_content
.firstChild
.nodeValue
);
91 dijit
.byId("headlines-toolbar").attr('content',
92 headlines_toolbar
.firstChild
.nodeValue
);
96 var cache_prefix
= "";
104 cache_invalidate(cache_prefix
+ feed_id
);
106 if (!disable_cache
) {
107 cache_inject(cache_prefix
+ feed_id
,
108 $("headlines-frame").innerHTML
, headlines_unread
);
112 console
.warn("headlines_callback: returned no data");
113 dijit
.byId("headlines-frame").attr('content',
114 "<div class='whiteBox'>" +
115 __('Could not update headlines (missing XML data)') + "</div>");
120 if (headlines_count
> 0) {
121 console
.log("adding some more headlines...");
123 var c
= dijit
.byId("headlines-frame");
124 var ids
= getSelectedArticleIds2();
126 //c.attr('content', c.attr('content') +
127 // headlines_content.firstChild.nodeValue);
129 $("headlines-tmp").innerHTML
= headlines_content
.firstChild
.nodeValue
;
131 $$("#headlines-tmp > div").each(function(row
) {
132 c
.domNode
.appendChild(row
);
135 console
.log("restore selected ids: " + ids
);
137 for (var i
= 0; i
< ids
.length
; i
++) {
138 markHeadline(ids
[i
]);
144 console
.log("no new headlines received");
147 console
.warn("headlines_callback: returned no data");
148 notify_error("Error while trying to load more headlines");
154 for (var i
= 0; i
< articles
.length
; i
++) {
155 var a_id
= articles
[i
].getAttribute("id");
156 //console.log("found id: " + a_id);
157 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
160 console
.log("no cached articles received");
164 parse_counters(counters
);
169 console
.warn("headlines_callback: returned no XML object");
170 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
171 __('Could not update headlines (missing XML object)') + "</div>");
175 if (_cdm_wd_timeout
) window
.clearTimeout(_cdm_wd_timeout
);
178 getActiveFeedId() != -3 &&
179 getInitParam("cdm_auto_catchup") == 1) {
180 console
.log("starting CDM watchdog");
181 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 5000);
182 _cdm_wd_vishist
= new Array();
184 console
.log("not in CDM mode or watchdog disabled");
187 _feed_cur_page
= feed_cur_page
;
188 _infscroll_request_sent
= 0;
193 exception_error("headlines_callback2", e
, transport
);
197 function render_article(article
) {
199 dijit
.byId("headlines-wrap-inner").addChild(
200 dijit
.byId("content-insert"));
202 var c
= dijit
.byId("content-insert");
205 c
.domNode
.scrollTop
= 0;
208 c
.attr('content', article
);
210 correctHeadlinesOffset(getActiveArticleId());
213 exception_error("render_article", e
);
217 function showArticleInHeadlines(id
) {
221 selectArticles("none");
223 var crow
= $("RROW-" + id
);
227 var article_is_unread
= crow
.hasClassName("Unread");
229 crow
.removeClassName("Unread");
231 selectArticles('none');
233 var upd_img_pic
= $("FUPDPIC-" + id
);
235 var cache_prefix
= "";
237 if (activeFeedIsCat()) {
243 var view_mode
= false;
246 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
247 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
252 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
253 upd_img_pic
.src
.match("fresh_sign.png"))) {
255 upd_img_pic
.src
= "images/blank_icon.gif";
257 cache_invalidate(cache_prefix
+ getActiveFeedId());
259 cache_inject(cache_prefix
+ getActiveFeedId(),
260 $("headlines-frame").innerHTML
,
261 getFeedUnread(getActiveFeedId()));
263 } else if (article_is_unread
&& view_mode
== "all_articles") {
265 cache_invalidate(cache_prefix
+ getActiveFeedId());
267 cache_inject(cache_prefix
+ getActiveFeedId(),
268 $("headlines-frame").innerHTML
,
269 getFeedUnread(getActiveFeedId())-1);
271 } else if (article_is_unread
) {
272 cache_invalidate(cache_prefix
+ getActiveFeedId());
277 if (article_is_unread
)
278 _force_scheduled_update
= true;
281 exception_error("showArticleInHeadlines", e
);
285 function article_callback2(transport
, id
) {
287 console
.log("article_callback2 " + id
);
289 if (!handle_rpc_reply(transport
)) return;
291 if (transport
.responseXML
) {
293 if (!transport_error_check(transport
)) return;
295 var upic
= $('FUPDPIC-' + id
);
298 upic
.src
= 'images/blank_icon.gif';
301 if (id
!= last_requested_article
) {
302 console
.log("requested article id is out of sequence, aborting");
306 // active_post_id = id;
308 //console.log("looking for articles to cache...");
310 var articles
= transport
.responseXML
.getElementsByTagName("article");
312 for (var i
= 0; i
< articles
.length
; i
++) {
313 var a_id
= articles
[i
].getAttribute("id");
315 //console.log("found id: " + a_id);
317 if (a_id
== active_post_id
) {
318 //console.log("active article, rendering...");
319 render_article(articles
[i
].firstChild
.nodeValue
);
322 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
326 // showArticleInHeadlines(id);
328 var reply
= transport
.responseXML
.firstChild
.firstChild
;
331 console
.warn("article_callback: returned no XML object");
332 //var f = $("content-frame");
333 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
336 var date
= new Date();
337 last_article_view
= date
.getTime() / 1000;
343 exception_error("article_callback2", e
, transport
);
349 console
.log("loading article: " + id
);
351 var cached_article
= cache_find(id
);
353 console
.log("cache check result: " + (cached_article
!= false));
357 var query
= "?op=view&id=" + param_escape(id
);
359 var neighbor_ids
= getRelativePostIds(active_post_id
);
361 /* only request uncached articles */
363 var cids_to_request
= Array();
365 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
366 if (!cache_check(neighbor_ids
[i
])) {
367 cids_to_request
.push(neighbor_ids
[i
]);
371 console
.log("additional ids: " + cids_to_request
.toString());
373 query
= query
+ "&cids=" + cids_to_request
.toString();
375 var crow
= $("RROW-" + id
);
376 var article_is_unread
= crow
.hasClassName("Unread");
379 showArticleInHeadlines(id
);
381 if (!cached_article
) {
383 var upic
= $('FUPDPIC-' + id
);
386 upic
.src
= getInitParam("sign_progress");
389 } else if (cached_article
&& article_is_unread
) {
391 query
= query
+ "&mode=prefetch";
393 render_article(cached_article
);
395 } else if (cached_article
) {
397 query
= query
+ "&mode=prefetch_old";
398 render_article(cached_article
);
404 last_requested_article
= id
;
406 new Ajax
.Request("backend.php", {
408 onComplete: function(transport
) {
409 article_callback2(transport
, id
);
415 exception_error("view", e
);
420 return toggleMark(id
);
424 return togglePub(id
);
427 function toggleMark(id
, client_only
) {
429 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
431 var img
= $("FMPIC-" + id
);
435 if (img
.src
.match("mark_unset")) {
436 img
.src
= img
.src
.replace("mark_unset", "mark_set");
437 img
.alt
= __("Unstar article");
438 query
= query
+ "&mark=1";
441 img
.src
= img
.src
.replace("mark_set", "mark_unset");
442 img
.alt
= __("Star article");
443 query
= query
+ "&mark=0";
447 new Ajax
.Request("backend.php", {
449 onComplete: function(transport
) {
450 handle_rpc_json(transport
);
455 exception_error("toggleMark", e
);
459 function togglePub(id
, client_only
, no_effects
, note
) {
461 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
463 if (note
!= undefined) {
464 query
= query
+ "¬e=" + param_escape(note
);
466 query
= query
+ "¬e=undefined";
469 var img
= $("FPPIC-" + id
);
473 if (img
.src
.match("pub_unset") || note
!= undefined) {
474 img
.src
= img
.src
.replace("pub_unset", "pub_set");
475 img
.alt
= __("Unpublish article");
476 query
= query
+ "&pub=1";
479 img
.src
= img
.src
.replace("pub_set", "pub_unset");
480 img
.alt
= __("Publish article");
482 query
= query
+ "&pub=0";
486 new Ajax
.Request("backend.php", {
488 onComplete: function(transport
) {
489 handle_rpc_reply(transport
);
491 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
494 var note_id
= note
.getAttribute("id");
495 var note_size
= note
.getAttribute("size");
496 var note_content
= note
.firstChild
.nodeValue
;
498 var container
= $('POSTNOTE-' + note_id
);
500 cache_invalidate(note_id
);
503 if (note_size
== "0") {
504 Element
.hide(container
);
506 container
.innerHTML
= note_content
;
507 Element
.show(container
);
516 exception_error("togglePub", e
);
520 function moveToPost(mode
) {
524 var rows
= getVisibleArticleIds();
529 if (!$('RROW-' + active_post_id
)) {
530 active_post_id
= false;
533 if (active_post_id
== false) {
534 next_id
= getFirstVisibleHeadlineId();
535 prev_id
= getLastVisibleHeadlineId();
537 for (var i
= 0; i
< rows
.length
; i
++) {
538 if (rows
[i
] == active_post_id
) {
545 if (mode
== "next") {
549 cdmExpandArticle(next_id
);
550 cdmScrollToArticleId(next_id
);
553 correctHeadlinesOffset(next_id
);
554 view(next_id
, getActiveFeedId());
559 if (mode
== "prev") {
562 cdmExpandArticle(prev_id
);
563 cdmScrollToArticleId(prev_id
);
565 correctHeadlinesOffset(prev_id
);
566 view(prev_id
, getActiveFeedId());
572 exception_error("moveToPost", e
);
576 function toggleSelected(id
, force_on
) {
579 var cb
= $("RCHK-" + id
);
580 var row
= $("RROW-" + id
);
583 if (row
.hasClassName('Selected') && !force_on
) {
584 row
.removeClassName('Selected');
585 if (cb
) cb
.checked
= false;
587 row
.addClassName('Selected');
588 if (cb
) cb
.checked
= true;
592 exception_error("toggleSelected", e
);
596 function toggleUnread_afh(effect
) {
599 var elem
= effect
.element
;
600 elem
.style
.backgroundColor
= "";
603 exception_error("toggleUnread_afh", e
);
607 function toggleUnread(id
, cmode
, effect
) {
610 var row
= $("RROW-" + id
);
612 if (cmode
== undefined || cmode
== 2) {
613 if (row
.hasClassName("Unread")) {
614 row
.removeClassName("Unread");
617 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
618 afterFinish
: toggleUnread_afh
,
619 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
623 row
.addClassName("Unread");
626 } else if (cmode
== 0) {
628 row
.removeClassName("Unread");
631 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
632 afterFinish
: toggleUnread_afh
,
633 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
636 } else if (cmode
== 1) {
637 row
.addClassName("Unread");
640 if (cmode
== undefined) cmode
= 2;
642 var query
= "?op=rpc&subop=catchupSelected" +
643 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
645 // notify_progress("Loading, please wait...");
647 new Ajax
.Request("backend.php", {
649 onComplete: function(transport
) {
650 handle_rpc_json(transport
);
656 exception_error("toggleUnread", e
);
660 function selectionRemoveLabel(id
, ids
) {
663 if (!ids
) var ids
= getSelectedArticleIds2();
665 if (ids
.length
== 0) {
666 alert(__("No articles are selected."));
670 // var ok = confirm(__("Remove selected articles from label?"));
674 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
675 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
679 // notify_progress("Loading, please wait...");
681 cache_invalidate("F:" + (-11 - id
));
683 new Ajax
.Request("backend.php", {
685 onComplete: function(transport
) {
686 show_labels_in_headlines(transport
);
687 handle_rpc_reply(transport
);
693 exception_error("selectionAssignLabel", e
);
698 function selectionAssignLabel(id
, ids
) {
701 if (!ids
) ids
= getSelectedArticleIds2();
703 if (ids
.length
== 0) {
704 alert(__("No articles are selected."));
708 // var ok = confirm(__("Assign selected articles to label?"));
712 cache_invalidate("F:" + (-11 - id
));
714 var query
= "?op=rpc&subop=assignToLabel&ids=" +
715 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
719 // notify_progress("Loading, please wait...");
721 new Ajax
.Request("backend.php", {
723 onComplete: function(transport
) {
724 show_labels_in_headlines(transport
);
725 handle_rpc_reply(transport
);
731 exception_error("selectionAssignLabel", e
);
736 function selectionToggleUnread(set_state
, callback
, no_error
) {
738 var rows
= getSelectedArticleIds2();
740 if (rows
.length
== 0 && !no_error
) {
741 alert(__("No articles are selected."));
745 for (i
= 0; i
< rows
.length
; i
++) {
746 var row
= $("RROW-" + rows
[i
]);
748 if (set_state
== undefined) {
749 if (row
.hasClassName("Unread")) {
750 row
.removeClassName("Unread");
752 row
.addClassName("Unread");
756 if (set_state
== false) {
757 row
.removeClassName("Unread");
760 if (set_state
== true) {
761 row
.addClassName("Unread");
766 if (rows
.length
> 0) {
770 if (set_state
== undefined) {
772 } else if (set_state
== true) {
774 } else if (set_state
== false) {
778 var query
= "?op=rpc&subop=catchupSelected" +
779 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
781 notify_progress("Loading, please wait...");
783 new Ajax
.Request("backend.php", {
785 onComplete: function(transport
) {
786 handle_rpc_json(transport
);
787 if (callback
) callback(transport
);
793 exception_error("selectionToggleUnread", e
);
797 function selectionToggleMarked() {
800 var rows
= getSelectedArticleIds2();
802 if (rows
.length
== 0) {
803 alert(__("No articles are selected."));
807 for (i
= 0; i
< rows
.length
; i
++) {
808 toggleMark(rows
[i
], true, true);
811 if (rows
.length
> 0) {
813 var query
= "?op=rpc&subop=markSelected&ids=" +
814 param_escape(rows
.toString()) + "&cmode=2";
816 new Ajax
.Request("backend.php", {
818 onComplete: function(transport
) {
819 handle_rpc_json(transport
);
825 exception_error("selectionToggleMarked", e
);
829 function selectionTogglePublished() {
832 var rows
= getSelectedArticleIds2();
834 if (rows
.length
== 0) {
835 alert(__("No articles are selected."));
839 for (i
= 0; i
< rows
.length
; i
++) {
840 togglePub(rows
[i
], true, true);
843 if (rows
.length
> 0) {
845 var query
= "?op=rpc&subop=publishSelected&ids=" +
846 param_escape(rows
.toString()) + "&cmode=2";
848 new Ajax
.Request("backend.php", {
850 onComplete: function(transport
) {
851 handle_rpc_json(transport
);
857 exception_error("selectionToggleMarked", e
);
861 function getSelectedArticleIds2() {
865 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
867 rv
.push(child
.id
.replace("RROW-", ""));
873 function getLoadedArticleIds() {
876 var children
= $$("#headlines-frame > div[id*=RROW-]");
878 children
.each(function(child
) {
879 rv
.push(child
.id
.replace("RROW-", ""));
886 // mode = all,none,unread,invert
887 function selectArticles(mode
) {
890 var children
= $$("#headlines-frame > div[id*=RROW]");
892 children
.each(function(child
) {
893 var id
= child
.id
.replace("RROW-", "");
894 var cb
= $("RCHK-" + id
);
897 child
.addClassName("Selected");
899 } else if (mode
== "unread") {
900 if (child
.hasClassName("Unread")) {
901 child
.addClassName("Selected");
904 child
.removeClassName("Selected");
907 } else if (mode
== "invert") {
908 if (child
.hasClassName("Selected")) {
909 child
.removeClassName("Selected");
912 child
.addClassName("Selected");
917 child
.removeClassName("Selected");
923 exception_error("selectArticles", e
);
927 function catchupPage() {
929 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
931 var str
= __("Mark all visible articles in %s as read?");
933 str
= str
.replace("%s", fn
);
935 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
939 selectArticles('all');
940 selectionToggleUnread(false, 'viewCurrentFeed()', true)
941 selectArticles('none');
944 function deleteSelection() {
948 var rows
= getSelectedArticleIds2();
950 if (rows
.length
== 0) {
951 alert(__("No articles are selected."));
955 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
959 if (getActiveFeedId() != 0) {
960 str
= __("Delete %d selected articles in %s?");
962 str
= __("Delete %d selected articles?");
965 str
= str
.replace("%d", rows
.length
);
966 str
= str
.replace("%s", fn
);
968 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
972 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
976 new Ajax
.Request("backend.php", {
978 onComplete: function(transport
) {
979 handle_rpc_json(transport
);
984 exception_error("deleteSelection", e
);
988 function archiveSelection() {
992 var rows
= getSelectedArticleIds2();
994 if (rows
.length
== 0) {
995 alert(__("No articles are selected."));
999 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1003 if (getActiveFeedId() != 0) {
1004 str
= __("Archive %d selected articles in %s?");
1007 str
= __("Move %d archived articles back?");
1011 str
= str
.replace("%d", rows
.length
);
1012 str
= str
.replace("%s", fn
);
1014 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1018 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1022 for (var i
= 0; i
< rows
.length
; i
++) {
1023 cache_invalidate(rows
[i
]);
1026 new Ajax
.Request("backend.php", {
1028 onComplete: function(transport
) {
1029 handle_rpc_json(transport
);
1034 exception_error("archiveSelection", e
);
1038 function catchupSelection() {
1042 var rows
= getSelectedArticleIds2();
1044 if (rows
.length
== 0) {
1045 alert(__("No articles are selected."));
1049 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1051 var str
= __("Mark %d selected articles in %s as read?");
1053 str
= str
.replace("%d", rows
.length
);
1054 str
= str
.replace("%s", fn
);
1056 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1060 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1063 exception_error("catchupSelection", e
);
1067 function editArticleTags(id
) {
1068 /* displayDlg('editArticleTags', id,
1070 $("tags_str").focus();
1072 new Ajax.Autocompleter('tags_str', 'tags_choices',
1073 "backend.php?op=rpc&subop=completeTags",
1074 { tokens: ',', paramName: "search" });
1077 var query
= "backend.php?op=dlg&id=editArticleTags¶m=" + param_escape(id
);
1079 if (dijit
.byId("editTagsDlg"))
1080 dijit
.byId("editTagsDlg").destroyRecursive();
1082 dialog
= new dijit
.Dialog({
1084 title
: __("Edit article Tags"),
1085 style
: "width: 600px",
1086 execute: function() {
1087 if (this.validate()) {
1088 var query
= dojo
.objectToQuery(this.attr('value'));
1090 notify_progress("Saving article tags...", true);
1092 new Ajax
.Request("backend.php", {
1094 onComplete: function(transport
) {
1098 if (transport
.responseXML
) {
1099 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1102 var id
= tags_str
.getAttribute("id");
1105 var tags
= $("ATSTR-" + id
);
1107 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1110 cache_invalidate(id
);
1121 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1122 dojo
.disconnect(tmph
);
1124 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1125 "backend.php?op=rpc&subop=completeTags",
1126 { tokens
: ',', paramName
: "search" });
1133 function cdmScrollToArticleId(id
) {
1135 var ctr
= $("headlines-frame");
1136 var e
= $("RROW-" + id
);
1138 if (!e
|| !ctr
) return;
1140 ctr
.scrollTop
= e
.offsetTop
;
1143 exception_error("cdmScrollToArticleId", e
);
1147 function cdmWatchdog() {
1151 var ctr
= $("headlines-frame");
1155 var ids
= new Array();
1157 var e
= ctr
.firstChild
;
1160 if (e
.className
&& e
.hasClassName("Unread") && e
.id
&&
1161 e
.id
.match("RROW-")) {
1163 // article fits in viewport OR article is longer than viewport and
1164 // its bottom is visible
1166 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1167 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1169 // console.log(e.id + " is visible " + e.offsetTop + "." +
1170 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1171 // (ctr.scrollTop + ctr.offsetHeight));
1173 ids
.push(e
.id
.replace("RROW-", ""));
1175 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1176 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1177 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1179 ids
.push(e
.id
.replace("RROW-", ""));
1183 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1185 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1186 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1188 ids.push(e.id.replace("RROW-", ""));
1197 console
.log("cdmWatchdog, ids= " + ids
.toString());
1199 if (ids
.length
> 0) {
1201 for (var i
= 0; i
< ids
.length
; i
++) {
1202 var e
= $("RROW-" + ids
[i
]);
1204 e
.removeClassName("Unread");
1208 var query
= "?op=rpc&subop=catchupSelected" +
1209 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1211 new Ajax
.Request("backend.php", {
1213 onComplete: function(transport
) {
1214 handle_rpc_json(transport
);
1219 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1222 exception_error("cdmWatchdog", e
);
1228 function cache_inject(id
, article
, param
) {
1231 if (!cache_check_param(id
, param
)) {
1232 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1234 var date
= new Date();
1235 var ts
= Math
.round(date
.getTime() / 1000);
1239 cache_obj
["id"] = id
;
1240 cache_obj
["data"] = article
;
1241 cache_obj
["param"] = param
;
1243 if (param
) id
= id
+ ":" + param
;
1245 cache_added
["TS:" + id
] = ts
;
1247 if (has_local_storage())
1248 sessionStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1250 article_cache
.push(cache_obj
);
1253 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1256 exception_error("cache_inject", e
);
1260 function cache_find(id
) {
1262 if (has_local_storage()) {
1263 var cache_obj
= sessionStorage
.getItem(id
);
1266 cache_obj
= JSON
.parse(cache_obj
);
1269 return cache_obj
['data'];
1273 for (var i
= 0; i
< article_cache
.length
; i
++) {
1274 if (article_cache
[i
]["id"] == id
) {
1275 return article_cache
[i
]["data"];
1282 function cache_find_param(id
, param
) {
1284 if (has_local_storage()) {
1286 if (param
) id
= id
+ ":" + param
;
1288 var cache_obj
= sessionStorage
.getItem(id
);
1291 cache_obj
= JSON
.parse(cache_obj
);
1294 return cache_obj
['data'];
1298 for (var i
= 0; i
< article_cache
.length
; i
++) {
1299 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1300 return article_cache
[i
]["data"];
1308 function cache_check(id
) {
1309 if (has_local_storage()) {
1310 if (sessionStorage
.getItem(id
))
1313 for (var i
= 0; i
< article_cache
.length
; i
++) {
1314 if (article_cache
[i
]["id"] == id
) {
1322 function cache_check_param(id
, param
) {
1323 if (has_local_storage()) {
1325 if (param
) id
= id
+ ":" + param
;
1327 if (sessionStorage
.getItem(id
))
1331 for (var i
= 0; i
< article_cache
.length
; i
++) {
1332 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1340 function cache_expire() {
1341 if (has_local_storage()) {
1343 var date
= new Date();
1344 var timestamp
= Math
.round(date
.getTime() / 1000);
1346 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1348 var id
= sessionStorage
.key(i
);
1350 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1351 sessionStorage
.removeItem(id
);
1356 while (article_cache
.length
> 25) {
1357 article_cache
.shift();
1362 function cache_flush() {
1363 if (has_local_storage()) {
1364 sessionStorage
.clear();
1366 article_cache
= new Array();
1370 function cache_invalidate(id
) {
1372 if (has_local_storage()) {
1376 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1377 var key
= sessionStorage
.key(i
);
1379 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1381 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1382 sessionStorage
.removeItem(key
);
1393 while (i
< article_cache
.length
) {
1394 if (article_cache
[i
]["id"] == id
) {
1395 //console.log("cache_invalidate: removed id " + id);
1396 article_cache
.splice(i
, 1);
1403 //console.log("cache_invalidate: id not found: " + id);
1406 exception_error("cache_invalidate", e
);
1410 function getActiveArticleId() {
1411 return active_post_id
;
1414 function preloadBatchedArticles() {
1417 var query
= "?op=rpc&subop=getArticles&ids=" +
1418 preload_id_batch
.toString();
1420 new Ajax
.Request("backend.php", {
1422 onComplete: function(transport
) {
1424 preload_id_batch
= [];
1426 var articles
= transport
.responseXML
.getElementsByTagName("article");
1428 for (var i
= 0; i
< articles
.length
; i
++) {
1429 var id
= articles
[i
].getAttribute("id");
1430 if (!cache_check(id
)) {
1431 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1432 console
.log("preloaded article: " + id
);
1438 exception_error("preloadBatchedArticles", e
);
1442 function preloadArticleUnderPointer(id
) {
1444 if (getInitParam("bw_limit") == "1") return;
1446 if (post_under_pointer
== id
&& !cache_check(id
)) {
1448 console
.log("trying to preload article " + id
);
1450 var neighbor_ids
= getRelativePostIds(id
, 1);
1452 /* only request uncached articles */
1454 if (preload_id_batch
.indexOf(id
) == -1) {
1455 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1456 if (!cache_check(neighbor_ids
[i
])) {
1457 preload_id_batch
.push(neighbor_ids
[i
]);
1462 if (preload_id_batch
.indexOf(id
) == -1)
1463 preload_id_batch
.push(id
);
1465 //console.log("preload ids batch: " + preload_id_batch.toString());
1467 window
.clearTimeout(preload_timeout_id
);
1468 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1472 exception_error("preloadArticleUnderPointer", e
);
1476 function postMouseIn(id
) {
1478 if (post_under_pointer
!= id
) {
1479 post_under_pointer
= id
;
1481 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1486 exception_error("postMouseIn", e
);
1490 function postMouseOut(id
) {
1492 post_under_pointer
= false;
1494 exception_error("postMouseOut", e
);
1498 function headlines_scroll_handler(e
) {
1501 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1502 if (!_infscroll_disable
) {
1508 exception_error("headlines_scroll_handler", e
);
1512 function catchupRelativeToArticle(below
) {
1517 if (!getActiveArticleId()) {
1518 alert(__("No article is selected."));
1522 var visible_ids
= getVisibleArticleIds();
1524 var ids_to_mark
= new Array();
1527 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1528 if (visible_ids
[i
] != getActiveArticleId()) {
1529 var e
= $("RROW-" + visible_ids
[i
]);
1531 if (e
&& e
.hasClassName("Unread")) {
1532 ids_to_mark
.push(visible_ids
[i
]);
1539 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1540 if (visible_ids
[i
] != getActiveArticleId()) {
1541 var e
= $("RROW-" + visible_ids
[i
]);
1543 if (e
&& e
.hasClassName("Unread")) {
1544 ids_to_mark
.push(visible_ids
[i
]);
1552 if (ids_to_mark
.length
== 0) {
1553 alert(__("No articles found to mark"));
1555 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1557 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1559 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1560 var e
= $("RROW-" + ids_to_mark
[i
]);
1561 e
.removeClassName("Unread");
1564 var query
= "?op=rpc&subop=catchupSelected" +
1565 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1567 new Ajax
.Request("backend.php", {
1569 onComplete: function(transport
) {
1570 handle_rpc_json(transport
);
1577 exception_error("catchupRelativeToArticle", e
);
1581 function cdmExpandArticle(id
) {
1586 var elem
= $("CICD-" + active_post_id
);
1588 var upd_img_pic
= $("FUPDPIC-" + id
);
1590 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1591 upd_img_pic
.src
.match("fresh_sign.png"))) {
1593 upd_img_pic
.src
= "images/blank_icon.gif";
1596 if (id
== active_post_id
&& Element
.visible(elem
))
1599 selectArticles("none");
1601 var old_offset
= $("RROW-" + id
).offsetTop
;
1603 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1605 Element
.show("CEXC-" + active_post_id
);
1608 active_post_id
= id
;
1610 elem
= $("CICD-" + id
);
1612 if (!Element
.visible(elem
)) {
1614 Element
.hide("CEXC-" + id
);
1616 if ($("CWRAP-" + id
).innerHTML
== "") {
1618 $("FUPDPIC-" + id
).src
= "images/indicator_tiny.gif";
1620 $("CWRAP-" + id
).innerHTML
= "<div class=\"insensitive\">" +
1621 __("Loading, please wait...") + "</div>";
1623 var query
= "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id
);
1625 //console.log(query);
1627 new Ajax
.Request("backend.php", {
1629 onComplete: function(transport
) {
1630 $("FUPDPIC-" + id
).src
= 'images/blank_icon.gif';
1632 handle_rpc_json(transport
);
1634 var reply
= JSON
.parse(transport
.responseText
);
1637 var article
= reply
['article']['content'];
1638 var recv_id
= reply
['article']['id'];
1641 $("CWRAP-" + id
).innerHTML
= article
;
1644 $("CWRAP-" + id
).innerHTML
= __("Unable to load article.");
1652 var new_offset
= $("RROW-" + id
).offsetTop
;
1654 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1656 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1657 $("headlines-frame").scrollTop
= new_offset
;
1659 toggleUnread(id
, 0, true);
1663 exception_error("cdmExpandArticle", e
);
1669 function fixHeadlinesOrder(ids
) {
1671 for (var i
= 0; i
< ids
.length
; i
++) {
1672 var e
= $("RROW-" + ids
[i
]);
1676 e
.removeClassName("even");
1677 e
.addClassName("odd");
1679 e
.removeClassName("odd");
1680 e
.addClassName("even");
1685 exception_error("fixHeadlinesOrder", e
);
1689 function getArticleUnderPointer() {
1690 return post_under_pointer
;
1693 function zoomToArticle(event
, id
) {
1695 var cached_article
= cache_find(id
);
1697 if (dijit
.byId("ATAB-" + id
))
1698 if (!event
|| !event
.shiftKey
)
1699 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1701 if (cached_article
) {
1702 //closeArticlePanel();
1704 var article_pane
= new dijit
.layout
.ContentPane({
1705 title
: __("Loading...") , content
: cached_article
,
1706 style
: 'padding : 0px;',
1710 dijit
.byId("content-tabs").addChild(article_pane
);
1712 if (!event
|| !event
.shiftKey
)
1713 dijit
.byId("content-tabs").selectChild(article_pane
);
1715 if ($("PTITLE-" + id
))
1716 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1720 var query
= "?op=rpc&subop=getArticles&ids=" + param_escape(id
);
1722 notify_progress("Loading, please wait...", true);
1724 new Ajax
.Request("backend.php", {
1726 onComplete: function(transport
) {
1729 if (transport
.responseXML
) {
1730 //closeArticlePanel();
1732 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1733 var content
= article
.firstChild
.nodeValue
;
1735 var article_pane
= new dijit
.layout
.ContentPane({
1736 title
: "article-" + id
, content
: content
,
1737 style
: 'padding : 0px;',
1741 dijit
.byId("content-tabs").addChild(article_pane
);
1743 if (!event
|| !event
.shiftKey
)
1744 dijit
.byId("content-tabs").selectChild(article_pane
);
1746 if ($("PTITLE-" + id
))
1747 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1754 exception_error("zoomToArticle", e
);
1758 function scrollArticle(offset
) {
1761 var ci
= $("content-insert");
1763 ci
.scrollTop
+= offset
;
1766 var hi
= $("headlines-frame");
1768 hi
.scrollTop
+= offset
;
1773 exception_error("scrollArticle", e
);
1777 function show_labels_in_headlines(transport
) {
1779 if (transport
.responseXML
) {
1780 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
1782 var elems
= info
.getElementsByTagName("entry");
1784 for (var l
= 0; l
< elems
.length
; l
++) {
1785 var e_id
= elems
[l
].getAttribute("id");
1789 var ctr
= $("HLLCTR-" + e_id
);
1792 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
1800 exception_error("show_labels_in_headlines", e
);
1805 function toggleHeadlineActions() {
1807 var e
= $("headlineActionsBody");
1808 var p
= $("headlineActionsDrop");
1810 if (!Element
.visible(e
)) {
1817 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
1818 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
1821 exception_error("toggleHeadlineActions", e
);
1825 function publishWithNote(id
, def_note
) {
1827 if (!def_note
) def_note
= '';
1829 var note
= prompt(__("Please enter a note for this article:"), def_note
);
1831 if (note
!= undefined) {
1832 togglePub(id
, false, false, note
);
1836 exception_error("publishWithNote", e
);
1840 function emailArticle(id
) {
1843 var ids
= getSelectedArticleIds2();
1845 if (ids
.length
== 0) {
1846 alert(__("No articles are selected."));
1850 id
= ids
.toString();
1853 if (dijit
.byId("emailArticleDlg"))
1854 dijit
.byId("emailArticleDlg").destroyRecursive();
1856 var query
= "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id
);
1858 dialog
= new dijit
.Dialog({
1859 id
: "emailArticleDlg",
1860 title
: __("Forward article by email"),
1861 style
: "width: 600px",
1862 execute: function() {
1863 if (this.validate()) {
1865 new Ajax
.Request("backend.php", {
1866 parameters
: dojo
.objectToQuery(this.attr('value')),
1867 onComplete: function(transport
) {
1869 var error
= transport
.responseXML
.getElementsByTagName('error')[0];
1872 alert(__('Error sending email:') + ' ' + error
.firstChild
.nodeValue
);
1874 notify_info('Your message has been sent.');
1883 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1884 dojo
.disconnect(tmph
);
1886 new Ajax
.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
1887 "backend.php?op=rpc&subop=completeEmails",
1888 { tokens
: '', paramName
: "search" });
1893 /* displayDlg('emailArticle', id,
1895 document.forms['article_email_form'].destination.focus();
1897 new Ajax.Autocompleter('destination', 'destination_choices',
1898 "backend.php?op=rpc&subop=completeEmails",
1899 { tokens: '', paramName: "search" });
1904 exception_error("emailArticle", e
);
1908 function dismissArticle(id
) {
1910 var elem
= $("RROW-" + id
);
1912 toggleUnread(id
, 0, true);
1914 new Effect
.Fade(elem
, {duration
: 0.5});
1916 active_post_id
= false;
1919 exception_error("dismissArticle", e
);
1923 function dismissSelectedArticles() {
1926 var ids
= getVisibleArticleIds();
1930 for (var i
= 0; i
< ids
.length
; i
++) {
1931 var elem
= $("RROW-" + ids
[i
]);
1933 if (elem
.className
&& elem
.hasClassName("Selected") &&
1934 ids
[i
] != active_post_id
) {
1935 new Effect
.Fade(elem
, {duration
: 0.5});
1943 selectionToggleUnread(false);
1945 fixHeadlinesOrder(tmp
);
1948 exception_error("dismissSelectedArticles", e
);
1952 function dismissReadArticles() {
1955 var ids
= getVisibleArticleIds();
1958 for (var i
= 0; i
< ids
.length
; i
++) {
1959 var elem
= $("RROW-" + ids
[i
]);
1961 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1962 !elem
.hasClassName("Selected")) {
1964 new Effect
.Fade(elem
, {duration
: 0.5});
1970 fixHeadlinesOrder(tmp
);
1973 exception_error("dismissSelectedArticles", e
);
1977 function getVisibleArticleIds() {
1982 getLoadedArticleIds().each(function(id
) {
1983 var elem
= $("RROW-" + id
);
1984 if (elem
&& Element
.visible(elem
))
1989 exception_error("getVisibleArticleIds", e
);
1995 function cdmClicked(event
, id
) {
1997 var shift_key
= event
.shiftKey
;
2001 if (!event
.ctrlKey
) {
2003 if (!getInitParam("cdm_expanded")) {
2004 return cdmExpandArticle(id
);
2007 selectArticles("none");
2010 var elem
= $("RROW-" + id
);
2013 elem
.removeClassName("Unread");
2015 var upd_img_pic
= $("FUPDPIC-" + id
);
2017 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
2018 upd_img_pic
.src
.match("fresh_sign.png"))) {
2020 upd_img_pic
.src
= "images/blank_icon.gif";
2023 active_post_id
= id
;
2025 var query
= "?op=rpc&subop=catchupSelected" +
2026 "&cmode=0&ids=" + param_escape(id
);
2028 new Ajax
.Request("backend.php", {
2030 onComplete: function(transport
) {
2031 handle_json_reply(transport
);
2036 toggleSelected(id
, true);
2037 toggleUnread(id
, 0, false);
2038 zoomToArticle(event
, id
);
2042 exception_error("cdmClicked");
2048 function postClicked(event
, id
) {
2051 if (!event
.ctrlKey
) {
2054 postOpenInNewTab(event
, id
);
2059 exception_error("postClicked");
2063 function hlOpenInNewTab(event
, id
) {
2064 toggleUnread(id
, 0, false);
2065 zoomToArticle(event
, id
);
2068 function postOpenInNewTab(event
, id
) {
2069 closeArticlePanel(id
);
2070 zoomToArticle(event
, id
);
2073 function hlClicked(event
, id
) {
2076 openArticleInNewWindow(id
);
2077 } else if (!event
.ctrlKey
) {
2082 toggleUnread(id
, 0, false);
2083 zoomToArticle(event
, id
);
2088 exception_error("hlClicked");
2092 function getFirstVisibleHeadlineId() {
2093 var rows
= getVisibleArticleIds();
2098 function getLastVisibleHeadlineId() {
2099 var rows
= getVisibleArticleIds();
2100 return rows
[rows
.length
-1];
2103 function openArticleInNewWindow(id
) {
2104 toggleUnread(id
, 0, false);
2105 window
.open("backend.php?op=la&id=" + id
);
2108 function isCdmMode() {
2109 return getInitParam("combined_display_mode");
2112 function markHeadline(id
) {
2113 var row
= $("RROW-" + id
);
2115 var check
= $("RCHK-" + id
);
2118 check
.checked
= true;
2121 row
.addClassName("Selected");
2125 function getRelativePostIds(id
, limit
) {
2131 if (!limit
) limit
= 3;
2133 var ids
= getVisibleArticleIds();
2135 for (var i
= 0; i
< ids
.length
; i
++) {
2137 for (var k
= 1; k
<= limit
; k
++) {
2138 if (i
> k
-1) tmp
.push(ids
[i
-k
]);
2139 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
2146 exception_error("getRelativePostIds", e
);
2152 function correctHeadlinesOffset(id
) {
2156 var container
= $("headlines-frame");
2157 var row
= $("RROW-" + id
);
2159 var viewport
= container
.offsetHeight
;
2161 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
2162 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
2164 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
2165 //console.log("Vport: " + viewport);
2167 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
2168 container
.scrollTop
= row
.offsetTop
;
2169 } else if (rel_offset_bottom
> viewport
) {
2171 /* doesn't properly work with Opera in some cases because
2172 Opera fucks up element scrolling */
2174 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
2178 exception_error("correctHeadlinesOffset", e
);
2183 function headlineActionsChange(elem
) {
2186 elem
.attr('value', 'false');
2188 exception_error("headlineActionsChange", e
);
2192 function closeArticlePanel() {
2194 var tabs
= dijit
.byId("content-tabs");
2195 var child
= tabs
.selectedChildWidget
;
2197 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
2198 tabs
.removeChild(child
);
2201 if (dijit
.byId("content-insert"))
2202 dijit
.byId("headlines-wrap-inner").removeChild(
2203 dijit
.byId("content-insert"));
2207 function initHeadlinesMenu() {
2209 if (dijit
.byId("headlinesMenu"))
2210 dijit
.byId("headlinesMenu").destroyRecursive();
2215 nodes
= $$("#headlines-frame > div[id*=RROW]");
2217 nodes
= $$("#headlines-frame span[id*=RTITLE]");
2220 nodes
.each(function(node
) {
2224 var menu
= new dijit
.Menu({
2225 id
: "headlinesMenu",
2229 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
2230 var callerNode
= event
.target
, match
= null, tries
= 0;
2232 while (match
== null && callerNode
&& tries
<= 3) {
2233 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
2234 callerNode
= callerNode
.parentNode
;
2238 if (match
) this.callerRowId
= parseInt(match
[1]);
2243 menu
.addChild(new dijit
.MenuItem({
2244 label
: __("View article"),
2245 onClick: function(event
) {
2246 view(this.getParent().callerRowId
);
2249 menu
.addChild(new dijit
.MenuItem({
2250 label
: __("View in a new tab"),
2251 onClick: function(event
) {
2252 hlOpenInNewTab(event
, this.getParent().callerRowId
);
2255 menu
.addChild(new dijit
.MenuSeparator());
2257 menu
.addChild(new dijit
.MenuItem({
2258 label
: __("Open original article"),
2259 onClick: function(event
) {
2260 openArticleInNewWindow(this.getParent().callerRowId
);
2263 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2267 menu
.addChild(new dijit
.MenuSeparator());
2269 var labelsMenu
= new dijit
.Menu({ownerMenu
: menu
});
2271 labels
.each(function(label
) {
2272 var id
= label
.id
[0];
2273 var bare_id
= id
.substr(id
.indexOf(":")+1);
2274 var name
= label
.name
[0];
2276 bare_id
= -11-bare_id
;
2278 labelsMenu
.addChild(new dijit
.MenuItem({
2281 onClick: function(event
) {
2282 //console.log(this.labelId);
2283 //console.log(this.getParent().ownerMenu.callerRowId);
2284 selectionAssignLabel(this.labelId
,
2285 [this.getParent().ownerMenu
.callerRowId
]);
2289 menu
.addChild(new dijit
.PopupMenuItem({
2290 label
: __("Labels"),
2298 exception_error("initHeadlinesMenu", e
);
2302 function tweetArticle(id
) {
2304 var query
= "?op=rpc&subop=getTweetInfo&id=" + param_escape(id
);
2309 var ts
= d
.getTime();
2311 var w
= window
.open('backend.php?op=loading', 'ttrss_tweet',
2312 "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
2314 new Ajax
.Request("backend.php", {
2316 onComplete: function(transport
) {
2317 var ti
= JSON
.parse(transport
.responseText
);
2319 var share_url
= "http://twitter.com/share?_=" + ts
+
2320 "&text=" + param_escape(ti
.title
) +
2321 "&url=" + param_escape(ti
.link
);
2323 w
.location
.href
= share_url
;
2329 exception_error("tweetArticle", e
);