]>
git.wh0rd.org - tt-rss.git/blob - js/viewfeed.js
1 var active_post_id
= false;
3 var article_cache
= new Array();
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;
12 var feed_precache_timeout_id
= false;
13 var precache_idle_timeout_id
= false;
15 var cids_requested
= [];
16 var loaded_article_ids
= [];
18 var has_storage
= 'sessionStorage' in window
&& window
['sessionStorage'] !== null;
20 function headlines_callback2(transport
, offset
, background
, infscroll_req
) {
22 handle_rpc_json(transport
);
24 loading_set_progress(25);
26 console
.log("headlines_callback2 [offset=" + offset
+ "] B:" + background
+ " I:" + infscroll_req
);
34 reply
= JSON
.parse(transport
.responseText
);
41 is_cat
= reply
['headlines']['is_cat'];
42 feed_id
= reply
['headlines']['id'];
45 var content
= reply
['headlines']['content'];
47 if (getInitParam("cdm_auto_catchup") == 1) {
48 content
= content
+ "<div id='headlines-spacer'></div>";
51 cache_headlines(feed_id
, is_cat
, reply
['headlines']['toolbar'], content
);
55 setActiveFeedId(feed_id
, is_cat
);
57 dijit
.getEnclosingWidget(
58 document
.forms
["main_toolbar_form"].update
).attr('disabled',
59 is_cat
|| feed_id
<= 0);
62 if (offset
== 0 && infscroll_req
== false) {
63 $("headlines-frame").scrollTop
= 0;
67 var headlines_count
= reply
['headlines-info']['count'];
69 vgroup_last_feed
= reply
['headlines-info']['vgroup_last_feed'];
71 if (parseInt(headlines_count
) < getInitParam("default_article_limit")) {
72 _infscroll_disable
= 1;
74 _infscroll_disable
= 0;
77 var counters
= reply
['counters'];
78 var articles
= reply
['articles'];
79 //var runtime_info = reply['runtime-info'];
81 if (offset
== 0 && infscroll_req
== false) {
82 loaded_article_ids
= [];
84 dijit
.byId("headlines-frame").attr('content',
85 reply
['headlines']['content']);
87 dijit
.byId("headlines-toolbar").attr('content',
88 reply
['headlines']['toolbar']);
90 $$("#headlines-frame > div[id*=RROW]").each(function(row
) {
91 if (loaded_article_ids
.indexOf(row
.id
) != -1) {
92 row
.parentNode
.removeChild(row
);
94 loaded_article_ids
.push(row
.id
);
98 if (getInitParam("cdm_auto_catchup") == 1) {
99 var hsp
= $("headlines-spacer");
100 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
101 dijit
.byId('headlines-frame').domNode
.appendChild(hsp
);
107 $("feed_title").innerHTML
+= "<span id='cancel_search'>" +
108 " (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" +
114 if (headlines_count
> 0 && feed_id
== getActiveFeedId() && is_cat
== activeFeedIsCat()) {
115 console
.log("adding some more headlines: " + headlines_count
);
117 var c
= dijit
.byId("headlines-frame");
118 var ids
= getSelectedArticleIds2();
121 $("headlines-tmp").innerHTML
= reply
['headlines']['content'];
123 var hsp
= $("headlines-spacer");
126 c
.domNode
.removeChild(hsp
);
128 $$("#headlines-tmp > div").each(function(row
) {
129 if (row
.className
== 'cdmFeedTitle') {
130 row
.addClassName('new');
131 row
.style
.display
= 'none';
132 c
.domNode
.appendChild(row
);
134 } else if (loaded_article_ids
.indexOf(row
.id
) == -1) {
135 row
.style
.display
= 'none';
136 row
.addClassName('new');
137 c
.domNode
.appendChild(row
);
139 loaded_article_ids
.push(row
.id
);
141 row
.parentNode
.removeChild(row
);
145 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
147 fixHeadlinesOrder(getLoadedArticleIds());
149 if (getInitParam("cdm_auto_catchup") == 1) {
150 c
.domNode
.appendChild(hsp
);
153 console
.log("added " + num_added
+ " headlines");
156 _infscroll_disable
= true;
158 console
.log("restore selected ids: " + ids
);
160 for (var i
= 0; i
< ids
.length
; i
++) {
161 markHeadline(ids
[i
]);
166 $$("#headlines-frame > div[class*=new]").each(
168 child
.removeClassName('new');
169 if (!Element
.visible(child
))
170 new Effect
.Appear(child
, { duration
: 0.5 });
174 console
.log("no new headlines received");
176 var hsp
= $("headlines-spacer");
178 if (hsp
) hsp
.innerHTML
= "";
182 if (headlines_count
> 0)
183 cache_headlines(feed_id
, is_cat
, reply
['headlines']['toolbar'], $("headlines-frame").innerHTML
);
186 for (var i
= 0; i
< articles
.length
; i
++) {
187 var a_id
= articles
[i
]['id'];
188 cache_set("article:" + a_id
, articles
[i
]['content']);
191 console
.log("no cached articles received");
194 // do not precache stuff after fresh feed
196 precache_headlines();
199 parse_counters(counters
);
204 console
.error("Invalid object received: " + transport
.responseText
);
205 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
206 __('Could not update headlines (invalid object received - see error console for details)') +
210 _infscroll_request_sent
= 0;
215 exception_error("headlines_callback2", e
, transport
);
219 function render_article(article
) {
221 dijit
.byId("headlines-wrap-inner").addChild(
222 dijit
.byId("content-insert"));
224 var c
= dijit
.byId("content-insert");
227 c
.domNode
.scrollTop
= 0;
230 c
.attr('content', article
);
232 correctHeadlinesOffset(getActiveArticleId());
239 exception_error("render_article", e
);
243 function showArticleInHeadlines(id
) {
247 selectArticles("none");
249 var crow
= $("RROW-" + id
);
253 var article_is_unread
= crow
.hasClassName("Unread");
255 crow
.removeClassName("Unread");
257 selectArticles('none');
259 var upd_img_pic
= $("FUPDPIC-" + id
);
261 var view_mode
= false;
264 view_mode
= document
.forms
['main_toolbar_form'].view_mode
;
265 view_mode
= view_mode
[view_mode
.selectedIndex
].value
;
270 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
271 upd_img_pic
.src
.match("fresh_sign.png"))) {
273 upd_img_pic
.src
= "images/blank_icon.gif";
275 cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML
);
277 } else if (article_is_unread
&& view_mode
== "all_articles") {
278 cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML
);
283 if (article_is_unread
)
284 _force_scheduled_update
= true;
287 exception_error("showArticleInHeadlines", e
);
291 function article_callback2(transport
, id
) {
293 console
.log("article_callback2 " + id
);
295 handle_rpc_json(transport
);
300 reply
= JSON
.parse(transport
.responseText
);
307 var upic
= $('FUPDPIC-' + id
);
309 if (upic
) upic
.src
= 'images/blank_icon.gif';
311 reply
.each(function(article
) {
312 if (active_post_id
== article
['id']) {
313 render_article(article
['content']);
315 cids_requested
.remove(article
['id']);
317 cache_set("article:" + article
['id'], article
['content']);
320 // if (id != last_requested_article) {
321 // console.log("requested article id is out of sequence, aborting");
326 console
.error("Invalid object received: " + transport
.responseText
);
328 render_article("<div class='whiteBox'>" +
329 __('Could not display article (invalid object received - see error console for details)') + "</div>");
334 headlines_scroll_handler($("headlines-frame"));
337 if (!_infscroll_disable &&
338 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
348 exception_error("article_callback2", e
, transport
);
354 console
.log("loading article: " + id
);
356 var cached_article
= cache_get("article:" + id
);
358 console
.log("cache check result: " + (cached_article
!= false));
362 var query
= "?op=article&method=view&id=" + param_escape(id
);
364 var neighbor_ids
= getRelativePostIds(id
);
366 /* only request uncached articles */
368 var cids_to_request
= [];
370 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
371 if (cids_requested
.indexOf(neighbor_ids
[i
]) == -1)
372 if (!cache_get("article:" + neighbor_ids
[i
])) {
373 cids_to_request
.push(neighbor_ids
[i
]);
374 cids_requested
.push(neighbor_ids
[i
]);
378 console
.log("additional ids: " + cids_to_request
.toString());
380 query
= query
+ "&cids=" + cids_to_request
.toString();
382 var crow
= $("RROW-" + id
);
383 var article_is_unread
= crow
.hasClassName("Unread");
386 showArticleInHeadlines(id
);
388 precache_headlines();
390 if (!cached_article
) {
392 var upic
= $('FUPDPIC-' + id
);
395 upic
.src
= getInitParam("sign_progress");
398 } else if (cached_article
&& article_is_unread
) {
400 query
= query
+ "&mode=prefetch";
402 render_article(cached_article
);
404 } else if (cached_article
) {
406 query
= query
+ "&mode=prefetch_old";
407 render_article(cached_article
);
409 // if we don't need to request any relative ids, we might as well skip
410 // the server roundtrip altogether
411 if (cids_to_request
.length
== 0) {
414 if (!_infscroll_disable &&
415 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
423 headlines_scroll_handler($("headlines-frame"));
429 last_requested_article
= id
;
433 if (article_is_unread
) {
434 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
437 new Ajax
.Request("backend.php", {
439 onComplete: function(transport
) {
440 article_callback2(transport
, id
);
446 exception_error("view", e
);
450 function toggleMark(id
, client_only
) {
452 var query
= "?op=rpc&id=" + id
+ "&method=mark";
454 var img
= $("FMPIC-" + id
);
458 if (img
.src
.match("mark_unset")) {
459 img
.src
= img
.src
.replace("mark_unset", "mark_set");
460 img
.alt
= __("Unstar article");
461 query
= query
+ "&mark=1";
464 img
.src
= img
.src
.replace("mark_set", "mark_unset");
465 img
.alt
= __("Star article");
466 query
= query
+ "&mark=0";
469 cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML
);
472 new Ajax
.Request("backend.php", {
474 onComplete: function(transport
) {
475 handle_rpc_json(transport
);
480 exception_error("toggleMark", e
);
484 function togglePub(id
, client_only
, no_effects
, note
) {
486 var query
= "?op=rpc&id=" + id
+ "&method=publ";
488 if (note
!= undefined) {
489 query
= query
+ "¬e=" + param_escape(note
);
491 query
= query
+ "¬e=undefined";
494 var img
= $("FPPIC-" + id
);
498 if (img
.src
.match("pub_unset") || note
!= undefined) {
499 img
.src
= img
.src
.replace("pub_unset", "pub_set");
500 img
.alt
= __("Unpublish article");
501 query
= query
+ "&pub=1";
504 img
.src
= img
.src
.replace("pub_set", "pub_unset");
505 img
.alt
= __("Publish article");
507 query
= query
+ "&pub=0";
510 cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML
);
513 new Ajax
.Request("backend.php", {
515 onComplete: function(transport
) {
516 handle_rpc_json(transport
);
521 exception_error("togglePub", e
);
525 function moveToPost(mode
) {
529 var rows
= getVisibleArticleIds();
534 if (!$('RROW-' + active_post_id
)) {
535 active_post_id
= false;
538 if (active_post_id
== false) {
540 prev_id
= rows
[rows
.length
-1]
542 for (var i
= 0; i
< rows
.length
; i
++) {
543 if (rows
[i
] == active_post_id
) {
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
] != active_post_id
) {
559 if (mode
== "next") {
563 cdmExpandArticle(next_id
);
564 cdmScrollToArticleId(next_id
);
567 correctHeadlinesOffset(next_id
);
568 view(next_id
, getActiveFeedId());
573 if (mode
== "prev") {
576 cdmExpandArticle(prev_id
);
577 cdmScrollToArticleId(prev_id
);
579 correctHeadlinesOffset(prev_id
);
580 view(prev_id
, getActiveFeedId());
586 exception_error("moveToPost", e
);
590 function toggleSelected(id
, force_on
) {
593 var cb
= $("RCHK-" + id
);
594 var row
= $("RROW-" + id
);
597 if (row
.hasClassName('Selected') && !force_on
) {
598 row
.removeClassName('Selected');
599 if (cb
) cb
.checked
= false;
601 row
.addClassName('Selected');
602 if (cb
) cb
.checked
= true;
606 exception_error("toggleSelected", e
);
610 function toggleUnread_afh(effect
) {
613 var elem
= effect
.element
;
614 elem
.style
.backgroundColor
= "";
617 exception_error("toggleUnread_afh", e
);
621 function toggleUnread(id
, cmode
, effect
) {
624 var row
= $("RROW-" + id
);
626 if (cmode
== undefined || cmode
== 2) {
627 if (row
.hasClassName("Unread")) {
628 row
.removeClassName("Unread");
631 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
632 afterFinish
: toggleUnread_afh
,
633 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
637 row
.addClassName("Unread");
640 } else if (cmode
== 0) {
642 row
.removeClassName("Unread");
645 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
646 afterFinish
: toggleUnread_afh
,
647 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
650 } else if (cmode
== 1) {
651 row
.addClassName("Unread");
654 if (cmode
== undefined) cmode
= 2;
656 var query
= "?op=rpc&method=catchupSelected" +
657 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
659 // notify_progress("Loading, please wait...");
661 new Ajax
.Request("backend.php", {
663 onComplete: function(transport
) {
664 handle_rpc_json(transport
);
670 exception_error("toggleUnread", e
);
674 function selectionRemoveLabel(id
, ids
) {
677 if (!ids
) ids
= getSelectedArticleIds2();
679 if (ids
.length
== 0) {
680 alert(__("No articles are selected."));
684 var query
= "?op=rpc&method=removeFromLabel&ids=" +
685 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
689 new Ajax
.Request("backend.php", {
691 onComplete: function(transport
) {
692 handle_rpc_json(transport
);
693 show_labels_in_headlines(transport
);
697 exception_error("selectionAssignLabel", e
);
702 function selectionAssignLabel(id
, ids
) {
705 if (!ids
) ids
= getSelectedArticleIds2();
707 if (ids
.length
== 0) {
708 alert(__("No articles are selected."));
712 var query
= "?op=rpc&method=assignToLabel&ids=" +
713 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
717 new Ajax
.Request("backend.php", {
719 onComplete: function(transport
) {
720 handle_rpc_json(transport
);
721 show_labels_in_headlines(transport
);
725 exception_error("selectionAssignLabel", e
);
730 function selectionToggleUnread(set_state
, callback
, no_error
) {
732 var rows
= getSelectedArticleIds2();
734 if (rows
.length
== 0 && !no_error
) {
735 alert(__("No articles are selected."));
739 for (var i
= 0; i
< rows
.length
; i
++) {
740 var row
= $("RROW-" + rows
[i
]);
742 if (set_state
== undefined) {
743 if (row
.hasClassName("Unread")) {
744 row
.removeClassName("Unread");
746 row
.addClassName("Unread");
750 if (set_state
== false) {
751 row
.removeClassName("Unread");
754 if (set_state
== true) {
755 row
.addClassName("Unread");
760 if (rows
.length
> 0) {
764 if (set_state
== undefined) {
766 } else if (set_state
== true) {
768 } else if (set_state
== false) {
772 var query
= "?op=rpc&method=catchupSelected" +
773 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
775 notify_progress("Loading, please wait...");
777 new Ajax
.Request("backend.php", {
779 onComplete: function(transport
) {
780 handle_rpc_json(transport
);
781 if (callback
) callback(transport
);
787 exception_error("selectionToggleUnread", e
);
791 function selectionToggleMarked() {
794 var rows
= getSelectedArticleIds2();
796 if (rows
.length
== 0) {
797 alert(__("No articles are selected."));
801 for (var i
= 0; i
< rows
.length
; i
++) {
802 toggleMark(rows
[i
], true, true);
805 if (rows
.length
> 0) {
807 var query
= "?op=rpc&method=markSelected&ids=" +
808 param_escape(rows
.toString()) + "&cmode=2";
810 new Ajax
.Request("backend.php", {
812 onComplete: function(transport
) {
813 handle_rpc_json(transport
);
819 exception_error("selectionToggleMarked", e
);
823 function selectionTogglePublished() {
826 var rows
= getSelectedArticleIds2();
828 if (rows
.length
== 0) {
829 alert(__("No articles are selected."));
833 for (var i
= 0; i
< rows
.length
; i
++) {
834 togglePub(rows
[i
], true, true);
837 if (rows
.length
> 0) {
839 var query
= "?op=rpc&method=publishSelected&ids=" +
840 param_escape(rows
.toString()) + "&cmode=2";
842 new Ajax
.Request("backend.php", {
844 onComplete: function(transport
) {
845 handle_rpc_json(transport
);
851 exception_error("selectionToggleMarked", e
);
855 function getSelectedArticleIds2() {
859 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
861 rv
.push(child
.id
.replace("RROW-", ""));
867 function getLoadedArticleIds() {
870 var children
= $$("#headlines-frame > div[id*=RROW-]");
872 children
.each(function(child
) {
873 rv
.push(child
.id
.replace("RROW-", ""));
880 // mode = all,none,unread,invert,marked,published
881 function selectArticles(mode
) {
884 var children
= $$("#headlines-frame > div[id*=RROW]");
886 children
.each(function(child
) {
887 var id
= child
.id
.replace("RROW-", "");
888 var cb
= $("RCHK-" + id
);
891 child
.addClassName("Selected");
893 } else if (mode
== "unread") {
894 if (child
.hasClassName("Unread")) {
895 child
.addClassName("Selected");
898 child
.removeClassName("Selected");
901 } else if (mode
== "marked") {
902 var img
= $("FMPIC-" + child
.id
.replace("RROW-", ""));
904 if (img
&& img
.src
.match("mark_set")) {
905 child
.addClassName("Selected");
908 child
.removeClassName("Selected");
911 } else if (mode
== "published") {
912 var img
= $("FPPIC-" + child
.id
.replace("RROW-", ""));
914 if (img
&& img
.src
.match("pub_set")) {
915 child
.addClassName("Selected");
918 child
.removeClassName("Selected");
922 } else if (mode
== "invert") {
923 if (child
.hasClassName("Selected")) {
924 child
.removeClassName("Selected");
927 child
.addClassName("Selected");
932 child
.removeClassName("Selected");
938 exception_error("selectArticles", e
);
942 function catchupPage() {
944 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
946 var str
= __("Mark all visible articles in %s as read?");
948 str
= str
.replace("%s", fn
);
950 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
954 selectArticles('all');
955 selectionToggleUnread(false, 'viewCurrentFeed()', true);
956 selectArticles('none');
959 function deleteSelection() {
963 var rows
= getSelectedArticleIds2();
965 if (rows
.length
== 0) {
966 alert(__("No articles are selected."));
970 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
973 if (getActiveFeedId() != 0) {
974 str
= __("Delete %d selected articles in %s?");
976 str
= __("Delete %d selected articles?");
979 str
= str
.replace("%d", rows
.length
);
980 str
= str
.replace("%s", fn
);
982 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
986 query
= "?op=rpc&method=delete&ids=" + param_escape(rows
);
990 new Ajax
.Request("backend.php", {
992 onComplete: function(transport
) {
993 handle_rpc_json(transport
);
998 exception_error("deleteSelection", e
);
1002 function archiveSelection() {
1006 var rows
= getSelectedArticleIds2();
1008 if (rows
.length
== 0) {
1009 alert(__("No articles are selected."));
1013 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1017 if (getActiveFeedId() != 0) {
1018 str
= __("Archive %d selected articles in %s?");
1021 str
= __("Move %d archived articles back?");
1025 str
= str
.replace("%d", rows
.length
);
1026 str
= str
.replace("%s", fn
);
1028 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1032 query
= "?op=rpc&method="+op
+"&ids=" + param_escape(rows
);
1036 for (var i
= 0; i
< rows
.length
; i
++) {
1037 cache_delete("article:" + rows
[i
]);
1040 new Ajax
.Request("backend.php", {
1042 onComplete: function(transport
) {
1043 handle_rpc_json(transport
);
1048 exception_error("archiveSelection", e
);
1052 function catchupSelection() {
1056 var rows
= getSelectedArticleIds2();
1058 if (rows
.length
== 0) {
1059 alert(__("No articles are selected."));
1063 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1065 var str
= __("Mark %d selected articles in %s as read?");
1067 str
= str
.replace("%d", rows
.length
);
1068 str
= str
.replace("%s", fn
);
1070 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1074 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1077 exception_error("catchupSelection", e
);
1081 function editArticleTags(id
) {
1082 var query
= "backend.php?op=dlg&method=editArticleTags¶m=" + param_escape(id
);
1084 if (dijit
.byId("editTagsDlg"))
1085 dijit
.byId("editTagsDlg").destroyRecursive();
1087 dialog
= new dijit
.Dialog({
1089 title
: __("Edit article Tags"),
1090 style
: "width: 600px",
1091 execute: function() {
1092 if (this.validate()) {
1093 var query
= dojo
.objectToQuery(this.attr('value'));
1095 notify_progress("Saving article tags...", true);
1097 new Ajax
.Request("backend.php", {
1099 onComplete: function(transport
) {
1103 var data
= JSON
.parse(transport
.responseText
);
1106 var tags_str
= article
.tags
;
1107 var id
= tags_str
.id
;
1109 var tags
= $("ATSTR-" + id
);
1110 var tooltip
= dijit
.byId("ATSTRTIP-" + id
);
1112 if (tags
) tags
.innerHTML
= tags_str
.content
;
1113 if (tooltip
) tooltip
.attr('label', tags_str
.content_full
);
1115 cache_delete("article:" + id
);
1124 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1125 dojo
.disconnect(tmph
);
1127 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1128 "backend.php?op=rpc&method=completeTags",
1129 { tokens
: ',', paramName
: "search" });
1136 function cdmScrollToArticleId(id
) {
1138 var ctr
= $("headlines-frame");
1139 var e
= $("RROW-" + id
);
1141 if (!e
|| !ctr
) return;
1143 ctr
.scrollTop
= e
.offsetTop
;
1146 exception_error("cdmScrollToArticleId", e
);
1150 function getActiveArticleId() {
1151 return active_post_id
;
1154 function postMouseIn(id
) {
1155 post_under_pointer
= id
;
1158 function postMouseOut(id
) {
1159 post_under_pointer
= false;
1162 function headlines_scroll_handler(e
) {
1164 var hsp
= $("headlines-spacer");
1166 if (!_infscroll_disable
) {
1167 if ((hsp
&& e
.scrollTop
+ e
.offsetHeight
>= hsp
.offsetTop
- hsp
.offsetHeight
) ||
1168 (e
.scrollHeight
!= 0 &&
1169 ((e
.scrollTop
+ e
.offsetHeight
) / e
.scrollHeight
>= 0.7))) {
1172 hsp
.innerHTML
= "<img src='images/indicator_tiny.gif'> " +
1173 __("Loading, please wait...");
1175 loadMoreHeadlines();
1180 if (hsp
) hsp
.innerHTML
= "";
1183 if (getInitParam("cdm_auto_catchup") == 1) {
1185 $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
1187 if ($("headlines-frame").scrollTop
>
1188 (child
.offsetTop
+ child
.offsetHeight
/2)) {
1190 var id
= child
.id
.replace("RROW-", "");
1192 if (catchup_id_batch
.indexOf(id
) == -1)
1193 catchup_id_batch
.push(id
);
1195 //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
1199 if (catchup_id_batch
.length
> 0) {
1200 window
.clearTimeout(catchup_timeout_id
);
1202 if (!_infscroll_request_sent
) {
1203 catchup_timeout_id
= window
.setTimeout('catchupBatchedArticles()',
1210 console
.warn("headlines_scroll_handler: " + e
);
1214 function catchupBatchedArticles() {
1216 if (catchup_id_batch
.length
> 0 && !_infscroll_request_sent
) {
1218 // make a copy of the array
1219 var batch
= catchup_id_batch
.slice();
1220 var query
= "?op=rpc&method=catchupSelected" +
1221 "&cmode=0&ids=" + param_escape(batch
.toString());
1225 new Ajax
.Request("backend.php", {
1227 onComplete: function(transport
) {
1228 handle_rpc_json(transport
);
1230 batch
.each(function(id
) {
1231 var elem
= $("RROW-" + id
);
1232 if (elem
) elem
.removeClassName("Unread");
1233 catchup_id_batch
.remove(id
);
1240 exception_error("catchupBatchedArticles", e
);
1244 function catchupRelativeToArticle(below
, id
) {
1248 if (!id
) id
= getActiveArticleId();
1251 alert(__("No article is selected."));
1255 var visible_ids
= getVisibleArticleIds();
1257 var ids_to_mark
= new Array();
1260 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1261 if (visible_ids
[i
] != id
) {
1262 var e
= $("RROW-" + visible_ids
[i
]);
1264 if (e
&& e
.hasClassName("Unread")) {
1265 ids_to_mark
.push(visible_ids
[i
]);
1272 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1273 if (visible_ids
[i
] != id
) {
1274 var e
= $("RROW-" + visible_ids
[i
]);
1276 if (e
&& e
.hasClassName("Unread")) {
1277 ids_to_mark
.push(visible_ids
[i
]);
1285 if (ids_to_mark
.length
== 0) {
1286 alert(__("No articles found to mark"));
1288 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1290 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1292 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1293 var e
= $("RROW-" + ids_to_mark
[i
]);
1294 e
.removeClassName("Unread");
1297 var query
= "?op=rpc&method=catchupSelected" +
1298 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1300 new Ajax
.Request("backend.php", {
1302 onComplete: function(transport
) {
1303 handle_rpc_json(transport
);
1310 exception_error("catchupRelativeToArticle", e
);
1314 function cdmExpandArticle(id
) {
1319 var elem
= $("CICD-" + active_post_id
);
1321 var upd_img_pic
= $("FUPDPIC-" + id
);
1323 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1324 upd_img_pic
.src
.match("fresh_sign.png"))) {
1326 upd_img_pic
.src
= "images/blank_icon.gif";
1329 if (id
== active_post_id
&& Element
.visible(elem
))
1332 selectArticles("none");
1334 var old_offset
= $("RROW-" + id
).offsetTop
;
1336 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1338 Element
.show("CEXC-" + active_post_id
);
1341 active_post_id
= id
;
1343 elem
= $("CICD-" + id
);
1345 if (!Element
.visible(elem
)) {
1347 Element
.hide("CEXC-" + id
);
1350 var new_offset
= $("RROW-" + id
).offsetTop
;
1352 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1354 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1355 $("headlines-frame").scrollTop
= new_offset
;
1357 toggleUnread(id
, 0, true);
1361 exception_error("cdmExpandArticle", e
);
1367 function fixHeadlinesOrder(ids
) {
1369 for (var i
= 0; i
< ids
.length
; i
++) {
1370 var e
= $("RROW-" + ids
[i
]);
1374 e
.removeClassName("even");
1375 e
.addClassName("odd");
1377 e
.removeClassName("odd");
1378 e
.addClassName("even");
1383 exception_error("fixHeadlinesOrder", e
);
1387 function getArticleUnderPointer() {
1388 return post_under_pointer
;
1391 function zoomToArticle(event
, id
) {
1393 var cached_article
= cache_get("article: " + id
);
1395 if (dijit
.byId("ATAB-" + id
))
1396 if (!event
|| !event
.shiftKey
)
1397 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1399 if (dijit
.byId("ATSTRTIP-" + id
))
1400 dijit
.byId("ATSTRTIP-" + id
).destroyRecursive();
1402 if (cached_article
) {
1403 //closeArticlePanel();
1405 var article_pane
= new dijit
.layout
.ContentPane({
1406 title
: __("Loading...") , content
: cached_article
,
1407 style
: 'padding : 0px;',
1411 dijit
.byId("content-tabs").addChild(article_pane
);
1413 if (!event
|| !event
.shiftKey
)
1414 dijit
.byId("content-tabs").selectChild(article_pane
);
1416 if ($("PTITLE-" + id
))
1417 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1421 var query
= "?op=rpc&method=getArticles&ids=" + param_escape(id
);
1423 notify_progress("Loading, please wait...", true);
1425 new Ajax
.Request("backend.php", {
1427 onComplete: function(transport
) {
1430 var reply
= JSON
.parse(transport
.responseText
);
1433 //closeArticlePanel();
1435 var content
= reply
[0]['content'];
1437 var article_pane
= new dijit
.layout
.ContentPane({
1438 title
: "article-" + id
, content
: content
,
1439 style
: 'padding : 0px;',
1443 dijit
.byId("content-tabs").addChild(article_pane
);
1445 if (!event
|| !event
.shiftKey
)
1446 dijit
.byId("content-tabs").selectChild(article_pane
);
1448 if ($("PTITLE-" + id
))
1449 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1456 exception_error("zoomToArticle", e
);
1460 function scrollArticle(offset
) {
1463 var ci
= $("content-insert");
1465 ci
.scrollTop
+= offset
;
1468 var hi
= $("headlines-frame");
1470 hi
.scrollTop
+= offset
;
1475 exception_error("scrollArticle", e
);
1479 function show_labels_in_headlines(transport
) {
1481 var data
= JSON
.parse(transport
.responseText
);
1484 data
['info-for-headlines'].each(function(elem
) {
1485 var ctr
= $("HLLCTR-" + elem
.id
);
1487 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1490 cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML
);
1494 exception_error("show_labels_in_headlines", e
);
1498 /* function toggleHeadlineActions() {
1500 var e = $("headlineActionsBody");
1501 var p = $("headlineActionsDrop");
1503 if (!Element.visible(e)) {
1510 e.style.left = (p.offsetLeft + 1) + "px";
1511 e.style.top = (p.offsetTop + p.offsetHeight + 2) + "px";
1514 exception_error("toggleHeadlineActions", e);
1518 /* function publishWithNote(id, def_note) {
1520 if (!def_note) def_note = '';
1522 var note = prompt(__("Please enter a note for this article:"), def_note);
1524 if (note != undefined) {
1525 togglePub(id, false, false, note);
1529 exception_error("publishWithNote", e);
1533 function dismissArticle(id
) {
1535 var elem
= $("RROW-" + id
);
1537 toggleUnread(id
, 0, true);
1539 new Effect
.Fade(elem
, {duration
: 0.5});
1541 active_post_id
= false;
1544 exception_error("dismissArticle", e
);
1548 function dismissSelectedArticles() {
1551 var ids
= getVisibleArticleIds();
1555 for (var i
= 0; i
< ids
.length
; i
++) {
1556 var elem
= $("RROW-" + ids
[i
]);
1558 if (elem
.className
&& elem
.hasClassName("Selected") &&
1559 ids
[i
] != active_post_id
) {
1560 new Effect
.Fade(elem
, {duration
: 0.5});
1568 selectionToggleUnread(false);
1570 fixHeadlinesOrder(tmp
);
1573 exception_error("dismissSelectedArticles", e
);
1577 function dismissReadArticles() {
1580 var ids
= getVisibleArticleIds();
1583 for (var i
= 0; i
< ids
.length
; i
++) {
1584 var elem
= $("RROW-" + ids
[i
]);
1586 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1587 !elem
.hasClassName("Selected")) {
1589 new Effect
.Fade(elem
, {duration
: 0.5});
1595 fixHeadlinesOrder(tmp
);
1598 exception_error("dismissSelectedArticles", e
);
1602 function getVisibleArticleIds() {
1607 getLoadedArticleIds().each(function(id
) {
1608 var elem
= $("RROW-" + id
);
1609 if (elem
&& Element
.visible(elem
))
1614 exception_error("getVisibleArticleIds", e
);
1620 function cdmClicked(event
, id
) {
1622 //var shift_key = event.shiftKey;
1626 if (!event
.ctrlKey
) {
1628 if (!getInitParam("cdm_expanded")) {
1629 return cdmExpandArticle(id
);
1632 selectArticles("none");
1635 var elem
= $("RROW-" + id
);
1636 var article_is_unread
= elem
.hasClassName("Unread");
1639 elem
.removeClassName("Unread");
1641 var upd_img_pic
= $("FUPDPIC-" + id
);
1643 if (upd_img_pic
&& (upd_img_pic
.src
.match("updated.png") ||
1644 upd_img_pic
.src
.match("fresh_sign.png"))) {
1646 upd_img_pic
.src
= "images/blank_icon.gif";
1649 active_post_id
= id
;
1651 if (article_is_unread
) {
1652 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1655 var query
= "?op=rpc&method=catchupSelected" +
1656 "&cmode=0&ids=" + param_escape(id
);
1658 new Ajax
.Request("backend.php", {
1660 onComplete: function(transport
) {
1661 handle_rpc_json(transport
);
1668 toggleSelected(id
, true);
1670 var elem
= $("RROW-" + id
);
1671 var article_is_unread
= elem
.hasClassName("Unread");
1673 if (article_is_unread
) {
1674 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1677 toggleUnread(id
, 0, false);
1678 zoomToArticle(event
, id
);
1682 exception_error("cdmClicked");
1688 function postClicked(event
, id
) {
1691 if (!event
.ctrlKey
) {
1694 postOpenInNewTab(event
, id
);
1699 exception_error("postClicked");
1703 function hlOpenInNewTab(event
, id
) {
1704 toggleUnread(id
, 0, false);
1705 zoomToArticle(event
, id
);
1708 function postOpenInNewTab(event
, id
) {
1709 closeArticlePanel(id
);
1710 zoomToArticle(event
, id
);
1713 function hlClicked(event
, id
) {
1715 if (event
.which
== 2) {
1718 } else if (event
.altKey
) {
1719 openArticleInNewWindow(id
);
1720 } else if (!event
.ctrlKey
) {
1725 toggleUnread(id
, 0, false);
1726 zoomToArticle(event
, id
);
1731 exception_error("hlClicked");
1735 function getFirstVisibleHeadlineId() {
1736 var rows
= getVisibleArticleIds();
1741 function getLastVisibleHeadlineId() {
1742 var rows
= getVisibleArticleIds();
1743 return rows
[rows
.length
-1];
1746 function openArticleInNewWindow(id
) {
1747 toggleUnread(id
, 0, false);
1748 window
.open("backend.php?op=article&method=redirect&id=" + id
);
1751 function isCdmMode() {
1752 return getInitParam("combined_display_mode");
1755 function markHeadline(id
) {
1756 var row
= $("RROW-" + id
);
1758 var check
= $("RCHK-" + id
);
1761 check
.checked
= true;
1764 row
.addClassName("Selected");
1768 function getRelativePostIds(id
, limit
) {
1774 if (!limit
) limit
= 6; //3
1776 var ids
= getVisibleArticleIds();
1778 for (var i
= 0; i
< ids
.length
; i
++) {
1780 for (var k
= 1; k
<= limit
; k
++) {
1781 //if (i > k-1) tmp.push(ids[i-k]);
1782 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
1789 exception_error("getRelativePostIds", e
);
1795 function correctHeadlinesOffset(id
) {
1799 var container
= $("headlines-frame");
1800 var row
= $("RROW-" + id
);
1802 if (!container
|| !row
) return;
1804 var viewport
= container
.offsetHeight
;
1806 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
1807 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
1809 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
1810 //console.log("Vport: " + viewport);
1812 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
1813 container
.scrollTop
= row
.offsetTop
;
1814 } else if (rel_offset_bottom
> viewport
) {
1816 /* doesn't properly work with Opera in some cases because
1817 Opera fucks up element scrolling */
1819 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
1823 exception_error("correctHeadlinesOffset", e
);
1828 function headlineActionsChange(elem
) {
1831 elem
.attr('value', 'false');
1833 exception_error("headlineActionsChange", e
);
1837 function closeArticlePanel() {
1839 var tabs
= dijit
.byId("content-tabs");
1840 var child
= tabs
.selectedChildWidget
;
1842 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
1843 tabs
.removeChild(child
);
1846 if (dijit
.byId("content-insert"))
1847 dijit
.byId("headlines-wrap-inner").removeChild(
1848 dijit
.byId("content-insert"));
1852 function initHeadlinesMenu() {
1854 if (dijit
.byId("headlinesMenu"))
1855 dijit
.byId("headlinesMenu").destroyRecursive();
1860 nodes
= $$("#headlines-frame > div[id*=RROW]");
1862 nodes
= $$("#headlines-frame span[id*=RTITLE]");
1865 nodes
.each(function(node
) {
1869 var menu
= new dijit
.Menu({
1870 id
: "headlinesMenu",
1874 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
1875 var callerNode
= event
.target
, match
= null, tries
= 0;
1877 while (match
== null && callerNode
&& tries
<= 3) {
1878 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
1879 callerNode
= callerNode
.parentNode
;
1883 if (match
) this.callerRowId
= parseInt(match
[1]);
1887 /* if (!isCdmMode())
1888 menu.addChild(new dijit.MenuItem({
1889 label: __("View article"),
1890 onClick: function(event) {
1891 view(this.getParent().callerRowId);
1894 menu
.addChild(new dijit
.MenuItem({
1895 label
: __("Open original article"),
1896 onClick: function(event
) {
1897 openArticleInNewWindow(this.getParent().callerRowId
);
1900 menu
.addChild(new dijit
.MenuItem({
1901 label
: __("View in a tt-rss tab"),
1902 onClick: function(event
) {
1903 hlOpenInNewTab(event
, this.getParent().callerRowId
);
1906 menu
.addChild(new dijit
.MenuSeparator());
1908 menu
.addChild(new dijit
.MenuItem({
1909 label
: __("Mark above as read"),
1910 onClick: function(event
) {
1911 catchupRelativeToArticle(0, this.getParent().callerRowId
);
1914 menu
.addChild(new dijit
.MenuItem({
1915 label
: __("Mark below as read"),
1916 onClick: function(event
) {
1917 catchupRelativeToArticle(1, this.getParent().callerRowId
);
1921 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
1925 menu
.addChild(new dijit
.MenuSeparator());
1927 var labelAddMenu
= new dijit
.Menu({ownerMenu
: menu
});
1928 var labelDelMenu
= new dijit
.Menu({ownerMenu
: menu
});
1930 labels
.each(function(label
) {
1931 var id
= label
.id
[0];
1932 var bare_id
= id
.substr(id
.indexOf(":")+1);
1933 var name
= label
.name
[0];
1935 bare_id
= -11-bare_id
;
1937 labelAddMenu
.addChild(new dijit
.MenuItem({
1940 onClick: function(event
) {
1941 var ids
= getSelectedArticleIds2();
1943 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
1945 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1947 selectionAssignLabel(this.labelId
, ids
);
1950 labelDelMenu
.addChild(new dijit
.MenuItem({
1953 onClick: function(event
) {
1954 var ids
= getSelectedArticleIds2();
1956 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
1958 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1960 selectionRemoveLabel(this.labelId
, ids
);
1965 menu
.addChild(new dijit
.PopupMenuItem({
1966 label
: __("Assign label"),
1967 popup
: labelAddMenu
,
1970 menu
.addChild(new dijit
.PopupMenuItem({
1971 label
: __("Remove label"),
1972 popup
: labelDelMenu
,
1980 exception_error("initHeadlinesMenu", e
);
1985 function player(elem
) {
1986 var aid
= elem
.getAttribute("audio-id");
1987 var status
= elem
.getAttribute("status");
1995 elem
.innerHTML
= __("Playing...");
1996 elem
.title
= __("Click to pause");
1997 elem
.addClassName("playing");
2001 elem
.innerHTML
= __("Play");
2002 elem
.title
= __("Click to play");
2003 elem
.removeClassName("playing");
2006 elem
.setAttribute("status", status
);
2008 alert("Your browser doesn't seem to support HTML5 audio.");
2012 function cache_set(id
, obj
) {
2013 //console.log("cache_set: " + id);
2016 sessionStorage
[id
] = obj
;
2018 sessionStorage
.clear();
2022 function cache_get(id
) {
2024 return sessionStorage
[id
];
2027 function cache_clear() {
2029 sessionStorage
.clear();
2032 function cache_delete(id
) {
2034 sessionStorage
.removeItem(id
);
2037 function cache_headlines(feed
, is_cat
, toolbar_obj
, content_obj
) {
2038 if (toolbar_obj
&& content_obj
) {
2039 cache_set("feed:" + feed
+ ":" + is_cat
,
2040 JSON
.stringify({toolbar
: toolbar_obj
, content
: content_obj
}));
2043 obj
= cache_get("feed:" + feed
+ ":" + is_cat
);
2046 obj
= JSON
.parse(obj
);
2048 if (toolbar_obj
) obj
.toolbar
= toolbar_obj
;
2049 if (content_obj
) obj
.content
= content_obj
;
2051 cache_set("feed:" + feed
+ ":" + is_cat
, JSON
.stringify(obj
));
2055 console
.warn("cache_headlines failed: " + e
);
2060 function render_local_headlines(feed
, is_cat
, obj
) {
2063 dijit
.byId("headlines-toolbar").attr('content',
2066 dijit
.byId("headlines-frame").attr('content',
2069 dojo
.parser
.parse('headlines-toolbar');
2071 $("headlines-frame").scrollTop
= 0;
2072 selectArticles('none');
2073 setActiveFeedId(feed
, is_cat
);
2074 initHeadlinesMenu();
2076 dijit
.getEnclosingWidget(
2077 document
.forms
["main_toolbar_form"].update
).attr('disabled',
2078 is_cat
|| feed
<= 0);
2080 precache_headlines();
2083 exception_error("render_local_headlines", e
);
2087 function precache_headlines_idle() {
2089 if (!feed_precache_timeout_id
) {
2090 if (get_timestamp() - _viewfeed_last
> 120) {
2092 var feeds
= dijit
.byId("feedTree").getVisibleUnreadFeeds();
2095 feeds
.each(function(item
) {
2096 if (parseInt(item
[0]) > 0 && !cache_get("feed:" + item
[0] + ":" + item
[1]))
2097 uncached
.push(item
);
2100 if (uncached
.length
> 0) {
2101 var rf
= uncached
[Math
.floor(Math
.random()*uncached
.length
)];
2102 viewfeed(rf
[0], '', rf
[1], 0, true);
2106 precache_idle_timeout_id
= setTimeout("precache_headlines_idle()", 1000*30);
2109 exception_error("precache_headlines_idle", e
);
2113 function precache_headlines() {
2116 if (!feed_precache_timeout_id
) {
2117 feed_precache_timeout_id
= window
.setTimeout(function() {
2118 var nuf
= getNextUnreadFeed(getActiveFeedId(), activeFeedIsCat());
2119 var nf
= dijit
.byId("feedTree").getNextFeed(getActiveFeedId(), activeFeedIsCat());
2121 if (nuf
&& !cache_get("feed:" + nuf
+ ":" + activeFeedIsCat()))
2122 viewfeed(nuf
, '', activeFeedIsCat(), 0, true);
2124 if (nf
&& nf
[0] != nuf
&& !cache_get("feed:" + nf
[0] + ":" + nf
[1]))
2125 viewfeed(nf
[0], '', nf
[1], 0, true);
2127 window
.setTimeout(function() {
2128 feed_precache_timeout_id
= false;
2134 exception_error("precache_headlines", e
);
2138 function cancelSearch() {
2143 exception_error("cancelSearch", e
);
2147 function setSelectionScore() {
2149 var ids
= getSelectedArticleIds2();
2151 if (ids
.length
> 0) {
2154 var score
= prompt(__("Please enter new score for selected articles:"), score
);
2156 if (score
!= undefined) {
2157 var query
= "op=rpc&method=setScore&id=" + param_escape(ids
.toString()) +
2158 "&score=" + param_escape(score
);
2160 new Ajax
.Request("backend.php", {
2162 onComplete: function(transport
) {
2163 var reply
= JSON
.parse(transport
.responseText
);
2167 ids
.each(function(id
) {
2168 var row
= $("RROW-" + id
);
2171 var pic
= row
.getElementsByClassName("hlScorePic")[0];
2174 pic
.src
= pic
.src
.replace(/score_.*?\.png/,
2175 reply
["score_pic"]);
2176 pic
.setAttribute("score", score
);
2185 alert(__("No articles are selected."));
2188 exception_error("setSelectionScore", e
);
2192 function changeScore(id
, pic
) {
2194 var score
= pic
.getAttribute("score");
2196 var new_score
= prompt(__("Please enter new score for this article:"), score
);
2198 if (new_score
!= undefined) {
2200 var query
= "op=rpc&method=setScore&id=" + param_escape(id
) +
2201 "&score=" + param_escape(new_score
);
2203 new Ajax
.Request("backend.php", {
2205 onComplete: function(transport
) {
2206 var reply
= JSON
.parse(transport
.responseText
);
2209 pic
.src
= pic
.src
.replace(/score_.*?\.png/, reply
["score_pic"]);
2210 pic
.setAttribute("score", new_score
);
2215 exception_error("changeScore", e
);