]>
git.wh0rd.org - tt-rss.git/blob - js/viewfeed.js
1 var article_cache
= new Array();
3 var _active_article_id
= 0;
5 var vgroup_last_feed
= false;
6 var post_under_pointer
= false;
8 var last_requested_article
= false;
10 var catchup_id_batch
= [];
11 var catchup_timeout_id
= false;
13 var cids_requested
= [];
14 var loaded_article_ids
= [];
15 var _last_headlines_update
= 0;
17 var has_storage
= 'sessionStorage' in window
&& window
['sessionStorage'] !== null;
19 function headlines_callback2(transport
, offset
, background
, infscroll_req
) {
21 handle_rpc_json(transport
);
23 loading_set_progress(25);
25 console
.log("headlines_callback2 [offset=" + offset
+ "] B:" + background
+ " I:" + infscroll_req
);
33 reply
= JSON
.parse(transport
.responseText
);
40 is_cat
= reply
['headlines']['is_cat'];
41 feed_id
= reply
['headlines']['id'];
44 var content
= reply
['headlines']['content'];
46 if (getInitParam("cdm_auto_catchup") == 1) {
47 content
= content
+ "<div id='headlines-spacer'></div>";
52 if (feed_id
!= getActiveFeedId() || is_cat
!= activeFeedIsCat())
55 /* dijit.getEnclosingWidget(
56 document.forms["main_toolbar_form"].update).attr('disabled',
57 is_cat || feed_id <= 0); */
60 if (infscroll_req
== false) {
61 $("headlines-frame").scrollTop
= 0;
65 var headlines_count
= reply
['headlines-info']['count'];
67 vgroup_last_feed
= reply
['headlines-info']['vgroup_last_feed'];
69 if (parseInt(headlines_count
) < 30) {
70 _infscroll_disable
= 1;
72 _infscroll_disable
= 0;
75 var counters
= reply
['counters'];
76 var articles
= reply
['articles'];
77 //var runtime_info = reply['runtime-info'];
79 if (infscroll_req
== false) {
80 loaded_article_ids
= [];
82 dijit
.byId("headlines-frame").attr('content',
83 reply
['headlines']['content']);
85 dijit
.byId("headlines-toolbar").attr('content',
86 reply
['headlines']['toolbar']);
88 $$("#headlines-frame > div[id*=RROW]").each(function(row
) {
89 if (loaded_article_ids
.indexOf(row
.id
) != -1) {
90 row
.parentNode
.removeChild(row
);
92 loaded_article_ids
.push(row
.id
);
96 if (getInitParam("cdm_auto_catchup") == 1) {
97 var hsp
= $("headlines-spacer");
98 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
99 dijit
.byId('headlines-frame').domNode
.appendChild(hsp
);
105 $("feed_title").innerHTML
+= "<span id='cancel_search'>" +
106 " (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" +
112 if (headlines_count
> 0 && feed_id
== getActiveFeedId() && is_cat
== activeFeedIsCat()) {
113 console
.log("adding some more headlines: " + headlines_count
);
115 var c
= dijit
.byId("headlines-frame");
116 var ids
= getSelectedArticleIds2();
119 $("headlines-tmp").innerHTML
= reply
['headlines']['content'];
121 var hsp
= $("headlines-spacer");
124 c
.domNode
.removeChild(hsp
);
126 $$("#headlines-tmp > div").each(function(row
) {
127 if (row
.className
== 'cdmFeedTitle') {
128 row
.style
.display
= 'none';
129 c
.domNode
.appendChild(row
);
131 } else if (loaded_article_ids
.indexOf(row
.id
) == -1) {
132 row
.style
.display
= 'none';
133 c
.domNode
.appendChild(row
);
135 loaded_article_ids
.push(row
.id
);
137 row
.parentNode
.removeChild(row
);
141 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
143 fixHeadlinesOrder(getLoadedArticleIds());
145 if (getInitParam("cdm_auto_catchup") == 1) {
146 c
.domNode
.appendChild(hsp
);
149 console
.log("added " + new_elems
.size() + " headlines");
151 if (new_elems
.size() == 0)
152 _infscroll_disable
= true;
154 console
.log("restore selected ids: " + ids
);
156 for (var i
= 0; i
< ids
.length
; i
++) {
157 markHeadline(ids
[i
]);
162 new_elems
.each(function(child
) {
163 dojo
.parser
.parse(child
);
165 if (!Element
.visible(child
))
166 new Effect
.Appear(child
, { duration
: 0.5 });
170 console
.log("no new headlines received");
172 var hsp
= $("headlines-spacer");
174 if (hsp
) hsp
.innerHTML
= "";
179 for (var i
= 0; i
< articles
.length
; i
++) {
180 var a_id
= articles
[i
]['id'];
181 cache_set("article:" + a_id
, articles
[i
]['content']);
184 console
.log("no cached articles received");
188 parse_counters(counters
);
190 request_counters(true);
192 } else if (transport
.responseText
) {
193 console
.error("Invalid object received: " + transport
.responseText
);
194 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
195 __('Could not update headlines (invalid object received - see error console for details)') +
198 //notify_error("Error communicating with server.");
199 Element
.show(dijit
.byId("net-alert").domNode
);
202 _infscroll_request_sent
= 0;
203 _last_headlines_update
= new Date().getTime();
205 unpackVisibleHeadlines();
207 // if we have some more space in the buffer, why not try to fill it
209 if (!_infscroll_disable
&& $("headlines-spacer") &&
210 $("headlines-spacer").offsetTop
< $("headlines-frame").offsetHeight
) {
212 window
.setTimeout(function() {
220 exception_error("headlines_callback2", e
, transport
);
224 function render_article(article
) {
226 dijit
.byId("headlines-wrap-inner").addChild(
227 dijit
.byId("content-insert"));
229 var c
= dijit
.byId("content-insert");
232 c
.domNode
.scrollTop
= 0;
235 c
.attr('content', article
);
237 correctHeadlinesOffset(getActiveArticleId());
244 exception_error("render_article", e
);
248 function showArticleInHeadlines(id
, noexpand
) {
251 selectArticles("none");
253 var crow
= $("RROW-" + id
);
257 var article_is_unread
= crow
.hasClassName("Unread");
260 crow
.removeClassName("Unread");
261 crow
.addClassName("active");
263 selectArticles('none');
265 var view_mode
= false;
268 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
269 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
276 if (article_is_unread
&& !noexpand
)
277 _force_scheduled_update
= true;
280 exception_error("showArticleInHeadlines", e
);
284 function article_callback2(transport
, id
) {
286 console
.log("article_callback2 " + id
);
288 handle_rpc_json(transport
);
293 reply
= JSON
.parse(transport
.responseText
);
300 reply
.each(function(article
) {
301 if (getActiveArticleId() == article
['id']) {
302 render_article(article
['content']);
304 cids_requested
.remove(article
['id']);
306 cache_set("article:" + article
['id'], article
['content']);
309 // if (id != last_requested_article) {
310 // console.log("requested article id is out of sequence, aborting");
314 } else if (transport
.responseText
) {
315 console
.error("Invalid object received: " + transport
.responseText
);
317 render_article("<div class='whiteBox'>" +
318 __('Could not display article (invalid object received - see error console for details)') + "</div>");
320 Element
.show(dijit
.byId("net-alert").domNode
);
323 var unread_in_buffer
= $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
324 request_counters(unread_in_buffer
== 0);
326 //headlines_scroll_handler($("headlines-frame"));
329 if (!_infscroll_disable &&
330 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
340 exception_error("article_callback2", e
, transport
);
344 function view(id
, activefeed
, noexpand
) {
346 var oldrow
= $("RROW-" + getActiveArticleId());
347 if (oldrow
) oldrow
.removeClassName("active");
349 var crow
= $("RROW-" + id
);
353 setActiveArticleId(id
);
354 showArticleInHeadlines(id
, noexpand
);
358 console
.log("loading article: " + id
);
360 var cached_article
= cache_get("article:" + id
);
362 console
.log("cache check result: " + (cached_article
!= false));
364 var query
= "?op=article&method=view&id=" + param_escape(id
);
366 var neighbor_ids
= getRelativePostIds(id
);
368 /* only request uncached articles */
370 var cids_to_request
= [];
372 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
373 if (cids_requested
.indexOf(neighbor_ids
[i
]) == -1)
374 if (!cache_get("article:" + neighbor_ids
[i
])) {
375 cids_to_request
.push(neighbor_ids
[i
]);
376 cids_requested
.push(neighbor_ids
[i
]);
380 console
.log("additional ids: " + cids_to_request
.toString());
382 query
= query
+ "&cids=" + cids_to_request
.toString();
384 var article_is_unread
= crow
.hasClassName("Unread");
386 setActiveArticleId(id
);
387 showArticleInHeadlines(id
);
389 if (cached_article
&& article_is_unread
) {
391 query
= query
+ "&mode=prefetch";
393 render_article(cached_article
);
395 } else if (cached_article
) {
397 query
= query
+ "&mode=prefetch_old";
398 render_article(cached_article
);
400 // if we don't need to request any relative ids, we might as well skip
401 // the server roundtrip altogether
402 if (cids_to_request
.length
== 0) {
405 if (!_infscroll_disable &&
406 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
414 //headlines_scroll_handler($("headlines-frame"));
420 last_requested_article
= id
;
424 if (article_is_unread
) {
425 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
428 new Ajax
.Request("backend.php", {
430 onComplete: function(transport
) {
431 article_callback2(transport
, id
);
437 exception_error("view", e
);
441 function toggleMark(id
, client_only
) {
443 var query
= "?op=rpc&id=" + id
+ "&method=mark";
445 var row
= $("RROW-" + id
);
448 var imgs
= row
.getElementsByClassName("markedPic");
450 for (i
= 0; i
< imgs
.length
; i
++) {
453 if (!row
.hasClassName("marked")) {
454 img
.src
= img
.src
.replace("mark_unset", "mark_set");
455 img
.alt
= __("Unstar article");
456 query
= query
+ "&mark=1";
458 img
.src
= img
.src
.replace("mark_set", "mark_unset");
459 img
.alt
= __("Star article");
460 query
= query
+ "&mark=0";
464 row
.toggleClassName("marked");
467 new Ajax
.Request("backend.php", {
469 onComplete: function(transport
) {
470 handle_rpc_json(transport
);
475 exception_error("toggleMark", e
);
479 function togglePub(id
, client_only
, no_effects
, note
) {
481 var query
= "?op=rpc&id=" + id
+ "&method=publ";
483 if (note
!= undefined) {
484 query
= query
+ "¬e=" + param_escape(note
);
486 query
= query
+ "¬e=undefined";
489 var row
= $("RROW-" + id
);
492 var imgs
= row
.getElementsByClassName("pubPic");
494 for (i
= 0; i
< imgs
.length
; i
++) {
497 if (!row
.hasClassName("published") || note
!= undefined) {
498 img
.src
= img
.src
.replace("pub_unset", "pub_set");
499 img
.alt
= __("Unpublish article");
500 query
= query
+ "&pub=1";
502 img
.src
= img
.src
.replace("pub_set", "pub_unset");
503 img
.alt
= __("Publish article");
504 query
= query
+ "&pub=0";
508 if (note
!= undefined)
509 row
.addClassName("published");
511 row
.toggleClassName("published");
514 new Ajax
.Request("backend.php", {
516 onComplete: function(transport
) {
517 handle_rpc_json(transport
);
522 exception_error("togglePub", e
);
526 function moveToPost(mode
, noscroll
, noexpand
) {
530 var rows
= getVisibleArticleIds();
535 if (!$('RROW-' + getActiveArticleId())) {
536 setActiveArticleId(0);
539 if (!getActiveArticleId()) {
541 prev_id
= rows
[rows
.length
-1]
543 for (var i
= 0; i
< rows
.length
; i
++) {
544 if (rows
[i
] == getActiveArticleId()) {
546 // Account for adjacent identical article ids.
547 if (i
> 0) prev_id
= rows
[i
-1];
549 for (var j
= i
+1; j
< rows
.length
; j
++) {
550 if (rows
[j
] != getActiveArticleId()) {
560 if (mode
== "next") {
561 if (next_id
|| getActiveArticleId()) {
564 var article
= $("RROW-" + getActiveArticleId());
565 var ctr
= $("headlines-frame");
567 if (!noscroll
&& article
&& article
.offsetTop
+ article
.offsetHeight
>
568 ctr
.scrollTop
+ ctr
.offsetHeight
) {
570 scrollArticle(ctr
.offsetHeight
/4);
572 } else if (next_id
) {
573 cdmExpandArticle(next_id
, noexpand
);
574 cdmScrollToArticleId(next_id
, true);
577 } else if (next_id
) {
578 correctHeadlinesOffset(next_id
);
579 view(next_id
, getActiveFeedId(), noexpand
);
584 if (mode
== "prev") {
585 if (prev_id
|| getActiveArticleId()) {
588 var article
= $("RROW-" + getActiveArticleId());
589 var prev_article
= $("RROW-" + prev_id
);
590 var ctr
= $("headlines-frame");
592 if (!getInitParam("cdm_expanded")) {
594 if (!noscroll
&& article
.offsetTop
< ctr
.scrollTop
) {
595 scrollArticle(-ctr
.offsetHeight
/4);
597 cdmExpandArticle(prev_id
, noexpand
);
598 cdmScrollToArticleId(prev_id
, true);
602 if (!noscroll
&& article
&& article
.offsetTop
< ctr
.scrollTop
) {
603 scrollArticle(-ctr
.offsetHeight
/3);
604 } else if (!noscroll
&& prev_article
&&
605 prev_article
.offsetTop
< ctr
.scrollTop
) {
606 cdmExpandArticle(prev_id
, noexpand
);
607 scrollArticle(-ctr
.offsetHeight
/4);
608 } else if (prev_id
) {
609 cdmExpandArticle(prev_id
, noexpand
);
610 cdmScrollToArticleId(prev_id
, noscroll
);
614 } else if (prev_id
) {
615 correctHeadlinesOffset(prev_id
);
616 view(prev_id
, getActiveFeedId(), noexpand
);
622 exception_error("moveToPost", e
);
626 function toggleSelected(id
, force_on
) {
628 var row
= $("RROW-" + id
);
631 var cb
= dijit
.getEnclosingWidget(
632 row
.getElementsByClassName("rchk")[0]);
634 if (row
.hasClassName('Selected') && !force_on
) {
635 row
.removeClassName('Selected');
636 if (cb
) cb
.attr("checked", false);
638 row
.addClassName('Selected');
639 if (cb
) cb
.attr("checked", true);
643 exception_error("toggleSelected", e
);
647 function toggleUnread_afh(effect
) {
650 var elem
= effect
.element
;
651 elem
.style
.backgroundColor
= "";
654 exception_error("toggleUnread_afh", e
);
658 function toggleUnread(id
, cmode
, effect
) {
661 var row
= $("RROW-" + id
);
663 if (cmode
== undefined || cmode
== 2) {
664 if (row
.hasClassName("Unread")) {
665 row
.removeClassName("Unread");
668 row
.addClassName("Unread");
671 } else if (cmode
== 0) {
673 row
.removeClassName("Unread");
675 } else if (cmode
== 1) {
676 row
.addClassName("Unread");
679 if (cmode
== undefined) cmode
= 2;
681 var query
= "?op=rpc&method=catchupSelected" +
682 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
684 // notify_progress("Loading, please wait...");
686 new Ajax
.Request("backend.php", {
688 onComplete: function(transport
) {
689 handle_rpc_json(transport
);
695 exception_error("toggleUnread", e
);
699 function selectionRemoveLabel(id
, ids
) {
702 if (!ids
) ids
= getSelectedArticleIds2();
704 if (ids
.length
== 0) {
705 alert(__("No articles are selected."));
709 var query
= "?op=article&method=removeFromLabel&ids=" +
710 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
714 new Ajax
.Request("backend.php", {
716 onComplete: function(transport
) {
717 handle_rpc_json(transport
);
718 show_labels_in_headlines(transport
);
722 exception_error("selectionAssignLabel", e
);
727 function selectionAssignLabel(id
, ids
) {
730 if (!ids
) ids
= getSelectedArticleIds2();
732 if (ids
.length
== 0) {
733 alert(__("No articles are selected."));
737 var query
= "?op=article&method=assignToLabel&ids=" +
738 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
742 new Ajax
.Request("backend.php", {
744 onComplete: function(transport
) {
745 handle_rpc_json(transport
);
746 show_labels_in_headlines(transport
);
750 exception_error("selectionAssignLabel", e
);
755 function selectionToggleUnread(set_state
, callback
, no_error
, ids
) {
757 var rows
= ids
? ids
: getSelectedArticleIds2();
759 if (rows
.length
== 0 && !no_error
) {
760 alert(__("No articles are selected."));
764 for (var i
= 0; i
< rows
.length
; i
++) {
765 var row
= $("RROW-" + rows
[i
]);
767 if (set_state
== undefined) {
768 if (row
.hasClassName("Unread")) {
769 row
.removeClassName("Unread");
771 row
.addClassName("Unread");
775 if (set_state
== false) {
776 row
.removeClassName("Unread");
779 if (set_state
== true) {
780 row
.addClassName("Unread");
785 if (rows
.length
> 0) {
789 if (set_state
== undefined) {
791 } else if (set_state
== true) {
793 } else if (set_state
== false) {
797 var query
= "?op=rpc&method=catchupSelected" +
798 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
800 notify_progress("Loading, please wait...");
802 new Ajax
.Request("backend.php", {
804 onComplete: function(transport
) {
805 handle_rpc_json(transport
);
806 if (callback
) callback(transport
);
812 exception_error("selectionToggleUnread", e
);
817 function selectionToggleMarked(sel_state
, callback
, no_error
, ids
) {
820 var rows
= ids
? ids
: getSelectedArticleIds2();
822 if (rows
.length
== 0 && !no_error
) {
823 alert(__("No articles are selected."));
827 for (var i
= 0; i
< rows
.length
; i
++) {
828 toggleMark(rows
[i
], true, true);
831 if (rows
.length
> 0) {
833 var query
= "?op=rpc&method=markSelected&ids=" +
834 param_escape(rows
.toString()) + "&cmode=2";
836 new Ajax
.Request("backend.php", {
838 onComplete: function(transport
) {
839 handle_rpc_json(transport
);
840 if (callback
) callback(transport
);
846 exception_error("selectionToggleMarked", e
);
851 function selectionTogglePublished(sel_state
, callback
, no_error
, ids
) {
854 var rows
= ids
? ids
: getSelectedArticleIds2();
856 if (rows
.length
== 0 && !no_error
) {
857 alert(__("No articles are selected."));
861 for (var i
= 0; i
< rows
.length
; i
++) {
862 togglePub(rows
[i
], true, true);
865 if (rows
.length
> 0) {
867 var query
= "?op=rpc&method=publishSelected&ids=" +
868 param_escape(rows
.toString()) + "&cmode=2";
870 new Ajax
.Request("backend.php", {
872 onComplete: function(transport
) {
873 handle_rpc_json(transport
);
879 exception_error("selectionToggleMarked", e
);
883 function getSelectedArticleIds2() {
887 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
889 rv
.push(child
.id
.replace("RROW-", ""));
895 function getLoadedArticleIds() {
898 var children
= $$("#headlines-frame > div[id*=RROW-]");
900 children
.each(function(child
) {
901 rv
.push(child
.id
.replace("RROW-", ""));
908 // mode = all,none,unread,invert,marked,published
909 function selectArticles(mode
) {
912 var children
= $$("#headlines-frame > div[id*=RROW]");
914 children
.each(function(child
) {
915 var id
= child
.id
.replace("RROW-", "");
917 var cb
= dijit
.getEnclosingWidget(
918 child
.getElementsByClassName("rchk")[0]);
921 child
.addClassName("Selected");
922 if (cb
) cb
.attr("checked", true);
923 } else if (mode
== "unread") {
924 if (child
.hasClassName("Unread")) {
925 child
.addClassName("Selected");
926 if (cb
) cb
.attr("checked", true);
928 child
.removeClassName("Selected");
929 if (cb
) cb
.attr("checked", false);
931 } else if (mode
== "marked") {
932 if (child
.hasClassName("marked")) {
933 child
.addClassName("Selected");
934 if (cb
) cb
.attr("checked", true);
936 child
.removeClassName("Selected");
937 if (cb
) cb
.attr("checked", false);
939 } else if (mode
== "published") {
940 if (child
.hasClassName("published")) {
941 child
.addClassName("Selected");
942 if (cb
) cb
.attr("checked", true);
944 child
.removeClassName("Selected");
945 if (cb
) cb
.attr("checked", false);
948 } else if (mode
== "invert") {
949 if (child
.hasClassName("Selected")) {
950 child
.removeClassName("Selected");
951 if (cb
) cb
.attr("checked", false);
953 child
.addClassName("Selected");
954 if (cb
) cb
.attr("checked", true);
958 child
.removeClassName("Selected");
959 if (cb
) cb
.attr("checked", false);
964 exception_error("selectArticles", e
);
968 function deleteSelection() {
972 var rows
= getSelectedArticleIds2();
974 if (rows
.length
== 0) {
975 alert(__("No articles are selected."));
979 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
982 if (getActiveFeedId() != 0) {
983 str
= ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?" , rows
.length
);
985 str
= ngettext("Delete %d selected article?", "Delete %d selected articles?", rows
.length
);
988 str
= str
.replace("%d", rows
.length
);
989 str
= str
.replace("%s", fn
);
991 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
995 query
= "?op=rpc&method=delete&ids=" + param_escape(rows
);
999 new Ajax
.Request("backend.php", {
1001 onComplete: function(transport
) {
1002 handle_rpc_json(transport
);
1007 exception_error("deleteSelection", e
);
1011 function archiveSelection() {
1015 var rows
= getSelectedArticleIds2();
1017 if (rows
.length
== 0) {
1018 alert(__("No articles are selected."));
1022 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1026 if (getActiveFeedId() != 0) {
1027 str
= ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows
.length
);
1030 str
= ngettext("Move %d archived article back?", "Move %d archived articles back?", rows
.length
);
1032 str
+= " " + __("Please note that unstarred articles might get purged on next feed update.");
1037 str
= str
.replace("%d", rows
.length
);
1038 str
= str
.replace("%s", fn
);
1040 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1044 query
= "?op=rpc&method="+op
+"&ids=" + param_escape(rows
);
1048 for (var i
= 0; i
< rows
.length
; i
++) {
1049 cache_delete("article:" + rows
[i
]);
1052 new Ajax
.Request("backend.php", {
1054 onComplete: function(transport
) {
1055 handle_rpc_json(transport
);
1060 exception_error("archiveSelection", e
);
1064 function catchupSelection() {
1068 var rows
= getSelectedArticleIds2();
1070 if (rows
.length
== 0) {
1071 alert(__("No articles are selected."));
1075 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1077 var str
= ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows
.length
);
1079 str
= str
.replace("%d", rows
.length
);
1080 str
= str
.replace("%s", fn
);
1082 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1086 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1089 exception_error("catchupSelection", e
);
1093 function editArticleTags(id
) {
1094 var query
= "backend.php?op=article&method=editArticleTags¶m=" + param_escape(id
);
1096 if (dijit
.byId("editTagsDlg"))
1097 dijit
.byId("editTagsDlg").destroyRecursive();
1099 dialog
= new dijit
.Dialog({
1101 title
: __("Edit article Tags"),
1102 style
: "width: 600px",
1103 execute: function() {
1104 if (this.validate()) {
1105 var query
= dojo
.objectToQuery(this.attr('value'));
1107 notify_progress("Saving article tags...", true);
1109 new Ajax
.Request("backend.php", {
1111 onComplete: function(transport
) {
1116 var data
= JSON
.parse(transport
.responseText
);
1123 var tags
= $("ATSTR-" + id
);
1124 var tooltip
= dijit
.byId("ATSTRTIP-" + id
);
1126 if (tags
) tags
.innerHTML
= data
.content
;
1127 if (tooltip
) tooltip
.attr('label', data
.content_full
);
1130 exception_error("editArticleTags/inner", e
);
1139 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1140 dojo
.disconnect(tmph
);
1142 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1143 "backend.php?op=article&method=completeTags",
1144 { tokens
: ',', paramName
: "search" });
1151 function cdmScrollToArticleId(id
, force
) {
1153 var ctr
= $("headlines-frame");
1154 var e
= $("RROW-" + id
);
1156 if (!e
|| !ctr
) return;
1158 if (force
|| e
.offsetTop
+e
.offsetHeight
> (ctr
.scrollTop
+ctr
.offsetHeight
) ||
1159 e
.offsetTop
< ctr
.scrollTop
) {
1161 // expanded cdm has a 4px margin now
1162 ctr
.scrollTop
= parseInt(e
.offsetTop
) - 4;
1166 exception_error("cdmScrollToArticleId", e
);
1170 function setActiveArticleId(id
) {
1171 _active_article_id
= id
;
1174 function getActiveArticleId() {
1175 return _active_article_id
;
1178 function postMouseIn(e
, id
) {
1179 post_under_pointer
= id
;
1182 function postMouseOut(id
) {
1183 post_under_pointer
= false;
1186 function unpackVisibleHeadlines() {
1188 if (!isCdmMode()) return;
1190 $$("#headlines-frame > div[id*=RROW]").each(
1192 if (child
.offsetTop
<= $("headlines-frame").scrollTop
+
1193 $("headlines-frame").offsetHeight
) {
1195 var cencw
= $("CENCW-" + child
.id
.replace("RROW-", ""));
1198 cencw
.innerHTML
= htmlspecialchars_decode(cencw
.innerHTML
);
1199 cencw
.setAttribute('id', '');
1200 Element
.show(cencw
);
1207 exception_error("unpackVisibleHeadlines", e
);
1211 function headlines_scroll_handler(e
) {
1213 var hsp
= $("headlines-spacer");
1215 unpackVisibleHeadlines();
1217 if (!_infscroll_disable
) {
1218 if ((hsp
&& e
.scrollTop
+ e
.offsetHeight
>= hsp
.offsetTop
- hsp
.offsetHeight
) ||
1219 (e
.scrollHeight
!= 0 &&
1220 ((e
.scrollTop
+ e
.offsetHeight
) / e
.scrollHeight
>= 0.7))) {
1223 hsp
.innerHTML
= "<img src='images/indicator_tiny.gif'> " +
1224 __("Loading, please wait...");
1226 loadMoreHeadlines();
1231 if (hsp
) hsp
.innerHTML
= "";
1234 if (getInitParam("cdm_auto_catchup") == 1) {
1236 // let's get DOM some time to settle down
1237 var ts
= new Date().getTime();
1238 if (ts
- _last_headlines_update
< 100) return;
1240 $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
1242 if (child
.hasClassName("Unread") && $("headlines-frame").scrollTop
>
1243 (child
.offsetTop
+ child
.offsetHeight
/2)) {
1245 var id
= child
.id
.replace("RROW-", "");
1247 if (catchup_id_batch
.indexOf(id
) == -1)
1248 catchup_id_batch
.push(id
);
1250 //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
1254 if (catchup_id_batch
.length
> 0) {
1255 window
.clearTimeout(catchup_timeout_id
);
1257 if (!_infscroll_request_sent
) {
1258 catchup_timeout_id
= window
.setTimeout('catchupBatchedArticles()',
1265 console
.warn("headlines_scroll_handler: " + e
);
1269 function catchupBatchedArticles() {
1271 if (catchup_id_batch
.length
> 0 && !_infscroll_request_sent
) {
1273 // make a copy of the array
1274 var batch
= catchup_id_batch
.slice();
1275 var query
= "?op=rpc&method=catchupSelected" +
1276 "&cmode=0&ids=" + param_escape(batch
.toString());
1280 new Ajax
.Request("backend.php", {
1282 onComplete: function(transport
) {
1283 handle_rpc_json(transport
);
1285 reply
= JSON
.parse(transport
.responseText
);
1286 var batch
= reply
.ids
;
1288 batch
.each(function(id
) {
1290 var elem
= $("RROW-" + id
);
1291 if (elem
) elem
.removeClassName("Unread");
1292 catchup_id_batch
.remove(id
);
1299 exception_error("catchupBatchedArticles", e
);
1303 function catchupRelativeToArticle(below
, id
) {
1307 if (!id
) id
= getActiveArticleId();
1310 alert(__("No article is selected."));
1314 var visible_ids
= getVisibleArticleIds();
1316 var ids_to_mark
= new Array();
1319 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1320 if (visible_ids
[i
] != id
) {
1321 var e
= $("RROW-" + visible_ids
[i
]);
1323 if (e
&& e
.hasClassName("Unread")) {
1324 ids_to_mark
.push(visible_ids
[i
]);
1331 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1332 if (visible_ids
[i
] != id
) {
1333 var e
= $("RROW-" + visible_ids
[i
]);
1335 if (e
&& e
.hasClassName("Unread")) {
1336 ids_to_mark
.push(visible_ids
[i
]);
1344 if (ids_to_mark
.length
== 0) {
1345 alert(__("No articles found to mark"));
1347 var msg
= ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark
.length
).replace("%d", ids_to_mark
.length
);
1349 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1351 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1352 var e
= $("RROW-" + ids_to_mark
[i
]);
1353 e
.removeClassName("Unread");
1356 var query
= "?op=rpc&method=catchupSelected" +
1357 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1359 new Ajax
.Request("backend.php", {
1361 onComplete: function(transport
) {
1362 handle_rpc_json(transport
);
1369 exception_error("catchupRelativeToArticle", e
);
1373 function cdmCollapseArticle(event
, id
) {
1375 var row
= $("RROW-" + id
);
1376 var elem
= $("CICD-" + id
);
1379 var collapse
= $$("div#RROW-" + id
+
1380 " span[class='collapseBtn']")[0];
1383 Element
.show("CEXC-" + id
);
1384 Element
.hide(collapse
);
1385 row
.removeClassName("active");
1387 markHeadline(id
, false);
1389 if (id
== getActiveArticleId()) {
1390 setActiveArticleId(0);
1393 if (event
) Event
.stop(event
);
1397 exception_error("cdmCollapseArticle", e
);
1401 function cdmUnexpandArticle(event
, id
) {
1403 var row
= $("RROW-" + id
);
1404 var elem
= $("CICD-" + id
);
1407 var collapse
= $$("div#RROW-" + id
+
1408 " span[class='collapseBtn']")[0];
1411 Element
.show("CEXC-" + id
);
1412 Element
.hide(collapse
);
1414 if (event
) Event
.stop(event
);
1418 exception_error("cdmUnexpandArticle", e
);
1422 function cdmExpandArticle(id
, noexpand
) {
1424 console
.log("cdmExpandArticle " + id
);
1426 if (!$("RROW-" + id
)) return false;
1428 var oldrow
= $("RROW-" + getActiveArticleId());
1430 var elem
= $("CICD-" + getActiveArticleId());
1432 if (id
== getActiveArticleId() && Element
.visible(elem
))
1435 selectArticles("none");
1437 var old_offset
= $("RROW-" + id
).offsetTop
;
1439 if (getActiveArticleId() && elem
&& !getInitParam("cdm_expanded")) {
1440 var collapse
= $$("div#RROW-" + getActiveArticleId() +
1441 " span[class='collapseBtn']")[0];
1444 Element
.show("CEXC-" + getActiveArticleId());
1445 Element
.hide(collapse
);
1448 if (oldrow
) oldrow
.removeClassName("active");
1450 setActiveArticleId(id
);
1452 elem
= $("CICD-" + id
);
1454 var collapse
= $$("div#RROW-" + id
+
1455 " span[class='collapseBtn']")[0];
1457 var cencw
= $("CENCW-" + id
);
1459 if (!Element
.visible(elem
) && !noexpand
) {
1461 cencw
.innerHTML
= htmlspecialchars_decode(cencw
.innerHTML
);
1462 cencw
.setAttribute('id', '');
1463 Element
.show(cencw
);
1467 Element
.hide("CEXC-" + id
);
1468 Element
.show(collapse
);
1471 var new_offset
= $("RROW-" + id
).offsetTop
;
1473 if (old_offset
> new_offset
)
1474 $("headlines-frame").scrollTop
-= (old_offset
-new_offset
);
1477 toggleUnread(id
, 0, true);
1479 $("RROW-" + id
).addClassName("active");
1482 exception_error("cdmExpandArticle", e
);
1488 function fixHeadlinesOrder(ids
) {
1490 for (var i
= 0; i
< ids
.length
; i
++) {
1491 var e
= $("RROW-" + ids
[i
]);
1495 e
.removeClassName("even");
1496 e
.addClassName("odd");
1498 e
.removeClassName("odd");
1499 e
.addClassName("even");
1504 exception_error("fixHeadlinesOrder", e
);
1508 function getArticleUnderPointer() {
1509 return post_under_pointer
;
1512 function scrollArticle(offset
) {
1515 var ci
= $("content-insert");
1517 ci
.scrollTop
+= offset
;
1520 var hi
= $("headlines-frame");
1522 hi
.scrollTop
+= offset
;
1527 exception_error("scrollArticle", e
);
1531 function show_labels_in_headlines(transport
) {
1533 var data
= JSON
.parse(transport
.responseText
);
1536 data
['info-for-headlines'].each(function(elem
) {
1537 var ctr
= $("HLLCTR-" + elem
.id
);
1539 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1543 exception_error("show_labels_in_headlines", e
);
1547 function dismissArticle(id
) {
1549 var elem
= $("RROW-" + id
);
1553 toggleUnread(id
, 0, true);
1555 new Effect
.Fade(elem
, {duration
: 0.5});
1557 if (id
== getActiveArticleId()) {
1558 setActiveArticleId(0);
1562 exception_error("dismissArticle", e
);
1566 function dismissSelectedArticles() {
1569 var ids
= getVisibleArticleIds();
1573 for (var i
= 0; i
< ids
.length
; i
++) {
1574 var elem
= $("RROW-" + ids
[i
]);
1576 if (elem
.className
&& elem
.hasClassName("Selected") &&
1577 ids
[i
] != getActiveArticleId()) {
1578 new Effect
.Fade(elem
, {duration
: 0.5});
1586 selectionToggleUnread(false);
1588 fixHeadlinesOrder(tmp
);
1591 exception_error("dismissSelectedArticles", e
);
1595 function dismissReadArticles() {
1598 var ids
= getVisibleArticleIds();
1601 for (var i
= 0; i
< ids
.length
; i
++) {
1602 var elem
= $("RROW-" + ids
[i
]);
1604 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1605 !elem
.hasClassName("Selected")) {
1607 new Effect
.Fade(elem
, {duration
: 0.5});
1613 fixHeadlinesOrder(tmp
);
1616 exception_error("dismissSelectedArticles", e
);
1620 function getVisibleArticleIds() {
1625 getLoadedArticleIds().each(function(id
) {
1626 var elem
= $("RROW-" + id
);
1627 if (elem
&& Element
.visible(elem
))
1632 exception_error("getVisibleArticleIds", e
);
1638 function cdmClicked(event
, id
) {
1640 //var shift_key = event.shiftKey;
1642 if (!event
.ctrlKey
) {
1644 if (!getInitParam("cdm_expanded")) {
1645 return cdmExpandArticle(id
);
1648 var elem
= $("RROW-" + getActiveArticleId());
1650 if (elem
) elem
.removeClassName("active");
1652 selectArticles("none");
1655 var elem
= $("RROW-" + id
);
1656 var article_is_unread
= elem
.hasClassName("Unread");
1658 elem
.removeClassName("Unread");
1659 elem
.addClassName("active");
1661 setActiveArticleId(id
);
1663 if (article_is_unread
) {
1664 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1667 var query
= "?op=rpc&method=catchupSelected" +
1668 "&cmode=0&ids=" + param_escape(id
);
1670 new Ajax
.Request("backend.php", {
1672 onComplete: function(transport
) {
1673 handle_rpc_json(transport
);
1676 return !event
.shiftKey
;
1680 toggleSelected(id
, true);
1682 var elem
= $("RROW-" + id
);
1683 var article_is_unread
= elem
.hasClassName("Unread");
1685 if (article_is_unread
) {
1686 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1689 toggleUnread(id
, 0, false);
1691 openArticleInNewWindow(id
);
1694 var unread_in_buffer
= $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
1695 request_counters(unread_in_buffer
== 0);
1698 exception_error("cdmClicked");
1704 function hlClicked(event
, id
) {
1706 if (event
.which
== 2) {
1709 } else if (event
.ctrlKey
) {
1710 toggleSelected(id
, true);
1711 toggleUnread(id
, 0, false);
1712 openArticleInNewWindow(id
);
1720 exception_error("hlClicked");
1724 function getFirstVisibleHeadlineId() {
1725 var rows
= getVisibleArticleIds();
1730 function getLastVisibleHeadlineId() {
1731 var rows
= getVisibleArticleIds();
1732 return rows
[rows
.length
-1];
1735 function openArticleInNewWindow(id
) {
1736 toggleUnread(id
, 0, false);
1737 window
.open("backend.php?op=article&method=redirect&id=" + id
);
1740 function isCdmMode() {
1741 return getInitParam("combined_display_mode");
1744 function markHeadline(id
, marked
) {
1745 if (marked
== undefined) marked
= true;
1747 var row
= $("RROW-" + id
);
1749 var check
= dijit
.getEnclosingWidget(
1750 row
.getElementsByClassName("rchk")[0]);
1753 check
.attr("checked", marked
);
1757 row
.addClassName("Selected");
1759 row
.removeClassName("Selected");
1763 function getRelativePostIds(id
, limit
) {
1769 if (!limit
) limit
= 6; //3
1771 var ids
= getVisibleArticleIds();
1773 for (var i
= 0; i
< ids
.length
; i
++) {
1775 for (var k
= 1; k
<= limit
; k
++) {
1776 //if (i > k-1) tmp.push(ids[i-k]);
1777 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
1784 exception_error("getRelativePostIds", e
);
1790 function correctHeadlinesOffset(id
) {
1794 var container
= $("headlines-frame");
1795 var row
= $("RROW-" + id
);
1797 if (!container
|| !row
) return;
1799 var viewport
= container
.offsetHeight
;
1801 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
1802 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
1804 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
1805 //console.log("Vport: " + viewport);
1807 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
1808 container
.scrollTop
= row
.offsetTop
;
1809 } else if (rel_offset_bottom
> viewport
) {
1811 /* doesn't properly work with Opera in some cases because
1812 Opera fucks up element scrolling */
1814 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
1818 exception_error("correctHeadlinesOffset", e
);
1823 function headlineActionsChange(elem
) {
1826 elem
.attr('value', 'false');
1828 exception_error("headlineActionsChange", e
);
1832 function closeArticlePanel() {
1834 if (dijit
.byId("content-insert"))
1835 dijit
.byId("headlines-wrap-inner").removeChild(
1836 dijit
.byId("content-insert"));
1839 function initHeadlinesMenu() {
1841 if (dijit
.byId("headlinesMenu"))
1842 dijit
.byId("headlinesMenu").destroyRecursive();
1847 nodes
= $$("#headlines-frame > div[id*=RROW]");
1849 nodes
= $$("#headlines-frame span[id*=RTITLE]");
1852 nodes
.each(function(node
) {
1856 var menu
= new dijit
.Menu({
1857 id
: "headlinesMenu",
1861 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
1862 var callerNode
= event
.target
, match
= null, tries
= 0;
1864 while (match
== null && callerNode
&& tries
<= 3) {
1865 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
1866 callerNode
= callerNode
.parentNode
;
1870 if (match
) this.callerRowId
= parseInt(match
[1]);
1874 /* if (!isCdmMode())
1875 menu.addChild(new dijit.MenuItem({
1876 label: __("View article"),
1877 onClick: function(event) {
1878 view(this.getParent().callerRowId);
1881 menu
.addChild(new dijit
.MenuItem({
1882 label
: __("Open original article"),
1883 onClick: function(event
) {
1884 openArticleInNewWindow(this.getParent().callerRowId
);
1887 menu
.addChild(new dijit
.MenuItem({
1888 label
: __("Display article URL"),
1889 onClick: function(event
) {
1890 displayArticleUrl(this.getParent().callerRowId
);
1893 menu
.addChild(new dijit
.MenuSeparator());
1895 menu
.addChild(new dijit
.MenuItem({
1896 label
: __("Toggle unread"),
1897 onClick: function(event
) {
1898 var ids
= getSelectedArticleIds2();
1900 var id
= this.getParent().callerRowId
+ "";
1901 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1903 selectionToggleUnread(undefined, false, true, ids
);
1906 menu
.addChild(new dijit
.MenuItem({
1907 label
: __("Toggle marked"),
1908 onClick: function(event
) {
1909 var ids
= getSelectedArticleIds2();
1911 var id
= this.getParent().callerRowId
+ "";
1912 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1914 selectionToggleMarked(undefined, false, true, ids
);
1917 menu
.addChild(new dijit
.MenuItem({
1918 label
: __("Toggle published"),
1919 onClick: function(event
) {
1920 var ids
= getSelectedArticleIds2();
1922 var id
= this.getParent().callerRowId
+ "";
1923 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1925 selectionTogglePublished(undefined, false, true, ids
);
1928 menu
.addChild(new dijit
.MenuSeparator());
1930 menu
.addChild(new dijit
.MenuItem({
1931 label
: __("Mark above as read"),
1932 onClick: function(event
) {
1933 catchupRelativeToArticle(0, this.getParent().callerRowId
);
1936 menu
.addChild(new dijit
.MenuItem({
1937 label
: __("Mark below as read"),
1938 onClick: function(event
) {
1939 catchupRelativeToArticle(1, this.getParent().callerRowId
);
1943 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
1947 menu
.addChild(new dijit
.MenuSeparator());
1949 var labelAddMenu
= new dijit
.Menu({ownerMenu
: menu
});
1950 var labelDelMenu
= new dijit
.Menu({ownerMenu
: menu
});
1952 labels
.each(function(label
) {
1953 var id
= label
.id
[0];
1954 var bare_id
= id
.substr(id
.indexOf(":")+1);
1955 var name
= label
.name
[0];
1957 bare_id
= feed_to_label_id(bare_id
);
1959 labelAddMenu
.addChild(new dijit
.MenuItem({
1962 onClick: function(event
) {
1963 var ids
= getSelectedArticleIds2();
1965 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
1967 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1969 selectionAssignLabel(this.labelId
, ids
);
1972 labelDelMenu
.addChild(new dijit
.MenuItem({
1975 onClick: function(event
) {
1976 var ids
= getSelectedArticleIds2();
1978 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
1980 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1982 selectionRemoveLabel(this.labelId
, ids
);
1987 menu
.addChild(new dijit
.PopupMenuItem({
1988 label
: __("Assign label"),
1989 popup
: labelAddMenu
,
1992 menu
.addChild(new dijit
.PopupMenuItem({
1993 label
: __("Remove label"),
1994 popup
: labelDelMenu
,
2002 exception_error("initHeadlinesMenu", e
);
2007 function player(elem
) {
2008 var aid
= elem
.getAttribute("audio-id");
2009 var status
= elem
.getAttribute("status");
2017 elem
.innerHTML
= __("Playing...");
2018 elem
.title
= __("Click to pause");
2019 elem
.addClassName("playing");
2023 elem
.innerHTML
= __("Play");
2024 elem
.title
= __("Click to play");
2025 elem
.removeClassName("playing");
2028 elem
.setAttribute("status", status
);
2030 alert("Your browser doesn't seem to support HTML5 audio.");
2034 function cache_set(id
, obj
) {
2035 //console.log("cache_set: " + id);
2038 sessionStorage
[id
] = obj
;
2040 sessionStorage
.clear();
2044 function cache_get(id
) {
2046 return sessionStorage
[id
];
2049 function cache_clear() {
2051 sessionStorage
.clear();
2054 function cache_delete(id
) {
2056 sessionStorage
.removeItem(id
);
2059 function cancelSearch() {
2064 exception_error("cancelSearch", e
);
2068 function setSelectionScore() {
2070 var ids
= getSelectedArticleIds2();
2072 if (ids
.length
> 0) {
2075 var score
= prompt(__("Please enter new score for selected articles:"), score
);
2077 if (score
!= undefined) {
2078 var query
= "op=article&method=setScore&id=" + param_escape(ids
.toString()) +
2079 "&score=" + param_escape(score
);
2081 new Ajax
.Request("backend.php", {
2083 onComplete: function(transport
) {
2084 var reply
= JSON
.parse(transport
.responseText
);
2088 ids
.each(function(id
) {
2089 var row
= $("RROW-" + id
);
2092 var pic
= row
.getElementsByClassName("hlScorePic")[0];
2095 pic
.src
= pic
.src
.replace(/score_.*?\.png/,
2096 reply
["score_pic"]);
2097 pic
.setAttribute("score", score
);
2106 alert(__("No articles are selected."));
2109 exception_error("setSelectionScore", e
);
2113 function changeScore(id
, pic
) {
2115 var score
= pic
.getAttribute("score");
2117 var new_score
= prompt(__("Please enter new score for this article:"), score
);
2119 if (new_score
!= undefined) {
2121 var query
= "op=article&method=setScore&id=" + param_escape(id
) +
2122 "&score=" + param_escape(new_score
);
2124 new Ajax
.Request("backend.php", {
2126 onComplete: function(transport
) {
2127 var reply
= JSON
.parse(transport
.responseText
);
2130 pic
.src
= pic
.src
.replace(/score_.*?\.png/, reply
["score_pic"]);
2131 pic
.setAttribute("score", new_score
);
2136 exception_error("changeScore", e
);
2140 function displayArticleUrl(id
) {
2142 var query
= "op=rpc&method=getlinktitlebyid&id=" + param_escape(id
);
2144 new Ajax
.Request("backend.php", {
2146 onComplete: function(transport
) {
2147 var reply
= JSON
.parse(transport
.responseText
);
2149 if (reply
&& reply
.link
) {
2150 prompt(__("Article URL:"), reply
.link
);
2154 exception_error("changeScore", e
);
2158 function openSelectedAttachment(elem
) {
2160 var url
= elem
[elem
.selectedIndex
].value
;
2164 elem
.selectedIndex
= 0;
2168 exception_error("openSelectedAttachment", e
);