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 console
.log("headlines_callback2 [offset=" + offset
+ "] B:" + background
+ " I:" + infscroll_req
);
31 reply
= JSON
.parse(transport
.responseText
);
38 is_cat
= reply
['headlines']['is_cat'];
39 feed_id
= reply
['headlines']['id'];
42 var content
= reply
['headlines']['content'];
44 content
= content
+ "<div id='headlines-spacer'></div>";
48 if (feed_id
!= getActiveFeedId() || is_cat
!= activeFeedIsCat())
51 /* dijit.getEnclosingWidget(
52 document.forms["main_toolbar_form"].update).attr('disabled',
53 is_cat || feed_id <= 0); */
56 if (infscroll_req
== false) {
57 $("headlines-frame").scrollTop
= 0;
61 $("headlines-frame").removeClassName("cdm");
62 $("headlines-frame").removeClassName("normal");
64 $("headlines-frame").addClassName(isCdmMode() ? "cdm" : "normal");
66 var headlines_count
= reply
['headlines-info']['count'];
68 vgroup_last_feed
= reply
['headlines-info']['vgroup_last_feed'];
70 if (parseInt(headlines_count
) < 30) {
71 _infscroll_disable
= 1;
73 _infscroll_disable
= 0;
76 var counters
= reply
['counters'];
77 var articles
= reply
['articles'];
78 //var runtime_info = reply['runtime-info'];
80 if (infscroll_req
== false) {
81 loaded_article_ids
= [];
83 dijit
.byId("headlines-frame").attr('content',
84 reply
['headlines']['content']);
86 dijit
.byId("headlines-toolbar").attr('content',
87 reply
['headlines']['toolbar']);
89 $$("#headlines-frame > div[id*=RROW]").each(function(row
) {
90 if (loaded_article_ids
.indexOf(row
.id
) != -1) {
91 row
.parentNode
.removeChild(row
);
93 loaded_article_ids
.push(row
.id
);
97 var hsp
= $("headlines-spacer");
98 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
99 dijit
.byId('headlines-frame').domNode
.appendChild(hsp
);
104 $("feed_title").innerHTML
+= "<span id='cancel_search'>" +
105 " (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" +
111 if (headlines_count
> 0 && feed_id
== getActiveFeedId() && is_cat
== activeFeedIsCat()) {
112 console
.log("adding some more headlines: " + headlines_count
);
114 var c
= dijit
.byId("headlines-frame");
115 var ids
= getSelectedArticleIds2();
118 $("headlines-tmp").innerHTML
= reply
['headlines']['content'];
120 var hsp
= $("headlines-spacer");
123 c
.domNode
.removeChild(hsp
);
125 $$("#headlines-tmp > div").each(function(row
) {
126 if (row
.className
== 'cdmFeedTitle') {
127 row
.style
.display
= 'none';
128 c
.domNode
.appendChild(row
);
130 } else if (loaded_article_ids
.indexOf(row
.id
) == -1) {
131 row
.style
.display
= 'none';
132 c
.domNode
.appendChild(row
);
134 loaded_article_ids
.push(row
.id
);
136 row
.parentNode
.removeChild(row
);
140 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
142 if (getInitParam("cdm_auto_catchup") == 1) {
143 c
.domNode
.appendChild(hsp
);
146 console
.log("added " + new_elems
.size() + " headlines");
148 if (new_elems
.size() == 0)
149 _infscroll_disable
= true;
151 console
.log("restore selected ids: " + ids
);
153 for (var i
= 0; i
< ids
.length
; i
++) {
154 markHeadline(ids
[i
]);
159 new_elems
.each(function(child
) {
160 dojo
.parser
.parse(child
);
162 if (!Element
.visible(child
))
163 new Effect
.Appear(child
, { duration
: 0.5 });
167 console
.log("no new headlines received");
169 var hsp
= $("headlines-spacer");
171 if (hsp
) hsp
.innerHTML
= "";
176 for (var i
= 0; i
< articles
.length
; i
++) {
177 var a_id
= articles
[i
]['id'];
178 cache_set("article:" + a_id
, articles
[i
]['content']);
181 console
.log("no cached articles received");
185 parse_counters(counters
);
187 request_counters(true);
189 } else if (transport
.responseText
) {
190 console
.error("Invalid object received: " + transport
.responseText
);
191 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
192 __('Could not update headlines (invalid object received - see error console for details)') +
195 //notify_error("Error communicating with server.");
196 Element
.show(dijit
.byId("net-alert").domNode
);
199 _infscroll_request_sent
= 0;
200 _last_headlines_update
= new Date().getTime();
202 unpackVisibleHeadlines();
204 // if we have some more space in the buffer, why not try to fill it
206 if (!_infscroll_disable
&& $("headlines-spacer") &&
207 $("headlines-spacer").offsetTop
< $("headlines-frame").offsetHeight
) {
209 window
.setTimeout(function() {
217 exception_error("headlines_callback2", e
, transport
);
221 function render_article(article
) {
223 dijit
.byId("headlines-wrap-inner").addChild(
224 dijit
.byId("content-insert"));
226 var c
= dijit
.byId("content-insert");
229 c
.domNode
.scrollTop
= 0;
232 PluginHost
.run(PluginHost
.HOOK_ARTICLE_RENDERED
, article
);
234 c
.attr('content', article
);
236 correctHeadlinesOffset(getActiveArticleId());
243 exception_error("render_article", e
);
247 function showArticleInHeadlines(id
, noexpand
) {
250 selectArticles("none");
252 var crow
= $("RROW-" + id
);
256 var article_is_unread
= crow
.hasClassName("Unread");
259 crow
.removeClassName("Unread");
260 crow
.addClassName("active");
262 selectArticles('none');
264 var view_mode
= false;
267 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
268 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
275 if (article_is_unread
&& !noexpand
)
276 _force_scheduled_update
= true;
279 exception_error("showArticleInHeadlines", e
);
283 function article_callback2(transport
, id
) {
285 console
.log("article_callback2 " + id
);
287 handle_rpc_json(transport
);
292 reply
= JSON
.parse(transport
.responseText
);
299 reply
.each(function(article
) {
300 if (getActiveArticleId() == article
['id']) {
301 render_article(article
['content']);
303 cids_requested
.remove(article
['id']);
305 cache_set("article:" + article
['id'], article
['content']);
308 // if (id != last_requested_article) {
309 // console.log("requested article id is out of sequence, aborting");
313 } else if (transport
.responseText
) {
314 console
.error("Invalid object received: " + transport
.responseText
);
316 render_article("<div class='whiteBox'>" +
317 __('Could not display article (invalid object received - see error console for details)') + "</div>");
319 Element
.show(dijit
.byId("net-alert").domNode
);
322 var unread_in_buffer
= $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
323 request_counters(unread_in_buffer
== 0);
325 //headlines_scroll_handler($("headlines-frame"));
328 if (!_infscroll_disable &&
329 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
339 exception_error("article_callback2", e
, transport
);
343 function view(id
, activefeed
, noexpand
) {
345 var oldrow
= $("RROW-" + getActiveArticleId());
346 if (oldrow
) oldrow
.removeClassName("active");
348 var crow
= $("RROW-" + id
);
352 setActiveArticleId(id
);
353 showArticleInHeadlines(id
, noexpand
);
357 console
.log("loading article: " + id
);
359 var cached_article
= cache_get("article:" + id
);
361 console
.log("cache check result: " + (cached_article
!= false));
363 var query
= "?op=article&method=view&id=" + param_escape(id
);
365 var neighbor_ids
= getRelativePostIds(id
);
367 /* only request uncached articles */
369 var cids_to_request
= [];
371 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
372 if (cids_requested
.indexOf(neighbor_ids
[i
]) == -1)
373 if (!cache_get("article:" + neighbor_ids
[i
])) {
374 cids_to_request
.push(neighbor_ids
[i
]);
375 cids_requested
.push(neighbor_ids
[i
]);
379 console
.log("additional ids: " + cids_to_request
.toString());
381 query
= query
+ "&cids=" + cids_to_request
.toString();
383 var article_is_unread
= crow
.hasClassName("Unread");
385 setActiveArticleId(id
);
386 showArticleInHeadlines(id
);
388 if (cached_article
&& article_is_unread
) {
390 query
= query
+ "&mode=prefetch";
392 render_article(cached_article
);
394 } else if (cached_article
) {
396 query
= query
+ "&mode=prefetch_old";
397 render_article(cached_article
);
399 // if we don't need to request any relative ids, we might as well skip
400 // the server roundtrip altogether
401 if (cids_to_request
.length
== 0) {
404 if (!_infscroll_disable &&
405 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
413 //headlines_scroll_handler($("headlines-frame"));
419 last_requested_article
= id
;
423 if (article_is_unread
) {
424 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
427 new Ajax
.Request("backend.php", {
429 onComplete: function(transport
) {
430 article_callback2(transport
, id
);
436 exception_error("view", e
);
440 function toggleMark(id
, client_only
) {
442 var query
= "?op=rpc&id=" + id
+ "&method=mark";
444 var row
= $("RROW-" + id
);
447 var imgs
= row
.getElementsByClassName("markedPic");
449 for (i
= 0; i
< imgs
.length
; i
++) {
452 if (!row
.hasClassName("marked")) {
453 img
.src
= img
.src
.replace("mark_unset", "mark_set");
454 img
.alt
= __("Unstar article");
455 query
= query
+ "&mark=1";
457 img
.src
= img
.src
.replace("mark_set", "mark_unset");
458 img
.alt
= __("Star article");
459 query
= query
+ "&mark=0";
463 row
.toggleClassName("marked");
466 new Ajax
.Request("backend.php", {
468 onComplete: function(transport
) {
469 handle_rpc_json(transport
);
474 exception_error("toggleMark", e
);
478 function togglePub(id
, client_only
, no_effects
, note
) {
480 var query
= "?op=rpc&id=" + id
+ "&method=publ";
482 if (note
!= undefined) {
483 query
= query
+ "¬e=" + param_escape(note
);
485 query
= query
+ "¬e=undefined";
488 var row
= $("RROW-" + id
);
491 var imgs
= row
.getElementsByClassName("pubPic");
493 for (i
= 0; i
< imgs
.length
; i
++) {
496 if (!row
.hasClassName("published") || note
!= undefined) {
497 img
.src
= img
.src
.replace("pub_unset", "pub_set");
498 img
.alt
= __("Unpublish article");
499 query
= query
+ "&pub=1";
501 img
.src
= img
.src
.replace("pub_set", "pub_unset");
502 img
.alt
= __("Publish article");
503 query
= query
+ "&pub=0";
507 if (note
!= undefined)
508 row
.addClassName("published");
510 row
.toggleClassName("published");
513 new Ajax
.Request("backend.php", {
515 onComplete: function(transport
) {
516 handle_rpc_json(transport
);
521 exception_error("togglePub", e
);
525 function moveToPost(mode
, noscroll
, noexpand
) {
529 var rows
= getVisibleArticleIds();
534 if (!$('RROW-' + getActiveArticleId())) {
535 setActiveArticleId(0);
538 if (!getActiveArticleId()) {
540 prev_id
= rows
[rows
.length
-1]
542 for (var i
= 0; i
< rows
.length
; i
++) {
543 if (rows
[i
] == getActiveArticleId()) {
545 // Account for adjacent identical article ids.
546 if (i
> 0) prev_id
= rows
[i
-1];
548 for (var j
= i
+1; j
< rows
.length
; j
++) {
549 if (rows
[j
] != getActiveArticleId()) {
559 if (mode
== "next") {
560 if (next_id
|| getActiveArticleId()) {
563 var article
= $("RROW-" + getActiveArticleId());
564 var ctr
= $("headlines-frame");
566 if (!noscroll
&& article
&& article
.offsetTop
+ article
.offsetHeight
>
567 ctr
.scrollTop
+ ctr
.offsetHeight
) {
569 scrollArticle(ctr
.offsetHeight
/4);
571 } else if (next_id
) {
572 cdmExpandArticle(next_id
, noexpand
);
573 cdmScrollToArticleId(next_id
, true);
576 } else if (next_id
) {
577 correctHeadlinesOffset(next_id
);
578 view(next_id
, getActiveFeedId(), noexpand
);
583 if (mode
== "prev") {
584 if (prev_id
|| getActiveArticleId()) {
587 var article
= $("RROW-" + getActiveArticleId());
588 var prev_article
= $("RROW-" + prev_id
);
589 var ctr
= $("headlines-frame");
591 if (!getInitParam("cdm_expanded")) {
593 if (!noscroll
&& article
.offsetTop
< ctr
.scrollTop
) {
594 scrollArticle(-ctr
.offsetHeight
/4);
596 cdmExpandArticle(prev_id
, noexpand
);
597 cdmScrollToArticleId(prev_id
, true);
601 if (!noscroll
&& article
&& article
.offsetTop
< ctr
.scrollTop
) {
602 scrollArticle(-ctr
.offsetHeight
/3);
603 } else if (!noscroll
&& prev_article
&&
604 prev_article
.offsetTop
< ctr
.scrollTop
) {
605 cdmExpandArticle(prev_id
, noexpand
);
606 scrollArticle(-ctr
.offsetHeight
/4);
607 } else if (prev_id
) {
608 cdmExpandArticle(prev_id
, noexpand
);
609 cdmScrollToArticleId(prev_id
, noscroll
);
613 } else if (prev_id
) {
614 correctHeadlinesOffset(prev_id
);
615 view(prev_id
, getActiveFeedId(), noexpand
);
621 exception_error("moveToPost", e
);
625 function toggleSelected(id
, force_on
) {
627 var row
= $("RROW-" + id
);
630 var cb
= dijit
.getEnclosingWidget(
631 row
.getElementsByClassName("rchk")[0]);
633 if (row
.hasClassName('Selected') && !force_on
) {
634 row
.removeClassName('Selected');
635 if (cb
) cb
.attr("checked", false);
637 row
.addClassName('Selected');
638 if (cb
) cb
.attr("checked", true);
642 updateSelectedPrompt();
644 exception_error("toggleSelected", e
);
648 function updateSelectedPrompt() {
650 var count
= getSelectedArticleIds2().size();
651 var elem
= $("selected_prompt");
654 elem
.innerHTML
= ngettext("%d article selected",
655 "%d articles selected", count
).replace("%d", count
);
664 exception_error("updateSelectedPrompt", e
);
668 function toggleUnread_afh(effect
) {
671 var elem
= effect
.element
;
672 elem
.style
.backgroundColor
= "";
675 exception_error("toggleUnread_afh", e
);
679 function toggleUnread(id
, cmode
, effect
) {
682 var row
= $("RROW-" + id
);
684 if (cmode
== undefined || cmode
== 2) {
685 if (row
.hasClassName("Unread")) {
686 row
.removeClassName("Unread");
689 row
.addClassName("Unread");
692 } else if (cmode
== 0) {
694 row
.removeClassName("Unread");
696 } else if (cmode
== 1) {
697 row
.addClassName("Unread");
700 if (cmode
== undefined) cmode
= 2;
702 var query
= "?op=rpc&method=catchupSelected" +
703 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
705 // notify_progress("Loading, please wait...");
707 new Ajax
.Request("backend.php", {
709 onComplete: function(transport
) {
710 handle_rpc_json(transport
);
716 exception_error("toggleUnread", e
);
720 function selectionRemoveLabel(id
, ids
) {
723 if (!ids
) ids
= getSelectedArticleIds2();
725 if (ids
.length
== 0) {
726 alert(__("No articles are selected."));
730 var query
= "?op=article&method=removeFromLabel&ids=" +
731 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
735 new Ajax
.Request("backend.php", {
737 onComplete: function(transport
) {
738 handle_rpc_json(transport
);
739 show_labels_in_headlines(transport
);
743 exception_error("selectionAssignLabel", e
);
748 function selectionAssignLabel(id
, ids
) {
751 if (!ids
) ids
= getSelectedArticleIds2();
753 if (ids
.length
== 0) {
754 alert(__("No articles are selected."));
758 var query
= "?op=article&method=assignToLabel&ids=" +
759 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
763 new Ajax
.Request("backend.php", {
765 onComplete: function(transport
) {
766 handle_rpc_json(transport
);
767 show_labels_in_headlines(transport
);
771 exception_error("selectionAssignLabel", e
);
776 function selectionToggleUnread(set_state
, callback
, no_error
, ids
) {
778 var rows
= ids
? ids
: getSelectedArticleIds2();
780 if (rows
.length
== 0 && !no_error
) {
781 alert(__("No articles are selected."));
785 for (var i
= 0; i
< rows
.length
; i
++) {
786 var row
= $("RROW-" + rows
[i
]);
788 if (set_state
== undefined) {
789 if (row
.hasClassName("Unread")) {
790 row
.removeClassName("Unread");
792 row
.addClassName("Unread");
796 if (set_state
== false) {
797 row
.removeClassName("Unread");
800 if (set_state
== true) {
801 row
.addClassName("Unread");
806 if (rows
.length
> 0) {
810 if (set_state
== undefined) {
812 } else if (set_state
== true) {
814 } else if (set_state
== false) {
818 var query
= "?op=rpc&method=catchupSelected" +
819 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
821 notify_progress("Loading, please wait...");
823 new Ajax
.Request("backend.php", {
825 onComplete: function(transport
) {
826 handle_rpc_json(transport
);
827 if (callback
) callback(transport
);
833 exception_error("selectionToggleUnread", e
);
838 function selectionToggleMarked(sel_state
, callback
, no_error
, ids
) {
841 var rows
= ids
? ids
: getSelectedArticleIds2();
843 if (rows
.length
== 0 && !no_error
) {
844 alert(__("No articles are selected."));
848 for (var i
= 0; i
< rows
.length
; i
++) {
849 toggleMark(rows
[i
], true, true);
852 if (rows
.length
> 0) {
854 var query
= "?op=rpc&method=markSelected&ids=" +
855 param_escape(rows
.toString()) + "&cmode=2";
857 new Ajax
.Request("backend.php", {
859 onComplete: function(transport
) {
860 handle_rpc_json(transport
);
861 if (callback
) callback(transport
);
867 exception_error("selectionToggleMarked", e
);
872 function selectionTogglePublished(sel_state
, callback
, no_error
, ids
) {
875 var rows
= ids
? ids
: getSelectedArticleIds2();
877 if (rows
.length
== 0 && !no_error
) {
878 alert(__("No articles are selected."));
882 for (var i
= 0; i
< rows
.length
; i
++) {
883 togglePub(rows
[i
], true, true);
886 if (rows
.length
> 0) {
888 var query
= "?op=rpc&method=publishSelected&ids=" +
889 param_escape(rows
.toString()) + "&cmode=2";
891 new Ajax
.Request("backend.php", {
893 onComplete: function(transport
) {
894 handle_rpc_json(transport
);
900 exception_error("selectionToggleMarked", e
);
904 function getSelectedArticleIds2() {
908 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
910 rv
.push(child
.id
.replace("RROW-", ""));
916 function getLoadedArticleIds() {
919 var children
= $$("#headlines-frame > div[id*=RROW-]");
921 children
.each(function(child
) {
922 rv
.push(child
.id
.replace("RROW-", ""));
929 // mode = all,none,unread,invert,marked,published
930 function selectArticles(mode
) {
933 var children
= $$("#headlines-frame > div[id*=RROW]");
935 children
.each(function(child
) {
936 var id
= child
.id
.replace("RROW-", "");
938 var cb
= dijit
.getEnclosingWidget(
939 child
.getElementsByClassName("rchk")[0]);
942 child
.addClassName("Selected");
943 if (cb
) cb
.attr("checked", true);
944 } else if (mode
== "unread") {
945 if (child
.hasClassName("Unread")) {
946 child
.addClassName("Selected");
947 if (cb
) cb
.attr("checked", true);
949 child
.removeClassName("Selected");
950 if (cb
) cb
.attr("checked", false);
952 } else if (mode
== "marked") {
953 if (child
.hasClassName("marked")) {
954 child
.addClassName("Selected");
955 if (cb
) cb
.attr("checked", true);
957 child
.removeClassName("Selected");
958 if (cb
) cb
.attr("checked", false);
960 } else if (mode
== "published") {
961 if (child
.hasClassName("published")) {
962 child
.addClassName("Selected");
963 if (cb
) cb
.attr("checked", true);
965 child
.removeClassName("Selected");
966 if (cb
) cb
.attr("checked", false);
969 } else if (mode
== "invert") {
970 if (child
.hasClassName("Selected")) {
971 child
.removeClassName("Selected");
972 if (cb
) cb
.attr("checked", false);
974 child
.addClassName("Selected");
975 if (cb
) cb
.attr("checked", true);
979 child
.removeClassName("Selected");
980 if (cb
) cb
.attr("checked", false);
984 updateSelectedPrompt();
987 exception_error("selectArticles", e
);
991 function deleteSelection() {
995 var rows
= getSelectedArticleIds2();
997 if (rows
.length
== 0) {
998 alert(__("No articles are selected."));
1002 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1005 if (getActiveFeedId() != 0) {
1006 str
= ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?" , rows
.length
);
1008 str
= ngettext("Delete %d selected article?", "Delete %d selected articles?", rows
.length
);
1011 str
= str
.replace("%d", rows
.length
);
1012 str
= str
.replace("%s", fn
);
1014 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1018 query
= "?op=rpc&method=delete&ids=" + param_escape(rows
);
1022 new Ajax
.Request("backend.php", {
1024 onComplete: function(transport
) {
1025 handle_rpc_json(transport
);
1030 exception_error("deleteSelection", e
);
1034 function archiveSelection() {
1038 var rows
= getSelectedArticleIds2();
1040 if (rows
.length
== 0) {
1041 alert(__("No articles are selected."));
1045 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1049 if (getActiveFeedId() != 0) {
1050 str
= ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows
.length
);
1053 str
= ngettext("Move %d archived article back?", "Move %d archived articles back?", rows
.length
);
1055 str
+= " " + __("Please note that unstarred articles might get purged on next feed update.");
1060 str
= str
.replace("%d", rows
.length
);
1061 str
= str
.replace("%s", fn
);
1063 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1067 query
= "?op=rpc&method="+op
+"&ids=" + param_escape(rows
);
1071 for (var i
= 0; i
< rows
.length
; i
++) {
1072 cache_delete("article:" + rows
[i
]);
1075 new Ajax
.Request("backend.php", {
1077 onComplete: function(transport
) {
1078 handle_rpc_json(transport
);
1083 exception_error("archiveSelection", e
);
1087 function catchupSelection() {
1091 var rows
= getSelectedArticleIds2();
1093 if (rows
.length
== 0) {
1094 alert(__("No articles are selected."));
1098 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1100 var str
= ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows
.length
);
1102 str
= str
.replace("%d", rows
.length
);
1103 str
= str
.replace("%s", fn
);
1105 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1109 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1112 exception_error("catchupSelection", e
);
1116 function editArticleTags(id
) {
1117 var query
= "backend.php?op=article&method=editArticleTags¶m=" + param_escape(id
);
1119 if (dijit
.byId("editTagsDlg"))
1120 dijit
.byId("editTagsDlg").destroyRecursive();
1122 dialog
= new dijit
.Dialog({
1124 title
: __("Edit article Tags"),
1125 style
: "width: 600px",
1126 execute: function() {
1127 if (this.validate()) {
1128 var query
= dojo
.objectToQuery(this.attr('value'));
1130 notify_progress("Saving article tags...", true);
1132 new Ajax
.Request("backend.php", {
1134 onComplete: function(transport
) {
1139 var data
= JSON
.parse(transport
.responseText
);
1146 var tags
= $("ATSTR-" + id
);
1147 var tooltip
= dijit
.byId("ATSTRTIP-" + id
);
1149 if (tags
) tags
.innerHTML
= data
.content
;
1150 if (tooltip
) tooltip
.attr('label', data
.content_full
);
1153 exception_error("editArticleTags/inner", e
);
1162 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1163 dojo
.disconnect(tmph
);
1165 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1166 "backend.php?op=article&method=completeTags",
1167 { tokens
: ',', paramName
: "search" });
1174 function cdmScrollToArticleId(id
, force
) {
1176 var ctr
= $("headlines-frame");
1177 var e
= $("RROW-" + id
);
1179 if (!e
|| !ctr
) return;
1181 if (force
|| e
.offsetTop
+e
.offsetHeight
> (ctr
.scrollTop
+ctr
.offsetHeight
) ||
1182 e
.offsetTop
< ctr
.scrollTop
) {
1184 // expanded cdm has a 4px margin now
1185 ctr
.scrollTop
= parseInt(e
.offsetTop
) - 4;
1189 exception_error("cdmScrollToArticleId", e
);
1193 function setActiveArticleId(id
) {
1194 _active_article_id
= id
;
1195 PluginHost
.run(PluginHost
.HOOK_ARTICLE_SET_ACTIVE
, _active_article_id
);
1198 function getActiveArticleId() {
1199 return _active_article_id
;
1202 function postMouseIn(e
, id
) {
1203 post_under_pointer
= id
;
1206 function postMouseOut(id
) {
1207 post_under_pointer
= false;
1210 function unpackVisibleHeadlines() {
1212 if (!isCdmMode()) return;
1214 $$("#headlines-frame > div[id*=RROW]").each(
1216 if (child
.offsetTop
<= $("headlines-frame").scrollTop
+
1217 $("headlines-frame").offsetHeight
) {
1219 var cencw
= $("CENCW-" + child
.id
.replace("RROW-", ""));
1222 PluginHost
.run(PluginHost
.HOOK_ARTICLE_RENDERED_CDM
, child
);
1224 cencw
.innerHTML
= htmlspecialchars_decode(cencw
.innerHTML
);
1225 cencw
.setAttribute('id', '');
1226 Element
.show(cencw
);
1233 exception_error("unpackVisibleHeadlines", e
);
1237 function headlines_scroll_handler(e
) {
1239 var hsp
= $("headlines-spacer");
1241 unpackVisibleHeadlines();
1243 var active_found
= false;
1245 // set topmost child in the buffer as active
1246 if (getInitParam("cdm_auto_catchup") == 1) {
1247 var rows
= $$("#headlines-frame > div[id*=RROW]");
1249 for (var i
= 0; i
< rows
.length
; i
++) {
1250 var child
= rows
[i
];
1252 if (!active_found
&& $("headlines-frame").scrollTop
< child
.offsetTop
) {
1253 active_found
= true;
1255 if (_active_article_id
) {
1256 var row
= $("RROW-" + _active_article_id
);
1257 if (row
) row
.removeClassName("active");
1260 _active_article_id
= child
.id
.replace("RROW-", "");
1261 showArticleInHeadlines(_active_article_id
, true);
1267 if (!_infscroll_disable
) {
1268 if ((hsp
&& e
.scrollTop
+ e
.offsetHeight
>= hsp
.offsetTop
- hsp
.offsetHeight
) ||
1269 (e
.scrollHeight
!= 0 &&
1270 ((e
.scrollTop
+ e
.offsetHeight
) / e
.scrollHeight
>= 0.7))) {
1273 hsp
.innerHTML
= "<img src='images/indicator_tiny.gif'> " +
1274 __("Loading, please wait...");
1276 loadMoreHeadlines();
1281 if (hsp
) hsp
.innerHTML
= "";
1284 if (getInitParam("cdm_auto_catchup") == 1) {
1286 // let's get DOM some time to settle down
1287 var ts
= new Date().getTime();
1288 if (ts
- _last_headlines_update
< 100) return;
1290 $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
1292 if (child
.hasClassName("Unread") && $("headlines-frame").scrollTop
>
1293 (child
.offsetTop
+ child
.offsetHeight
/2)) {
1295 var id
= child
.id
.replace("RROW-", "");
1297 if (catchup_id_batch
.indexOf(id
) == -1)
1298 catchup_id_batch
.push(id
);
1300 //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
1305 if (catchup_id_batch
.length
> 0) {
1306 window
.clearTimeout(catchup_timeout_id
);
1308 if (!_infscroll_request_sent
) {
1309 catchup_timeout_id
= window
.setTimeout('catchupBatchedArticles()',
1316 console
.warn("headlines_scroll_handler: " + e
);
1320 function catchupBatchedArticles() {
1322 if (catchup_id_batch
.length
> 0 && !_infscroll_request_sent
) {
1324 // make a copy of the array
1325 var batch
= catchup_id_batch
.slice();
1326 var query
= "?op=rpc&method=catchupSelected" +
1327 "&cmode=0&ids=" + param_escape(batch
.toString());
1331 new Ajax
.Request("backend.php", {
1333 onComplete: function(transport
) {
1334 handle_rpc_json(transport
);
1336 reply
= JSON
.parse(transport
.responseText
);
1337 var batch
= reply
.ids
;
1339 batch
.each(function(id
) {
1341 var elem
= $("RROW-" + id
);
1342 if (elem
) elem
.removeClassName("Unread");
1343 catchup_id_batch
.remove(id
);
1350 exception_error("catchupBatchedArticles", e
);
1354 function catchupRelativeToArticle(below
, id
) {
1358 if (!id
) id
= getActiveArticleId();
1361 alert(__("No article is selected."));
1365 var visible_ids
= getVisibleArticleIds();
1367 var ids_to_mark
= new Array();
1370 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1371 if (visible_ids
[i
] != id
) {
1372 var e
= $("RROW-" + visible_ids
[i
]);
1374 if (e
&& e
.hasClassName("Unread")) {
1375 ids_to_mark
.push(visible_ids
[i
]);
1382 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1383 if (visible_ids
[i
] != id
) {
1384 var e
= $("RROW-" + visible_ids
[i
]);
1386 if (e
&& e
.hasClassName("Unread")) {
1387 ids_to_mark
.push(visible_ids
[i
]);
1395 if (ids_to_mark
.length
== 0) {
1396 alert(__("No articles found to mark"));
1398 var msg
= ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark
.length
).replace("%d", ids_to_mark
.length
);
1400 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1402 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1403 var e
= $("RROW-" + ids_to_mark
[i
]);
1404 e
.removeClassName("Unread");
1407 var query
= "?op=rpc&method=catchupSelected" +
1408 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1410 new Ajax
.Request("backend.php", {
1412 onComplete: function(transport
) {
1413 handle_rpc_json(transport
);
1420 exception_error("catchupRelativeToArticle", e
);
1424 function cdmCollapseArticle(event
, id
, unmark
) {
1426 if (unmark
== undefined) unmark
= true;
1428 var row
= $("RROW-" + id
);
1429 var elem
= $("CICD-" + id
);
1432 var collapse
= $$("div#RROW-" + id
+
1433 " span[class='collapseBtn']")[0];
1436 Element
.show("CEXC-" + id
);
1437 Element
.hide(collapse
);
1440 row
.removeClassName("active");
1442 markHeadline(id
, false);
1444 if (id
== getActiveArticleId()) {
1445 setActiveArticleId(0);
1448 updateSelectedPrompt();
1451 if (event
) Event
.stop(event
);
1453 PluginHost
.run(PluginHost
.HOOK_ARTICLE_COLLAPSED
, id
);
1457 exception_error("cdmCollapseArticle", e
);
1461 function cdmExpandArticle(id
, noexpand
) {
1463 console
.log("cdmExpandArticle " + id
);
1465 if (!$("RROW-" + id
)) return false;
1467 var oldrow
= $("RROW-" + getActiveArticleId());
1469 var elem
= $("CICD-" + getActiveArticleId());
1471 if (id
== getActiveArticleId() && Element
.visible(elem
))
1474 selectArticles("none");
1476 var old_offset
= $("RROW-" + id
).offsetTop
;
1478 if (getActiveArticleId() && elem
&& !getInitParam("cdm_expanded")) {
1479 var collapse
= $$("div#RROW-" + getActiveArticleId() +
1480 " span[class='collapseBtn']")[0];
1483 Element
.show("CEXC-" + getActiveArticleId());
1484 Element
.hide(collapse
);
1487 if (oldrow
) oldrow
.removeClassName("active");
1489 setActiveArticleId(id
);
1491 elem
= $("CICD-" + id
);
1493 var collapse
= $$("div#RROW-" + id
+
1494 " span[class='collapseBtn']")[0];
1496 var cencw
= $("CENCW-" + id
);
1498 if (!Element
.visible(elem
) && !noexpand
) {
1500 cencw
.innerHTML
= htmlspecialchars_decode(cencw
.innerHTML
);
1501 cencw
.setAttribute('id', '');
1502 Element
.show(cencw
);
1506 Element
.hide("CEXC-" + id
);
1507 Element
.show(collapse
);
1510 var new_offset
= $("RROW-" + id
).offsetTop
;
1512 if (old_offset
> new_offset
)
1513 $("headlines-frame").scrollTop
-= (old_offset
-new_offset
);
1516 toggleUnread(id
, 0, true);
1518 $("RROW-" + id
).addClassName("active");
1520 PluginHost
.run(PluginHost
.HOOK_ARTICLE_EXPANDED
, id
);
1523 exception_error("cdmExpandArticle", e
);
1529 function getArticleUnderPointer() {
1530 return post_under_pointer
;
1533 function scrollArticle(offset
) {
1536 var ci
= $("content-insert");
1538 ci
.scrollTop
+= offset
;
1541 var hi
= $("headlines-frame");
1543 hi
.scrollTop
+= offset
;
1548 exception_error("scrollArticle", e
);
1552 function show_labels_in_headlines(transport
) {
1554 var data
= JSON
.parse(transport
.responseText
);
1557 data
['info-for-headlines'].each(function(elem
) {
1558 var ctr
= $("HLLCTR-" + elem
.id
);
1560 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1564 exception_error("show_labels_in_headlines", e
);
1568 function dismissArticle(id
) {
1570 var elem
= $("RROW-" + id
);
1574 toggleUnread(id
, 0, true);
1576 new Effect
.Fade(elem
, {duration
: 0.5});
1578 if (id
== getActiveArticleId()) {
1579 setActiveArticleId(0);
1583 exception_error("dismissArticle", e
);
1587 function dismissSelectedArticles() {
1590 var ids
= getVisibleArticleIds();
1594 for (var i
= 0; i
< ids
.length
; i
++) {
1595 var elem
= $("RROW-" + ids
[i
]);
1597 if (elem
.className
&& elem
.hasClassName("Selected") &&
1598 ids
[i
] != getActiveArticleId()) {
1599 new Effect
.Fade(elem
, {duration
: 0.5});
1607 selectionToggleUnread(false);
1611 exception_error("dismissSelectedArticles", e
);
1615 function dismissReadArticles() {
1618 var ids
= getVisibleArticleIds();
1621 for (var i
= 0; i
< ids
.length
; i
++) {
1622 var elem
= $("RROW-" + ids
[i
]);
1624 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1625 !elem
.hasClassName("Selected")) {
1627 new Effect
.Fade(elem
, {duration
: 0.5});
1634 exception_error("dismissSelectedArticles", e
);
1638 function getVisibleArticleIds() {
1643 getLoadedArticleIds().each(function(id
) {
1644 var elem
= $("RROW-" + id
);
1645 if (elem
&& Element
.visible(elem
))
1650 exception_error("getVisibleArticleIds", e
);
1656 function cdmClicked(event
, id
) {
1658 //var shift_key = event.shiftKey;
1660 if (!event
.ctrlKey
) {
1662 if (!getInitParam("cdm_expanded")) {
1663 return cdmExpandArticle(id
);
1666 var elem
= $("RROW-" + getActiveArticleId());
1668 if (elem
) elem
.removeClassName("active");
1670 selectArticles("none");
1673 var elem
= $("RROW-" + id
);
1674 var article_is_unread
= elem
.hasClassName("Unread");
1676 elem
.removeClassName("Unread");
1677 elem
.addClassName("active");
1679 setActiveArticleId(id
);
1681 if (article_is_unread
) {
1682 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1685 var query
= "?op=rpc&method=catchupSelected" +
1686 "&cmode=0&ids=" + param_escape(id
);
1688 new Ajax
.Request("backend.php", {
1690 onComplete: function(transport
) {
1691 handle_rpc_json(transport
);
1694 return !event
.shiftKey
;
1698 toggleSelected(id
, true);
1700 var elem
= $("RROW-" + id
);
1701 var article_is_unread
= elem
.hasClassName("Unread");
1703 if (article_is_unread
) {
1704 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1707 toggleUnread(id
, 0, false);
1709 openArticleInNewWindow(id
);
1712 var unread_in_buffer
= $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
1713 request_counters(unread_in_buffer
== 0);
1716 exception_error("cdmClicked");
1722 function hlClicked(event
, id
) {
1724 if (event
.which
== 2) {
1727 } else if (event
.ctrlKey
) {
1728 toggleSelected(id
, true);
1729 toggleUnread(id
, 0, false);
1730 openArticleInNewWindow(id
);
1738 exception_error("hlClicked");
1742 function getFirstVisibleHeadlineId() {
1743 var rows
= getVisibleArticleIds();
1748 function getLastVisibleHeadlineId() {
1749 var rows
= getVisibleArticleIds();
1750 return rows
[rows
.length
-1];
1753 function openArticleInNewWindow(id
) {
1754 toggleUnread(id
, 0, false);
1755 window
.open("backend.php?op=article&method=redirect&id=" + id
);
1758 function isCdmMode() {
1759 return getInitParam("combined_display_mode");
1762 function markHeadline(id
, marked
) {
1763 if (marked
== undefined) marked
= true;
1765 var row
= $("RROW-" + id
);
1767 var check
= dijit
.getEnclosingWidget(
1768 row
.getElementsByClassName("rchk")[0]);
1771 check
.attr("checked", marked
);
1775 row
.addClassName("Selected");
1777 row
.removeClassName("Selected");
1781 function getRelativePostIds(id
, limit
) {
1787 if (!limit
) limit
= 6; //3
1789 var ids
= getVisibleArticleIds();
1791 for (var i
= 0; i
< ids
.length
; i
++) {
1793 for (var k
= 1; k
<= limit
; k
++) {
1794 //if (i > k-1) tmp.push(ids[i-k]);
1795 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
1802 exception_error("getRelativePostIds", e
);
1808 function correctHeadlinesOffset(id
) {
1812 var container
= $("headlines-frame");
1813 var row
= $("RROW-" + id
);
1815 if (!container
|| !row
) return;
1817 var viewport
= container
.offsetHeight
;
1819 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
1820 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
1822 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
1823 //console.log("Vport: " + viewport);
1825 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
1826 container
.scrollTop
= row
.offsetTop
;
1827 } else if (rel_offset_bottom
> viewport
) {
1829 /* doesn't properly work with Opera in some cases because
1830 Opera fucks up element scrolling */
1832 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
1836 exception_error("correctHeadlinesOffset", e
);
1841 function headlineActionsChange(elem
) {
1844 elem
.attr('value', 'false');
1846 exception_error("headlineActionsChange", e
);
1850 function closeArticlePanel() {
1852 if (dijit
.byId("content-insert"))
1853 dijit
.byId("headlines-wrap-inner").removeChild(
1854 dijit
.byId("content-insert"));
1857 function initHeadlinesMenu() {
1859 if (dijit
.byId("headlinesMenu"))
1860 dijit
.byId("headlinesMenu").destroyRecursive();
1865 nodes
= $$("#headlines-frame > div[id*=RROW]");
1867 nodes
= $$("#headlines-frame span[id*=RTITLE]");
1870 nodes
.each(function(node
) {
1874 var menu
= new dijit
.Menu({
1875 id
: "headlinesMenu",
1879 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
1880 var callerNode
= event
.target
, match
= null, tries
= 0;
1882 while (match
== null && callerNode
&& tries
<= 3) {
1883 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
1884 callerNode
= callerNode
.parentNode
;
1888 if (match
) this.callerRowId
= parseInt(match
[1]);
1892 /* if (!isCdmMode())
1893 menu.addChild(new dijit.MenuItem({
1894 label: __("View article"),
1895 onClick: function(event) {
1896 view(this.getParent().callerRowId);
1899 menu
.addChild(new dijit
.MenuItem({
1900 label
: __("Open original article"),
1901 onClick: function(event
) {
1902 openArticleInNewWindow(this.getParent().callerRowId
);
1905 menu
.addChild(new dijit
.MenuItem({
1906 label
: __("Display article URL"),
1907 onClick: function(event
) {
1908 displayArticleUrl(this.getParent().callerRowId
);
1911 menu
.addChild(new dijit
.MenuSeparator());
1913 menu
.addChild(new dijit
.MenuItem({
1914 label
: __("Toggle unread"),
1915 onClick: function(event
) {
1916 var ids
= getSelectedArticleIds2();
1918 var id
= this.getParent().callerRowId
+ "";
1919 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1921 selectionToggleUnread(undefined, false, true, ids
);
1924 menu
.addChild(new dijit
.MenuItem({
1925 label
: __("Toggle marked"),
1926 onClick: function(event
) {
1927 var ids
= getSelectedArticleIds2();
1929 var id
= this.getParent().callerRowId
+ "";
1930 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1932 selectionToggleMarked(undefined, false, true, ids
);
1935 menu
.addChild(new dijit
.MenuItem({
1936 label
: __("Toggle published"),
1937 onClick: function(event
) {
1938 var ids
= getSelectedArticleIds2();
1940 var id
= this.getParent().callerRowId
+ "";
1941 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1943 selectionTogglePublished(undefined, false, true, ids
);
1946 menu
.addChild(new dijit
.MenuSeparator());
1948 menu
.addChild(new dijit
.MenuItem({
1949 label
: __("Mark above as read"),
1950 onClick: function(event
) {
1951 catchupRelativeToArticle(0, this.getParent().callerRowId
);
1954 menu
.addChild(new dijit
.MenuItem({
1955 label
: __("Mark below as read"),
1956 onClick: function(event
) {
1957 catchupRelativeToArticle(1, this.getParent().callerRowId
);
1961 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
1965 menu
.addChild(new dijit
.MenuSeparator());
1967 var labelAddMenu
= new dijit
.Menu({ownerMenu
: menu
});
1968 var labelDelMenu
= new dijit
.Menu({ownerMenu
: menu
});
1970 labels
.each(function(label
) {
1971 var id
= label
.id
[0];
1972 var bare_id
= id
.substr(id
.indexOf(":")+1);
1973 var name
= label
.name
[0];
1975 bare_id
= feed_to_label_id(bare_id
);
1977 labelAddMenu
.addChild(new dijit
.MenuItem({
1980 onClick: function(event
) {
1981 var ids
= getSelectedArticleIds2();
1983 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
1985 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1987 selectionAssignLabel(this.labelId
, ids
);
1990 labelDelMenu
.addChild(new dijit
.MenuItem({
1993 onClick: function(event
) {
1994 var ids
= getSelectedArticleIds2();
1996 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
1998 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
2000 selectionRemoveLabel(this.labelId
, ids
);
2005 menu
.addChild(new dijit
.PopupMenuItem({
2006 label
: __("Assign label"),
2007 popup
: labelAddMenu
,
2010 menu
.addChild(new dijit
.PopupMenuItem({
2011 label
: __("Remove label"),
2012 popup
: labelDelMenu
,
2020 exception_error("initHeadlinesMenu", e
);
2024 function cache_set(id
, obj
) {
2025 //console.log("cache_set: " + id);
2028 sessionStorage
[id
] = obj
;
2030 sessionStorage
.clear();
2034 function cache_get(id
) {
2036 return sessionStorage
[id
];
2039 function cache_clear() {
2041 sessionStorage
.clear();
2044 function cache_delete(id
) {
2046 sessionStorage
.removeItem(id
);
2049 function cancelSearch() {
2054 exception_error("cancelSearch", e
);
2058 function setSelectionScore() {
2060 var ids
= getSelectedArticleIds2();
2062 if (ids
.length
> 0) {
2065 var score
= prompt(__("Please enter new score for selected articles:"), score
);
2067 if (score
!= undefined) {
2068 var query
= "op=article&method=setScore&id=" + param_escape(ids
.toString()) +
2069 "&score=" + param_escape(score
);
2071 new Ajax
.Request("backend.php", {
2073 onComplete: function(transport
) {
2074 var reply
= JSON
.parse(transport
.responseText
);
2078 ids
.each(function(id
) {
2079 var row
= $("RROW-" + id
);
2082 var pic
= row
.getElementsByClassName("hlScorePic")[0];
2085 pic
.src
= pic
.src
.replace(/score_.*?\.png/,
2086 reply
["score_pic"]);
2087 pic
.setAttribute("score", score
);
2096 alert(__("No articles are selected."));
2099 exception_error("setSelectionScore", e
);
2103 function changeScore(id
, pic
) {
2105 var score
= pic
.getAttribute("score");
2107 var new_score
= prompt(__("Please enter new score for this article:"), score
);
2109 if (new_score
!= undefined) {
2111 var query
= "op=article&method=setScore&id=" + param_escape(id
) +
2112 "&score=" + param_escape(new_score
);
2114 new Ajax
.Request("backend.php", {
2116 onComplete: function(transport
) {
2117 var reply
= JSON
.parse(transport
.responseText
);
2120 pic
.src
= pic
.src
.replace(/score_.*?\.png/, reply
["score_pic"]);
2121 pic
.setAttribute("score", new_score
);
2126 exception_error("changeScore", e
);
2130 function displayArticleUrl(id
) {
2132 var query
= "op=rpc&method=getlinktitlebyid&id=" + param_escape(id
);
2134 new Ajax
.Request("backend.php", {
2136 onComplete: function(transport
) {
2137 var reply
= JSON
.parse(transport
.responseText
);
2139 if (reply
&& reply
.link
) {
2140 prompt(__("Article URL:"), reply
.link
);
2144 exception_error("changeScore", e
);
2148 function openSelectedAttachment(elem
) {
2150 var url
= elem
[elem
.selectedIndex
].value
;
2154 elem
.selectedIndex
= 0;
2158 exception_error("openSelectedAttachment", e
);