]>
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 console
.log("restore selected ids: " + ids
);
131 for (var i
= 0; i
< ids
.length
; i
++) {
132 markHeadline(ids
[i
]);
138 console
.log("no new headlines received");
141 console
.warn("headlines_callback: returned no data");
142 notify_error("Error while trying to load more headlines");
148 for (var i
= 0; i
< articles
.length
; i
++) {
149 var a_id
= articles
[i
].getAttribute("id");
150 //console.log("found id: " + a_id);
151 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
154 console
.log("no cached articles received");
158 parse_counters(counters
);
163 console
.warn("headlines_callback: returned no XML object");
164 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
165 __('Could not update headlines (missing XML object)') + "</div>");
169 if (_cdm_wd_timeout
) window
.clearTimeout(_cdm_wd_timeout
);
172 getActiveFeedId() != -3 &&
173 getInitParam("cdm_auto_catchup") == 1) {
174 console
.log("starting CDM watchdog");
175 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 5000);
176 _cdm_wd_vishist
= new Array();
178 console
.log("not in CDM mode or watchdog disabled");
181 _feed_cur_page
= feed_cur_page
;
182 _infscroll_request_sent
= 0;
187 exception_error("headlines_callback2", e
, transport
);
191 function render_article(article
) {
193 dijit
.byId("headlines-wrap-inner").addChild(
194 dijit
.byId("content-insert"));
196 var c
= dijit
.byId("content-insert");
199 c
.domNode
.scrollTop
= 0;
202 c
.attr('content', article
);
204 correctHeadlinesOffset(getActiveArticleId());
207 exception_error("render_article", e
);
211 function showArticleInHeadlines(id
) {
215 selectArticles("none");
217 var crow
= $("RROW-" + id
);
221 var article_is_unread
= crow
.hasClassName("Unread");
223 crow
.removeClassName("Unread");
225 selectArticles('none');
227 var upd_img_pic
= $("FUPDPIC-" + id
);
229 var cache_prefix
= "";
231 if (activeFeedIsCat()) {
237 var view_mode
= false;
240 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
241 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
246 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
247 upd_img_pic
.src
.match("fresh_sign.png"))) {
249 upd_img_pic
.src
= "images/blank_icon.gif";
251 cache_invalidate(cache_prefix
+ getActiveFeedId());
253 cache_inject(cache_prefix
+ getActiveFeedId(),
254 $("headlines-frame").innerHTML
,
255 getFeedUnread(getActiveFeedId()));
257 } else if (article_is_unread
&& view_mode
== "all_articles") {
259 cache_invalidate(cache_prefix
+ getActiveFeedId());
261 cache_inject(cache_prefix
+ getActiveFeedId(),
262 $("headlines-frame").innerHTML
,
263 getFeedUnread(getActiveFeedId())-1);
265 } else if (article_is_unread
) {
266 cache_invalidate(cache_prefix
+ getActiveFeedId());
271 if (article_is_unread
)
272 _force_scheduled_update
= true;
275 exception_error("showArticleInHeadlines", e
);
279 function article_callback2(transport
, id
) {
281 console
.log("article_callback2 " + id
);
283 if (!handle_rpc_reply(transport
)) return;
285 if (transport
.responseXML
) {
287 if (!transport_error_check(transport
)) return;
289 var upic
= $('FUPDPIC-' + id
);
292 upic
.src
= 'images/blank_icon.gif';
295 if (id
!= last_requested_article
) {
296 console
.log("requested article id is out of sequence, aborting");
300 // active_post_id = id;
302 //console.log("looking for articles to cache...");
304 var articles
= transport
.responseXML
.getElementsByTagName("article");
306 for (var i
= 0; i
< articles
.length
; i
++) {
307 var a_id
= articles
[i
].getAttribute("id");
309 //console.log("found id: " + a_id);
311 if (a_id
== active_post_id
) {
312 //console.log("active article, rendering...");
313 render_article(articles
[i
].firstChild
.nodeValue
);
316 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
320 // showArticleInHeadlines(id);
322 var reply
= transport
.responseXML
.firstChild
.firstChild
;
325 console
.warn("article_callback: returned no XML object");
326 //var f = $("content-frame");
327 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
330 var date
= new Date();
331 last_article_view
= date
.getTime() / 1000;
337 exception_error("article_callback2", e
, transport
);
343 console
.log("loading article: " + id
);
345 var cached_article
= cache_find(id
);
347 console
.log("cache check result: " + (cached_article
!= false));
351 var query
= "?op=view&id=" + param_escape(id
);
353 var neighbor_ids
= getRelativePostIds(active_post_id
);
355 /* only request uncached articles */
357 var cids_to_request
= Array();
359 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
360 if (!cache_check(neighbor_ids
[i
])) {
361 cids_to_request
.push(neighbor_ids
[i
]);
365 console
.log("additional ids: " + cids_to_request
.toString());
367 query
= query
+ "&cids=" + cids_to_request
.toString();
369 var crow
= $("RROW-" + id
);
370 var article_is_unread
= crow
.hasClassName("Unread");
373 showArticleInHeadlines(id
);
375 if (!cached_article
) {
377 var upic
= $('FUPDPIC-' + id
);
380 upic
.src
= getInitParam("sign_progress");
383 } else if (cached_article
&& article_is_unread
) {
385 query
= query
+ "&mode=prefetch";
387 render_article(cached_article
);
389 } else if (cached_article
) {
391 query
= query
+ "&mode=prefetch_old";
392 render_article(cached_article
);
398 last_requested_article
= id
;
400 new Ajax
.Request("backend.php", {
402 onComplete: function(transport
) {
403 article_callback2(transport
, id
);
409 exception_error("view", e
);
414 return toggleMark(id
);
418 return togglePub(id
);
421 function toggleMark(id
, client_only
) {
423 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
425 var img
= $("FMPIC-" + id
);
429 if (img
.src
.match("mark_unset")) {
430 img
.src
= img
.src
.replace("mark_unset", "mark_set");
431 img
.alt
= __("Unstar article");
432 query
= query
+ "&mark=1";
435 img
.src
= img
.src
.replace("mark_set", "mark_unset");
436 img
.alt
= __("Star article");
437 query
= query
+ "&mark=0";
441 new Ajax
.Request("backend.php", {
443 onComplete: function(transport
) {
444 handle_rpc_json(transport
);
449 exception_error("toggleMark", e
);
453 function togglePub(id
, client_only
, no_effects
, note
) {
455 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
457 if (note
!= undefined) {
458 query
= query
+ "¬e=" + param_escape(note
);
460 query
= query
+ "¬e=undefined";
463 var img
= $("FPPIC-" + id
);
467 if (img
.src
.match("pub_unset") || note
!= undefined) {
468 img
.src
= img
.src
.replace("pub_unset", "pub_set");
469 img
.alt
= __("Unpublish article");
470 query
= query
+ "&pub=1";
473 img
.src
= img
.src
.replace("pub_set", "pub_unset");
474 img
.alt
= __("Publish article");
476 query
= query
+ "&pub=0";
480 new Ajax
.Request("backend.php", {
482 onComplete: function(transport
) {
483 handle_rpc_reply(transport
);
485 var note
= transport
.responseXML
.getElementsByTagName("note")[0];
488 var note_id
= note
.getAttribute("id");
489 var note_size
= note
.getAttribute("size");
490 var note_content
= note
.firstChild
.nodeValue
;
492 var container
= $('POSTNOTE-' + note_id
);
494 cache_invalidate(note_id
);
497 if (note_size
== "0") {
498 Element
.hide(container
);
500 container
.innerHTML
= note_content
;
501 Element
.show(container
);
510 exception_error("togglePub", e
);
514 function moveToPost(mode
) {
518 var rows
= getVisibleArticleIds();
523 if (!$('RROW-' + active_post_id
)) {
524 active_post_id
= false;
527 if (active_post_id
== false) {
528 next_id
= getFirstVisibleHeadlineId();
529 prev_id
= getLastVisibleHeadlineId();
531 for (var i
= 0; i
< rows
.length
; i
++) {
532 if (rows
[i
] == active_post_id
) {
539 if (mode
== "next") {
543 cdmExpandArticle(next_id
);
544 cdmScrollToArticleId(next_id
);
547 correctHeadlinesOffset(next_id
);
548 view(next_id
, getActiveFeedId());
553 if (mode
== "prev") {
556 cdmExpandArticle(prev_id
);
557 cdmScrollToArticleId(prev_id
);
559 correctHeadlinesOffset(prev_id
);
560 view(prev_id
, getActiveFeedId());
566 exception_error("moveToPost", e
);
570 function toggleSelected(id
, force_on
) {
573 var cb
= $("RCHK-" + id
);
574 var row
= $("RROW-" + id
);
577 if (row
.hasClassName('Selected') && !force_on
) {
578 row
.removeClassName('Selected');
579 if (cb
) cb
.checked
= false;
581 row
.addClassName('Selected');
582 if (cb
) cb
.checked
= true;
586 exception_error("toggleSelected", e
);
590 function toggleUnread_afh(effect
) {
593 var elem
= effect
.element
;
594 elem
.style
.backgroundColor
= "";
597 exception_error("toggleUnread_afh", e
);
601 function toggleUnread(id
, cmode
, effect
) {
604 var row
= $("RROW-" + id
);
606 if (cmode
== undefined || cmode
== 2) {
607 if (row
.hasClassName("Unread")) {
608 row
.removeClassName("Unread");
611 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
612 afterFinish
: toggleUnread_afh
,
613 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
617 row
.addClassName("Unread");
620 } else if (cmode
== 0) {
622 row
.removeClassName("Unread");
625 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
626 afterFinish
: toggleUnread_afh
,
627 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
630 } else if (cmode
== 1) {
631 row
.addClassName("Unread");
634 if (cmode
== undefined) cmode
= 2;
636 var query
= "?op=rpc&subop=catchupSelected" +
637 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
639 // notify_progress("Loading, please wait...");
641 new Ajax
.Request("backend.php", {
643 onComplete: function(transport
) {
644 handle_rpc_json(transport
);
650 exception_error("toggleUnread", e
);
654 function selectionRemoveLabel(id
, ids
) {
657 if (!ids
) var ids
= getSelectedArticleIds2();
659 if (ids
.length
== 0) {
660 alert(__("No articles are selected."));
664 // var ok = confirm(__("Remove selected articles from label?"));
668 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
669 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
673 // notify_progress("Loading, please wait...");
675 cache_invalidate("F:" + (-11 - id
));
677 new Ajax
.Request("backend.php", {
679 onComplete: function(transport
) {
680 show_labels_in_headlines(transport
);
681 handle_rpc_reply(transport
);
687 exception_error("selectionAssignLabel", e
);
692 function selectionAssignLabel(id
, ids
) {
695 if (!ids
) ids
= getSelectedArticleIds2();
697 if (ids
.length
== 0) {
698 alert(__("No articles are selected."));
702 // var ok = confirm(__("Assign selected articles to label?"));
706 cache_invalidate("F:" + (-11 - id
));
708 var query
= "?op=rpc&subop=assignToLabel&ids=" +
709 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
713 // notify_progress("Loading, please wait...");
715 new Ajax
.Request("backend.php", {
717 onComplete: function(transport
) {
718 show_labels_in_headlines(transport
);
719 handle_rpc_reply(transport
);
725 exception_error("selectionAssignLabel", e
);
730 function selectionToggleUnread(set_state
, callback
, no_error
) {
732 var rows
= getSelectedArticleIds2();
734 if (rows
.length
== 0 && !no_error
) {
735 alert(__("No articles are selected."));
739 for (i
= 0; i
< rows
.length
; i
++) {
740 var row
= $("RROW-" + rows
[i
]);
742 if (set_state
== undefined) {
743 if (row
.hasClassName("Unread")) {
744 row
.removeClassName("Unread");
746 row
.addClassName("Unread");
750 if (set_state
== false) {
751 row
.removeClassName("Unread");
754 if (set_state
== true) {
755 row
.addClassName("Unread");
760 if (rows
.length
> 0) {
764 if (set_state
== undefined) {
766 } else if (set_state
== true) {
768 } else if (set_state
== false) {
772 var query
= "?op=rpc&subop=catchupSelected" +
773 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
775 notify_progress("Loading, please wait...");
777 new Ajax
.Request("backend.php", {
779 onComplete: function(transport
) {
780 handle_rpc_json(transport
);
781 if (callback
) callback(transport
);
787 exception_error("selectionToggleUnread", e
);
791 function selectionToggleMarked() {
794 var rows
= getSelectedArticleIds2();
796 if (rows
.length
== 0) {
797 alert(__("No articles are selected."));
801 for (i
= 0; i
< rows
.length
; i
++) {
802 toggleMark(rows
[i
], true, true);
805 if (rows
.length
> 0) {
807 var query
= "?op=rpc&subop=markSelected&ids=" +
808 param_escape(rows
.toString()) + "&cmode=2";
810 new Ajax
.Request("backend.php", {
812 onComplete: function(transport
) {
813 handle_rpc_json(transport
);
819 exception_error("selectionToggleMarked", e
);
823 function selectionTogglePublished() {
826 var rows
= getSelectedArticleIds2();
828 if (rows
.length
== 0) {
829 alert(__("No articles are selected."));
833 for (i
= 0; i
< rows
.length
; i
++) {
834 togglePub(rows
[i
], true, true);
837 if (rows
.length
> 0) {
839 var query
= "?op=rpc&subop=publishSelected&ids=" +
840 param_escape(rows
.toString()) + "&cmode=2";
842 new Ajax
.Request("backend.php", {
844 onComplete: function(transport
) {
845 handle_rpc_json(transport
);
851 exception_error("selectionToggleMarked", e
);
855 function getSelectedArticleIds2() {
859 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
861 rv
.push(child
.id
.replace("RROW-", ""));
867 function getLoadedArticleIds() {
870 var children
= $$("#headlines-frame > div[id*=RROW-]");
872 children
.each(function(child
) {
873 rv
.push(child
.id
.replace("RROW-", ""));
880 // mode = all,none,unread,invert
881 function selectArticles(mode
) {
884 var children
= $$("#headlines-frame > div[id*=RROW]");
886 children
.each(function(child
) {
887 var id
= child
.id
.replace("RROW-", "");
888 var cb
= $("RCHK-" + id
);
891 child
.addClassName("Selected");
893 } else if (mode
== "unread") {
894 if (child
.hasClassName("Unread")) {
895 child
.addClassName("Selected");
898 child
.removeClassName("Selected");
901 } else if (mode
== "invert") {
902 if (child
.hasClassName("Selected")) {
903 child
.removeClassName("Selected");
906 child
.addClassName("Selected");
911 child
.removeClassName("Selected");
917 exception_error("selectArticles", e
);
921 function catchupPage() {
923 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
925 var str
= __("Mark all visible articles in %s as read?");
927 str
= str
.replace("%s", fn
);
929 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
933 selectArticles('all');
934 selectionToggleUnread(false, 'viewCurrentFeed()', true)
935 selectArticles('none');
938 function deleteSelection() {
942 var rows
= getSelectedArticleIds2();
944 if (rows
.length
== 0) {
945 alert(__("No articles are selected."));
949 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
953 if (getActiveFeedId() != 0) {
954 str
= __("Delete %d selected articles in %s?");
956 str
= __("Delete %d selected articles?");
959 str
= str
.replace("%d", rows
.length
);
960 str
= str
.replace("%s", fn
);
962 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
966 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
970 new Ajax
.Request("backend.php", {
972 onComplete: function(transport
) {
973 handle_rpc_json(transport
);
978 exception_error("deleteSelection", e
);
982 function archiveSelection() {
986 var rows
= getSelectedArticleIds2();
988 if (rows
.length
== 0) {
989 alert(__("No articles are selected."));
993 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
997 if (getActiveFeedId() != 0) {
998 str
= __("Archive %d selected articles in %s?");
1001 str
= __("Move %d archived articles back?");
1005 str
= str
.replace("%d", rows
.length
);
1006 str
= str
.replace("%s", fn
);
1008 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1012 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1016 for (var i
= 0; i
< rows
.length
; i
++) {
1017 cache_invalidate(rows
[i
]);
1020 new Ajax
.Request("backend.php", {
1022 onComplete: function(transport
) {
1023 handle_rpc_json(transport
);
1028 exception_error("archiveSelection", e
);
1032 function catchupSelection() {
1036 var rows
= getSelectedArticleIds2();
1038 if (rows
.length
== 0) {
1039 alert(__("No articles are selected."));
1043 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1045 var str
= __("Mark %d selected articles in %s as read?");
1047 str
= str
.replace("%d", rows
.length
);
1048 str
= str
.replace("%s", fn
);
1050 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1054 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1057 exception_error("catchupSelection", e
);
1061 function editArticleTags(id
) {
1062 /* displayDlg('editArticleTags', id,
1064 $("tags_str").focus();
1066 new Ajax.Autocompleter('tags_str', 'tags_choices',
1067 "backend.php?op=rpc&subop=completeTags",
1068 { tokens: ',', paramName: "search" });
1071 var query
= "backend.php?op=dlg&id=editArticleTags¶m=" + param_escape(id
);
1073 if (dijit
.byId("editTagsDlg"))
1074 dijit
.byId("editTagsDlg").destroyRecursive();
1076 dialog
= new dijit
.Dialog({
1078 title
: __("Edit article Tags"),
1079 style
: "width: 600px",
1080 execute: function() {
1081 if (this.validate()) {
1082 var query
= dojo
.objectToQuery(this.attr('value'));
1084 notify_progress("Saving article tags...", true);
1086 new Ajax
.Request("backend.php", {
1088 onComplete: function(transport
) {
1092 if (transport
.responseXML
) {
1093 var tags_str
= transport
.responseXML
.getElementsByTagName("tags-str")[0];
1096 var id
= tags_str
.getAttribute("id");
1099 var tags
= $("ATSTR-" + id
);
1101 tags
.innerHTML
= tags_str
.firstChild
.nodeValue
;
1104 cache_invalidate(id
);
1115 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1116 dojo
.disconnect(tmph
);
1118 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1119 "backend.php?op=rpc&subop=completeTags",
1120 { tokens
: ',', paramName
: "search" });
1127 function cdmScrollToArticleId(id
) {
1129 var ctr
= $("headlines-frame");
1130 var e
= $("RROW-" + id
);
1132 if (!e
|| !ctr
) return;
1134 ctr
.scrollTop
= e
.offsetTop
;
1137 exception_error("cdmScrollToArticleId", e
);
1141 function cdmWatchdog() {
1145 var ctr
= $("headlines-frame");
1149 var ids
= new Array();
1151 var e
= ctr
.firstChild
;
1154 if (e
.className
&& e
.hasClassName("Unread") && e
.id
&&
1155 e
.id
.match("RROW-")) {
1157 // article fits in viewport OR article is longer than viewport and
1158 // its bottom is visible
1160 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1161 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1163 // console.log(e.id + " is visible " + e.offsetTop + "." +
1164 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1165 // (ctr.scrollTop + ctr.offsetHeight));
1167 ids
.push(e
.id
.replace("RROW-", ""));
1169 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1170 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1171 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1173 ids
.push(e
.id
.replace("RROW-", ""));
1177 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1179 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1180 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1182 ids.push(e.id.replace("RROW-", ""));
1191 console
.log("cdmWatchdog, ids= " + ids
.toString());
1193 if (ids
.length
> 0) {
1195 for (var i
= 0; i
< ids
.length
; i
++) {
1196 var e
= $("RROW-" + ids
[i
]);
1198 e
.removeClassName("Unread");
1202 var query
= "?op=rpc&subop=catchupSelected" +
1203 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1205 new Ajax
.Request("backend.php", {
1207 onComplete: function(transport
) {
1208 handle_rpc_json(transport
);
1213 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1216 exception_error("cdmWatchdog", e
);
1222 function cache_inject(id
, article
, param
) {
1225 if (!cache_check_param(id
, param
)) {
1226 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1228 var date
= new Date();
1229 var ts
= Math
.round(date
.getTime() / 1000);
1233 cache_obj
["id"] = id
;
1234 cache_obj
["data"] = article
;
1235 cache_obj
["param"] = param
;
1237 if (param
) id
= id
+ ":" + param
;
1239 cache_added
["TS:" + id
] = ts
;
1241 if (has_local_storage())
1242 sessionStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1244 article_cache
.push(cache_obj
);
1247 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1250 exception_error("cache_inject", e
);
1254 function cache_find(id
) {
1256 if (has_local_storage()) {
1257 var cache_obj
= sessionStorage
.getItem(id
);
1260 cache_obj
= JSON
.parse(cache_obj
);
1263 return cache_obj
['data'];
1267 for (var i
= 0; i
< article_cache
.length
; i
++) {
1268 if (article_cache
[i
]["id"] == id
) {
1269 return article_cache
[i
]["data"];
1276 function cache_find_param(id
, param
) {
1278 if (has_local_storage()) {
1280 if (param
) id
= id
+ ":" + param
;
1282 var cache_obj
= sessionStorage
.getItem(id
);
1285 cache_obj
= JSON
.parse(cache_obj
);
1288 return cache_obj
['data'];
1292 for (var i
= 0; i
< article_cache
.length
; i
++) {
1293 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1294 return article_cache
[i
]["data"];
1302 function cache_check(id
) {
1303 if (has_local_storage()) {
1304 if (sessionStorage
.getItem(id
))
1307 for (var i
= 0; i
< article_cache
.length
; i
++) {
1308 if (article_cache
[i
]["id"] == id
) {
1316 function cache_check_param(id
, param
) {
1317 if (has_local_storage()) {
1319 if (param
) id
= id
+ ":" + param
;
1321 if (sessionStorage
.getItem(id
))
1325 for (var i
= 0; i
< article_cache
.length
; i
++) {
1326 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1334 function cache_expire() {
1335 if (has_local_storage()) {
1337 var date
= new Date();
1338 var timestamp
= Math
.round(date
.getTime() / 1000);
1340 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1342 var id
= sessionStorage
.key(i
);
1344 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1345 sessionStorage
.removeItem(id
);
1350 while (article_cache
.length
> 25) {
1351 article_cache
.shift();
1356 function cache_flush() {
1357 if (has_local_storage()) {
1358 sessionStorage
.clear();
1360 article_cache
= new Array();
1364 function cache_invalidate(id
) {
1366 if (has_local_storage()) {
1370 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1371 var key
= sessionStorage
.key(i
);
1373 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1375 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1376 sessionStorage
.removeItem(key
);
1387 while (i
< article_cache
.length
) {
1388 if (article_cache
[i
]["id"] == id
) {
1389 //console.log("cache_invalidate: removed id " + id);
1390 article_cache
.splice(i
, 1);
1397 //console.log("cache_invalidate: id not found: " + id);
1400 exception_error("cache_invalidate", e
);
1404 function getActiveArticleId() {
1405 return active_post_id
;
1408 function preloadBatchedArticles() {
1411 var query
= "?op=rpc&subop=getArticles&ids=" +
1412 preload_id_batch
.toString();
1414 new Ajax
.Request("backend.php", {
1416 onComplete: function(transport
) {
1418 preload_id_batch
= [];
1420 var articles
= transport
.responseXML
.getElementsByTagName("article");
1422 for (var i
= 0; i
< articles
.length
; i
++) {
1423 var id
= articles
[i
].getAttribute("id");
1424 if (!cache_check(id
)) {
1425 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1426 console
.log("preloaded article: " + id
);
1432 exception_error("preloadBatchedArticles", e
);
1436 function preloadArticleUnderPointer(id
) {
1438 if (getInitParam("bw_limit") == "1") return;
1440 if (post_under_pointer
== id
&& !cache_check(id
)) {
1442 console
.log("trying to preload article " + id
);
1444 var neighbor_ids
= getRelativePostIds(id
, 1);
1446 /* only request uncached articles */
1448 if (preload_id_batch
.indexOf(id
) == -1) {
1449 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1450 if (!cache_check(neighbor_ids
[i
])) {
1451 preload_id_batch
.push(neighbor_ids
[i
]);
1456 if (preload_id_batch
.indexOf(id
) == -1)
1457 preload_id_batch
.push(id
);
1459 //console.log("preload ids batch: " + preload_id_batch.toString());
1461 window
.clearTimeout(preload_timeout_id
);
1462 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1466 exception_error("preloadArticleUnderPointer", e
);
1470 function postMouseIn(id
) {
1472 if (post_under_pointer
!= id
) {
1473 post_under_pointer
= id
;
1475 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1480 exception_error("postMouseIn", e
);
1484 function postMouseOut(id
) {
1486 post_under_pointer
= false;
1488 exception_error("postMouseOut", e
);
1492 function headlines_scroll_handler(e
) {
1495 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1496 if (!_infscroll_disable
) {
1502 exception_error("headlines_scroll_handler", e
);
1506 function catchupRelativeToArticle(below
) {
1511 if (!getActiveArticleId()) {
1512 alert(__("No article is selected."));
1516 var visible_ids
= getVisibleArticleIds();
1518 var ids_to_mark
= new Array();
1521 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1522 if (visible_ids
[i
] != getActiveArticleId()) {
1523 var e
= $("RROW-" + visible_ids
[i
]);
1525 if (e
&& e
.hasClassName("Unread")) {
1526 ids_to_mark
.push(visible_ids
[i
]);
1533 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1534 if (visible_ids
[i
] != getActiveArticleId()) {
1535 var e
= $("RROW-" + visible_ids
[i
]);
1537 if (e
&& e
.hasClassName("Unread")) {
1538 ids_to_mark
.push(visible_ids
[i
]);
1546 if (ids_to_mark
.length
== 0) {
1547 alert(__("No articles found to mark"));
1549 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1551 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1553 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1554 var e
= $("RROW-" + ids_to_mark
[i
]);
1555 e
.removeClassName("Unread");
1558 var query
= "?op=rpc&subop=catchupSelected" +
1559 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1561 new Ajax
.Request("backend.php", {
1563 onComplete: function(transport
) {
1564 handle_rpc_json(transport
);
1571 exception_error("catchupRelativeToArticle", e
);
1575 function cdmExpandArticle(id
) {
1580 var elem
= $("CICD-" + active_post_id
);
1582 var upd_img_pic
= $("FUPDPIC-" + id
);
1584 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1585 upd_img_pic
.src
.match("fresh_sign.png"))) {
1587 upd_img_pic
.src
= "images/blank_icon.gif";
1590 if (id
== active_post_id
&& Element
.visible(elem
))
1593 selectArticles("none");
1595 var old_offset
= $("RROW-" + id
).offsetTop
;
1597 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1599 Element
.show("CEXC-" + active_post_id
);
1602 active_post_id
= id
;
1604 elem
= $("CICD-" + id
);
1606 if (!Element
.visible(elem
)) {
1608 Element
.hide("CEXC-" + id
);
1610 if ($("CWRAP-" + id
).innerHTML
== "") {
1612 $("FUPDPIC-" + id
).src
= "images/indicator_tiny.gif";
1614 $("CWRAP-" + id
).innerHTML
= "<div class=\"insensitive\">" +
1615 __("Loading, please wait...") + "</div>";
1617 var query
= "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id
);
1619 //console.log(query);
1621 new Ajax
.Request("backend.php", {
1623 onComplete: function(transport
) {
1624 $("FUPDPIC-" + id
).src
= 'images/blank_icon.gif';
1626 handle_rpc_json(transport
);
1628 var reply
= JSON
.parse(transport
.responseText
);
1631 var article
= reply
['article']['content'];
1632 var recv_id
= reply
['article']['id'];
1635 $("CWRAP-" + id
).innerHTML
= article
;
1638 $("CWRAP-" + id
).innerHTML
= __("Unable to load article.");
1646 var new_offset
= $("RROW-" + id
).offsetTop
;
1648 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1650 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1651 $("headlines-frame").scrollTop
= new_offset
;
1653 toggleUnread(id
, 0, true);
1657 exception_error("cdmExpandArticle", e
);
1663 function fixHeadlinesOrder(ids
) {
1665 for (var i
= 0; i
< ids
.length
; i
++) {
1666 var e
= $("RROW-" + ids
[i
]);
1670 e
.removeClassName("even");
1671 e
.addClassName("odd");
1673 e
.removeClassName("odd");
1674 e
.addClassName("even");
1679 exception_error("fixHeadlinesOrder", e
);
1683 function getArticleUnderPointer() {
1684 return post_under_pointer
;
1687 function zoomToArticle(event
, id
) {
1689 var cached_article
= cache_find(id
);
1691 if (dijit
.byId("ATAB-" + id
))
1692 if (!event
|| !event
.shiftKey
)
1693 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1695 if (cached_article
) {
1696 //closeArticlePanel();
1698 var article_pane
= new dijit
.layout
.ContentPane({
1699 title
: __("Loading...") , content
: cached_article
,
1700 style
: 'padding : 0px;',
1704 dijit
.byId("content-tabs").addChild(article_pane
);
1706 if (!event
|| !event
.shiftKey
)
1707 dijit
.byId("content-tabs").selectChild(article_pane
);
1709 if ($("PTITLE-" + id
))
1710 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1714 var query
= "?op=rpc&subop=getArticles&ids=" + param_escape(id
);
1716 notify_progress("Loading, please wait...", true);
1718 new Ajax
.Request("backend.php", {
1720 onComplete: function(transport
) {
1723 if (transport
.responseXML
) {
1724 //closeArticlePanel();
1726 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1727 var content
= article
.firstChild
.nodeValue
;
1729 var article_pane
= new dijit
.layout
.ContentPane({
1730 title
: "article-" + id
, content
: content
,
1731 style
: 'padding : 0px;',
1735 dijit
.byId("content-tabs").addChild(article_pane
);
1737 if (!event
|| !event
.shiftKey
)
1738 dijit
.byId("content-tabs").selectChild(article_pane
);
1740 if ($("PTITLE-" + id
))
1741 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1748 exception_error("zoomToArticle", e
);
1752 function scrollArticle(offset
) {
1755 var ci
= $("content-insert");
1757 ci
.scrollTop
+= offset
;
1760 var hi
= $("headlines-frame");
1762 hi
.scrollTop
+= offset
;
1767 exception_error("scrollArticle", e
);
1771 function show_labels_in_headlines(transport
) {
1773 if (transport
.responseXML
) {
1774 var info
= transport
.responseXML
.getElementsByTagName("info-for-headlines")[0];
1776 var elems
= info
.getElementsByTagName("entry");
1778 for (var l
= 0; l
< elems
.length
; l
++) {
1779 var e_id
= elems
[l
].getAttribute("id");
1783 var ctr
= $("HLLCTR-" + e_id
);
1786 ctr
.innerHTML
= elems
[l
].firstChild
.nodeValue
;
1794 exception_error("show_labels_in_headlines", e
);
1799 function toggleHeadlineActions() {
1801 var e
= $("headlineActionsBody");
1802 var p
= $("headlineActionsDrop");
1804 if (!Element
.visible(e
)) {
1811 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
1812 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
1815 exception_error("toggleHeadlineActions", e
);
1819 function publishWithNote(id
, def_note
) {
1821 if (!def_note
) def_note
= '';
1823 var note
= prompt(__("Please enter a note for this article:"), def_note
);
1825 if (note
!= undefined) {
1826 togglePub(id
, false, false, note
);
1830 exception_error("publishWithNote", e
);
1834 function emailArticle(id
) {
1837 var ids
= getSelectedArticleIds2();
1839 if (ids
.length
== 0) {
1840 alert(__("No articles are selected."));
1844 id
= ids
.toString();
1847 if (dijit
.byId("emailArticleDlg"))
1848 dijit
.byId("emailArticleDlg").destroyRecursive();
1850 var query
= "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id
);
1852 dialog
= new dijit
.Dialog({
1853 id
: "emailArticleDlg",
1854 title
: __("Forward article by email"),
1855 style
: "width: 600px",
1856 execute: function() {
1857 if (this.validate()) {
1859 new Ajax
.Request("backend.php", {
1860 parameters
: dojo
.objectToQuery(this.attr('value')),
1861 onComplete: function(transport
) {
1863 var error
= transport
.responseXML
.getElementsByTagName('error')[0];
1866 alert(__('Error sending email:') + ' ' + error
.firstChild
.nodeValue
);
1868 notify_info('Your message has been sent.');
1877 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1878 dojo
.disconnect(tmph
);
1880 new Ajax
.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
1881 "backend.php?op=rpc&subop=completeEmails",
1882 { tokens
: '', paramName
: "search" });
1887 /* displayDlg('emailArticle', id,
1889 document.forms['article_email_form'].destination.focus();
1891 new Ajax.Autocompleter('destination', 'destination_choices',
1892 "backend.php?op=rpc&subop=completeEmails",
1893 { tokens: '', paramName: "search" });
1898 exception_error("emailArticle", e
);
1902 function dismissArticle(id
) {
1904 var elem
= $("RROW-" + id
);
1906 toggleUnread(id
, 0, true);
1908 new Effect
.Fade(elem
, {duration
: 0.5});
1910 active_post_id
= false;
1913 exception_error("dismissArticle", e
);
1917 function dismissSelectedArticles() {
1920 var ids
= getVisibleArticleIds();
1924 for (var i
= 0; i
< ids
.length
; i
++) {
1925 var elem
= $("RROW-" + ids
[i
]);
1927 if (elem
.className
&& elem
.hasClassName("Selected") &&
1928 ids
[i
] != active_post_id
) {
1929 new Effect
.Fade(elem
, {duration
: 0.5});
1937 selectionToggleUnread(false);
1939 fixHeadlinesOrder(tmp
);
1942 exception_error("dismissSelectedArticles", e
);
1946 function dismissReadArticles() {
1949 var ids
= getVisibleArticleIds();
1952 for (var i
= 0; i
< ids
.length
; i
++) {
1953 var elem
= $("RROW-" + ids
[i
]);
1955 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1956 !elem
.hasClassName("Selected")) {
1958 new Effect
.Fade(elem
, {duration
: 0.5});
1964 fixHeadlinesOrder(tmp
);
1967 exception_error("dismissSelectedArticles", e
);
1971 function getVisibleArticleIds() {
1976 getLoadedArticleIds().each(function(id
) {
1977 var elem
= $("RROW-" + id
);
1978 if (elem
&& Element
.visible(elem
))
1983 exception_error("getVisibleArticleIds", e
);
1989 function cdmClicked(event
, id
) {
1991 var shift_key
= event
.shiftKey
;
1995 if (!event
.ctrlKey
) {
1997 if (!getInitParam("cdm_expanded")) {
1998 return cdmExpandArticle(id
);
2001 selectArticles("none");
2004 var elem
= $("RROW-" + id
);
2007 elem
.removeClassName("Unread");
2009 var upd_img_pic
= $("FUPDPIC-" + id
);
2011 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
2012 upd_img_pic
.src
.match("fresh_sign.png"))) {
2014 upd_img_pic
.src
= "images/blank_icon.gif";
2017 active_post_id
= id
;
2019 var query
= "?op=rpc&subop=catchupSelected" +
2020 "&cmode=0&ids=" + param_escape(id
);
2022 new Ajax
.Request("backend.php", {
2024 onComplete: function(transport
) {
2025 handle_rpc_reply(transport
);
2030 toggleSelected(id
, true);
2031 toggleUnread(id
, 0, false);
2032 zoomToArticle(event
, id
);
2036 exception_error("cdmClicked");
2042 function postClicked(event
, id
) {
2045 if (!event
.ctrlKey
) {
2048 postOpenInNewTab(event
, id
);
2053 exception_error("postClicked");
2057 function hlOpenInNewTab(event
, id
) {
2058 toggleUnread(id
, 0, false);
2059 zoomToArticle(event
, id
);
2062 function postOpenInNewTab(event
, id
) {
2063 closeArticlePanel(id
);
2064 zoomToArticle(event
, id
);
2067 function hlClicked(event
, id
) {
2070 openArticleInNewWindow(id
);
2071 } else if (!event
.ctrlKey
) {
2076 toggleUnread(id
, 0, false);
2077 zoomToArticle(event
, id
);
2082 exception_error("hlClicked");
2086 function getFirstVisibleHeadlineId() {
2087 var rows
= getVisibleArticleIds();
2092 function getLastVisibleHeadlineId() {
2093 var rows
= getVisibleArticleIds();
2094 return rows
[rows
.length
-1];
2097 function openArticleInNewWindow(id
) {
2098 toggleUnread(id
, 0, false);
2099 window
.open("backend.php?op=la&id=" + id
);
2102 function isCdmMode() {
2103 return getInitParam("combined_display_mode");
2106 function markHeadline(id
) {
2107 var row
= $("RROW-" + id
);
2109 var check
= $("RCHK-" + id
);
2112 check
.checked
= true;
2115 row
.addClassName("Selected");
2119 function getRelativePostIds(id
, limit
) {
2125 if (!limit
) limit
= 3;
2127 var ids
= getVisibleArticleIds();
2129 for (var i
= 0; i
< ids
.length
; i
++) {
2131 for (var k
= 1; k
<= limit
; k
++) {
2132 if (i
> k
-1) tmp
.push(ids
[i
-k
]);
2133 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
2140 exception_error("getRelativePostIds", e
);
2146 function correctHeadlinesOffset(id
) {
2150 var container
= $("headlines-frame");
2151 var row
= $("RROW-" + id
);
2153 var viewport
= container
.offsetHeight
;
2155 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
2156 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
2158 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
2159 //console.log("Vport: " + viewport);
2161 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
2162 container
.scrollTop
= row
.offsetTop
;
2163 } else if (rel_offset_bottom
> viewport
) {
2165 /* doesn't properly work with Opera in some cases because
2166 Opera fucks up element scrolling */
2168 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
2172 exception_error("correctHeadlinesOffset", e
);
2177 function headlineActionsChange(elem
) {
2180 elem
.attr('value', 'false');
2182 exception_error("headlineActionsChange", e
);
2186 function closeArticlePanel() {
2188 var tabs
= dijit
.byId("content-tabs");
2189 var child
= tabs
.selectedChildWidget
;
2191 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
2192 tabs
.removeChild(child
);
2195 if (dijit
.byId("content-insert"))
2196 dijit
.byId("headlines-wrap-inner").removeChild(
2197 dijit
.byId("content-insert"));
2201 function initHeadlinesMenu() {
2203 if (dijit
.byId("headlinesMenu"))
2204 dijit
.byId("headlinesMenu").destroyRecursive();
2209 nodes
= $$("#headlines-frame > div[id*=RROW]");
2211 nodes
= $$("#headlines-frame span[id*=RTITLE]");
2214 nodes
.each(function(node
) {
2218 var menu
= new dijit
.Menu({
2219 id
: "headlinesMenu",
2223 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
2224 var callerNode
= event
.target
, match
= null, tries
= 0;
2226 while (match
== null && callerNode
&& tries
<= 3) {
2227 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
2228 callerNode
= callerNode
.parentNode
;
2232 if (match
) this.callerRowId
= parseInt(match
[1]);
2237 menu
.addChild(new dijit
.MenuItem({
2238 label
: __("View article"),
2239 onClick: function(event
) {
2240 view(this.getParent().callerRowId
);
2243 menu
.addChild(new dijit
.MenuItem({
2244 label
: __("View in a new tab"),
2245 onClick: function(event
) {
2246 hlOpenInNewTab(event
, this.getParent().callerRowId
);
2249 menu
.addChild(new dijit
.MenuSeparator());
2251 menu
.addChild(new dijit
.MenuItem({
2252 label
: __("Open original article"),
2253 onClick: function(event
) {
2254 openArticleInNewWindow(this.getParent().callerRowId
);
2257 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2261 menu
.addChild(new dijit
.MenuSeparator());
2263 var labelsMenu
= new dijit
.Menu({ownerMenu
: menu
});
2265 labels
.each(function(label
) {
2266 var id
= label
.id
[0];
2267 var bare_id
= id
.substr(id
.indexOf(":")+1);
2268 var name
= label
.name
[0];
2270 bare_id
= -11-bare_id
;
2272 labelsMenu
.addChild(new dijit
.MenuItem({
2275 onClick: function(event
) {
2276 //console.log(this.labelId);
2277 //console.log(this.getParent().ownerMenu.callerRowId);
2278 selectionAssignLabel(this.labelId
,
2279 [this.getParent().ownerMenu
.callerRowId
]);
2283 menu
.addChild(new dijit
.PopupMenuItem({
2284 label
: __("Labels"),
2292 exception_error("initHeadlinesMenu", e
);
2296 function tweetArticle(id
) {
2298 var query
= "?op=rpc&subop=getTweetInfo&id=" + param_escape(id
);
2303 var ts
= d
.getTime();
2305 var w
= window
.open('backend.php?op=loading', 'ttrss_tweet',
2306 "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
2308 new Ajax
.Request("backend.php", {
2310 onComplete: function(transport
) {
2311 var ti
= JSON
.parse(transport
.responseText
);
2313 var share_url
= "http://twitter.com/share?_=" + ts
+
2314 "&text=" + param_escape(ti
.title
) +
2315 "&url=" + param_escape(ti
.link
);
2317 w
.location
.href
= share_url
;
2323 exception_error("tweetArticle", e
);