]>
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 article_cache
= new Array();
7 var vgroup_last_feed
= false;
8 var post_under_pointer
= false;
10 var last_requested_article
= false;
12 var preload_id_batch
= [];
13 var preload_timeout_id
= false;
17 function headlines_callback2(transport
, feed_cur_page
) {
20 if (!handle_rpc_reply(transport
)) return;
22 loading_set_progress(25);
24 console
.log("headlines_callback2 [page=" + feed_cur_page
+ "]");
26 if (!transport_error_check(transport
)) return;
31 if (transport
.responseXML
) {
32 var headlines
= transport
.responseXML
.getElementsByTagName("headlines")[0];
34 is_cat
= headlines
.getAttribute("is_cat");
35 feed_id
= headlines
.getAttribute("id");
36 setActiveFeedId(feed_id
, is_cat
);
40 var update_btn
= document
.forms
["main_toolbar_form"].update
;
42 update_btn
.disabled
= !(feed_id
>= 0 && !is_cat
);
45 if (feed_cur_page
== 0) {
46 $("headlines-frame").scrollTop
= 0;
50 if (transport
.responseXML
) {
51 var response
= transport
.responseXML
;
53 var headlines
= response
.getElementsByTagName("headlines")[0];
55 var headlines_content
= headlines
.getElementsByTagName("content")[0];
56 var headlines_toolbar
= headlines
.getElementsByTagName("toolbar")[0];
58 var headlines_info
= response
.getElementsByTagName("headlines-info")[0];
61 headlines_info
= JSON
.parse(headlines_info
.firstChild
.nodeValue
);
63 console
.error("didn't find headlines-info object in response");
67 var headlines_count
= headlines_info
.count
;
68 var headlines_unread
= headlines_info
.unread
;
69 var disable_cache
= headlines_info
.disable_cache
;
71 vgroup_last_feed
= headlines_info
.vgroup_last_feed
;
73 if (parseInt(headlines_count
) < getInitParam("default_article_limit")) {
74 _infscroll_disable
= 1;
76 _infscroll_disable
= 0;
79 var counters
= response
.getElementsByTagName("counters")[0];
80 var articles
= response
.getElementsByTagName("article");
81 var runtime_info
= response
.getElementsByTagName("runtime-info");
83 if (feed_cur_page
== 0) {
85 dijit
.byId("headlines-frame").attr('content',
86 headlines_content
.firstChild
.nodeValue
);
88 dijit
.byId("headlines-toolbar").attr('content',
89 headlines_toolbar
.firstChild
.nodeValue
);
93 /* var cache_prefix = "";
101 cache_invalidate(cache_prefix + feed_id);
103 if (!disable_cache) {
104 cache_inject(cache_prefix + feed_id,
105 $("headlines-frame").innerHTML, headlines_unread);
109 console
.warn("headlines_callback: returned no data");
110 dijit
.byId("headlines-frame").attr('content',
111 "<div class='whiteBox'>" +
112 __('Could not update headlines (missing XML data)') + "</div>");
117 if (headlines_count
> 0) {
118 console
.log("adding some more headlines...");
120 var c
= dijit
.byId("headlines-frame");
121 var ids
= getSelectedArticleIds2();
123 //c.attr('content', c.attr('content') +
124 // headlines_content.firstChild.nodeValue);
126 $("headlines-tmp").innerHTML
= headlines_content
.firstChild
.nodeValue
;
128 $$("#headlines-tmp > div").each(function(row
) {
129 c
.domNode
.appendChild(row
);
132 console
.log("restore selected ids: " + ids
);
134 for (var i
= 0; i
< ids
.length
; i
++) {
135 markHeadline(ids
[i
]);
141 console
.log("no new headlines received");
144 console
.warn("headlines_callback: returned no data");
145 notify_error("Error while trying to load more headlines");
151 for (var i
= 0; i
< articles
.length
; i
++) {
152 var a_id
= articles
[i
].getAttribute("id");
153 //console.log("found id: " + a_id);
154 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
157 console
.log("no cached articles received");
161 parse_counters(counters
);
166 console
.warn("headlines_callback: returned no XML object");
167 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
168 __('Could not update headlines (missing XML object)') + "</div>");
173 _feed_cur_page
= feed_cur_page
;
174 _infscroll_request_sent
= 0;
179 exception_error("headlines_callback2", e
, transport
);
183 function render_article(article
) {
185 dijit
.byId("headlines-wrap-inner").addChild(
186 dijit
.byId("content-insert"));
188 var c
= dijit
.byId("content-insert");
191 c
.domNode
.scrollTop
= 0;
194 c
.attr('content', article
);
196 correctHeadlinesOffset(getActiveArticleId());
203 exception_error("render_article", e
);
207 function showArticleInHeadlines(id
) {
211 selectArticles("none");
213 var crow
= $("RROW-" + id
);
217 var article_is_unread
= crow
.hasClassName("Unread");
219 crow
.removeClassName("Unread");
221 selectArticles('none');
223 var upd_img_pic
= $("FUPDPIC-" + id
);
225 var cache_prefix
= "";
227 if (activeFeedIsCat()) {
233 var view_mode
= false;
236 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
237 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
242 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
243 upd_img_pic
.src
.match("fresh_sign.png"))) {
245 upd_img_pic
.src
= "images/blank_icon.gif";
247 cache_invalidate(cache_prefix
+ getActiveFeedId());
249 /* cache_inject(cache_prefix + getActiveFeedId(),
250 $("headlines-frame").innerHTML,
251 getFeedUnread(getActiveFeedId())); */
253 } else if (article_is_unread
&& view_mode
== "all_articles") {
255 cache_invalidate(cache_prefix
+ getActiveFeedId());
257 /* cache_inject(cache_prefix + getActiveFeedId(),
258 $("headlines-frame").innerHTML,
259 getFeedUnread(getActiveFeedId())-1); */
261 } else if (article_is_unread
) {
262 cache_invalidate(cache_prefix
+ getActiveFeedId());
267 if (article_is_unread
)
268 _force_scheduled_update
= true;
271 exception_error("showArticleInHeadlines", e
);
275 function article_callback2(transport
, id
) {
277 console
.log("article_callback2 " + id
);
279 if (!handle_rpc_reply(transport
)) return;
281 if (transport
.responseXML
) {
283 if (!transport_error_check(transport
)) return;
285 var upic
= $('FUPDPIC-' + id
);
288 upic
.src
= 'images/blank_icon.gif';
291 if (id
!= last_requested_article
) {
292 console
.log("requested article id is out of sequence, aborting");
296 // active_post_id = id;
298 //console.log("looking for articles to cache...");
300 var articles
= transport
.responseXML
.getElementsByTagName("article");
302 for (var i
= 0; i
< articles
.length
; i
++) {
303 var a_id
= articles
[i
].getAttribute("id");
305 //console.log("found id: " + a_id);
307 if (a_id
== active_post_id
) {
308 //console.log("active article, rendering...");
309 render_article(articles
[i
].firstChild
.nodeValue
);
312 cache_inject(a_id
, articles
[i
].firstChild
.nodeValue
);
316 // showArticleInHeadlines(id);
318 var reply
= transport
.responseXML
.firstChild
.firstChild
;
321 console
.warn("article_callback: returned no XML object");
322 //var f = $("content-frame");
323 //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
326 var date
= new Date();
327 last_article_view
= date
.getTime() / 1000;
333 exception_error("article_callback2", e
, transport
);
339 console
.log("loading article: " + id
);
341 var cached_article
= cache_find(id
);
343 console
.log("cache check result: " + (cached_article
!= false));
347 var query
= "?op=view&id=" + param_escape(id
);
349 var neighbor_ids
= getRelativePostIds(active_post_id
);
351 /* only request uncached articles */
353 var cids_to_request
= Array();
355 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
356 if (!cache_check(neighbor_ids
[i
])) {
357 cids_to_request
.push(neighbor_ids
[i
]);
361 console
.log("additional ids: " + cids_to_request
.toString());
363 query
= query
+ "&cids=" + cids_to_request
.toString();
365 var crow
= $("RROW-" + id
);
366 var article_is_unread
= crow
.hasClassName("Unread");
369 showArticleInHeadlines(id
);
371 if (!cached_article
) {
373 var upic
= $('FUPDPIC-' + id
);
376 upic
.src
= getInitParam("sign_progress");
379 } else if (cached_article
&& article_is_unread
) {
381 query
= query
+ "&mode=prefetch";
383 render_article(cached_article
);
385 } else if (cached_article
) {
387 query
= query
+ "&mode=prefetch_old";
388 render_article(cached_article
);
394 last_requested_article
= id
;
396 new Ajax
.Request("backend.php", {
398 onComplete: function(transport
) {
399 article_callback2(transport
, id
);
405 exception_error("view", e
);
410 return toggleMark(id
);
414 return togglePub(id
);
417 function toggleMark(id
, client_only
) {
419 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
421 var img
= $("FMPIC-" + id
);
425 if (img
.src
.match("mark_unset")) {
426 img
.src
= img
.src
.replace("mark_unset", "mark_set");
427 img
.alt
= __("Unstar article");
428 query
= query
+ "&mark=1";
431 img
.src
= img
.src
.replace("mark_set", "mark_unset");
432 img
.alt
= __("Star article");
433 query
= query
+ "&mark=0";
437 new Ajax
.Request("backend.php", {
439 onComplete: function(transport
) {
440 handle_rpc_json(transport
);
445 exception_error("toggleMark", e
);
449 function togglePub(id
, client_only
, no_effects
, note
) {
451 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
453 if (note
!= undefined) {
454 query
= query
+ "¬e=" + param_escape(note
);
456 query
= query
+ "¬e=undefined";
459 var img
= $("FPPIC-" + id
);
463 if (img
.src
.match("pub_unset") || note
!= undefined) {
464 img
.src
= img
.src
.replace("pub_unset", "pub_set");
465 img
.alt
= __("Unpublish article");
466 query
= query
+ "&pub=1";
469 img
.src
= img
.src
.replace("pub_set", "pub_unset");
470 img
.alt
= __("Publish article");
472 query
= query
+ "&pub=0";
476 new Ajax
.Request("backend.php", {
478 onComplete: function(transport
) {
479 handle_rpc_json(transport
);
483 /* if (!client_only) {
484 new Ajax.Request("backend.php", {
486 onComplete: function(transport) {
487 handle_rpc_reply(transport);
489 var note = transport.responseXML.getElementsByTagName("note")[0];
492 var note_id = note.getAttribute("id");
493 var note_size = note.getAttribute("size");
494 var note_content = note.firstChild.nodeValue;
496 var container = $('POSTNOTE-' + note_id);
498 cache_invalidate(note_id);
501 if (note_size == "0") {
502 Element.hide(container);
504 container.innerHTML = note_content;
505 Element.show(container);
514 exception_error("togglePub", e
);
518 function moveToPost(mode
) {
522 var rows
= getVisibleArticleIds();
527 if (!$('RROW-' + active_post_id
)) {
528 active_post_id
= false;
531 if (active_post_id
== false) {
532 next_id
= getFirstVisibleHeadlineId();
533 prev_id
= getLastVisibleHeadlineId();
535 for (var i
= 0; i
< rows
.length
; i
++) {
536 if (rows
[i
] == active_post_id
) {
543 if (mode
== "next") {
547 cdmExpandArticle(next_id
);
548 cdmScrollToArticleId(next_id
);
551 correctHeadlinesOffset(next_id
);
552 view(next_id
, getActiveFeedId());
557 if (mode
== "prev") {
560 cdmExpandArticle(prev_id
);
561 cdmScrollToArticleId(prev_id
);
563 correctHeadlinesOffset(prev_id
);
564 view(prev_id
, getActiveFeedId());
570 exception_error("moveToPost", e
);
574 function toggleSelected(id
, force_on
) {
577 var cb
= $("RCHK-" + id
);
578 var row
= $("RROW-" + id
);
581 if (row
.hasClassName('Selected') && !force_on
) {
582 row
.removeClassName('Selected');
583 if (cb
) cb
.checked
= false;
585 row
.addClassName('Selected');
586 if (cb
) cb
.checked
= true;
590 exception_error("toggleSelected", e
);
594 function toggleUnread_afh(effect
) {
597 var elem
= effect
.element
;
598 elem
.style
.backgroundColor
= "";
601 exception_error("toggleUnread_afh", e
);
605 function toggleUnread(id
, cmode
, effect
) {
608 var row
= $("RROW-" + id
);
610 if (cmode
== undefined || cmode
== 2) {
611 if (row
.hasClassName("Unread")) {
612 row
.removeClassName("Unread");
615 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
616 afterFinish
: toggleUnread_afh
,
617 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
621 row
.addClassName("Unread");
624 } else if (cmode
== 0) {
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 } } );
634 } else if (cmode
== 1) {
635 row
.addClassName("Unread");
638 if (cmode
== undefined) cmode
= 2;
640 var query
= "?op=rpc&subop=catchupSelected" +
641 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
643 // notify_progress("Loading, please wait...");
645 new Ajax
.Request("backend.php", {
647 onComplete: function(transport
) {
648 handle_rpc_json(transport
);
654 exception_error("toggleUnread", e
);
658 function selectionRemoveLabel(id
, ids
) {
661 if (!ids
) var ids
= getSelectedArticleIds2();
663 if (ids
.length
== 0) {
664 alert(__("No articles are selected."));
668 // var ok = confirm(__("Remove selected articles from label?"));
672 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
673 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
677 // notify_progress("Loading, please wait...");
679 cache_invalidate("F:" + (-11 - id
));
681 new Ajax
.Request("backend.php", {
683 onComplete: function(transport
) {
684 handle_rpc_json(transport
);
685 show_labels_in_headlines(transport
);
691 exception_error("selectionAssignLabel", e
);
696 function selectionAssignLabel(id
, ids
) {
699 if (!ids
) ids
= getSelectedArticleIds2();
701 if (ids
.length
== 0) {
702 alert(__("No articles are selected."));
706 // var ok = confirm(__("Assign selected articles to label?"));
710 cache_invalidate("F:" + (-11 - id
));
712 var query
= "?op=rpc&subop=assignToLabel&ids=" +
713 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
717 // notify_progress("Loading, please wait...");
719 new Ajax
.Request("backend.php", {
721 onComplete: function(transport
) {
722 handle_rpc_json(transport
);
723 show_labels_in_headlines(transport
);
729 exception_error("selectionAssignLabel", e
);
734 function selectionToggleUnread(set_state
, callback
, no_error
) {
736 var rows
= getSelectedArticleIds2();
738 if (rows
.length
== 0 && !no_error
) {
739 alert(__("No articles are selected."));
743 for (i
= 0; i
< rows
.length
; i
++) {
744 var row
= $("RROW-" + rows
[i
]);
746 if (set_state
== undefined) {
747 if (row
.hasClassName("Unread")) {
748 row
.removeClassName("Unread");
750 row
.addClassName("Unread");
754 if (set_state
== false) {
755 row
.removeClassName("Unread");
758 if (set_state
== true) {
759 row
.addClassName("Unread");
764 if (rows
.length
> 0) {
768 if (set_state
== undefined) {
770 } else if (set_state
== true) {
772 } else if (set_state
== false) {
776 var query
= "?op=rpc&subop=catchupSelected" +
777 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
779 notify_progress("Loading, please wait...");
781 new Ajax
.Request("backend.php", {
783 onComplete: function(transport
) {
784 handle_rpc_json(transport
);
785 if (callback
) callback(transport
);
791 exception_error("selectionToggleUnread", e
);
795 function selectionToggleMarked() {
798 var rows
= getSelectedArticleIds2();
800 if (rows
.length
== 0) {
801 alert(__("No articles are selected."));
805 for (i
= 0; i
< rows
.length
; i
++) {
806 toggleMark(rows
[i
], true, true);
809 if (rows
.length
> 0) {
811 var query
= "?op=rpc&subop=markSelected&ids=" +
812 param_escape(rows
.toString()) + "&cmode=2";
814 new Ajax
.Request("backend.php", {
816 onComplete: function(transport
) {
817 handle_rpc_json(transport
);
823 exception_error("selectionToggleMarked", e
);
827 function selectionTogglePublished() {
830 var rows
= getSelectedArticleIds2();
832 if (rows
.length
== 0) {
833 alert(__("No articles are selected."));
837 for (i
= 0; i
< rows
.length
; i
++) {
838 togglePub(rows
[i
], true, true);
841 if (rows
.length
> 0) {
843 var query
= "?op=rpc&subop=publishSelected&ids=" +
844 param_escape(rows
.toString()) + "&cmode=2";
846 new Ajax
.Request("backend.php", {
848 onComplete: function(transport
) {
849 handle_rpc_json(transport
);
855 exception_error("selectionToggleMarked", e
);
859 function getSelectedArticleIds2() {
863 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
865 rv
.push(child
.id
.replace("RROW-", ""));
871 function getLoadedArticleIds() {
874 var children
= $$("#headlines-frame > div[id*=RROW-]");
876 children
.each(function(child
) {
877 rv
.push(child
.id
.replace("RROW-", ""));
884 // mode = all,none,unread,invert
885 function selectArticles(mode
) {
888 var children
= $$("#headlines-frame > div[id*=RROW]");
890 children
.each(function(child
) {
891 var id
= child
.id
.replace("RROW-", "");
892 var cb
= $("RCHK-" + id
);
895 child
.addClassName("Selected");
897 } else if (mode
== "unread") {
898 if (child
.hasClassName("Unread")) {
899 child
.addClassName("Selected");
902 child
.removeClassName("Selected");
905 } else if (mode
== "invert") {
906 if (child
.hasClassName("Selected")) {
907 child
.removeClassName("Selected");
910 child
.addClassName("Selected");
915 child
.removeClassName("Selected");
921 exception_error("selectArticles", e
);
925 function catchupPage() {
927 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
929 var str
= __("Mark all visible articles in %s as read?");
931 str
= str
.replace("%s", fn
);
933 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
937 selectArticles('all');
938 selectionToggleUnread(false, 'viewCurrentFeed()', true)
939 selectArticles('none');
942 function deleteSelection() {
946 var rows
= getSelectedArticleIds2();
948 if (rows
.length
== 0) {
949 alert(__("No articles are selected."));
953 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
957 if (getActiveFeedId() != 0) {
958 str
= __("Delete %d selected articles in %s?");
960 str
= __("Delete %d selected articles?");
963 str
= str
.replace("%d", rows
.length
);
964 str
= str
.replace("%s", fn
);
966 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
970 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
974 new Ajax
.Request("backend.php", {
976 onComplete: function(transport
) {
977 handle_rpc_json(transport
);
982 exception_error("deleteSelection", e
);
986 function archiveSelection() {
990 var rows
= getSelectedArticleIds2();
992 if (rows
.length
== 0) {
993 alert(__("No articles are selected."));
997 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1001 if (getActiveFeedId() != 0) {
1002 str
= __("Archive %d selected articles in %s?");
1005 str
= __("Move %d archived articles back?");
1009 str
= str
.replace("%d", rows
.length
);
1010 str
= str
.replace("%s", fn
);
1012 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1016 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
1020 for (var i
= 0; i
< rows
.length
; i
++) {
1021 cache_invalidate(rows
[i
]);
1024 new Ajax
.Request("backend.php", {
1026 onComplete: function(transport
) {
1027 handle_rpc_json(transport
);
1032 exception_error("archiveSelection", e
);
1036 function catchupSelection() {
1040 var rows
= getSelectedArticleIds2();
1042 if (rows
.length
== 0) {
1043 alert(__("No articles are selected."));
1047 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1049 var str
= __("Mark %d selected articles in %s as read?");
1051 str
= str
.replace("%d", rows
.length
);
1052 str
= str
.replace("%s", fn
);
1054 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1058 selectionToggleUnread(false, 'viewCurrentFeed()', true)
1061 exception_error("catchupSelection", e
);
1065 function editArticleTags(id
) {
1066 var query
= "backend.php?op=dlg&id=editArticleTags¶m=" + param_escape(id
);
1068 if (dijit
.byId("editTagsDlg"))
1069 dijit
.byId("editTagsDlg").destroyRecursive();
1071 dialog
= new dijit
.Dialog({
1073 title
: __("Edit article Tags"),
1074 style
: "width: 600px",
1075 execute: function() {
1076 if (this.validate()) {
1077 var query
= dojo
.objectToQuery(this.attr('value'));
1079 notify_progress("Saving article tags...", true);
1081 new Ajax
.Request("backend.php", {
1083 onComplete: function(transport
) {
1087 var data
= JSON
.parse(transport
.responseText
);
1090 var tags_str
= data
.tags_str
;
1091 var id
= tags_str
.id
;
1093 var tags
= $("ATSTR-" + id
);
1096 tags
.innerHTML
= tags_str
.content
;
1099 cache_invalidate(id
);
1108 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1109 dojo
.disconnect(tmph
);
1111 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1112 "backend.php?op=rpc&subop=completeTags",
1113 { tokens
: ',', paramName
: "search" });
1120 function cdmScrollToArticleId(id
) {
1122 var ctr
= $("headlines-frame");
1123 var e
= $("RROW-" + id
);
1125 if (!e
|| !ctr
) return;
1127 ctr
.scrollTop
= e
.offsetTop
;
1130 exception_error("cdmScrollToArticleId", e
);
1134 function cache_inject(id
, article
, param
) {
1137 if (!cache_check_param(id
, param
)) {
1138 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1140 var date
= new Date();
1141 var ts
= Math
.round(date
.getTime() / 1000);
1145 cache_obj
["id"] = id
;
1146 cache_obj
["data"] = article
;
1147 cache_obj
["param"] = param
;
1149 if (param
) id
= id
+ ":" + param
;
1151 cache_added
["TS:" + id
] = ts
;
1153 if (has_local_storage())
1154 sessionStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1156 article_cache
.push(cache_obj
);
1159 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1162 exception_error("cache_inject", e
);
1166 function cache_find(id
) {
1168 if (has_local_storage()) {
1169 var cache_obj
= sessionStorage
.getItem(id
);
1172 cache_obj
= JSON
.parse(cache_obj
);
1175 return cache_obj
['data'];
1179 for (var i
= 0; i
< article_cache
.length
; i
++) {
1180 if (article_cache
[i
]["id"] == id
) {
1181 return article_cache
[i
]["data"];
1188 function cache_find_param(id
, param
) {
1190 if (has_local_storage()) {
1192 if (param
) id
= id
+ ":" + param
;
1194 var cache_obj
= sessionStorage
.getItem(id
);
1197 cache_obj
= JSON
.parse(cache_obj
);
1200 return cache_obj
['data'];
1204 for (var i
= 0; i
< article_cache
.length
; i
++) {
1205 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1206 return article_cache
[i
]["data"];
1214 function cache_check(id
) {
1215 if (has_local_storage()) {
1216 if (sessionStorage
.getItem(id
))
1219 for (var i
= 0; i
< article_cache
.length
; i
++) {
1220 if (article_cache
[i
]["id"] == id
) {
1228 function cache_check_param(id
, param
) {
1229 if (has_local_storage()) {
1231 if (param
) id
= id
+ ":" + param
;
1233 if (sessionStorage
.getItem(id
))
1237 for (var i
= 0; i
< article_cache
.length
; i
++) {
1238 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1246 function cache_expire() {
1247 if (has_local_storage()) {
1249 var date
= new Date();
1250 var timestamp
= Math
.round(date
.getTime() / 1000);
1252 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1254 var id
= sessionStorage
.key(i
);
1256 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1257 sessionStorage
.removeItem(id
);
1262 while (article_cache
.length
> 25) {
1263 article_cache
.shift();
1268 function cache_flush() {
1269 if (has_local_storage()) {
1270 sessionStorage
.clear();
1272 article_cache
= new Array();
1276 function cache_invalidate(id
) {
1278 if (has_local_storage()) {
1282 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1283 var key
= sessionStorage
.key(i
);
1285 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1287 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1288 sessionStorage
.removeItem(key
);
1299 while (i
< article_cache
.length
) {
1300 if (article_cache
[i
]["id"] == id
) {
1301 //console.log("cache_invalidate: removed id " + id);
1302 article_cache
.splice(i
, 1);
1309 //console.log("cache_invalidate: id not found: " + id);
1312 exception_error("cache_invalidate", e
);
1316 function getActiveArticleId() {
1317 return active_post_id
;
1320 function preloadBatchedArticles() {
1323 var query
= "?op=rpc&subop=getArticles&ids=" +
1324 preload_id_batch
.toString();
1326 new Ajax
.Request("backend.php", {
1328 onComplete: function(transport
) {
1330 preload_id_batch
= [];
1332 var articles
= transport
.responseXML
.getElementsByTagName("article");
1334 for (var i
= 0; i
< articles
.length
; i
++) {
1335 var id
= articles
[i
].getAttribute("id");
1336 if (!cache_check(id
)) {
1337 cache_inject(id
, articles
[i
].firstChild
.nodeValue
);
1338 console
.log("preloaded article: " + id
);
1344 exception_error("preloadBatchedArticles", e
);
1348 function preloadArticleUnderPointer(id
) {
1350 if (getInitParam("bw_limit") == "1") return;
1352 if (post_under_pointer
== id
&& !cache_check(id
)) {
1354 console
.log("trying to preload article " + id
);
1356 var neighbor_ids
= getRelativePostIds(id
, 1);
1358 /* only request uncached articles */
1360 if (preload_id_batch
.indexOf(id
) == -1) {
1361 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1362 if (!cache_check(neighbor_ids
[i
])) {
1363 preload_id_batch
.push(neighbor_ids
[i
]);
1368 if (preload_id_batch
.indexOf(id
) == -1)
1369 preload_id_batch
.push(id
);
1371 //console.log("preload ids batch: " + preload_id_batch.toString());
1373 window
.clearTimeout(preload_timeout_id
);
1374 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1378 exception_error("preloadArticleUnderPointer", e
);
1382 function postMouseIn(id
) {
1384 if (post_under_pointer
!= id
) {
1385 post_under_pointer
= id
;
1387 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1392 exception_error("postMouseIn", e
);
1396 function postMouseOut(id
) {
1398 post_under_pointer
= false;
1400 exception_error("postMouseOut", e
);
1404 function headlines_scroll_handler(e
) {
1407 if (e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1408 if (!_infscroll_disable
) {
1414 if (getInitParam("cdm_auto_catchup") == 1) {
1418 $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
1420 if ($("headlines-frame").scrollTop
>
1421 (child
.offsetTop
+ child
.offsetHeight
)) {
1423 ids
.push(child
.id
.replace("RROW-", ""));
1427 if (ids
.length
> 0) {
1429 var query
= "?op=rpc&subop=catchupSelected" +
1430 "&cmode=0&ids=" + param_escape(ids
.toString());
1432 new Ajax
.Request("backend.php", {
1434 onComplete: function(transport
) {
1435 handle_rpc_json(transport
);
1437 ids
.each(function(id
) {
1438 var elem
= $("RROW-" + id
);
1439 if (elem
) elem
.removeClassName("Unread");
1445 exception_error("headlines_scroll_handler", e
);
1449 function catchupRelativeToArticle(below
) {
1454 if (!getActiveArticleId()) {
1455 alert(__("No article is selected."));
1459 var visible_ids
= getVisibleArticleIds();
1461 var ids_to_mark
= new Array();
1464 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1465 if (visible_ids
[i
] != getActiveArticleId()) {
1466 var e
= $("RROW-" + visible_ids
[i
]);
1468 if (e
&& e
.hasClassName("Unread")) {
1469 ids_to_mark
.push(visible_ids
[i
]);
1476 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1477 if (visible_ids
[i
] != getActiveArticleId()) {
1478 var e
= $("RROW-" + visible_ids
[i
]);
1480 if (e
&& e
.hasClassName("Unread")) {
1481 ids_to_mark
.push(visible_ids
[i
]);
1489 if (ids_to_mark
.length
== 0) {
1490 alert(__("No articles found to mark"));
1492 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1494 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1496 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1497 var e
= $("RROW-" + ids_to_mark
[i
]);
1498 e
.removeClassName("Unread");
1501 var query
= "?op=rpc&subop=catchupSelected" +
1502 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1504 new Ajax
.Request("backend.php", {
1506 onComplete: function(transport
) {
1507 handle_rpc_json(transport
);
1514 exception_error("catchupRelativeToArticle", e
);
1518 function cdmExpandArticle(id
) {
1523 var elem
= $("CICD-" + active_post_id
);
1525 var upd_img_pic
= $("FUPDPIC-" + id
);
1527 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1528 upd_img_pic
.src
.match("fresh_sign.png"))) {
1530 upd_img_pic
.src
= "images/blank_icon.gif";
1533 if (id
== active_post_id
&& Element
.visible(elem
))
1536 selectArticles("none");
1538 var old_offset
= $("RROW-" + id
).offsetTop
;
1540 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1542 Element
.show("CEXC-" + active_post_id
);
1545 active_post_id
= id
;
1547 elem
= $("CICD-" + id
);
1549 if (!Element
.visible(elem
)) {
1551 Element
.hide("CEXC-" + id
);
1553 if ($("CWRAP-" + id
).innerHTML
== "") {
1555 $("FUPDPIC-" + id
).src
= "images/indicator_tiny.gif";
1557 $("CWRAP-" + id
).innerHTML
= "<div class=\"insensitive\">" +
1558 __("Loading, please wait...") + "</div>";
1560 var query
= "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id
);
1562 //console.log(query);
1564 new Ajax
.Request("backend.php", {
1566 onComplete: function(transport
) {
1567 $("FUPDPIC-" + id
).src
= 'images/blank_icon.gif';
1569 handle_rpc_json(transport
);
1571 var reply
= JSON
.parse(transport
.responseText
);
1574 var article
= reply
['article']['content'];
1575 var recv_id
= reply
['article']['id'];
1578 $("CWRAP-" + id
).innerHTML
= article
;
1581 $("CWRAP-" + id
).innerHTML
= __("Unable to load article.");
1589 var new_offset
= $("RROW-" + id
).offsetTop
;
1591 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1593 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1594 $("headlines-frame").scrollTop
= new_offset
;
1596 toggleUnread(id
, 0, true);
1600 exception_error("cdmExpandArticle", e
);
1606 function fixHeadlinesOrder(ids
) {
1608 for (var i
= 0; i
< ids
.length
; i
++) {
1609 var e
= $("RROW-" + ids
[i
]);
1613 e
.removeClassName("even");
1614 e
.addClassName("odd");
1616 e
.removeClassName("odd");
1617 e
.addClassName("even");
1622 exception_error("fixHeadlinesOrder", e
);
1626 function getArticleUnderPointer() {
1627 return post_under_pointer
;
1630 function zoomToArticle(event
, id
) {
1632 var cached_article
= cache_find(id
);
1634 if (dijit
.byId("ATAB-" + id
))
1635 if (!event
|| !event
.shiftKey
)
1636 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1638 if (cached_article
) {
1639 //closeArticlePanel();
1641 var article_pane
= new dijit
.layout
.ContentPane({
1642 title
: __("Loading...") , content
: cached_article
,
1643 style
: 'padding : 0px;',
1647 dijit
.byId("content-tabs").addChild(article_pane
);
1649 if (!event
|| !event
.shiftKey
)
1650 dijit
.byId("content-tabs").selectChild(article_pane
);
1652 if ($("PTITLE-" + id
))
1653 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1657 var query
= "?op=rpc&subop=getArticles&ids=" + param_escape(id
);
1659 notify_progress("Loading, please wait...", true);
1661 new Ajax
.Request("backend.php", {
1663 onComplete: function(transport
) {
1666 if (transport
.responseXML
) {
1667 //closeArticlePanel();
1669 var article
= transport
.responseXML
.getElementsByTagName("article")[0];
1670 var content
= article
.firstChild
.nodeValue
;
1672 var article_pane
= new dijit
.layout
.ContentPane({
1673 title
: "article-" + id
, content
: content
,
1674 style
: 'padding : 0px;',
1678 dijit
.byId("content-tabs").addChild(article_pane
);
1680 if (!event
|| !event
.shiftKey
)
1681 dijit
.byId("content-tabs").selectChild(article_pane
);
1683 if ($("PTITLE-" + id
))
1684 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1691 exception_error("zoomToArticle", e
);
1695 function scrollArticle(offset
) {
1698 var ci
= $("content-insert");
1700 ci
.scrollTop
+= offset
;
1703 var hi
= $("headlines-frame");
1705 hi
.scrollTop
+= offset
;
1710 exception_error("scrollArticle", e
);
1714 function show_labels_in_headlines(transport
) {
1716 var data
= JSON
.parse(transport
.responseText
);
1719 data
['info-for-headlines'].each(function(elem
) {
1720 var ctr
= $("HLLCTR-" + elem
.id
);
1722 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1726 exception_error("show_labels_in_headlines", e
);
1730 function toggleHeadlineActions() {
1732 var e
= $("headlineActionsBody");
1733 var p
= $("headlineActionsDrop");
1735 if (!Element
.visible(e
)) {
1742 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
1743 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
1746 exception_error("toggleHeadlineActions", e
);
1750 /* function publishWithNote(id, def_note) {
1752 if (!def_note) def_note = '';
1754 var note = prompt(__("Please enter a note for this article:"), def_note);
1756 if (note != undefined) {
1757 togglePub(id, false, false, note);
1761 exception_error("publishWithNote", e);
1765 function emailArticle(id
) {
1768 var ids
= getSelectedArticleIds2();
1770 if (ids
.length
== 0) {
1771 alert(__("No articles are selected."));
1775 id
= ids
.toString();
1778 if (dijit
.byId("emailArticleDlg"))
1779 dijit
.byId("emailArticleDlg").destroyRecursive();
1781 var query
= "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id
);
1783 dialog
= new dijit
.Dialog({
1784 id
: "emailArticleDlg",
1785 title
: __("Forward article by email"),
1786 style
: "width: 600px",
1787 execute: function() {
1788 if (this.validate()) {
1790 new Ajax
.Request("backend.php", {
1791 parameters
: dojo
.objectToQuery(this.attr('value')),
1792 onComplete: function(transport
) {
1794 var reply
= JSON
.parse(transport
.responseText
);
1796 var error
= reply
['error'];
1799 alert(__('Error sending email:') + ' ' + error
);
1801 notify_info('Your message has been sent.');
1810 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1811 dojo
.disconnect(tmph
);
1813 new Ajax
.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
1814 "backend.php?op=rpc&subop=completeEmails",
1815 { tokens
: '', paramName
: "search" });
1820 /* displayDlg('emailArticle', id,
1822 document.forms['article_email_form'].destination.focus();
1824 new Ajax.Autocompleter('destination', 'destination_choices',
1825 "backend.php?op=rpc&subop=completeEmails",
1826 { tokens: '', paramName: "search" });
1831 exception_error("emailArticle", e
);
1835 function dismissArticle(id
) {
1837 var elem
= $("RROW-" + id
);
1839 toggleUnread(id
, 0, true);
1841 new Effect
.Fade(elem
, {duration
: 0.5});
1843 active_post_id
= false;
1846 exception_error("dismissArticle", e
);
1850 function dismissSelectedArticles() {
1853 var ids
= getVisibleArticleIds();
1857 for (var i
= 0; i
< ids
.length
; i
++) {
1858 var elem
= $("RROW-" + ids
[i
]);
1860 if (elem
.className
&& elem
.hasClassName("Selected") &&
1861 ids
[i
] != active_post_id
) {
1862 new Effect
.Fade(elem
, {duration
: 0.5});
1870 selectionToggleUnread(false);
1872 fixHeadlinesOrder(tmp
);
1875 exception_error("dismissSelectedArticles", e
);
1879 function dismissReadArticles() {
1882 var ids
= getVisibleArticleIds();
1885 for (var i
= 0; i
< ids
.length
; i
++) {
1886 var elem
= $("RROW-" + ids
[i
]);
1888 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1889 !elem
.hasClassName("Selected")) {
1891 new Effect
.Fade(elem
, {duration
: 0.5});
1897 fixHeadlinesOrder(tmp
);
1900 exception_error("dismissSelectedArticles", e
);
1904 function getVisibleArticleIds() {
1909 getLoadedArticleIds().each(function(id
) {
1910 var elem
= $("RROW-" + id
);
1911 if (elem
&& Element
.visible(elem
))
1916 exception_error("getVisibleArticleIds", e
);
1922 function cdmClicked(event
, id
) {
1924 var shift_key
= event
.shiftKey
;
1928 if (!event
.ctrlKey
) {
1930 if (!getInitParam("cdm_expanded")) {
1931 return cdmExpandArticle(id
);
1934 selectArticles("none");
1937 var elem
= $("RROW-" + id
);
1940 elem
.removeClassName("Unread");
1942 var upd_img_pic
= $("FUPDPIC-" + id
);
1944 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1945 upd_img_pic
.src
.match("fresh_sign.png"))) {
1947 upd_img_pic
.src
= "images/blank_icon.gif";
1950 active_post_id
= id
;
1952 var query
= "?op=rpc&subop=catchupSelected" +
1953 "&cmode=0&ids=" + param_escape(id
);
1955 new Ajax
.Request("backend.php", {
1957 onComplete: function(transport
) {
1958 handle_rpc_json(transport
);
1965 toggleSelected(id
, true);
1966 toggleUnread(id
, 0, false);
1967 zoomToArticle(event
, id
);
1971 exception_error("cdmClicked");
1977 function postClicked(event
, id
) {
1980 if (!event
.ctrlKey
) {
1983 postOpenInNewTab(event
, id
);
1988 exception_error("postClicked");
1992 function hlOpenInNewTab(event
, id
) {
1993 toggleUnread(id
, 0, false);
1994 zoomToArticle(event
, id
);
1997 function postOpenInNewTab(event
, id
) {
1998 closeArticlePanel(id
);
1999 zoomToArticle(event
, id
);
2002 function hlClicked(event
, id
) {
2005 openArticleInNewWindow(id
);
2006 } else if (!event
.ctrlKey
) {
2011 toggleUnread(id
, 0, false);
2012 zoomToArticle(event
, id
);
2017 exception_error("hlClicked");
2021 function getFirstVisibleHeadlineId() {
2022 var rows
= getVisibleArticleIds();
2027 function getLastVisibleHeadlineId() {
2028 var rows
= getVisibleArticleIds();
2029 return rows
[rows
.length
-1];
2032 function openArticleInNewWindow(id
) {
2033 toggleUnread(id
, 0, false);
2034 window
.open("backend.php?op=la&id=" + id
);
2037 function isCdmMode() {
2038 return getInitParam("combined_display_mode");
2041 function markHeadline(id
) {
2042 var row
= $("RROW-" + id
);
2044 var check
= $("RCHK-" + id
);
2047 check
.checked
= true;
2050 row
.addClassName("Selected");
2054 function getRelativePostIds(id
, limit
) {
2060 if (!limit
) limit
= 3;
2062 var ids
= getVisibleArticleIds();
2064 for (var i
= 0; i
< ids
.length
; i
++) {
2066 for (var k
= 1; k
<= limit
; k
++) {
2067 if (i
> k
-1) tmp
.push(ids
[i
-k
]);
2068 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
2075 exception_error("getRelativePostIds", e
);
2081 function correctHeadlinesOffset(id
) {
2085 var container
= $("headlines-frame");
2086 var row
= $("RROW-" + id
);
2088 var viewport
= container
.offsetHeight
;
2090 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
2091 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
2093 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
2094 //console.log("Vport: " + viewport);
2096 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
2097 container
.scrollTop
= row
.offsetTop
;
2098 } else if (rel_offset_bottom
> viewport
) {
2100 /* doesn't properly work with Opera in some cases because
2101 Opera fucks up element scrolling */
2103 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
2107 exception_error("correctHeadlinesOffset", e
);
2112 function headlineActionsChange(elem
) {
2115 elem
.attr('value', 'false');
2117 exception_error("headlineActionsChange", e
);
2121 function closeArticlePanel() {
2123 var tabs
= dijit
.byId("content-tabs");
2124 var child
= tabs
.selectedChildWidget
;
2126 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
2127 tabs
.removeChild(child
);
2130 if (dijit
.byId("content-insert"))
2131 dijit
.byId("headlines-wrap-inner").removeChild(
2132 dijit
.byId("content-insert"));
2136 function initHeadlinesMenu() {
2138 if (dijit
.byId("headlinesMenu"))
2139 dijit
.byId("headlinesMenu").destroyRecursive();
2144 nodes
= $$("#headlines-frame > div[id*=RROW]");
2146 nodes
= $$("#headlines-frame span[id*=RTITLE]");
2149 nodes
.each(function(node
) {
2153 var menu
= new dijit
.Menu({
2154 id
: "headlinesMenu",
2158 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
2159 var callerNode
= event
.target
, match
= null, tries
= 0;
2161 while (match
== null && callerNode
&& tries
<= 3) {
2162 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
2163 callerNode
= callerNode
.parentNode
;
2167 if (match
) this.callerRowId
= parseInt(match
[1]);
2171 /* if (!isCdmMode())
2172 menu.addChild(new dijit.MenuItem({
2173 label: __("View article"),
2174 onClick: function(event) {
2175 view(this.getParent().callerRowId);
2178 menu
.addChild(new dijit
.MenuItem({
2179 label
: __("Open original article"),
2180 onClick: function(event
) {
2181 openArticleInNewWindow(this.getParent().callerRowId
);
2184 menu
.addChild(new dijit
.MenuItem({
2185 label
: __("View in a tt-rss tab"),
2186 onClick: function(event
) {
2187 hlOpenInNewTab(event
, this.getParent().callerRowId
);
2190 // menu.addChild(new dijit.MenuSeparator());
2192 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2196 menu
.addChild(new dijit
.MenuSeparator());
2198 var labelAddMenu
= new dijit
.Menu({ownerMenu
: menu
});
2199 var labelDelMenu
= new dijit
.Menu({ownerMenu
: menu
});
2201 labels
.each(function(label
) {
2202 var id
= label
.id
[0];
2203 var bare_id
= id
.substr(id
.indexOf(":")+1);
2204 var name
= label
.name
[0];
2206 bare_id
= -11-bare_id
;
2208 labelAddMenu
.addChild(new dijit
.MenuItem({
2211 onClick: function(event
) {
2212 selectionAssignLabel(this.labelId
,
2213 [this.getParent().ownerMenu
.callerRowId
]);
2216 labelDelMenu
.addChild(new dijit
.MenuItem({
2219 onClick: function(event
) {
2220 selectionRemoveLabel(this.labelId
,
2221 [this.getParent().ownerMenu
.callerRowId
]);
2226 menu
.addChild(new dijit
.PopupMenuItem({
2227 label
: __("Assign label"),
2228 popup
: labelAddMenu
,
2231 menu
.addChild(new dijit
.PopupMenuItem({
2232 label
: __("Remove label"),
2233 popup
: labelDelMenu
,
2241 exception_error("initHeadlinesMenu", e
);
2245 function tweetArticle(id
) {
2247 var query
= "?op=rpc&subop=getTweetInfo&id=" + param_escape(id
);
2252 var ts
= d
.getTime();
2254 var w
= window
.open('backend.php?op=loading', 'ttrss_tweet',
2255 "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
2257 new Ajax
.Request("backend.php", {
2259 onComplete: function(transport
) {
2260 var ti
= JSON
.parse(transport
.responseText
);
2262 var share_url
= "http://twitter.com/share?_=" + ts
+
2263 "&text=" + param_escape(ti
.title
) +
2264 "&url=" + param_escape(ti
.link
);
2266 w
.location
.href
= share_url
;
2272 exception_error("tweetArticle", e
);
2276 function editArticleNote(id
) {
2279 var query
= "backend.php?op=dlg&id=editArticleNote¶m=" + param_escape(id
);
2281 if (dijit
.byId("editNoteDlg"))
2282 dijit
.byId("editNoteDlg").destroyRecursive();
2284 dialog
= new dijit
.Dialog({
2286 title
: __("Edit article note"),
2287 style
: "width: 600px",
2288 execute: function() {
2289 if (this.validate()) {
2290 var query
= dojo
.objectToQuery(this.attr('value'));
2292 notify_progress("Saving article note...", true);
2294 new Ajax
.Request("backend.php", {
2296 onComplete: function(transport
) {
2300 var reply
= JSON
.parse(transport
.responseText
);
2302 cache_invalidate(id
);
2304 var elem
= $("POSTNOTE-" + id
);
2308 elem
.innerHTML
= reply
.note
;
2309 new Effect
.Appear(elem
);
2321 exception_error("editArticleNote", e
);
2325 function player(elem
) {
2326 var aid
= elem
.getAttribute("audio-id");
2327 var status
= elem
.getAttribute("status");
2335 elem
.innerHTML
= __("Playing...");
2336 elem
.title
= __("Click to pause");
2337 elem
.addClassName("playing");
2341 elem
.innerHTML
= __("Play");
2342 elem
.title
= __("Click to play");
2343 elem
.removeClassName("playing");
2346 elem
.setAttribute("status", status
);
2348 alert("Your browser doesn't seem to support HTML5 audio.");