]>
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());
217 exception_error("render_article", e
);
221 function showArticleInHeadlines(id
) {
225 selectArticles("none");
227 var crow
= $("RROW-" + id
);
231 var article_is_unread
= crow
.hasClassName("Unread");
233 crow
.removeClassName("Unread");
235 selectArticles('none');
237 var upd_img_pic
= $("FUPDPIC-" + id
);
239 var cache_prefix
= "";
241 if (activeFeedIsCat()) {
247 var view_mode
= false;
250 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
251 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
256 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
257 upd_img_pic
.src
.match("fresh_sign.png"))) {
259 upd_img_pic
.src
= "images/blank_icon.gif";
261 cache_invalidate(cache_prefix
+ getActiveFeedId());
263 /* cache_inject(cache_prefix + getActiveFeedId(),
264 $("headlines-frame").innerHTML,
265 getFeedUnread(getActiveFeedId())); */
267 } else if (article_is_unread
&& view_mode
== "all_articles") {
269 cache_invalidate(cache_prefix
+ getActiveFeedId());
271 /* cache_inject(cache_prefix + getActiveFeedId(),
272 $("headlines-frame").innerHTML,
273 getFeedUnread(getActiveFeedId())-1); */
275 } else if (article_is_unread
) {
276 cache_invalidate(cache_prefix
+ getActiveFeedId());
281 if (article_is_unread
)
282 _force_scheduled_update
= true;
285 exception_error("showArticleInHeadlines", e
);
289 function article_callback2(transport
, id
) {
291 console
.log("article_callback2 " + id
);
293 if (!handle_rpc_reply(transport
)) return;
295 if (transport
.responseXML
) {
297 if (!transport_error_check(transport
)) return;
299 var upic
= $('FUPDPIC-' + id
);
302 upic
.src
= 'images/blank_icon.gif';
305 if (id
!= last_requested_article
) {
306 console
.log("requested article id is out of sequence, aborting");
310 // active_post_id = id;
312 //console.log("looking for articles to cache...");
314 var articles
= transport
.responseXML
.getElementsByTagName("article");
316 for (var i
= 0; i
< articles
.length
; i
++) {
317 var a_id
= articles
[i
].getAttribute("id");
319 //console.log("found id: " + a_id);
321 if (a_id
== active_post_id
) {
322 //console.log("active article, rendering...");
323 render_article(articles
[i
].firstChild
.nodeValue
);
326 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
330 // showArticleInHeadlines(id);
332 var reply
= transport
.responseXML
.firstChild
.firstChild
;
335 console
.warn("article_callback: returned no XML object");
336 //var f = $("content-frame");
337 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
340 var date
= new Date();
341 last_article_view
= date
.getTime() / 1000;
347 exception_error("article_callback2", e
, transport
);
353 console
.log("loading article: " + id
);
355 var cached_article
= cache_find(id
);
357 console
.log("cache check result: " + (cached_article
!= false));
361 var query
= "?op=view&id=" + param_escape(id
);
363 var neighbor_ids
= getRelativePostIds(active_post_id
);
365 /* only request uncached articles */
367 var cids_to_request
= Array();
369 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
370 if (!cache_check(neighbor_ids
[i
])) {
371 cids_to_request
.push(neighbor_ids
[i
]);
375 console
.log("additional ids: " + cids_to_request
.toString());
377 query
= query
+ "&cids=" + cids_to_request
.toString();
379 var crow
= $("RROW-" + id
);
380 var article_is_unread
= crow
.hasClassName("Unread");
383 showArticleInHeadlines(id
);
385 if (!cached_article
) {
387 var upic
= $('FUPDPIC-' + id
);
390 upic
.src
= getInitParam("sign_progress");
393 } else if (cached_article
&& article_is_unread
) {
395 query
= query
+ "&mode=prefetch";
397 render_article(cached_article
);
399 } else if (cached_article
) {
401 query
= query
+ "&mode=prefetch_old";
402 render_article(cached_article
);
408 last_requested_article
= id
;
410 new Ajax
.Request("backend.php", {
412 onComplete: function(transport
) {
413 article_callback2(transport
, id
);
419 exception_error("view", e
);
424 return toggleMark(id
);
428 return togglePub(id
);
431 function toggleMark(id
, client_only
) {
433 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
435 var img
= $("FMPIC-" + id
);
439 if (img
.src
.match("mark_unset")) {
440 img
.src
= img
.src
.replace("mark_unset", "mark_set");
441 img
.alt
= __("Unstar article");
442 query
= query
+ "&mark=1";
445 img
.src
= img
.src
.replace("mark_set", "mark_unset");
446 img
.alt
= __("Star article");
447 query
= query
+ "&mark=0";
451 new Ajax
.Request("backend.php", {
453 onComplete: function(transport
) {
454 handle_rpc_json(transport
);
459 exception_error("toggleMark", e
);
463 function togglePub(id
, client_only
, no_effects
, note
) {
465 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
467 if (note
!= undefined) {
468 query
= query
+ "¬e=" + param_escape(note
);
470 query
= query
+ "¬e=undefined";
473 var img
= $("FPPIC-" + id
);
477 if (img
.src
.match("pub_unset") || note
!= undefined) {
478 img
.src
= img
.src
.replace("pub_unset", "pub_set");
479 img
.alt
= __("Unpublish article");
480 query
= query
+ "&pub=1";
483 img
.src
= img
.src
.replace("pub_set", "pub_unset");
484 img
.alt
= __("Publish article");
486 query
= query
+ "&pub=0";
490 new Ajax
.Request("backend.php", {
492 onComplete: function(transport
) {
493 handle_rpc_json(transport
);
497 /* if (!client_only) {
498 new Ajax.Request("backend.php", {
500 onComplete: function(transport) {
501 handle_rpc_reply(transport);
503 var note = transport.responseXML.getElementsByTagName("note")[0];
506 var note_id = note.getAttribute("id");
507 var note_size = note.getAttribute("size");
508 var note_content = note.firstChild.nodeValue;
510 var container = $('POSTNOTE-' + note_id);
512 cache_invalidate(note_id);
515 if (note_size == "0") {
516 Element.hide(container);
518 container.innerHTML = note_content;
519 Element.show(container);
528 exception_error("togglePub", e
);
532 function moveToPost(mode
) {
536 var rows
= getVisibleArticleIds();
541 if (!$('RROW-' + active_post_id
)) {
542 active_post_id
= false;
545 if (active_post_id
== false) {
546 next_id
= getFirstVisibleHeadlineId();
547 prev_id
= getLastVisibleHeadlineId();
549 for (var i
= 0; i
< rows
.length
; i
++) {
550 if (rows
[i
] == active_post_id
) {
557 if (mode
== "next") {
561 cdmExpandArticle(next_id
);
562 cdmScrollToArticleId(next_id
);
565 correctHeadlinesOffset(next_id
);
566 view(next_id
, getActiveFeedId());
571 if (mode
== "prev") {
574 cdmExpandArticle(prev_id
);
575 cdmScrollToArticleId(prev_id
);
577 correctHeadlinesOffset(prev_id
);
578 view(prev_id
, getActiveFeedId());
584 exception_error("moveToPost", e
);
588 function toggleSelected(id
, force_on
) {
591 var cb
= $("RCHK-" + id
);
592 var row
= $("RROW-" + id
);
595 if (row
.hasClassName('Selected') && !force_on
) {
596 row
.removeClassName('Selected');
597 if (cb
) cb
.checked
= false;
599 row
.addClassName('Selected');
600 if (cb
) cb
.checked
= true;
604 exception_error("toggleSelected", e
);
608 function toggleUnread_afh(effect
) {
611 var elem
= effect
.element
;
612 elem
.style
.backgroundColor
= "";
615 exception_error("toggleUnread_afh", e
);
619 function toggleUnread(id
, cmode
, effect
) {
622 var row
= $("RROW-" + id
);
624 if (cmode
== undefined || cmode
== 2) {
625 if (row
.hasClassName("Unread")) {
626 row
.removeClassName("Unread");
629 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
630 afterFinish
: toggleUnread_afh
,
631 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
635 row
.addClassName("Unread");
638 } else if (cmode
== 0) {
640 row
.removeClassName("Unread");
643 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
644 afterFinish
: toggleUnread_afh
,
645 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
648 } else if (cmode
== 1) {
649 row
.addClassName("Unread");
652 if (cmode
== undefined) cmode
= 2;
654 var query
= "?op=rpc&subop=catchupSelected" +
655 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
657 // notify_progress("Loading, please wait...");
659 new Ajax
.Request("backend.php", {
661 onComplete: function(transport
) {
662 handle_rpc_json(transport
);
668 exception_error("toggleUnread", e
);
672 function selectionRemoveLabel(id
, ids
) {
675 if (!ids
) var ids
= getSelectedArticleIds2();
677 if (ids
.length
== 0) {
678 alert(__("No articles are selected."));
682 // var ok = confirm(__("Remove selected articles from label?"));
686 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
687 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
691 // notify_progress("Loading, please wait...");
693 cache_invalidate("F:" + (-11 - id
));
695 new Ajax
.Request("backend.php", {
697 onComplete: function(transport
) {
698 handle_rpc_json(transport
);
699 show_labels_in_headlines(transport
);
705 exception_error("selectionAssignLabel", e
);
710 function selectionAssignLabel(id
, ids
) {
713 if (!ids
) ids
= getSelectedArticleIds2();
715 if (ids
.length
== 0) {
716 alert(__("No articles are selected."));
720 // var ok = confirm(__("Assign selected articles to label?"));
724 cache_invalidate("F:" + (-11 - id
));
726 var query
= "?op=rpc&subop=assignToLabel&ids=" +
727 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
731 // notify_progress("Loading, please wait...");
733 new Ajax
.Request("backend.php", {
735 onComplete: function(transport
) {
736 handle_rpc_json(transport
);
737 show_labels_in_headlines(transport
);
743 exception_error("selectionAssignLabel", e
);
748 function selectionToggleUnread(set_state
, callback
, no_error
) {
750 var rows
= getSelectedArticleIds2();
752 if (rows
.length
== 0 && !no_error
) {
753 alert(__("No articles are selected."));
757 for (i
= 0; i
< rows
.length
; i
++) {
758 var row
= $("RROW-" + rows
[i
]);
760 if (set_state
== undefined) {
761 if (row
.hasClassName("Unread")) {
762 row
.removeClassName("Unread");
764 row
.addClassName("Unread");
768 if (set_state
== false) {
769 row
.removeClassName("Unread");
772 if (set_state
== true) {
773 row
.addClassName("Unread");
778 if (rows
.length
> 0) {
782 if (set_state
== undefined) {
784 } else if (set_state
== true) {
786 } else if (set_state
== false) {
790 var query
= "?op=rpc&subop=catchupSelected" +
791 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
793 notify_progress("Loading, please wait...");
795 new Ajax
.Request("backend.php", {
797 onComplete: function(transport
) {
798 handle_rpc_json(transport
);
799 if (callback
) callback(transport
);
805 exception_error("selectionToggleUnread", e
);
809 function selectionToggleMarked() {
812 var rows
= getSelectedArticleIds2();
814 if (rows
.length
== 0) {
815 alert(__("No articles are selected."));
819 for (i
= 0; i
< rows
.length
; i
++) {
820 toggleMark(rows
[i
], true, true);
823 if (rows
.length
> 0) {
825 var query
= "?op=rpc&subop=markSelected&ids=" +
826 param_escape(rows
.toString()) + "&cmode=2";
828 new Ajax
.Request("backend.php", {
830 onComplete: function(transport
) {
831 handle_rpc_json(transport
);
837 exception_error("selectionToggleMarked", e
);
841 function selectionTogglePublished() {
844 var rows
= getSelectedArticleIds2();
846 if (rows
.length
== 0) {
847 alert(__("No articles are selected."));
851 for (i
= 0; i
< rows
.length
; i
++) {
852 togglePub(rows
[i
], true, true);
855 if (rows
.length
> 0) {
857 var query
= "?op=rpc&subop=publishSelected&ids=" +
858 param_escape(rows
.toString()) + "&cmode=2";
860 new Ajax
.Request("backend.php", {
862 onComplete: function(transport
) {
863 handle_rpc_json(transport
);
869 exception_error("selectionToggleMarked", e
);
873 function getSelectedArticleIds2() {
877 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
879 rv
.push(child
.id
.replace("RROW-", ""));
885 function getLoadedArticleIds() {
888 var children
= $$("#headlines-frame > div[id*=RROW-]");
890 children
.each(function(child
) {
891 rv
.push(child
.id
.replace("RROW-", ""));
898 // mode = all,none,unread,invert
899 function selectArticles(mode
) {
902 var children
= $$("#headlines-frame > div[id*=RROW]");
904 children
.each(function(child
) {
905 var id
= child
.id
.replace("RROW-", "");
906 var cb
= $("RCHK-" + id
);
909 child
.addClassName("Selected");
911 } else if (mode
== "unread") {
912 if (child
.hasClassName("Unread")) {
913 child
.addClassName("Selected");
916 child
.removeClassName("Selected");
919 } else if (mode
== "invert") {
920 if (child
.hasClassName("Selected")) {
921 child
.removeClassName("Selected");
924 child
.addClassName("Selected");
929 child
.removeClassName("Selected");
935 exception_error("selectArticles", e
);
939 function catchupPage() {
941 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
943 var str
= __("Mark all visible articles in %s as read?");
945 str
= str
.replace("%s", fn
);
947 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
951 selectArticles('all');
952 selectionToggleUnread(false, 'viewCurrentFeed()', true)
953 selectArticles('none');
956 function deleteSelection() {
960 var rows
= getSelectedArticleIds2();
962 if (rows
.length
== 0) {
963 alert(__("No articles are selected."));
967 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
971 if (getActiveFeedId() != 0) {
972 str
= __("Delete %d selected articles in %s?");
974 str
= __("Delete %d selected articles?");
977 str
= str
.replace("%d", rows
.length
);
978 str
= str
.replace("%s", fn
);
980 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
984 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
988 new Ajax
.Request("backend.php", {
990 onComplete: function(transport
) {
991 handle_rpc_json(transport
);
996 exception_error("deleteSelection", e
);
1000 function archiveSelection() {
1004 var rows
= getSelectedArticleIds2();
1006 if (rows
.length
== 0) {
1007 alert(__("No articles are selected."));
1011 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1015 if (getActiveFeedId() != 0) {
1016 str
= __("Archive %d selected articles in %s?");
1019 str
= __("Move %d archived articles back?");
1023 str
= str
.replace("%d", rows
.length
);
1024 str
= str
.replace("%s", fn
);
1026 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1030 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1034 for (var i
= 0; i
< rows
.length
; i
++) {
1035 cache_invalidate(rows
[i
]);
1038 new Ajax
.Request("backend.php", {
1040 onComplete: function(transport
) {
1041 handle_rpc_json(transport
);
1046 exception_error("archiveSelection", e
);
1050 function catchupSelection() {
1054 var rows
= getSelectedArticleIds2();
1056 if (rows
.length
== 0) {
1057 alert(__("No articles are selected."));
1061 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1063 var str
= __("Mark %d selected articles in %s as read?");
1065 str
= str
.replace("%d", rows
.length
);
1066 str
= str
.replace("%s", fn
);
1068 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1072 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1075 exception_error("catchupSelection", e
);
1079 function editArticleTags(id
) {
1080 var query
= "backend.php?op=dlg&id=editArticleTags¶m=" + param_escape(id
);
1082 if (dijit
.byId("editTagsDlg"))
1083 dijit
.byId("editTagsDlg").destroyRecursive();
1085 dialog
= new dijit
.Dialog({
1087 title
: __("Edit article Tags"),
1088 style
: "width: 600px",
1089 execute: function() {
1090 if (this.validate()) {
1091 var query
= dojo
.objectToQuery(this.attr('value'));
1093 notify_progress("Saving article tags...", true);
1095 new Ajax
.Request("backend.php", {
1097 onComplete: function(transport
) {
1101 var data
= JSON
.parse(transport
.responseText
);
1104 var tags_str
= data
.tags_str
;
1105 var id
= tags_str
.id
;
1107 var tags
= $("ATSTR-" + id
);
1110 tags
.innerHTML
= tags_str
.content
;
1113 cache_invalidate(id
);
1122 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1123 dojo
.disconnect(tmph
);
1125 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1126 "backend.php?op=rpc&subop=completeTags",
1127 { tokens
: ',', paramName
: "search" });
1134 function cdmScrollToArticleId(id
) {
1136 var ctr
= $("headlines-frame");
1137 var e
= $("RROW-" + id
);
1139 if (!e
|| !ctr
) return;
1141 ctr
.scrollTop
= e
.offsetTop
;
1144 exception_error("cdmScrollToArticleId", e
);
1148 function cdmWatchdog() {
1152 var ctr
= $("headlines-frame");
1156 var ids
= new Array();
1158 var e
= ctr
.firstChild
;
1161 if (e
.className
&& e
.hasClassName("Unread") && e
.id
&&
1162 e
.id
.match("RROW-")) {
1164 // article fits in viewport OR article is longer than viewport and
1165 // its bottom is visible
1167 if (ctr
.scrollTop
<= e
.offsetTop
&& e
.offsetTop
+ e
.offsetHeight
<=
1168 ctr
.scrollTop
+ ctr
.offsetHeight
) {
1170 // console.log(e.id + " is visible " + e.offsetTop + "." +
1171 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
1172 // (ctr.scrollTop + ctr.offsetHeight));
1174 ids
.push(e
.id
.replace("RROW-", ""));
1176 } else if (e
.offsetHeight
> ctr
.offsetHeight
&&
1177 e
.offsetTop
+ e
.offsetHeight
>= ctr
.scrollTop
&&
1178 e
.offsetTop
+ e
.offsetHeight
<= ctr
.scrollTop
+ ctr
.offsetHeight
) {
1180 ids
.push(e
.id
.replace("RROW-", ""));
1184 // method 2: article bottom is visible and is in upper 1/2 of the viewport
1186 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
1187 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
1189 ids.push(e.id.replace("RROW-", ""));
1198 console
.log("cdmWatchdog, ids= " + ids
.toString());
1200 if (ids
.length
> 0) {
1202 for (var i
= 0; i
< ids
.length
; i
++) {
1203 var e
= $("RROW-" + ids
[i
]);
1205 e
.removeClassName("Unread");
1209 var query
= "?op=rpc&subop=catchupSelected" +
1210 "&cmode=0" + "&ids=" + param_escape(ids
.toString());
1212 new Ajax
.Request("backend.php", {
1214 onComplete: function(transport
) {
1215 handle_rpc_json(transport
);
1220 _cdm_wd_timeout
= window
.setTimeout("cdmWatchdog()", 4000);
1223 exception_error("cdmWatchdog", e
);
1229 function cache_inject(id
, article
, param
) {
1232 if (!cache_check_param(id
, param
)) {
1233 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1235 var date
= new Date();
1236 var ts
= Math
.round(date
.getTime() / 1000);
1240 cache_obj
["id"] = id
;
1241 cache_obj
["data"] = article
;
1242 cache_obj
["param"] = param
;
1244 if (param
) id
= id
+ ":" + param
;
1246 cache_added
["TS:" + id
] = ts
;
1248 if (has_local_storage())
1249 sessionStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1251 article_cache
.push(cache_obj
);
1254 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1257 exception_error("cache_inject", e
);
1261 function cache_find(id
) {
1263 if (has_local_storage()) {
1264 var cache_obj
= sessionStorage
.getItem(id
);
1267 cache_obj
= JSON
.parse(cache_obj
);
1270 return cache_obj
['data'];
1274 for (var i
= 0; i
< article_cache
.length
; i
++) {
1275 if (article_cache
[i
]["id"] == id
) {
1276 return article_cache
[i
]["data"];
1283 function cache_find_param(id
, param
) {
1285 if (has_local_storage()) {
1287 if (param
) id
= id
+ ":" + param
;
1289 var cache_obj
= sessionStorage
.getItem(id
);
1292 cache_obj
= JSON
.parse(cache_obj
);
1295 return cache_obj
['data'];
1299 for (var i
= 0; i
< article_cache
.length
; i
++) {
1300 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1301 return article_cache
[i
]["data"];
1309 function cache_check(id
) {
1310 if (has_local_storage()) {
1311 if (sessionStorage
.getItem(id
))
1314 for (var i
= 0; i
< article_cache
.length
; i
++) {
1315 if (article_cache
[i
]["id"] == id
) {
1323 function cache_check_param(id
, param
) {
1324 if (has_local_storage()) {
1326 if (param
) id
= id
+ ":" + param
;
1328 if (sessionStorage
.getItem(id
))
1332 for (var i
= 0; i
< article_cache
.length
; i
++) {
1333 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1341 function cache_expire() {
1342 if (has_local_storage()) {
1344 var date
= new Date();
1345 var timestamp
= Math
.round(date
.getTime() / 1000);
1347 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1349 var id
= sessionStorage
.key(i
);
1351 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1352 sessionStorage
.removeItem(id
);
1357 while (article_cache
.length
> 25) {
1358 article_cache
.shift();
1363 function cache_flush() {
1364 if (has_local_storage()) {
1365 sessionStorage
.clear();
1367 article_cache
= new Array();
1371 function cache_invalidate(id
) {
1373 if (has_local_storage()) {
1377 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1378 var key
= sessionStorage
.key(i
);
1380 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1382 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1383 sessionStorage
.removeItem(key
);
1394 while (i
< article_cache
.length
) {
1395 if (article_cache
[i
]["id"] == id
) {
1396 //console.log("cache_invalidate: removed id " + id);
1397 article_cache
.splice(i
, 1);
1404 //console.log("cache_invalidate: id not found: " + id);
1407 exception_error("cache_invalidate", e
);
1411 function getActiveArticleId() {
1412 return active_post_id
;
1415 function preloadBatchedArticles() {
1418 var query
= "?op=rpc&subop=getArticles&ids=" +
1419 preload_id_batch
.toString();
1421 new Ajax
.Request("backend.php", {
1423 onComplete: function(transport
) {
1425 preload_id_batch
= [];
1427 var articles
= transport
.responseXML
.getElementsByTagName("article");
1429 for (var i
= 0; i
< articles
.length
; i
++) {
1430 var id
= articles
[i
].getAttribute("id");
1431 if (!cache_check(id
)) {
1432 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1433 console
.log("preloaded article: " + id
);
1439 exception_error("preloadBatchedArticles", e
);
1443 function preloadArticleUnderPointer(id
) {
1445 if (getInitParam("bw_limit") == "1") return;
1447 if (post_under_pointer
== id
&& !cache_check(id
)) {
1449 console
.log("trying to preload article " + id
);
1451 var neighbor_ids
= getRelativePostIds(id
, 1);
1453 /* only request uncached articles */
1455 if (preload_id_batch
.indexOf(id
) == -1) {
1456 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1457 if (!cache_check(neighbor_ids
[i
])) {
1458 preload_id_batch
.push(neighbor_ids
[i
]);
1463 if (preload_id_batch
.indexOf(id
) == -1)
1464 preload_id_batch
.push(id
);
1466 //console.log("preload ids batch: " + preload_id_batch.toString());
1468 window
.clearTimeout(preload_timeout_id
);
1469 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1473 exception_error("preloadArticleUnderPointer", e
);
1477 function postMouseIn(id
) {
1479 if (post_under_pointer
!= id
) {
1480 post_under_pointer
= id
;
1482 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1487 exception_error("postMouseIn", e
);
1491 function postMouseOut(id
) {
1493 post_under_pointer
= false;
1495 exception_error("postMouseOut", e
);
1499 function headlines_scroll_handler(e
) {
1502 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1503 if (!_infscroll_disable
) {
1509 exception_error("headlines_scroll_handler", e
);
1513 function catchupRelativeToArticle(below
) {
1518 if (!getActiveArticleId()) {
1519 alert(__("No article is selected."));
1523 var visible_ids
= getVisibleArticleIds();
1525 var ids_to_mark
= new Array();
1528 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1529 if (visible_ids
[i
] != getActiveArticleId()) {
1530 var e
= $("RROW-" + visible_ids
[i
]);
1532 if (e
&& e
.hasClassName("Unread")) {
1533 ids_to_mark
.push(visible_ids
[i
]);
1540 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1541 if (visible_ids
[i
] != getActiveArticleId()) {
1542 var e
= $("RROW-" + visible_ids
[i
]);
1544 if (e
&& e
.hasClassName("Unread")) {
1545 ids_to_mark
.push(visible_ids
[i
]);
1553 if (ids_to_mark
.length
== 0) {
1554 alert(__("No articles found to mark"));
1556 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1558 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1560 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1561 var e
= $("RROW-" + ids_to_mark
[i
]);
1562 e
.removeClassName("Unread");
1565 var query
= "?op=rpc&subop=catchupSelected" +
1566 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1568 new Ajax
.Request("backend.php", {
1570 onComplete: function(transport
) {
1571 handle_rpc_json(transport
);
1578 exception_error("catchupRelativeToArticle", e
);
1582 function cdmExpandArticle(id
) {
1587 var elem
= $("CICD-" + active_post_id
);
1589 var upd_img_pic
= $("FUPDPIC-" + id
);
1591 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1592 upd_img_pic
.src
.match("fresh_sign.png"))) {
1594 upd_img_pic
.src
= "images/blank_icon.gif";
1597 if (id
== active_post_id
&& Element
.visible(elem
))
1600 selectArticles("none");
1602 var old_offset
= $("RROW-" + id
).offsetTop
;
1604 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1606 Element
.show("CEXC-" + active_post_id
);
1609 active_post_id
= id
;
1611 elem
= $("CICD-" + id
);
1613 if (!Element
.visible(elem
)) {
1615 Element
.hide("CEXC-" + id
);
1617 if ($("CWRAP-" + id
).innerHTML
== "") {
1619 $("FUPDPIC-" + id
).src
= "images/indicator_tiny.gif";
1621 $("CWRAP-" + id
).innerHTML
= "<div class=\"insensitive\">" +
1622 __("Loading, please wait...") + "</div>";
1624 var query
= "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id
);
1626 //console.log(query);
1628 new Ajax
.Request("backend.php", {
1630 onComplete: function(transport
) {
1631 $("FUPDPIC-" + id
).src
= 'images/blank_icon.gif';
1633 handle_rpc_json(transport
);
1635 var reply
= JSON
.parse(transport
.responseText
);
1638 var article
= reply
['article']['content'];
1639 var recv_id
= reply
['article']['id'];
1642 $("CWRAP-" + id
).innerHTML
= article
;
1645 $("CWRAP-" + id
).innerHTML
= __("Unable to load article.");
1653 var new_offset
= $("RROW-" + id
).offsetTop
;
1655 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1657 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1658 $("headlines-frame").scrollTop
= new_offset
;
1660 toggleUnread(id
, 0, true);
1664 exception_error("cdmExpandArticle", e
);
1670 function fixHeadlinesOrder(ids
) {
1672 for (var i
= 0; i
< ids
.length
; i
++) {
1673 var e
= $("RROW-" + ids
[i
]);
1677 e
.removeClassName("even");
1678 e
.addClassName("odd");
1680 e
.removeClassName("odd");
1681 e
.addClassName("even");
1686 exception_error("fixHeadlinesOrder", e
);
1690 function getArticleUnderPointer() {
1691 return post_under_pointer
;
1694 function zoomToArticle(event
, id
) {
1696 var cached_article
= cache_find(id
);
1698 if (dijit
.byId("ATAB-" + id
))
1699 if (!event
|| !event
.shiftKey
)
1700 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1702 if (cached_article
) {
1703 //closeArticlePanel();
1705 var article_pane
= new dijit
.layout
.ContentPane({
1706 title
: __("Loading...") , content
: cached_article
,
1707 style
: 'padding : 0px;',
1711 dijit
.byId("content-tabs").addChild(article_pane
);
1713 if (!event
|| !event
.shiftKey
)
1714 dijit
.byId("content-tabs").selectChild(article_pane
);
1716 if ($("PTITLE-" + id
))
1717 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1721 var query
= "?op=rpc&subop=getArticles&ids=" + param_escape(id
);
1723 notify_progress("Loading, please wait...", true);
1725 new Ajax
.Request("backend.php", {
1727 onComplete: function(transport
) {
1730 if (transport
.responseXML
) {
1731 //closeArticlePanel();
1733 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1734 var content
= article
.firstChild
.nodeValue
;
1736 var article_pane
= new dijit
.layout
.ContentPane({
1737 title
: "article-" + id
, content
: content
,
1738 style
: 'padding : 0px;',
1742 dijit
.byId("content-tabs").addChild(article_pane
);
1744 if (!event
|| !event
.shiftKey
)
1745 dijit
.byId("content-tabs").selectChild(article_pane
);
1747 if ($("PTITLE-" + id
))
1748 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1755 exception_error("zoomToArticle", e
);
1759 function scrollArticle(offset
) {
1762 var ci
= $("content-insert");
1764 ci
.scrollTop
+= offset
;
1767 var hi
= $("headlines-frame");
1769 hi
.scrollTop
+= offset
;
1774 exception_error("scrollArticle", e
);
1778 function show_labels_in_headlines(transport
) {
1780 var data
= JSON
.parse(transport
.responseText
);
1783 data
['info-for-headlines'].each(function(elem
) {
1784 var ctr
= $("HLLCTR-" + elem
.id
);
1786 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1790 exception_error("show_labels_in_headlines", e
);
1794 function toggleHeadlineActions() {
1796 var e
= $("headlineActionsBody");
1797 var p
= $("headlineActionsDrop");
1799 if (!Element
.visible(e
)) {
1806 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
1807 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
1810 exception_error("toggleHeadlineActions", e
);
1814 /* function publishWithNote(id, def_note) {
1816 if (!def_note) def_note = '';
1818 var note = prompt(__("Please enter a note for this article:"), def_note);
1820 if (note != undefined) {
1821 togglePub(id, false, false, note);
1825 exception_error("publishWithNote", e);
1829 function emailArticle(id
) {
1832 var ids
= getSelectedArticleIds2();
1834 if (ids
.length
== 0) {
1835 alert(__("No articles are selected."));
1839 id
= ids
.toString();
1842 if (dijit
.byId("emailArticleDlg"))
1843 dijit
.byId("emailArticleDlg").destroyRecursive();
1845 var query
= "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id
);
1847 dialog
= new dijit
.Dialog({
1848 id
: "emailArticleDlg",
1849 title
: __("Forward article by email"),
1850 style
: "width: 600px",
1851 execute: function() {
1852 if (this.validate()) {
1854 new Ajax
.Request("backend.php", {
1855 parameters
: dojo
.objectToQuery(this.attr('value')),
1856 onComplete: function(transport
) {
1858 var reply
= JSON
.parse(transport
.responseText
);
1860 var error
= reply
['error'];
1863 alert(__('Error sending email:') + ' ' + error
);
1865 notify_info('Your message has been sent.');
1874 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1875 dojo
.disconnect(tmph
);
1877 new Ajax
.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
1878 "backend.php?op=rpc&subop=completeEmails",
1879 { tokens
: '', paramName
: "search" });
1884 /* displayDlg('emailArticle', id,
1886 document.forms['article_email_form'].destination.focus();
1888 new Ajax.Autocompleter('destination', 'destination_choices',
1889 "backend.php?op=rpc&subop=completeEmails",
1890 { tokens: '', paramName: "search" });
1895 exception_error("emailArticle", e
);
1899 function dismissArticle(id
) {
1901 var elem
= $("RROW-" + id
);
1903 toggleUnread(id
, 0, true);
1905 new Effect
.Fade(elem
, {duration
: 0.5});
1907 active_post_id
= false;
1910 exception_error("dismissArticle", e
);
1914 function dismissSelectedArticles() {
1917 var ids
= getVisibleArticleIds();
1921 for (var i
= 0; i
< ids
.length
; i
++) {
1922 var elem
= $("RROW-" + ids
[i
]);
1924 if (elem
.className
&& elem
.hasClassName("Selected") &&
1925 ids
[i
] != active_post_id
) {
1926 new Effect
.Fade(elem
, {duration
: 0.5});
1934 selectionToggleUnread(false);
1936 fixHeadlinesOrder(tmp
);
1939 exception_error("dismissSelectedArticles", e
);
1943 function dismissReadArticles() {
1946 var ids
= getVisibleArticleIds();
1949 for (var i
= 0; i
< ids
.length
; i
++) {
1950 var elem
= $("RROW-" + ids
[i
]);
1952 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1953 !elem
.hasClassName("Selected")) {
1955 new Effect
.Fade(elem
, {duration
: 0.5});
1961 fixHeadlinesOrder(tmp
);
1964 exception_error("dismissSelectedArticles", e
);
1968 function getVisibleArticleIds() {
1973 getLoadedArticleIds().each(function(id
) {
1974 var elem
= $("RROW-" + id
);
1975 if (elem
&& Element
.visible(elem
))
1980 exception_error("getVisibleArticleIds", e
);
1986 function cdmClicked(event
, id
) {
1988 var shift_key
= event
.shiftKey
;
1992 if (!event
.ctrlKey
) {
1994 if (!getInitParam("cdm_expanded")) {
1995 return cdmExpandArticle(id
);
1998 selectArticles("none");
2001 var elem
= $("RROW-" + id
);
2004 elem
.removeClassName("Unread");
2006 var upd_img_pic
= $("FUPDPIC-" + id
);
2008 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
2009 upd_img_pic
.src
.match("fresh_sign.png"))) {
2011 upd_img_pic
.src
= "images/blank_icon.gif";
2014 active_post_id
= id
;
2016 var query
= "?op=rpc&subop=catchupSelected" +
2017 "&cmode=0&ids=" + param_escape(id
);
2019 new Ajax
.Request("backend.php", {
2021 onComplete: function(transport
) {
2022 handle_rpc_json(transport
);
2029 toggleSelected(id
, true);
2030 toggleUnread(id
, 0, false);
2031 zoomToArticle(event
, id
);
2035 exception_error("cdmClicked");
2041 function postClicked(event
, id
) {
2044 if (!event
.ctrlKey
) {
2047 postOpenInNewTab(event
, id
);
2052 exception_error("postClicked");
2056 function hlOpenInNewTab(event
, id
) {
2057 toggleUnread(id
, 0, false);
2058 zoomToArticle(event
, id
);
2061 function postOpenInNewTab(event
, id
) {
2062 closeArticlePanel(id
);
2063 zoomToArticle(event
, id
);
2066 function hlClicked(event
, id
) {
2069 openArticleInNewWindow(id
);
2070 } else if (!event
.ctrlKey
) {
2075 toggleUnread(id
, 0, false);
2076 zoomToArticle(event
, id
);
2081 exception_error("hlClicked");
2085 function getFirstVisibleHeadlineId() {
2086 var rows
= getVisibleArticleIds();
2091 function getLastVisibleHeadlineId() {
2092 var rows
= getVisibleArticleIds();
2093 return rows
[rows
.length
-1];
2096 function openArticleInNewWindow(id
) {
2097 toggleUnread(id
, 0, false);
2098 window
.open("backend.php?op=la&id=" + id
);
2101 function isCdmMode() {
2102 return getInitParam("combined_display_mode");
2105 function markHeadline(id
) {
2106 var row
= $("RROW-" + id
);
2108 var check
= $("RCHK-" + id
);
2111 check
.checked
= true;
2114 row
.addClassName("Selected");
2118 function getRelativePostIds(id
, limit
) {
2124 if (!limit
) limit
= 3;
2126 var ids
= getVisibleArticleIds();
2128 for (var i
= 0; i
< ids
.length
; i
++) {
2130 for (var k
= 1; k
<= limit
; k
++) {
2131 if (i
> k
-1) tmp
.push(ids
[i
-k
]);
2132 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
2139 exception_error("getRelativePostIds", e
);
2145 function correctHeadlinesOffset(id
) {
2149 var container
= $("headlines-frame");
2150 var row
= $("RROW-" + id
);
2152 var viewport
= container
.offsetHeight
;
2154 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
2155 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
2157 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
2158 //console.log("Vport: " + viewport);
2160 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
2161 container
.scrollTop
= row
.offsetTop
;
2162 } else if (rel_offset_bottom
> viewport
) {
2164 /* doesn't properly work with Opera in some cases because
2165 Opera fucks up element scrolling */
2167 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
2171 exception_error("correctHeadlinesOffset", e
);
2176 function headlineActionsChange(elem
) {
2179 elem
.attr('value', 'false');
2181 exception_error("headlineActionsChange", e
);
2185 function closeArticlePanel() {
2187 var tabs
= dijit
.byId("content-tabs");
2188 var child
= tabs
.selectedChildWidget
;
2190 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
2191 tabs
.removeChild(child
);
2194 if (dijit
.byId("content-insert"))
2195 dijit
.byId("headlines-wrap-inner").removeChild(
2196 dijit
.byId("content-insert"));
2200 function initHeadlinesMenu() {
2202 if (dijit
.byId("headlinesMenu"))
2203 dijit
.byId("headlinesMenu").destroyRecursive();
2208 nodes
= $$("#headlines-frame > div[id*=RROW]");
2210 nodes
= $$("#headlines-frame span[id*=RTITLE]");
2213 nodes
.each(function(node
) {
2217 var menu
= new dijit
.Menu({
2218 id
: "headlinesMenu",
2222 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
2223 var callerNode
= event
.target
, match
= null, tries
= 0;
2225 while (match
== null && callerNode
&& tries
<= 3) {
2226 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
2227 callerNode
= callerNode
.parentNode
;
2231 if (match
) this.callerRowId
= parseInt(match
[1]);
2236 menu
.addChild(new dijit
.MenuItem({
2237 label
: __("View article"),
2238 onClick: function(event
) {
2239 view(this.getParent().callerRowId
);
2242 menu
.addChild(new dijit
.MenuItem({
2243 label
: __("View in a new tab"),
2244 onClick: function(event
) {
2245 hlOpenInNewTab(event
, this.getParent().callerRowId
);
2248 menu
.addChild(new dijit
.MenuSeparator());
2250 menu
.addChild(new dijit
.MenuItem({
2251 label
: __("Open original article"),
2252 onClick: function(event
) {
2253 openArticleInNewWindow(this.getParent().callerRowId
);
2256 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2260 menu
.addChild(new dijit
.MenuSeparator());
2262 var labelsMenu
= new dijit
.Menu({ownerMenu
: menu
});
2264 labels
.each(function(label
) {
2265 var id
= label
.id
[0];
2266 var bare_id
= id
.substr(id
.indexOf(":")+1);
2267 var name
= label
.name
[0];
2269 bare_id
= -11-bare_id
;
2271 labelsMenu
.addChild(new dijit
.MenuItem({
2274 onClick: function(event
) {
2275 //console.log(this.labelId);
2276 //console.log(this.getParent().ownerMenu.callerRowId);
2277 selectionAssignLabel(this.labelId
,
2278 [this.getParent().ownerMenu
.callerRowId
]);
2282 menu
.addChild(new dijit
.PopupMenuItem({
2283 label
: __("Labels"),
2291 exception_error("initHeadlinesMenu", e
);
2295 function tweetArticle(id
) {
2297 var query
= "?op=rpc&subop=getTweetInfo&id=" + param_escape(id
);
2302 var ts
= d
.getTime();
2304 var w
= window
.open('backend.php?op=loading', 'ttrss_tweet',
2305 "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
2307 new Ajax
.Request("backend.php", {
2309 onComplete: function(transport
) {
2310 var ti
= JSON
.parse(transport
.responseText
);
2312 var share_url
= "http://twitter.com/share?_=" + ts
+
2313 "&text=" + param_escape(ti
.title
) +
2314 "&url=" + param_escape(ti
.link
);
2316 w
.location
.href
= share_url
;
2322 exception_error("tweetArticle", e
);
2326 function editArticleNote(id
) {
2329 var query
= "backend.php?op=dlg&id=editArticleNote¶m=" + param_escape(id
);
2331 if (dijit
.byId("editNoteDlg"))
2332 dijit
.byId("editNoteDlg").destroyRecursive();
2334 dialog
= new dijit
.Dialog({
2336 title
: __("Edit article note"),
2337 style
: "width: 600px",
2338 execute: function() {
2339 if (this.validate()) {
2340 var query
= dojo
.objectToQuery(this.attr('value'));
2342 notify_progress("Saving article note...", true);
2344 new Ajax
.Request("backend.php", {
2346 onComplete: function(transport
) {
2350 var reply
= JSON
.parse(transport
.responseText
);
2352 cache_invalidate(id
);
2354 var elem
= $("POSTNOTE-" + id
);
2358 elem
.innerHTML
= reply
.note
;
2359 new Effect
.Appear(elem
);
2371 exception_error("editArticleNote", e
);
2375 function player(elem
) {
2376 var aid
= elem
.getAttribute("audio-id");
2377 var status
= elem
.getAttribute("status");
2385 elem
.innerHTML
= __("Playing...");
2386 elem
.title
= __("Click to pause");
2387 elem
.addClassName("playing");
2391 elem
.innerHTML
= __("Play");
2392 elem
.title
= __("Click to play");
2393 elem
.removeClassName("playing");
2396 elem
.setAttribute("status", status
);
2398 alert("Your browser doesn't seem to support HTML5 audio.");