]>
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_json(transport
);
493 /* if (!client_only) {
494 new Ajax.Request("backend.php", {
496 onComplete: function(transport) {
497 handle_rpc_reply(transport);
499 var note = transport.responseXML.getElementsByTagName("note")[0];
502 var note_id = note.getAttribute("id");
503 var note_size = note.getAttribute("size");
504 var note_content = note.firstChild.nodeValue;
506 var container = $('POSTNOTE-' + note_id);
508 cache_invalidate(note_id);
511 if (note_size == "0") {
512 Element.hide(container);
514 container.innerHTML = note_content;
515 Element.show(container);
524 exception_error("togglePub", e
);
528 function moveToPost(mode
) {
532 var rows
= getVisibleArticleIds();
537 if (!$('RROW-' + active_post_id
)) {
538 active_post_id
= false;
541 if (active_post_id
== false) {
542 next_id
= getFirstVisibleHeadlineId();
543 prev_id
= getLastVisibleHeadlineId();
545 for (var i
= 0; i
< rows
.length
; i
++) {
546 if (rows
[i
] == active_post_id
) {
553 if (mode
== "next") {
557 cdmExpandArticle(next_id
);
558 cdmScrollToArticleId(next_id
);
561 correctHeadlinesOffset(next_id
);
562 view(next_id
, getActiveFeedId());
567 if (mode
== "prev") {
570 cdmExpandArticle(prev_id
);
571 cdmScrollToArticleId(prev_id
);
573 correctHeadlinesOffset(prev_id
);
574 view(prev_id
, getActiveFeedId());
580 exception_error("moveToPost", e
);
584 function toggleSelected(id
, force_on
) {
587 var cb
= $("RCHK-" + id
);
588 var row
= $("RROW-" + id
);
591 if (row
.hasClassName('Selected') && !force_on
) {
592 row
.removeClassName('Selected');
593 if (cb
) cb
.checked
= false;
595 row
.addClassName('Selected');
596 if (cb
) cb
.checked
= true;
600 exception_error("toggleSelected", e
);
604 function toggleUnread_afh(effect
) {
607 var elem
= effect
.element
;
608 elem
.style
.backgroundColor
= "";
611 exception_error("toggleUnread_afh", e
);
615 function toggleUnread(id
, cmode
, effect
) {
618 var row
= $("RROW-" + id
);
620 if (cmode
== undefined || cmode
== 2) {
621 if (row
.hasClassName("Unread")) {
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 } } );
631 row
.addClassName("Unread");
634 } else if (cmode
== 0) {
636 row
.removeClassName("Unread");
639 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
640 afterFinish
: toggleUnread_afh
,
641 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
644 } else if (cmode
== 1) {
645 row
.addClassName("Unread");
648 if (cmode
== undefined) cmode
= 2;
650 var query
= "?op=rpc&subop=catchupSelected" +
651 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
653 // notify_progress("Loading, please wait...");
655 new Ajax
.Request("backend.php", {
657 onComplete: function(transport
) {
658 handle_rpc_json(transport
);
664 exception_error("toggleUnread", e
);
668 function selectionRemoveLabel(id
, ids
) {
671 if (!ids
) var ids
= getSelectedArticleIds2();
673 if (ids
.length
== 0) {
674 alert(__("No articles are selected."));
678 // var ok = confirm(__("Remove selected articles from label?"));
682 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
683 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
687 // notify_progress("Loading, please wait...");
689 cache_invalidate("F:" + (-11 - id
));
691 new Ajax
.Request("backend.php", {
693 onComplete: function(transport
) {
694 handle_rpc_json(transport
);
695 show_labels_in_headlines(transport
);
701 exception_error("selectionAssignLabel", e
);
706 function selectionAssignLabel(id
, ids
) {
709 if (!ids
) ids
= getSelectedArticleIds2();
711 if (ids
.length
== 0) {
712 alert(__("No articles are selected."));
716 // var ok = confirm(__("Assign selected articles to label?"));
720 cache_invalidate("F:" + (-11 - id
));
722 var query
= "?op=rpc&subop=assignToLabel&ids=" +
723 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
727 // notify_progress("Loading, please wait...");
729 new Ajax
.Request("backend.php", {
731 onComplete: function(transport
) {
732 handle_rpc_json(transport
);
733 show_labels_in_headlines(transport
);
739 exception_error("selectionAssignLabel", e
);
744 function selectionToggleUnread(set_state
, callback
, no_error
) {
746 var rows
= getSelectedArticleIds2();
748 if (rows
.length
== 0 && !no_error
) {
749 alert(__("No articles are selected."));
753 for (i
= 0; i
< rows
.length
; i
++) {
754 var row
= $("RROW-" + rows
[i
]);
756 if (set_state
== undefined) {
757 if (row
.hasClassName("Unread")) {
758 row
.removeClassName("Unread");
760 row
.addClassName("Unread");
764 if (set_state
== false) {
765 row
.removeClassName("Unread");
768 if (set_state
== true) {
769 row
.addClassName("Unread");
774 if (rows
.length
> 0) {
778 if (set_state
== undefined) {
780 } else if (set_state
== true) {
782 } else if (set_state
== false) {
786 var query
= "?op=rpc&subop=catchupSelected" +
787 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
789 notify_progress("Loading, please wait...");
791 new Ajax
.Request("backend.php", {
793 onComplete: function(transport
) {
794 handle_rpc_json(transport
);
795 if (callback
) callback(transport
);
801 exception_error("selectionToggleUnread", e
);
805 function selectionToggleMarked() {
808 var rows
= getSelectedArticleIds2();
810 if (rows
.length
== 0) {
811 alert(__("No articles are selected."));
815 for (i
= 0; i
< rows
.length
; i
++) {
816 toggleMark(rows
[i
], true, true);
819 if (rows
.length
> 0) {
821 var query
= "?op=rpc&subop=markSelected&ids=" +
822 param_escape(rows
.toString()) + "&cmode=2";
824 new Ajax
.Request("backend.php", {
826 onComplete: function(transport
) {
827 handle_rpc_json(transport
);
833 exception_error("selectionToggleMarked", e
);
837 function selectionTogglePublished() {
840 var rows
= getSelectedArticleIds2();
842 if (rows
.length
== 0) {
843 alert(__("No articles are selected."));
847 for (i
= 0; i
< rows
.length
; i
++) {
848 togglePub(rows
[i
], true, true);
851 if (rows
.length
> 0) {
853 var query
= "?op=rpc&subop=publishSelected&ids=" +
854 param_escape(rows
.toString()) + "&cmode=2";
856 new Ajax
.Request("backend.php", {
858 onComplete: function(transport
) {
859 handle_rpc_json(transport
);
865 exception_error("selectionToggleMarked", e
);
869 function getSelectedArticleIds2() {
873 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
875 rv
.push(child
.id
.replace("RROW-", ""));
881 function getLoadedArticleIds() {
884 var children
= $$("#headlines-frame > div[id*=RROW-]");
886 children
.each(function(child
) {
887 rv
.push(child
.id
.replace("RROW-", ""));
894 // mode = all,none,unread,invert
895 function selectArticles(mode
) {
898 var children
= $$("#headlines-frame > div[id*=RROW]");
900 children
.each(function(child
) {
901 var id
= child
.id
.replace("RROW-", "");
902 var cb
= $("RCHK-" + id
);
905 child
.addClassName("Selected");
907 } else if (mode
== "unread") {
908 if (child
.hasClassName("Unread")) {
909 child
.addClassName("Selected");
912 child
.removeClassName("Selected");
915 } else if (mode
== "invert") {
916 if (child
.hasClassName("Selected")) {
917 child
.removeClassName("Selected");
920 child
.addClassName("Selected");
925 child
.removeClassName("Selected");
931 exception_error("selectArticles", e
);
935 function catchupPage() {
937 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
939 var str
= __("Mark all visible articles in %s as read?");
941 str
= str
.replace("%s", fn
);
943 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
947 selectArticles('all');
948 selectionToggleUnread(false, 'viewCurrentFeed()', true)
949 selectArticles('none');
952 function deleteSelection() {
956 var rows
= getSelectedArticleIds2();
958 if (rows
.length
== 0) {
959 alert(__("No articles are selected."));
963 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
967 if (getActiveFeedId() != 0) {
968 str
= __("Delete %d selected articles in %s?");
970 str
= __("Delete %d selected articles?");
973 str
= str
.replace("%d", rows
.length
);
974 str
= str
.replace("%s", fn
);
976 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
980 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
984 new Ajax
.Request("backend.php", {
986 onComplete: function(transport
) {
987 handle_rpc_json(transport
);
992 exception_error("deleteSelection", e
);
996 function archiveSelection() {
1000 var rows
= getSelectedArticleIds2();
1002 if (rows
.length
== 0) {
1003 alert(__("No articles are selected."));
1007 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1011 if (getActiveFeedId() != 0) {
1012 str
= __("Archive %d selected articles in %s?");
1015 str
= __("Move %d archived articles back?");
1019 str
= str
.replace("%d", rows
.length
);
1020 str
= str
.replace("%s", fn
);
1022 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1026 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1030 for (var i
= 0; i
< rows
.length
; i
++) {
1031 cache_invalidate(rows
[i
]);
1034 new Ajax
.Request("backend.php", {
1036 onComplete: function(transport
) {
1037 handle_rpc_json(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 var query
= "backend.php?op=dlg&id=editArticleTags¶m=" + param_escape(id
);
1078 if (dijit
.byId("editTagsDlg"))
1079 dijit
.byId("editTagsDlg").destroyRecursive();
1081 dialog
= new dijit
.Dialog({
1083 title
: __("Edit article Tags"),
1084 style
: "width: 600px",
1085 execute: function() {
1086 if (this.validate()) {
1087 var query
= dojo
.objectToQuery(this.attr('value'));
1089 notify_progress("Saving article tags...", true);
1091 new Ajax
.Request("backend.php", {
1093 onComplete: function(transport
) {
1097 var data
= JSON
.parse(transport
.responseText
);
1100 var tags_str
= data
.tags_str
;
1101 var id
= tags_str
.id
;
1103 var tags
= $("ATSTR-" + id
);
1106 tags
.innerHTML
= tags_str
.content
;
1109 cache_invalidate(id
);
1118 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1119 dojo
.disconnect(tmph
);
1121 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1122 "backend.php?op=rpc&subop=completeTags",
1123 { tokens
: ',', paramName
: "search" });
1130 function cdmScrollToArticleId(id
) {
1132 var ctr
= $("headlines-frame");
1133 var e
= $("RROW-" + id
);
1135 if (!e
|| !ctr
) return;
1137 ctr
.scrollTop
= e
.offsetTop
;
1140 exception_error("cdmScrollToArticleId", e
);
1144 function cdmWatchdog() {
1148 var ctr
= $("headlines-frame");
1152 var ids
= new Array();
1154 var e
= ctr
.firstChild
;
1157 if (e
.className
&& e
.hasClassName("Unread") && e
.id
&&
1158 e
.id
.match("RROW-")) {
1160 // article fits in viewport OR article is longer than viewport and
1161 // its bottom is visible
1163 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1164 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1166 // console.log(e.id + " is visible " + e.offsetTop + "." +
1167 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1168 // (ctr.scrollTop + ctr.offsetHeight));
1170 ids
.push(e
.id
.replace("RROW-", ""));
1172 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1173 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1174 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1176 ids
.push(e
.id
.replace("RROW-", ""));
1180 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1182 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1183 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1185 ids.push(e.id.replace("RROW-", ""));
1194 console
.log("cdmWatchdog, ids= " + ids
.toString());
1196 if (ids
.length
> 0) {
1198 for (var i
= 0; i
< ids
.length
; i
++) {
1199 var e
= $("RROW-" + ids
[i
]);
1201 e
.removeClassName("Unread");
1205 var query
= "?op=rpc&subop=catchupSelected" +
1206 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1208 new Ajax
.Request("backend.php", {
1210 onComplete: function(transport
) {
1211 handle_rpc_json(transport
);
1216 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1219 exception_error("cdmWatchdog", e
);
1225 function cache_inject(id
, article
, param
) {
1228 if (!cache_check_param(id
, param
)) {
1229 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1231 var date
= new Date();
1232 var ts
= Math
.round(date
.getTime() / 1000);
1236 cache_obj
["id"] = id
;
1237 cache_obj
["data"] = article
;
1238 cache_obj
["param"] = param
;
1240 if (param
) id
= id
+ ":" + param
;
1242 cache_added
["TS:" + id
] = ts
;
1244 if (has_local_storage())
1245 sessionStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1247 article_cache
.push(cache_obj
);
1250 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1253 exception_error("cache_inject", e
);
1257 function cache_find(id
) {
1259 if (has_local_storage()) {
1260 var cache_obj
= sessionStorage
.getItem(id
);
1263 cache_obj
= JSON
.parse(cache_obj
);
1266 return cache_obj
['data'];
1270 for (var i
= 0; i
< article_cache
.length
; i
++) {
1271 if (article_cache
[i
]["id"] == id
) {
1272 return article_cache
[i
]["data"];
1279 function cache_find_param(id
, param
) {
1281 if (has_local_storage()) {
1283 if (param
) id
= id
+ ":" + param
;
1285 var cache_obj
= sessionStorage
.getItem(id
);
1288 cache_obj
= JSON
.parse(cache_obj
);
1291 return cache_obj
['data'];
1295 for (var i
= 0; i
< article_cache
.length
; i
++) {
1296 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1297 return article_cache
[i
]["data"];
1305 function cache_check(id
) {
1306 if (has_local_storage()) {
1307 if (sessionStorage
.getItem(id
))
1310 for (var i
= 0; i
< article_cache
.length
; i
++) {
1311 if (article_cache
[i
]["id"] == id
) {
1319 function cache_check_param(id
, param
) {
1320 if (has_local_storage()) {
1322 if (param
) id
= id
+ ":" + param
;
1324 if (sessionStorage
.getItem(id
))
1328 for (var i
= 0; i
< article_cache
.length
; i
++) {
1329 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1337 function cache_expire() {
1338 if (has_local_storage()) {
1340 var date
= new Date();
1341 var timestamp
= Math
.round(date
.getTime() / 1000);
1343 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1345 var id
= sessionStorage
.key(i
);
1347 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1348 sessionStorage
.removeItem(id
);
1353 while (article_cache
.length
> 25) {
1354 article_cache
.shift();
1359 function cache_flush() {
1360 if (has_local_storage()) {
1361 sessionStorage
.clear();
1363 article_cache
= new Array();
1367 function cache_invalidate(id
) {
1369 if (has_local_storage()) {
1373 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1374 var key
= sessionStorage
.key(i
);
1376 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1378 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1379 sessionStorage
.removeItem(key
);
1390 while (i
< article_cache
.length
) {
1391 if (article_cache
[i
]["id"] == id
) {
1392 //console.log("cache_invalidate: removed id " + id);
1393 article_cache
.splice(i
, 1);
1400 //console.log("cache_invalidate: id not found: " + id);
1403 exception_error("cache_invalidate", e
);
1407 function getActiveArticleId() {
1408 return active_post_id
;
1411 function preloadBatchedArticles() {
1414 var query
= "?op=rpc&subop=getArticles&ids=" +
1415 preload_id_batch
.toString();
1417 new Ajax
.Request("backend.php", {
1419 onComplete: function(transport
) {
1421 preload_id_batch
= [];
1423 var articles
= transport
.responseXML
.getElementsByTagName("article");
1425 for (var i
= 0; i
< articles
.length
; i
++) {
1426 var id
= articles
[i
].getAttribute("id");
1427 if (!cache_check(id
)) {
1428 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1429 console
.log("preloaded article: " + id
);
1435 exception_error("preloadBatchedArticles", e
);
1439 function preloadArticleUnderPointer(id
) {
1441 if (getInitParam("bw_limit") == "1") return;
1443 if (post_under_pointer
== id
&& !cache_check(id
)) {
1445 console
.log("trying to preload article " + id
);
1447 var neighbor_ids
= getRelativePostIds(id
, 1);
1449 /* only request uncached articles */
1451 if (preload_id_batch
.indexOf(id
) == -1) {
1452 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1453 if (!cache_check(neighbor_ids
[i
])) {
1454 preload_id_batch
.push(neighbor_ids
[i
]);
1459 if (preload_id_batch
.indexOf(id
) == -1)
1460 preload_id_batch
.push(id
);
1462 //console.log("preload ids batch: " + preload_id_batch.toString());
1464 window
.clearTimeout(preload_timeout_id
);
1465 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1469 exception_error("preloadArticleUnderPointer", e
);
1473 function postMouseIn(id
) {
1475 if (post_under_pointer
!= id
) {
1476 post_under_pointer
= id
;
1478 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1483 exception_error("postMouseIn", e
);
1487 function postMouseOut(id
) {
1489 post_under_pointer
= false;
1491 exception_error("postMouseOut", e
);
1495 function headlines_scroll_handler(e
) {
1498 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1499 if (!_infscroll_disable
) {
1505 exception_error("headlines_scroll_handler", e
);
1509 function catchupRelativeToArticle(below
) {
1514 if (!getActiveArticleId()) {
1515 alert(__("No article is selected."));
1519 var visible_ids
= getVisibleArticleIds();
1521 var ids_to_mark
= new Array();
1524 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1525 if (visible_ids
[i
] != getActiveArticleId()) {
1526 var e
= $("RROW-" + visible_ids
[i
]);
1528 if (e
&& e
.hasClassName("Unread")) {
1529 ids_to_mark
.push(visible_ids
[i
]);
1536 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1537 if (visible_ids
[i
] != getActiveArticleId()) {
1538 var e
= $("RROW-" + visible_ids
[i
]);
1540 if (e
&& e
.hasClassName("Unread")) {
1541 ids_to_mark
.push(visible_ids
[i
]);
1549 if (ids_to_mark
.length
== 0) {
1550 alert(__("No articles found to mark"));
1552 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1554 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1556 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1557 var e
= $("RROW-" + ids_to_mark
[i
]);
1558 e
.removeClassName("Unread");
1561 var query
= "?op=rpc&subop=catchupSelected" +
1562 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1564 new Ajax
.Request("backend.php", {
1566 onComplete: function(transport
) {
1567 handle_rpc_json(transport
);
1574 exception_error("catchupRelativeToArticle", e
);
1578 function cdmExpandArticle(id
) {
1583 var elem
= $("CICD-" + active_post_id
);
1585 var upd_img_pic
= $("FUPDPIC-" + id
);
1587 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1588 upd_img_pic
.src
.match("fresh_sign.png"))) {
1590 upd_img_pic
.src
= "images/blank_icon.gif";
1593 if (id
== active_post_id
&& Element
.visible(elem
))
1596 selectArticles("none");
1598 var old_offset
= $("RROW-" + id
).offsetTop
;
1600 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1602 Element
.show("CEXC-" + active_post_id
);
1605 active_post_id
= id
;
1607 elem
= $("CICD-" + id
);
1609 if (!Element
.visible(elem
)) {
1611 Element
.hide("CEXC-" + id
);
1613 if ($("CWRAP-" + id
).innerHTML
== "") {
1615 $("FUPDPIC-" + id
).src
= "images/indicator_tiny.gif";
1617 $("CWRAP-" + id
).innerHTML
= "<div class=\"insensitive\">" +
1618 __("Loading, please wait...") + "</div>";
1620 var query
= "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id
);
1622 //console.log(query);
1624 new Ajax
.Request("backend.php", {
1626 onComplete: function(transport
) {
1627 $("FUPDPIC-" + id
).src
= 'images/blank_icon.gif';
1629 handle_rpc_json(transport
);
1631 var reply
= JSON
.parse(transport
.responseText
);
1634 var article
= reply
['article']['content'];
1635 var recv_id
= reply
['article']['id'];
1638 $("CWRAP-" + id
).innerHTML
= article
;
1641 $("CWRAP-" + id
).innerHTML
= __("Unable to load article.");
1649 var new_offset
= $("RROW-" + id
).offsetTop
;
1651 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1653 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1654 $("headlines-frame").scrollTop
= new_offset
;
1656 toggleUnread(id
, 0, true);
1660 exception_error("cdmExpandArticle", e
);
1666 function fixHeadlinesOrder(ids
) {
1668 for (var i
= 0; i
< ids
.length
; i
++) {
1669 var e
= $("RROW-" + ids
[i
]);
1673 e
.removeClassName("even");
1674 e
.addClassName("odd");
1676 e
.removeClassName("odd");
1677 e
.addClassName("even");
1682 exception_error("fixHeadlinesOrder", e
);
1686 function getArticleUnderPointer() {
1687 return post_under_pointer
;
1690 function zoomToArticle(event
, id
) {
1692 var cached_article
= cache_find(id
);
1694 if (dijit
.byId("ATAB-" + id
))
1695 if (!event
|| !event
.shiftKey
)
1696 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1698 if (cached_article
) {
1699 //closeArticlePanel();
1701 var article_pane
= new dijit
.layout
.ContentPane({
1702 title
: __("Loading...") , content
: cached_article
,
1703 style
: 'padding : 0px;',
1707 dijit
.byId("content-tabs").addChild(article_pane
);
1709 if (!event
|| !event
.shiftKey
)
1710 dijit
.byId("content-tabs").selectChild(article_pane
);
1712 if ($("PTITLE-" + id
))
1713 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1717 var query
= "?op=rpc&subop=getArticles&ids=" + param_escape(id
);
1719 notify_progress("Loading, please wait...", true);
1721 new Ajax
.Request("backend.php", {
1723 onComplete: function(transport
) {
1726 if (transport
.responseXML
) {
1727 //closeArticlePanel();
1729 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1730 var content
= article
.firstChild
.nodeValue
;
1732 var article_pane
= new dijit
.layout
.ContentPane({
1733 title
: "article-" + id
, content
: content
,
1734 style
: 'padding : 0px;',
1738 dijit
.byId("content-tabs").addChild(article_pane
);
1740 if (!event
|| !event
.shiftKey
)
1741 dijit
.byId("content-tabs").selectChild(article_pane
);
1743 if ($("PTITLE-" + id
))
1744 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1751 exception_error("zoomToArticle", e
);
1755 function scrollArticle(offset
) {
1758 var ci
= $("content-insert");
1760 ci
.scrollTop
+= offset
;
1763 var hi
= $("headlines-frame");
1765 hi
.scrollTop
+= offset
;
1770 exception_error("scrollArticle", e
);
1774 function show_labels_in_headlines(transport
) {
1776 var data
= JSON
.parse(transport
.responseText
);
1779 data
['info-for-headlines'].each(function(elem
) {
1780 var ctr
= $("HLLCTR-" + elem
.id
);
1782 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1786 exception_error("show_labels_in_headlines", e
);
1790 function toggleHeadlineActions() {
1792 var e
= $("headlineActionsBody");
1793 var p
= $("headlineActionsDrop");
1795 if (!Element
.visible(e
)) {
1802 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
1803 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
1806 exception_error("toggleHeadlineActions", e
);
1810 /* function publishWithNote(id, def_note) {
1812 if (!def_note) def_note = '';
1814 var note = prompt(__("Please enter a note for this article:"), def_note);
1816 if (note != undefined) {
1817 togglePub(id, false, false, note);
1821 exception_error("publishWithNote", e);
1825 function emailArticle(id
) {
1828 var ids
= getSelectedArticleIds2();
1830 if (ids
.length
== 0) {
1831 alert(__("No articles are selected."));
1835 id
= ids
.toString();
1838 if (dijit
.byId("emailArticleDlg"))
1839 dijit
.byId("emailArticleDlg").destroyRecursive();
1841 var query
= "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id
);
1843 dialog
= new dijit
.Dialog({
1844 id
: "emailArticleDlg",
1845 title
: __("Forward article by email"),
1846 style
: "width: 600px",
1847 execute: function() {
1848 if (this.validate()) {
1850 new Ajax
.Request("backend.php", {
1851 parameters
: dojo
.objectToQuery(this.attr('value')),
1852 onComplete: function(transport
) {
1854 var reply
= JSON
.parse(transport
.responseText
);
1856 var error
= reply
['error'];
1859 alert(__('Error sending email:') + ' ' + error
);
1861 notify_info('Your message has been sent.');
1870 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1871 dojo
.disconnect(tmph
);
1873 new Ajax
.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
1874 "backend.php?op=rpc&subop=completeEmails",
1875 { tokens
: '', paramName
: "search" });
1880 /* displayDlg('emailArticle', id,
1882 document.forms['article_email_form'].destination.focus();
1884 new Ajax.Autocompleter('destination', 'destination_choices',
1885 "backend.php?op=rpc&subop=completeEmails",
1886 { tokens: '', paramName: "search" });
1891 exception_error("emailArticle", e
);
1895 function dismissArticle(id
) {
1897 var elem
= $("RROW-" + id
);
1899 toggleUnread(id
, 0, true);
1901 new Effect
.Fade(elem
, {duration
: 0.5});
1903 active_post_id
= false;
1906 exception_error("dismissArticle", e
);
1910 function dismissSelectedArticles() {
1913 var ids
= getVisibleArticleIds();
1917 for (var i
= 0; i
< ids
.length
; i
++) {
1918 var elem
= $("RROW-" + ids
[i
]);
1920 if (elem
.className
&& elem
.hasClassName("Selected") &&
1921 ids
[i
] != active_post_id
) {
1922 new Effect
.Fade(elem
, {duration
: 0.5});
1930 selectionToggleUnread(false);
1932 fixHeadlinesOrder(tmp
);
1935 exception_error("dismissSelectedArticles", e
);
1939 function dismissReadArticles() {
1942 var ids
= getVisibleArticleIds();
1945 for (var i
= 0; i
< ids
.length
; i
++) {
1946 var elem
= $("RROW-" + ids
[i
]);
1948 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1949 !elem
.hasClassName("Selected")) {
1951 new Effect
.Fade(elem
, {duration
: 0.5});
1957 fixHeadlinesOrder(tmp
);
1960 exception_error("dismissSelectedArticles", e
);
1964 function getVisibleArticleIds() {
1969 getLoadedArticleIds().each(function(id
) {
1970 var elem
= $("RROW-" + id
);
1971 if (elem
&& Element
.visible(elem
))
1976 exception_error("getVisibleArticleIds", e
);
1982 function cdmClicked(event
, id
) {
1984 var shift_key
= event
.shiftKey
;
1988 if (!event
.ctrlKey
) {
1990 if (!getInitParam("cdm_expanded")) {
1991 return cdmExpandArticle(id
);
1994 selectArticles("none");
1997 var elem
= $("RROW-" + id
);
2000 elem
.removeClassName("Unread");
2002 var upd_img_pic
= $("FUPDPIC-" + id
);
2004 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
2005 upd_img_pic
.src
.match("fresh_sign.png"))) {
2007 upd_img_pic
.src
= "images/blank_icon.gif";
2010 active_post_id
= id
;
2012 var query
= "?op=rpc&subop=catchupSelected" +
2013 "&cmode=0&ids=" + param_escape(id
);
2015 new Ajax
.Request("backend.php", {
2017 onComplete: function(transport
) {
2018 handle_json_reply(transport
);
2023 toggleSelected(id
, true);
2024 toggleUnread(id
, 0, false);
2025 zoomToArticle(event
, id
);
2029 exception_error("cdmClicked");
2035 function postClicked(event
, id
) {
2038 if (!event
.ctrlKey
) {
2041 postOpenInNewTab(event
, id
);
2046 exception_error("postClicked");
2050 function hlOpenInNewTab(event
, id
) {
2051 toggleUnread(id
, 0, false);
2052 zoomToArticle(event
, id
);
2055 function postOpenInNewTab(event
, id
) {
2056 closeArticlePanel(id
);
2057 zoomToArticle(event
, id
);
2060 function hlClicked(event
, id
) {
2063 openArticleInNewWindow(id
);
2064 } else if (!event
.ctrlKey
) {
2069 toggleUnread(id
, 0, false);
2070 zoomToArticle(event
, id
);
2075 exception_error("hlClicked");
2079 function getFirstVisibleHeadlineId() {
2080 var rows
= getVisibleArticleIds();
2085 function getLastVisibleHeadlineId() {
2086 var rows
= getVisibleArticleIds();
2087 return rows
[rows
.length
-1];
2090 function openArticleInNewWindow(id
) {
2091 toggleUnread(id
, 0, false);
2092 window
.open("backend.php?op=la&id=" + id
);
2095 function isCdmMode() {
2096 return getInitParam("combined_display_mode");
2099 function markHeadline(id
) {
2100 var row
= $("RROW-" + id
);
2102 var check
= $("RCHK-" + id
);
2105 check
.checked
= true;
2108 row
.addClassName("Selected");
2112 function getRelativePostIds(id
, limit
) {
2118 if (!limit
) limit
= 3;
2120 var ids
= getVisibleArticleIds();
2122 for (var i
= 0; i
< ids
.length
; i
++) {
2124 for (var k
= 1; k
<= limit
; k
++) {
2125 if (i
> k
-1) tmp
.push(ids
[i
-k
]);
2126 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
2133 exception_error("getRelativePostIds", e
);
2139 function correctHeadlinesOffset(id
) {
2143 var container
= $("headlines-frame");
2144 var row
= $("RROW-" + id
);
2146 var viewport
= container
.offsetHeight
;
2148 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
2149 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
2151 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
2152 //console.log("Vport: " + viewport);
2154 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
2155 container
.scrollTop
= row
.offsetTop
;
2156 } else if (rel_offset_bottom
> viewport
) {
2158 /* doesn't properly work with Opera in some cases because
2159 Opera fucks up element scrolling */
2161 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
2165 exception_error("correctHeadlinesOffset", e
);
2170 function headlineActionsChange(elem
) {
2173 elem
.attr('value', 'false');
2175 exception_error("headlineActionsChange", e
);
2179 function closeArticlePanel() {
2181 var tabs
= dijit
.byId("content-tabs");
2182 var child
= tabs
.selectedChildWidget
;
2184 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
2185 tabs
.removeChild(child
);
2188 if (dijit
.byId("content-insert"))
2189 dijit
.byId("headlines-wrap-inner").removeChild(
2190 dijit
.byId("content-insert"));
2194 function initHeadlinesMenu() {
2196 if (dijit
.byId("headlinesMenu"))
2197 dijit
.byId("headlinesMenu").destroyRecursive();
2202 nodes
= $$("#headlines-frame > div[id*=RROW]");
2204 nodes
= $$("#headlines-frame span[id*=RTITLE]");
2207 nodes
.each(function(node
) {
2211 var menu
= new dijit
.Menu({
2212 id
: "headlinesMenu",
2216 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
2217 var callerNode
= event
.target
, match
= null, tries
= 0;
2219 while (match
== null && callerNode
&& tries
<= 3) {
2220 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
2221 callerNode
= callerNode
.parentNode
;
2225 if (match
) this.callerRowId
= parseInt(match
[1]);
2230 menu
.addChild(new dijit
.MenuItem({
2231 label
: __("View article"),
2232 onClick: function(event
) {
2233 view(this.getParent().callerRowId
);
2236 menu
.addChild(new dijit
.MenuItem({
2237 label
: __("View in a new tab"),
2238 onClick: function(event
) {
2239 hlOpenInNewTab(event
, this.getParent().callerRowId
);
2242 menu
.addChild(new dijit
.MenuSeparator());
2244 menu
.addChild(new dijit
.MenuItem({
2245 label
: __("Open original article"),
2246 onClick: function(event
) {
2247 openArticleInNewWindow(this.getParent().callerRowId
);
2250 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2254 menu
.addChild(new dijit
.MenuSeparator());
2256 var labelsMenu
= new dijit
.Menu({ownerMenu
: menu
});
2258 labels
.each(function(label
) {
2259 var id
= label
.id
[0];
2260 var bare_id
= id
.substr(id
.indexOf(":")+1);
2261 var name
= label
.name
[0];
2263 bare_id
= -11-bare_id
;
2265 labelsMenu
.addChild(new dijit
.MenuItem({
2268 onClick: function(event
) {
2269 //console.log(this.labelId);
2270 //console.log(this.getParent().ownerMenu.callerRowId);
2271 selectionAssignLabel(this.labelId
,
2272 [this.getParent().ownerMenu
.callerRowId
]);
2276 menu
.addChild(new dijit
.PopupMenuItem({
2277 label
: __("Labels"),
2285 exception_error("initHeadlinesMenu", e
);
2289 function tweetArticle(id
) {
2291 var query
= "?op=rpc&subop=getTweetInfo&id=" + param_escape(id
);
2296 var ts
= d
.getTime();
2298 var w
= window
.open('backend.php?op=loading', 'ttrss_tweet',
2299 "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
2301 new Ajax
.Request("backend.php", {
2303 onComplete: function(transport
) {
2304 var ti
= JSON
.parse(transport
.responseText
);
2306 var share_url
= "http://twitter.com/share?_=" + ts
+
2307 "&text=" + param_escape(ti
.title
) +
2308 "&url=" + param_escape(ti
.link
);
2310 w
.location
.href
= share_url
;
2316 exception_error("tweetArticle", e
);
2320 function editArticleNote(id
) {
2323 var query
= "backend.php?op=dlg&id=editArticleNote¶m=" + param_escape(id
);
2325 if (dijit
.byId("editNoteDlg"))
2326 dijit
.byId("editNoteDlg").destroyRecursive();
2328 dialog
= new dijit
.Dialog({
2330 title
: __("Edit article note"),
2331 style
: "width: 600px",
2332 execute: function() {
2333 if (this.validate()) {
2334 var query
= dojo
.objectToQuery(this.attr('value'));
2336 notify_progress("Saving article note...", true);
2338 new Ajax
.Request("backend.php", {
2340 onComplete: function(transport
) {
2344 var reply
= JSON
.parse(transport
.responseText
);
2346 cache_invalidate(id
);
2348 var elem
= $("POSTNOTE-" + id
);
2352 elem
.innerHTML
= reply
.note
;
2353 new Effect
.Appear(elem
);
2365 exception_error("editArticleNote", e
);
2369 function player(elem
) {
2370 var aid
= elem
.getAttribute("audio-id");
2371 var status
= elem
.getAttribute("status");
2379 elem
.innerHTML
= __("Playing...");
2380 elem
.title
= __("Click to pause");
2381 elem
.addClassName("playing");
2385 elem
.innerHTML
= __("Play");
2386 elem
.title
= __("Click to play");
2387 elem
.removeClassName("playing");
2390 elem
.setAttribute("status", status
);
2392 alert("Your browser doesn't seem to support HTML5 audio.");