]>
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
) {
19 handle_rpc_json(transport
);
21 loading_set_progress(25);
23 console
.log("headlines_callback2 [page=" + feed_cur_page
+ "]");
31 reply
= JSON
.parse(transport
.responseText
);
38 is_cat
= reply
['headlines']['is_cat'];
39 feed_id
= reply
['headlines']['id'];
41 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 var headlines_count
= reply
['headlines-info']['count'];
54 var headlines_unread
= reply
['headlines-info']['unread'];
56 vgroup_last_feed
= reply
['headlines-info']['vgroup_last_feed'];
58 if (parseInt(headlines_count
) < getInitParam("default_article_limit")) {
59 _infscroll_disable
= 1;
61 _infscroll_disable
= 0;
64 var counters
= reply
['counters'];
65 var articles
= reply
['articles'];
66 var runtime_info
= reply
['runtime-info'];
68 if (feed_cur_page
== 0) {
69 dijit
.byId("headlines-frame").attr('content',
70 reply
['headlines']['content']);
72 dijit
.byId("headlines-toolbar").attr('content',
73 reply
['headlines']['toolbar']);
75 var hsp
= $("headlines-spacer");
76 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
78 if (!_infscroll_disable
)
79 hsp
.innerHTML
= "<img src='images/indicator_tiny.gif'> " +
80 __("Loading, please wait...");
82 dijit
.byId('headlines-frame').domNode
.appendChild(hsp
);
87 if (headlines_count
> 0) {
88 console
.log("adding some more headlines...");
90 var c
= dijit
.byId("headlines-frame");
91 var ids
= getSelectedArticleIds2();
93 $("headlines-tmp").innerHTML
= reply
['headlines']['content'];
95 var hsp
= $("headlines-spacer");
98 c
.domNode
.removeChild(hsp
);
100 $$("#headlines-tmp > div").each(function(row
) {
101 c
.domNode
.appendChild(row
);
104 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
106 if (!_infscroll_disable
)
107 hsp
.innerHTML
= "<img src='images/indicator_tiny.gif'> " +
108 __("Loading, please wait...");
110 c
.domNode
.appendChild(hsp
);
112 console
.log("restore selected ids: " + ids
);
114 for (var i
= 0; i
< ids
.length
; i
++) {
115 markHeadline(ids
[i
]);
121 console
.log("no new headlines received");
123 var hsp
= $("headlines-spacer");
125 if (hsp
) hsp
.innerHTML
= "";
130 for (var i
= 0; i
< articles
.length
; i
++) {
131 var a_id
= articles
[i
]['id'];
132 cache_inject(a_id
, articles
[i
]['content']);
135 console
.log("no cached articles received");
139 parse_counters(counters
);
144 console
.warn("headlines_callback: returned no XML object");
145 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
146 __('Could not update headlines (invalid object received)') + "</div>");
149 _feed_cur_page
= feed_cur_page
;
150 _infscroll_request_sent
= 0;
155 exception_error("headlines_callback2", e
, transport
);
159 function render_article(article
) {
161 dijit
.byId("headlines-wrap-inner").addChild(
162 dijit
.byId("content-insert"));
164 var c
= dijit
.byId("content-insert");
167 c
.domNode
.scrollTop
= 0;
170 c
.attr('content', article
);
172 correctHeadlinesOffset(getActiveArticleId());
179 exception_error("render_article", e
);
183 function showArticleInHeadlines(id
) {
187 selectArticles("none");
189 var crow
= $("RROW-" + id
);
193 var article_is_unread
= crow
.hasClassName("Unread");
195 crow
.removeClassName("Unread");
197 selectArticles('none');
199 var upd_img_pic
= $("FUPDPIC-" + id
);
201 var cache_prefix
= "";
203 if (activeFeedIsCat()) {
209 var view_mode
= false;
212 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
213 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
218 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
219 upd_img_pic
.src
.match("fresh_sign.png"))) {
221 upd_img_pic
.src
= "images/blank_icon.gif";
223 cache_invalidate(cache_prefix
+ getActiveFeedId());
225 /* cache_inject(cache_prefix + getActiveFeedId(),
226 $("headlines-frame").innerHTML,
227 getFeedUnread(getActiveFeedId())); */
229 } else if (article_is_unread
&& view_mode
== "all_articles") {
231 cache_invalidate(cache_prefix
+ getActiveFeedId());
233 /* cache_inject(cache_prefix + getActiveFeedId(),
234 $("headlines-frame").innerHTML,
235 getFeedUnread(getActiveFeedId())-1); */
237 } else if (article_is_unread
) {
238 cache_invalidate(cache_prefix
+ getActiveFeedId());
243 if (article_is_unread
)
244 _force_scheduled_update
= true;
247 exception_error("showArticleInHeadlines", e
);
251 function article_callback2(transport
, id
) {
253 console
.log("article_callback2 " + id
);
255 handle_rpc_json(transport
);
257 var reply
= JSON
.parse(transport
.responseText
);
260 var upic
= $('FUPDPIC-' + id
);
262 if (upic
) upic
.src
= 'images/blank_icon.gif';
264 if (id
!= last_requested_article
) {
265 console
.log("requested article id is out of sequence, aborting");
269 reply
.each(function(article
) {
270 if (active_post_id
== article
['id']) {
271 render_article(article
['content']);
273 cache_inject(article
['id'], article
['content']);
277 console
.warn("article_callback: returned invalid data");
279 render_article("<div class='whiteBox'>" +
280 __('Could not display article (invalid data received)') + "</div>");
283 var date
= new Date();
284 last_article_view
= date
.getTime() / 1000;
290 exception_error("article_callback2", e
, transport
);
296 console
.log("loading article: " + id
);
298 var cached_article
= cache_find(id
);
300 console
.log("cache check result: " + (cached_article
!= false));
304 var query
= "?op=view&id=" + param_escape(id
);
306 var neighbor_ids
= getRelativePostIds(active_post_id
);
308 /* only request uncached articles */
310 var cids_to_request
= Array();
312 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
313 if (!cache_check(neighbor_ids
[i
])) {
314 cids_to_request
.push(neighbor_ids
[i
]);
318 console
.log("additional ids: " + cids_to_request
.toString());
320 query
= query
+ "&cids=" + cids_to_request
.toString();
322 var crow
= $("RROW-" + id
);
323 var article_is_unread
= crow
.hasClassName("Unread");
326 showArticleInHeadlines(id
);
328 if (!cached_article
) {
330 var upic
= $('FUPDPIC-' + id
);
333 upic
.src
= getInitParam("sign_progress");
336 } else if (cached_article
&& article_is_unread
) {
338 query
= query
+ "&mode=prefetch";
340 render_article(cached_article
);
342 } else if (cached_article
) {
344 query
= query
+ "&mode=prefetch_old";
345 render_article(cached_article
);
351 last_requested_article
= id
;
355 new Ajax
.Request("backend.php", {
357 onComplete: function(transport
) {
358 article_callback2(transport
, id
);
364 exception_error("view", e
);
369 return toggleMark(id
);
373 return togglePub(id
);
376 function toggleMark(id
, client_only
) {
378 var query
= "?op=rpc&id=" + id
+ "&subop=mark";
380 var img
= $("FMPIC-" + id
);
384 if (img
.src
.match("mark_unset")) {
385 img
.src
= img
.src
.replace("mark_unset", "mark_set");
386 img
.alt
= __("Unstar article");
387 query
= query
+ "&mark=1";
390 img
.src
= img
.src
.replace("mark_set", "mark_unset");
391 img
.alt
= __("Star article");
392 query
= query
+ "&mark=0";
396 new Ajax
.Request("backend.php", {
398 onComplete: function(transport
) {
399 handle_rpc_json(transport
);
404 exception_error("toggleMark", e
);
408 function togglePub(id
, client_only
, no_effects
, note
) {
410 var query
= "?op=rpc&id=" + id
+ "&subop=publ";
412 if (note
!= undefined) {
413 query
= query
+ "¬e=" + param_escape(note
);
415 query
= query
+ "¬e=undefined";
418 var img
= $("FPPIC-" + id
);
422 if (img
.src
.match("pub_unset") || note
!= undefined) {
423 img
.src
= img
.src
.replace("pub_unset", "pub_set");
424 img
.alt
= __("Unpublish article");
425 query
= query
+ "&pub=1";
428 img
.src
= img
.src
.replace("pub_set", "pub_unset");
429 img
.alt
= __("Publish article");
431 query
= query
+ "&pub=0";
435 new Ajax
.Request("backend.php", {
437 onComplete: function(transport
) {
438 handle_rpc_json(transport
);
443 exception_error("togglePub", e
);
447 function moveToPost(mode
) {
451 var rows
= getVisibleArticleIds();
456 if (!$('RROW-' + active_post_id
)) {
457 active_post_id
= false;
460 if (active_post_id
== false) {
461 next_id
= getFirstVisibleHeadlineId();
462 prev_id
= getLastVisibleHeadlineId();
464 for (var i
= 0; i
< rows
.length
; i
++) {
465 if (rows
[i
] == active_post_id
) {
472 if (mode
== "next") {
476 cdmExpandArticle(next_id
);
477 cdmScrollToArticleId(next_id
);
480 correctHeadlinesOffset(next_id
);
481 view(next_id
, getActiveFeedId());
486 if (mode
== "prev") {
489 cdmExpandArticle(prev_id
);
490 cdmScrollToArticleId(prev_id
);
492 correctHeadlinesOffset(prev_id
);
493 view(prev_id
, getActiveFeedId());
499 exception_error("moveToPost", e
);
503 function toggleSelected(id
, force_on
) {
506 var cb
= $("RCHK-" + id
);
507 var row
= $("RROW-" + id
);
510 if (row
.hasClassName('Selected') && !force_on
) {
511 row
.removeClassName('Selected');
512 if (cb
) cb
.checked
= false;
514 row
.addClassName('Selected');
515 if (cb
) cb
.checked
= true;
519 exception_error("toggleSelected", e
);
523 function toggleUnread_afh(effect
) {
526 var elem
= effect
.element
;
527 elem
.style
.backgroundColor
= "";
530 exception_error("toggleUnread_afh", e
);
534 function toggleUnread(id
, cmode
, effect
) {
537 var row
= $("RROW-" + id
);
539 if (cmode
== undefined || cmode
== 2) {
540 if (row
.hasClassName("Unread")) {
541 row
.removeClassName("Unread");
544 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
545 afterFinish
: toggleUnread_afh
,
546 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
550 row
.addClassName("Unread");
553 } else if (cmode
== 0) {
555 row
.removeClassName("Unread");
558 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
559 afterFinish
: toggleUnread_afh
,
560 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
563 } else if (cmode
== 1) {
564 row
.addClassName("Unread");
567 if (cmode
== undefined) cmode
= 2;
569 var query
= "?op=rpc&subop=catchupSelected" +
570 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
572 // notify_progress("Loading, please wait...");
574 new Ajax
.Request("backend.php", {
576 onComplete: function(transport
) {
577 handle_rpc_json(transport
);
583 exception_error("toggleUnread", e
);
587 function selectionRemoveLabel(id
, ids
) {
590 if (!ids
) var ids
= getSelectedArticleIds2();
592 if (ids
.length
== 0) {
593 alert(__("No articles are selected."));
597 // var ok = confirm(__("Remove selected articles from label?"));
601 var query
= "?op=rpc&subop=removeFromLabel&ids=" +
602 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
606 // notify_progress("Loading, please wait...");
608 cache_invalidate("F:" + (-11 - id
));
610 new Ajax
.Request("backend.php", {
612 onComplete: function(transport
) {
613 handle_rpc_json(transport
);
614 show_labels_in_headlines(transport
);
620 exception_error("selectionAssignLabel", e
);
625 function selectionAssignLabel(id
, ids
) {
628 if (!ids
) ids
= getSelectedArticleIds2();
630 if (ids
.length
== 0) {
631 alert(__("No articles are selected."));
635 // var ok = confirm(__("Assign selected articles to label?"));
639 cache_invalidate("F:" + (-11 - id
));
641 var query
= "?op=rpc&subop=assignToLabel&ids=" +
642 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
646 // notify_progress("Loading, please wait...");
648 new Ajax
.Request("backend.php", {
650 onComplete: function(transport
) {
651 handle_rpc_json(transport
);
652 show_labels_in_headlines(transport
);
658 exception_error("selectionAssignLabel", e
);
663 function selectionToggleUnread(set_state
, callback
, no_error
) {
665 var rows
= getSelectedArticleIds2();
667 if (rows
.length
== 0 && !no_error
) {
668 alert(__("No articles are selected."));
672 for (i
= 0; i
< rows
.length
; i
++) {
673 var row
= $("RROW-" + rows
[i
]);
675 if (set_state
== undefined) {
676 if (row
.hasClassName("Unread")) {
677 row
.removeClassName("Unread");
679 row
.addClassName("Unread");
683 if (set_state
== false) {
684 row
.removeClassName("Unread");
687 if (set_state
== true) {
688 row
.addClassName("Unread");
693 if (rows
.length
> 0) {
697 if (set_state
== undefined) {
699 } else if (set_state
== true) {
701 } else if (set_state
== false) {
705 var query
= "?op=rpc&subop=catchupSelected" +
706 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
708 notify_progress("Loading, please wait...");
710 new Ajax
.Request("backend.php", {
712 onComplete: function(transport
) {
713 handle_rpc_json(transport
);
714 if (callback
) callback(transport
);
720 exception_error("selectionToggleUnread", e
);
724 function selectionToggleMarked() {
727 var rows
= getSelectedArticleIds2();
729 if (rows
.length
== 0) {
730 alert(__("No articles are selected."));
734 for (i
= 0; i
< rows
.length
; i
++) {
735 toggleMark(rows
[i
], true, true);
738 if (rows
.length
> 0) {
740 var query
= "?op=rpc&subop=markSelected&ids=" +
741 param_escape(rows
.toString()) + "&cmode=2";
743 new Ajax
.Request("backend.php", {
745 onComplete: function(transport
) {
746 handle_rpc_json(transport
);
752 exception_error("selectionToggleMarked", e
);
756 function selectionTogglePublished() {
759 var rows
= getSelectedArticleIds2();
761 if (rows
.length
== 0) {
762 alert(__("No articles are selected."));
766 for (i
= 0; i
< rows
.length
; i
++) {
767 togglePub(rows
[i
], true, true);
770 if (rows
.length
> 0) {
772 var query
= "?op=rpc&subop=publishSelected&ids=" +
773 param_escape(rows
.toString()) + "&cmode=2";
775 new Ajax
.Request("backend.php", {
777 onComplete: function(transport
) {
778 handle_rpc_json(transport
);
784 exception_error("selectionToggleMarked", e
);
788 function getSelectedArticleIds2() {
792 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
794 rv
.push(child
.id
.replace("RROW-", ""));
800 function getLoadedArticleIds() {
803 var children
= $$("#headlines-frame > div[id*=RROW-]");
805 children
.each(function(child
) {
806 rv
.push(child
.id
.replace("RROW-", ""));
813 // mode = all,none,unread,invert
814 function selectArticles(mode
) {
817 var children
= $$("#headlines-frame > div[id*=RROW]");
819 children
.each(function(child
) {
820 var id
= child
.id
.replace("RROW-", "");
821 var cb
= $("RCHK-" + id
);
824 child
.addClassName("Selected");
826 } else if (mode
== "unread") {
827 if (child
.hasClassName("Unread")) {
828 child
.addClassName("Selected");
831 child
.removeClassName("Selected");
834 } else if (mode
== "invert") {
835 if (child
.hasClassName("Selected")) {
836 child
.removeClassName("Selected");
839 child
.addClassName("Selected");
844 child
.removeClassName("Selected");
850 exception_error("selectArticles", e
);
854 function catchupPage() {
856 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
858 var str
= __("Mark all visible articles in %s as read?");
860 str
= str
.replace("%s", fn
);
862 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
866 selectArticles('all');
867 selectionToggleUnread(false, 'viewCurrentFeed()', true)
868 selectArticles('none');
871 function deleteSelection() {
875 var rows
= getSelectedArticleIds2();
877 if (rows
.length
== 0) {
878 alert(__("No articles are selected."));
882 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
886 if (getActiveFeedId() != 0) {
887 str
= __("Delete %d selected articles in %s?");
889 str
= __("Delete %d selected articles?");
892 str
= str
.replace("%d", rows
.length
);
893 str
= str
.replace("%s", fn
);
895 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
899 query
= "?op=rpc&subop=delete&ids=" + param_escape(rows
);
903 new Ajax
.Request("backend.php", {
905 onComplete: function(transport
) {
906 handle_rpc_json(transport
);
911 exception_error("deleteSelection", e
);
915 function archiveSelection() {
919 var rows
= getSelectedArticleIds2();
921 if (rows
.length
== 0) {
922 alert(__("No articles are selected."));
926 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
930 if (getActiveFeedId() != 0) {
931 str
= __("Archive %d selected articles in %s?");
934 str
= __("Move %d archived articles back?");
938 str
= str
.replace("%d", rows
.length
);
939 str
= str
.replace("%s", fn
);
941 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
945 query
= "?op=rpc&subop="+op
+"&ids=" + param_escape(rows
);
949 for (var i
= 0; i
< rows
.length
; i
++) {
950 cache_invalidate(rows
[i
]);
953 new Ajax
.Request("backend.php", {
955 onComplete: function(transport
) {
956 handle_rpc_json(transport
);
961 exception_error("archiveSelection", e
);
965 function catchupSelection() {
969 var rows
= getSelectedArticleIds2();
971 if (rows
.length
== 0) {
972 alert(__("No articles are selected."));
976 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
978 var str
= __("Mark %d selected articles in %s as read?");
980 str
= str
.replace("%d", rows
.length
);
981 str
= str
.replace("%s", fn
);
983 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
987 selectionToggleUnread(false, 'viewCurrentFeed()', true)
990 exception_error("catchupSelection", e
);
994 function editArticleTags(id
) {
995 var query
= "backend.php?op=dlg&id=editArticleTags¶m=" + param_escape(id
);
997 if (dijit
.byId("editTagsDlg"))
998 dijit
.byId("editTagsDlg").destroyRecursive();
1000 dialog
= new dijit
.Dialog({
1002 title
: __("Edit article Tags"),
1003 style
: "width: 600px",
1004 execute: function() {
1005 if (this.validate()) {
1006 var query
= dojo
.objectToQuery(this.attr('value'));
1008 notify_progress("Saving article tags...", true);
1010 new Ajax
.Request("backend.php", {
1012 onComplete: function(transport
) {
1016 var data
= JSON
.parse(transport
.responseText
);
1019 var tags_str
= data
.tags_str
;
1020 var id
= tags_str
.id
;
1022 var tags
= $("ATSTR-" + id
);
1023 var tooltip
= dijit
.byId("ATSTRTIP-" + id
);
1025 if (tags
) tags
.innerHTML
= tags_str
.content
;
1026 if (tooltip
) tooltip
.attr('label', tags_str
.content_full
);
1028 cache_invalidate(id
);
1037 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1038 dojo
.disconnect(tmph
);
1040 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1041 "backend.php?op=rpc&subop=completeTags",
1042 { tokens
: ',', paramName
: "search" });
1049 function cdmScrollToArticleId(id
) {
1051 var ctr
= $("headlines-frame");
1052 var e
= $("RROW-" + id
);
1054 if (!e
|| !ctr
) return;
1056 ctr
.scrollTop
= e
.offsetTop
;
1059 exception_error("cdmScrollToArticleId", e
);
1063 function cache_inject(id
, article
, param
) {
1066 if (!cache_check_param(id
, param
)) {
1067 //console.log("cache_article: miss: " + id + " [p=" + param + "]");
1069 var date
= new Date();
1070 var ts
= Math
.round(date
.getTime() / 1000);
1074 cache_obj
["id"] = id
;
1075 cache_obj
["data"] = article
;
1076 cache_obj
["param"] = param
;
1078 if (param
) id
= id
+ ":" + param
;
1080 cache_added
["TS:" + id
] = ts
;
1082 if (has_local_storage())
1083 sessionStorage
.setItem(id
, JSON
.stringify(cache_obj
));
1085 article_cache
.push(cache_obj
);
1088 //console.log("cache_article: hit: " + id + " [p=" + param + "]");
1091 exception_error("cache_inject", e
);
1095 function cache_find(id
) {
1097 if (has_local_storage()) {
1098 var cache_obj
= sessionStorage
.getItem(id
);
1101 cache_obj
= JSON
.parse(cache_obj
);
1104 return cache_obj
['data'];
1108 for (var i
= 0; i
< article_cache
.length
; i
++) {
1109 if (article_cache
[i
]["id"] == id
) {
1110 return article_cache
[i
]["data"];
1117 function cache_find_param(id
, param
) {
1119 if (has_local_storage()) {
1121 if (param
) id
= id
+ ":" + param
;
1123 var cache_obj
= sessionStorage
.getItem(id
);
1126 cache_obj
= JSON
.parse(cache_obj
);
1129 return cache_obj
['data'];
1133 for (var i
= 0; i
< article_cache
.length
; i
++) {
1134 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1135 return article_cache
[i
]["data"];
1143 function cache_check(id
) {
1144 if (has_local_storage()) {
1145 if (sessionStorage
.getItem(id
))
1148 for (var i
= 0; i
< article_cache
.length
; i
++) {
1149 if (article_cache
[i
]["id"] == id
) {
1157 function cache_check_param(id
, param
) {
1158 if (has_local_storage()) {
1160 if (param
) id
= id
+ ":" + param
;
1162 if (sessionStorage
.getItem(id
))
1166 for (var i
= 0; i
< article_cache
.length
; i
++) {
1167 if (article_cache
[i
]["id"] == id
&& article_cache
[i
]["param"] == param
) {
1175 function cache_expire() {
1176 if (has_local_storage()) {
1178 var date
= new Date();
1179 var timestamp
= Math
.round(date
.getTime() / 1000);
1181 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1183 var id
= sessionStorage
.key(i
);
1185 if (timestamp
- cache_added
["TS:" + id
] > 180) {
1186 sessionStorage
.removeItem(id
);
1191 while (article_cache
.length
> 25) {
1192 article_cache
.shift();
1197 function cache_flush() {
1198 if (has_local_storage()) {
1199 sessionStorage
.clear();
1201 article_cache
= new Array();
1205 function cache_invalidate(id
) {
1207 if (has_local_storage()) {
1211 for (var i
= 0; i
< sessionStorage
.length
; i
++) {
1212 var key
= sessionStorage
.key(i
);
1214 // console.warn("cache_invalidate: " + key_id + " cmp " + id);
1216 if (key
== id
|| key
.indexOf(id
+ ":") == 0) {
1217 sessionStorage
.removeItem(key
);
1228 while (i
< article_cache
.length
) {
1229 if (article_cache
[i
]["id"] == id
) {
1230 //console.log("cache_invalidate: removed id " + id);
1231 article_cache
.splice(i
, 1);
1238 //console.log("cache_invalidate: id not found: " + id);
1241 exception_error("cache_invalidate", e
);
1245 function getActiveArticleId() {
1246 return active_post_id
;
1249 function preloadBatchedArticles() {
1252 var query
= "?op=rpc&subop=getArticles&ids=" +
1253 preload_id_batch
.toString();
1255 new Ajax
.Request("backend.php", {
1257 onComplete: function(transport
) {
1259 preload_id_batch
= [];
1261 var articles
= JSON
.parse(transport
.responseText
);
1263 for (var i
= 0; i
< articles
.length
; i
++) {
1264 var id
= articles
[i
]['id'];
1265 if (!cache_check(id
)) {
1266 cache_inject(id
, articles
[i
]['content']);
1267 console
.log("preloaded article: " + id
);
1273 exception_error("preloadBatchedArticles", e
);
1277 function preloadArticleUnderPointer(id
) {
1279 if (getInitParam("bw_limit") == "1") return;
1281 if (post_under_pointer
== id
&& !cache_check(id
)) {
1283 console
.log("trying to preload article " + id
);
1285 var neighbor_ids
= getRelativePostIds(id
, 1);
1287 /* only request uncached articles */
1289 if (preload_id_batch
.indexOf(id
) == -1) {
1290 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
1291 if (!cache_check(neighbor_ids
[i
])) {
1292 preload_id_batch
.push(neighbor_ids
[i
]);
1297 if (preload_id_batch
.indexOf(id
) == -1)
1298 preload_id_batch
.push(id
);
1300 //console.log("preload ids batch: " + preload_id_batch.toString());
1302 window
.clearTimeout(preload_timeout_id
);
1303 preload_batch_timeout_id
= window
.setTimeout('preloadBatchedArticles()', 1000);
1307 exception_error("preloadArticleUnderPointer", e
);
1311 function postMouseIn(id
) {
1313 if (post_under_pointer
!= id
) {
1314 post_under_pointer
= id
;
1316 window
.setTimeout("preloadArticleUnderPointer(" + id
+ ")", 250);
1321 exception_error("postMouseIn", e
);
1325 function postMouseOut(id
) {
1327 post_under_pointer
= false;
1329 exception_error("postMouseOut", e
);
1333 function headlines_scroll_handler(e
) {
1335 var hsp
= $("headlines-spacer");
1337 if (!_infscroll_disable
) {
1338 if (hsp
&& (e
.scrollTop
+ e
.offsetHeight
> hsp
.offsetTop
) ||
1339 e
.scrollTop
+ e
.offsetHeight
> e
.scrollHeight
- 100) {
1344 if (hsp
) hsp
.innerHTML
= "";
1347 if (getInitParam("cdm_auto_catchup") == 1) {
1351 $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
1353 if ($("headlines-frame").scrollTop
>
1354 (child
.offsetTop
+ child
.offsetHeight
/2)) {
1356 ids
.push(child
.id
.replace("RROW-", ""));
1360 if (ids
.length
> 0) {
1362 var query
= "?op=rpc&subop=catchupSelected" +
1363 "&cmode=0&ids=" + param_escape(ids
.toString());
1365 new Ajax
.Request("backend.php", {
1367 onComplete: function(transport
) {
1368 handle_rpc_json(transport
);
1370 ids
.each(function(id
) {
1371 var elem
= $("RROW-" + id
);
1372 if (elem
) elem
.removeClassName("Unread");
1378 exception_error("headlines_scroll_handler", e
);
1382 function catchupRelativeToArticle(below
) {
1387 if (!getActiveArticleId()) {
1388 alert(__("No article is selected."));
1392 var visible_ids
= getVisibleArticleIds();
1394 var ids_to_mark
= new Array();
1397 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1398 if (visible_ids
[i
] != getActiveArticleId()) {
1399 var e
= $("RROW-" + visible_ids
[i
]);
1401 if (e
&& e
.hasClassName("Unread")) {
1402 ids_to_mark
.push(visible_ids
[i
]);
1409 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1410 if (visible_ids
[i
] != getActiveArticleId()) {
1411 var e
= $("RROW-" + visible_ids
[i
]);
1413 if (e
&& e
.hasClassName("Unread")) {
1414 ids_to_mark
.push(visible_ids
[i
]);
1422 if (ids_to_mark
.length
== 0) {
1423 alert(__("No articles found to mark"));
1425 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1427 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1429 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1430 var e
= $("RROW-" + ids_to_mark
[i
]);
1431 e
.removeClassName("Unread");
1434 var query
= "?op=rpc&subop=catchupSelected" +
1435 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1437 new Ajax
.Request("backend.php", {
1439 onComplete: function(transport
) {
1440 handle_rpc_json(transport
);
1447 exception_error("catchupRelativeToArticle", e
);
1451 function cdmExpandArticle(id
) {
1456 var elem
= $("CICD-" + active_post_id
);
1458 var upd_img_pic
= $("FUPDPIC-" + id
);
1460 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1461 upd_img_pic
.src
.match("fresh_sign.png"))) {
1463 upd_img_pic
.src
= "images/blank_icon.gif";
1466 if (id
== active_post_id
&& Element
.visible(elem
))
1469 selectArticles("none");
1471 var old_offset
= $("RROW-" + id
).offsetTop
;
1473 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1475 Element
.show("CEXC-" + active_post_id
);
1478 active_post_id
= id
;
1480 elem
= $("CICD-" + id
);
1482 if (!Element
.visible(elem
)) {
1484 Element
.hide("CEXC-" + id
);
1486 if ($("CWRAP-" + id
).innerHTML
== "") {
1488 $("FUPDPIC-" + id
).src
= "images/indicator_tiny.gif";
1490 $("CWRAP-" + id
).innerHTML
= "<div class=\"insensitive\">" +
1491 __("Loading, please wait...") + "</div>";
1493 var query
= "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id
);
1495 //console.log(query);
1497 new Ajax
.Request("backend.php", {
1499 onComplete: function(transport
) {
1500 $("FUPDPIC-" + id
).src
= 'images/blank_icon.gif';
1502 handle_rpc_json(transport
);
1504 var reply
= JSON
.parse(transport
.responseText
);
1507 var article
= reply
['article']['content'];
1508 var recv_id
= reply
['article']['id'];
1511 $("CWRAP-" + id
).innerHTML
= article
;
1514 $("CWRAP-" + id
).innerHTML
= __("Unable to load article.");
1522 var new_offset
= $("RROW-" + id
).offsetTop
;
1524 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1526 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1527 $("headlines-frame").scrollTop
= new_offset
;
1529 toggleUnread(id
, 0, true);
1533 exception_error("cdmExpandArticle", e
);
1539 function fixHeadlinesOrder(ids
) {
1541 for (var i
= 0; i
< ids
.length
; i
++) {
1542 var e
= $("RROW-" + ids
[i
]);
1546 e
.removeClassName("even");
1547 e
.addClassName("odd");
1549 e
.removeClassName("odd");
1550 e
.addClassName("even");
1555 exception_error("fixHeadlinesOrder", e
);
1559 function getArticleUnderPointer() {
1560 return post_under_pointer
;
1563 function zoomToArticle(event
, id
) {
1565 var cached_article
= cache_find(id
);
1567 if (dijit
.byId("ATAB-" + id
))
1568 if (!event
|| !event
.shiftKey
)
1569 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1571 if (dijit
.byId("ATSTRTIP-" + id
))
1572 dijit
.byId("ATSTRTIP-" + id
).destroyRecursive();
1574 if (cached_article
) {
1575 //closeArticlePanel();
1577 var article_pane
= new dijit
.layout
.ContentPane({
1578 title
: __("Loading...") , content
: cached_article
,
1579 style
: 'padding : 0px;',
1583 dijit
.byId("content-tabs").addChild(article_pane
);
1585 if (!event
|| !event
.shiftKey
)
1586 dijit
.byId("content-tabs").selectChild(article_pane
);
1588 if ($("PTITLE-" + id
))
1589 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1593 var query
= "?op=rpc&subop=getArticles&ids=" + param_escape(id
);
1595 notify_progress("Loading, please wait...", true);
1597 new Ajax
.Request("backend.php", {
1599 onComplete: function(transport
) {
1602 var reply
= JSON
.parse(transport
.responseText
);
1605 //closeArticlePanel();
1607 var content
= reply
[0]['content'];
1609 var article_pane
= new dijit
.layout
.ContentPane({
1610 title
: "article-" + id
, content
: content
,
1611 style
: 'padding : 0px;',
1615 dijit
.byId("content-tabs").addChild(article_pane
);
1617 if (!event
|| !event
.shiftKey
)
1618 dijit
.byId("content-tabs").selectChild(article_pane
);
1620 if ($("PTITLE-" + id
))
1621 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1628 exception_error("zoomToArticle", e
);
1632 function scrollArticle(offset
) {
1635 var ci
= $("content-insert");
1637 ci
.scrollTop
+= offset
;
1640 var hi
= $("headlines-frame");
1642 hi
.scrollTop
+= offset
;
1647 exception_error("scrollArticle", e
);
1651 function show_labels_in_headlines(transport
) {
1653 var data
= JSON
.parse(transport
.responseText
);
1656 data
['info-for-headlines'].each(function(elem
) {
1657 var ctr
= $("HLLCTR-" + elem
.id
);
1659 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1663 exception_error("show_labels_in_headlines", e
);
1667 function toggleHeadlineActions() {
1669 var e
= $("headlineActionsBody");
1670 var p
= $("headlineActionsDrop");
1672 if (!Element
.visible(e
)) {
1679 e
.style
.left
= (p
.offsetLeft
+ 1) + "px";
1680 e
.style
.top
= (p
.offsetTop
+ p
.offsetHeight
+ 2) + "px";
1683 exception_error("toggleHeadlineActions", e
);
1687 /* function publishWithNote(id, def_note) {
1689 if (!def_note) def_note = '';
1691 var note = prompt(__("Please enter a note for this article:"), def_note);
1693 if (note != undefined) {
1694 togglePub(id, false, false, note);
1698 exception_error("publishWithNote", e);
1702 function emailArticle(id
) {
1705 var ids
= getSelectedArticleIds2();
1707 if (ids
.length
== 0) {
1708 alert(__("No articles are selected."));
1712 id
= ids
.toString();
1715 if (dijit
.byId("emailArticleDlg"))
1716 dijit
.byId("emailArticleDlg").destroyRecursive();
1718 var query
= "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id
);
1720 dialog
= new dijit
.Dialog({
1721 id
: "emailArticleDlg",
1722 title
: __("Forward article by email"),
1723 style
: "width: 600px",
1724 execute: function() {
1725 if (this.validate()) {
1727 new Ajax
.Request("backend.php", {
1728 parameters
: dojo
.objectToQuery(this.attr('value')),
1729 onComplete: function(transport
) {
1731 var reply
= JSON
.parse(transport
.responseText
);
1733 var error
= reply
['error'];
1736 alert(__('Error sending email:') + ' ' + error
);
1738 notify_info('Your message has been sent.');
1747 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1748 dojo
.disconnect(tmph
);
1750 new Ajax
.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
1751 "backend.php?op=rpc&subop=completeEmails",
1752 { tokens
: '', paramName
: "search" });
1757 /* displayDlg('emailArticle', id,
1759 document.forms['article_email_form'].destination.focus();
1761 new Ajax.Autocompleter('destination', 'destination_choices',
1762 "backend.php?op=rpc&subop=completeEmails",
1763 { tokens: '', paramName: "search" });
1768 exception_error("emailArticle", e
);
1772 function dismissArticle(id
) {
1774 var elem
= $("RROW-" + id
);
1776 toggleUnread(id
, 0, true);
1778 new Effect
.Fade(elem
, {duration
: 0.5});
1780 active_post_id
= false;
1783 exception_error("dismissArticle", e
);
1787 function dismissSelectedArticles() {
1790 var ids
= getVisibleArticleIds();
1794 for (var i
= 0; i
< ids
.length
; i
++) {
1795 var elem
= $("RROW-" + ids
[i
]);
1797 if (elem
.className
&& elem
.hasClassName("Selected") &&
1798 ids
[i
] != active_post_id
) {
1799 new Effect
.Fade(elem
, {duration
: 0.5});
1807 selectionToggleUnread(false);
1809 fixHeadlinesOrder(tmp
);
1812 exception_error("dismissSelectedArticles", e
);
1816 function dismissReadArticles() {
1819 var ids
= getVisibleArticleIds();
1822 for (var i
= 0; i
< ids
.length
; i
++) {
1823 var elem
= $("RROW-" + ids
[i
]);
1825 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1826 !elem
.hasClassName("Selected")) {
1828 new Effect
.Fade(elem
, {duration
: 0.5});
1834 fixHeadlinesOrder(tmp
);
1837 exception_error("dismissSelectedArticles", e
);
1841 function getVisibleArticleIds() {
1846 getLoadedArticleIds().each(function(id
) {
1847 var elem
= $("RROW-" + id
);
1848 if (elem
&& Element
.visible(elem
))
1853 exception_error("getVisibleArticleIds", e
);
1859 function cdmClicked(event
, id
) {
1861 var shift_key
= event
.shiftKey
;
1865 if (!event
.ctrlKey
) {
1867 if (!getInitParam("cdm_expanded")) {
1868 return cdmExpandArticle(id
);
1871 selectArticles("none");
1874 var elem
= $("RROW-" + id
);
1877 elem
.removeClassName("Unread");
1879 var upd_img_pic
= $("FUPDPIC-" + id
);
1881 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1882 upd_img_pic
.src
.match("fresh_sign.png"))) {
1884 upd_img_pic
.src
= "images/blank_icon.gif";
1887 active_post_id
= id
;
1889 var query
= "?op=rpc&subop=catchupSelected" +
1890 "&cmode=0&ids=" + param_escape(id
);
1892 new Ajax
.Request("backend.php", {
1894 onComplete: function(transport
) {
1895 handle_rpc_json(transport
);
1902 toggleSelected(id
, true);
1903 toggleUnread(id
, 0, false);
1904 zoomToArticle(event
, id
);
1908 exception_error("cdmClicked");
1914 function postClicked(event
, id
) {
1917 if (!event
.ctrlKey
) {
1920 postOpenInNewTab(event
, id
);
1925 exception_error("postClicked");
1929 function hlOpenInNewTab(event
, id
) {
1930 toggleUnread(id
, 0, false);
1931 zoomToArticle(event
, id
);
1934 function postOpenInNewTab(event
, id
) {
1935 closeArticlePanel(id
);
1936 zoomToArticle(event
, id
);
1939 function hlClicked(event
, id
) {
1941 if (event
.which
== 2) {
1944 } else if (event
.altKey
) {
1945 openArticleInNewWindow(id
);
1946 } else if (!event
.ctrlKey
) {
1951 toggleUnread(id
, 0, false);
1952 zoomToArticle(event
, id
);
1957 exception_error("hlClicked");
1961 function getFirstVisibleHeadlineId() {
1962 var rows
= getVisibleArticleIds();
1967 function getLastVisibleHeadlineId() {
1968 var rows
= getVisibleArticleIds();
1969 return rows
[rows
.length
-1];
1972 function openArticleInNewWindow(id
) {
1973 toggleUnread(id
, 0, false);
1974 window
.open("backend.php?op=la&id=" + id
);
1977 function isCdmMode() {
1978 return getInitParam("combined_display_mode");
1981 function markHeadline(id
) {
1982 var row
= $("RROW-" + id
);
1984 var check
= $("RCHK-" + id
);
1987 check
.checked
= true;
1990 row
.addClassName("Selected");
1994 function getRelativePostIds(id
, limit
) {
2000 if (!limit
) limit
= 3;
2002 var ids
= getVisibleArticleIds();
2004 for (var i
= 0; i
< ids
.length
; i
++) {
2006 for (var k
= 1; k
<= limit
; k
++) {
2007 if (i
> k
-1) tmp
.push(ids
[i
-k
]);
2008 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
2015 exception_error("getRelativePostIds", e
);
2021 function correctHeadlinesOffset(id
) {
2025 var container
= $("headlines-frame");
2026 var row
= $("RROW-" + id
);
2028 var viewport
= container
.offsetHeight
;
2030 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
2031 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
2033 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
2034 //console.log("Vport: " + viewport);
2036 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
2037 container
.scrollTop
= row
.offsetTop
;
2038 } else if (rel_offset_bottom
> viewport
) {
2040 /* doesn't properly work with Opera in some cases because
2041 Opera fucks up element scrolling */
2043 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
2047 exception_error("correctHeadlinesOffset", e
);
2052 function headlineActionsChange(elem
) {
2055 elem
.attr('value', 'false');
2057 exception_error("headlineActionsChange", e
);
2061 function closeArticlePanel() {
2063 var tabs
= dijit
.byId("content-tabs");
2064 var child
= tabs
.selectedChildWidget
;
2066 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
2067 tabs
.removeChild(child
);
2070 if (dijit
.byId("content-insert"))
2071 dijit
.byId("headlines-wrap-inner").removeChild(
2072 dijit
.byId("content-insert"));
2076 function initHeadlinesMenu() {
2078 if (dijit
.byId("headlinesMenu"))
2079 dijit
.byId("headlinesMenu").destroyRecursive();
2084 nodes
= $$("#headlines-frame > div[id*=RROW]");
2086 nodes
= $$("#headlines-frame span[id*=RTITLE]");
2089 nodes
.each(function(node
) {
2093 var menu
= new dijit
.Menu({
2094 id
: "headlinesMenu",
2098 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
2099 var callerNode
= event
.target
, match
= null, tries
= 0;
2101 while (match
== null && callerNode
&& tries
<= 3) {
2102 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
2103 callerNode
= callerNode
.parentNode
;
2107 if (match
) this.callerRowId
= parseInt(match
[1]);
2111 /* if (!isCdmMode())
2112 menu.addChild(new dijit.MenuItem({
2113 label: __("View article"),
2114 onClick: function(event) {
2115 view(this.getParent().callerRowId);
2118 menu
.addChild(new dijit
.MenuItem({
2119 label
: __("Open original article"),
2120 onClick: function(event
) {
2121 openArticleInNewWindow(this.getParent().callerRowId
);
2124 menu
.addChild(new dijit
.MenuItem({
2125 label
: __("View in a tt-rss tab"),
2126 onClick: function(event
) {
2127 hlOpenInNewTab(event
, this.getParent().callerRowId
);
2130 // menu.addChild(new dijit.MenuSeparator());
2132 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
2136 menu
.addChild(new dijit
.MenuSeparator());
2138 var labelAddMenu
= new dijit
.Menu({ownerMenu
: menu
});
2139 var labelDelMenu
= new dijit
.Menu({ownerMenu
: menu
});
2141 labels
.each(function(label
) {
2142 var id
= label
.id
[0];
2143 var bare_id
= id
.substr(id
.indexOf(":")+1);
2144 var name
= label
.name
[0];
2146 bare_id
= -11-bare_id
;
2148 labelAddMenu
.addChild(new dijit
.MenuItem({
2151 onClick: function(event
) {
2152 selectionAssignLabel(this.labelId
,
2153 [this.getParent().ownerMenu
.callerRowId
]);
2156 labelDelMenu
.addChild(new dijit
.MenuItem({
2159 onClick: function(event
) {
2160 selectionRemoveLabel(this.labelId
,
2161 [this.getParent().ownerMenu
.callerRowId
]);
2166 menu
.addChild(new dijit
.PopupMenuItem({
2167 label
: __("Assign label"),
2168 popup
: labelAddMenu
,
2171 menu
.addChild(new dijit
.PopupMenuItem({
2172 label
: __("Remove label"),
2173 popup
: labelDelMenu
,
2181 exception_error("initHeadlinesMenu", e
);
2185 function tweetArticle(id
) {
2187 var query
= "?op=rpc&subop=getTweetInfo&id=" + param_escape(id
);
2192 var ts
= d
.getTime();
2194 var w
= window
.open('backend.php?op=loading', 'ttrss_tweet',
2195 "status=0,toolbar=0,location=0,width=500,height=400,scrollbars=1,menubar=0");
2197 new Ajax
.Request("backend.php", {
2199 onComplete: function(transport
) {
2200 var ti
= JSON
.parse(transport
.responseText
);
2202 var share_url
= "http://twitter.com/share?_=" + ts
+
2203 "&text=" + param_escape(ti
.title
) +
2204 "&url=" + param_escape(ti
.link
);
2206 w
.location
.href
= share_url
;
2212 exception_error("tweetArticle", e
);
2216 function editArticleNote(id
) {
2219 var query
= "backend.php?op=dlg&id=editArticleNote¶m=" + param_escape(id
);
2221 if (dijit
.byId("editNoteDlg"))
2222 dijit
.byId("editNoteDlg").destroyRecursive();
2224 dialog
= new dijit
.Dialog({
2226 title
: __("Edit article note"),
2227 style
: "width: 600px",
2228 execute: function() {
2229 if (this.validate()) {
2230 var query
= dojo
.objectToQuery(this.attr('value'));
2232 notify_progress("Saving article note...", true);
2234 new Ajax
.Request("backend.php", {
2236 onComplete: function(transport
) {
2240 var reply
= JSON
.parse(transport
.responseText
);
2242 cache_invalidate(id
);
2244 var elem
= $("POSTNOTE-" + id
);
2248 elem
.innerHTML
= reply
.note
;
2250 if (reply
.raw_length
!= 0)
2251 new Effect
.Appear(elem
);
2263 exception_error("editArticleNote", e
);
2267 function player(elem
) {
2268 var aid
= elem
.getAttribute("audio-id");
2269 var status
= elem
.getAttribute("status");
2277 elem
.innerHTML
= __("Playing...");
2278 elem
.title
= __("Click to pause");
2279 elem
.addClassName("playing");
2283 elem
.innerHTML
= __("Play");
2284 elem
.title
= __("Click to play");
2285 elem
.removeClassName("playing");
2288 elem
.setAttribute("status", status
);
2290 alert("Your browser doesn't seem to support HTML5 audio.");