]>
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
.style
.display
= 'none';
131 c
.domNode
.appendChild(row
);
133 } else if (loaded_article_ids
.indexOf(row
.id
) == -1) {
134 row
.style
.display
= 'none';
135 c
.domNode
.appendChild(row
);
137 loaded_article_ids
.push(row
.id
);
139 row
.parentNode
.removeChild(row
);
143 if (!hsp
) hsp
= new Element("DIV", {"id": "headlines-spacer"});
145 fixHeadlinesOrder(getLoadedArticleIds());
147 if (getInitParam("cdm_auto_catchup") == 1) {
148 c
.domNode
.appendChild(hsp
);
151 console
.log("added " + new_elems
.size() + " headlines");
153 if (new_elems
.size() == 0)
154 _infscroll_disable
= true;
156 console
.log("restore selected ids: " + ids
);
158 for (var i
= 0; i
< ids
.length
; i
++) {
159 markHeadline(ids
[i
]);
164 new_elems
.each(function(child
) {
165 var cb
= dijit
.byId(child
.id
.replace("RROW-", "RCHK-"));
168 dojo
.parser
.parse(child
);
170 if (!Element
.visible(child
))
171 new Effect
.Appear(child
, { duration
: 0.5 });
173 c
.domNode
.removeChild(child
);
178 console
.log("no new headlines received");
180 var hsp
= $("headlines-spacer");
182 if (hsp
) hsp
.innerHTML
= "";
186 if (headlines_count
> 0)
187 cache_headlines(feed_id
, is_cat
, reply
['headlines']['toolbar'], $("headlines-frame").innerHTML
);
190 for (var i
= 0; i
< articles
.length
; i
++) {
191 var a_id
= articles
[i
]['id'];
192 cache_set("article:" + a_id
, articles
[i
]['content']);
195 console
.log("no cached articles received");
198 // do not precache stuff after fresh feed
200 precache_headlines();
203 parse_counters(counters
);
207 } else if (transport
.responseText
) {
208 console
.error("Invalid object received: " + transport
.responseText
);
209 dijit
.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
210 __('Could not update headlines (invalid object received - see error console for details)') +
213 notify_error("Error communicating with server.");
216 _infscroll_request_sent
= 0;
221 exception_error("headlines_callback2", e
, transport
);
225 function render_article(article
) {
227 dijit
.byId("headlines-wrap-inner").addChild(
228 dijit
.byId("content-insert"));
230 var c
= dijit
.byId("content-insert");
233 c
.domNode
.scrollTop
= 0;
236 c
.attr('content', article
);
238 correctHeadlinesOffset(getActiveArticleId());
245 exception_error("render_article", e
);
249 function showArticleInHeadlines(id
) {
253 selectArticles("none");
255 var crow
= $("RROW-" + id
);
259 var article_is_unread
= crow
.hasClassName("Unread");
261 crow
.removeClassName("Unread");
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
;
274 if (article_is_unread
&& view_mode
== "all_articles") {
275 cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML
);
280 if (article_is_unread
)
281 _force_scheduled_update
= true;
284 exception_error("showArticleInHeadlines", e
);
288 function article_callback2(transport
, id
) {
290 console
.log("article_callback2 " + id
);
292 handle_rpc_json(transport
);
297 reply
= JSON
.parse(transport
.responseText
);
304 reply
.each(function(article
) {
305 if (active_post_id
== article
['id']) {
306 render_article(article
['content']);
308 cids_requested
.remove(article
['id']);
310 cache_set("article:" + article
['id'], article
['content']);
313 // if (id != last_requested_article) {
314 // console.log("requested article id is out of sequence, aborting");
319 console
.error("Invalid object received: " + transport
.responseText
);
321 render_article("<div class='whiteBox'>" +
322 __('Could not display article (invalid object received - see error console for details)') + "</div>");
327 headlines_scroll_handler($("headlines-frame"));
330 if (!_infscroll_disable &&
331 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
341 exception_error("article_callback2", e
, transport
);
347 console
.log("loading article: " + id
);
349 var cached_article
= cache_get("article:" + id
);
351 console
.log("cache check result: " + (cached_article
!= false));
355 var query
= "?op=article&method=view&id=" + param_escape(id
);
357 var neighbor_ids
= getRelativePostIds(id
);
359 /* only request uncached articles */
361 var cids_to_request
= [];
363 for (var i
= 0; i
< neighbor_ids
.length
; i
++) {
364 if (cids_requested
.indexOf(neighbor_ids
[i
]) == -1)
365 if (!cache_get("article:" + neighbor_ids
[i
])) {
366 cids_to_request
.push(neighbor_ids
[i
]);
367 cids_requested
.push(neighbor_ids
[i
]);
371 console
.log("additional ids: " + cids_to_request
.toString());
373 query
= query
+ "&cids=" + cids_to_request
.toString();
375 var crow
= $("RROW-" + id
);
376 var article_is_unread
= crow
.hasClassName("Unread");
379 showArticleInHeadlines(id
);
381 precache_headlines();
383 if (cached_article
&& article_is_unread
) {
385 query
= query
+ "&mode=prefetch";
387 render_article(cached_article
);
389 } else if (cached_article
) {
391 query
= query
+ "&mode=prefetch_old";
392 render_article(cached_article
);
394 // if we don't need to request any relative ids, we might as well skip
395 // the server roundtrip altogether
396 if (cids_to_request
.length
== 0) {
399 if (!_infscroll_disable &&
400 $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
408 headlines_scroll_handler($("headlines-frame"));
414 last_requested_article
= id
;
418 if (article_is_unread
) {
419 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
422 new Ajax
.Request("backend.php", {
424 onComplete: function(transport
) {
425 article_callback2(transport
, id
);
431 exception_error("view", e
);
435 function toggleMark(id
, client_only
) {
437 var query
= "?op=rpc&id=" + id
+ "&method=mark";
439 var img
= $("FMPIC-" + id
);
443 if (img
.src
.match("mark_unset")) {
444 img
.src
= img
.src
.replace("mark_unset", "mark_set");
445 img
.alt
= __("Unstar article");
446 query
= query
+ "&mark=1";
449 img
.src
= img
.src
.replace("mark_set", "mark_unset");
450 img
.alt
= __("Star article");
451 query
= query
+ "&mark=0";
454 cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML
);
457 new Ajax
.Request("backend.php", {
459 onComplete: function(transport
) {
460 handle_rpc_json(transport
);
465 exception_error("toggleMark", e
);
469 function togglePub(id
, client_only
, no_effects
, note
) {
471 var query
= "?op=rpc&id=" + id
+ "&method=publ";
473 if (note
!= undefined) {
474 query
= query
+ "¬e=" + param_escape(note
);
476 query
= query
+ "¬e=undefined";
479 var img
= $("FPPIC-" + id
);
483 if (img
.src
.match("pub_unset") || note
!= undefined) {
484 img
.src
= img
.src
.replace("pub_unset", "pub_set");
485 img
.alt
= __("Unpublish article");
486 query
= query
+ "&pub=1";
489 img
.src
= img
.src
.replace("pub_set", "pub_unset");
490 img
.alt
= __("Publish article");
492 query
= query
+ "&pub=0";
495 cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML
);
498 new Ajax
.Request("backend.php", {
500 onComplete: function(transport
) {
501 handle_rpc_json(transport
);
506 exception_error("togglePub", e
);
510 function moveToPost(mode
) {
514 var rows
= getVisibleArticleIds();
519 if (!$('RROW-' + active_post_id
)) {
520 active_post_id
= false;
523 if (active_post_id
== false) {
525 prev_id
= rows
[rows
.length
-1]
527 for (var i
= 0; i
< rows
.length
; i
++) {
528 if (rows
[i
] == active_post_id
) {
530 // Account for adjacent identical article ids.
531 if (i
> 0) prev_id
= rows
[i
-1];
533 for (var j
= i
+1; j
< rows
.length
; j
++) {
534 if (rows
[j
] != active_post_id
) {
544 if (mode
== "next") {
548 cdmExpandArticle(next_id
);
549 cdmScrollToArticleId(next_id
);
552 correctHeadlinesOffset(next_id
);
553 view(next_id
, getActiveFeedId());
558 if (mode
== "prev") {
561 cdmExpandArticle(prev_id
);
562 cdmScrollToArticleId(prev_id
);
564 correctHeadlinesOffset(prev_id
);
565 view(prev_id
, getActiveFeedId());
571 exception_error("moveToPost", e
);
575 function toggleSelected(id
, force_on
) {
578 var cb
= dijit
.byId("RCHK-" + id
);
579 var row
= $("RROW-" + id
);
582 if (row
.hasClassName('Selected') && !force_on
) {
583 row
.removeClassName('Selected');
584 if (cb
) cb
.attr("checked", false);
586 row
.addClassName('Selected');
587 if (cb
) cb
.attr("checked", true);
591 exception_error("toggleSelected", e
);
595 function toggleUnread_afh(effect
) {
598 var elem
= effect
.element
;
599 elem
.style
.backgroundColor
= "";
602 exception_error("toggleUnread_afh", e
);
606 function toggleUnread(id
, cmode
, effect
) {
609 var row
= $("RROW-" + id
);
611 if (cmode
== undefined || cmode
== 2) {
612 if (row
.hasClassName("Unread")) {
613 row
.removeClassName("Unread");
616 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
617 afterFinish
: toggleUnread_afh
,
618 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
622 row
.addClassName("Unread");
625 } else if (cmode
== 0) {
627 row
.removeClassName("Unread");
630 new Effect
.Highlight(row
, {duration
: 1, startcolor
: "#fff7d5",
631 afterFinish
: toggleUnread_afh
,
632 queue
: { position
:'end', scope
: 'TMRQ-' + id
, limit
: 1 } } );
635 } else if (cmode
== 1) {
636 row
.addClassName("Unread");
639 if (cmode
== undefined) cmode
= 2;
641 var query
= "?op=rpc&method=catchupSelected" +
642 "&cmode=" + param_escape(cmode
) + "&ids=" + param_escape(id
);
644 // notify_progress("Loading, please wait...");
646 new Ajax
.Request("backend.php", {
648 onComplete: function(transport
) {
649 handle_rpc_json(transport
);
655 exception_error("toggleUnread", e
);
659 function selectionRemoveLabel(id
, ids
) {
662 if (!ids
) ids
= getSelectedArticleIds2();
664 if (ids
.length
== 0) {
665 alert(__("No articles are selected."));
669 var query
= "?op=rpc&method=removeFromLabel&ids=" +
670 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
674 new Ajax
.Request("backend.php", {
676 onComplete: function(transport
) {
677 handle_rpc_json(transport
);
678 show_labels_in_headlines(transport
);
682 exception_error("selectionAssignLabel", e
);
687 function selectionAssignLabel(id
, ids
) {
690 if (!ids
) ids
= getSelectedArticleIds2();
692 if (ids
.length
== 0) {
693 alert(__("No articles are selected."));
697 var query
= "?op=rpc&method=assignToLabel&ids=" +
698 param_escape(ids
.toString()) + "&lid=" + param_escape(id
);
702 new Ajax
.Request("backend.php", {
704 onComplete: function(transport
) {
705 handle_rpc_json(transport
);
706 show_labels_in_headlines(transport
);
710 exception_error("selectionAssignLabel", e
);
715 function selectionToggleUnread(set_state
, callback
, no_error
) {
717 var rows
= getSelectedArticleIds2();
719 if (rows
.length
== 0 && !no_error
) {
720 alert(__("No articles are selected."));
724 for (var i
= 0; i
< rows
.length
; i
++) {
725 var row
= $("RROW-" + rows
[i
]);
727 if (set_state
== undefined) {
728 if (row
.hasClassName("Unread")) {
729 row
.removeClassName("Unread");
731 row
.addClassName("Unread");
735 if (set_state
== false) {
736 row
.removeClassName("Unread");
739 if (set_state
== true) {
740 row
.addClassName("Unread");
745 if (rows
.length
> 0) {
749 if (set_state
== undefined) {
751 } else if (set_state
== true) {
753 } else if (set_state
== false) {
757 var query
= "?op=rpc&method=catchupSelected" +
758 "&cmode=" + cmode
+ "&ids=" + param_escape(rows
.toString());
760 notify_progress("Loading, please wait...");
762 new Ajax
.Request("backend.php", {
764 onComplete: function(transport
) {
765 handle_rpc_json(transport
);
766 if (callback
) callback(transport
);
772 exception_error("selectionToggleUnread", e
);
776 function selectionToggleMarked() {
779 var rows
= getSelectedArticleIds2();
781 if (rows
.length
== 0) {
782 alert(__("No articles are selected."));
786 for (var i
= 0; i
< rows
.length
; i
++) {
787 toggleMark(rows
[i
], true, true);
790 if (rows
.length
> 0) {
792 var query
= "?op=rpc&method=markSelected&ids=" +
793 param_escape(rows
.toString()) + "&cmode=2";
795 new Ajax
.Request("backend.php", {
797 onComplete: function(transport
) {
798 handle_rpc_json(transport
);
804 exception_error("selectionToggleMarked", e
);
808 function selectionTogglePublished() {
811 var rows
= getSelectedArticleIds2();
813 if (rows
.length
== 0) {
814 alert(__("No articles are selected."));
818 for (var i
= 0; i
< rows
.length
; i
++) {
819 togglePub(rows
[i
], true, true);
822 if (rows
.length
> 0) {
824 var query
= "?op=rpc&method=publishSelected&ids=" +
825 param_escape(rows
.toString()) + "&cmode=2";
827 new Ajax
.Request("backend.php", {
829 onComplete: function(transport
) {
830 handle_rpc_json(transport
);
836 exception_error("selectionToggleMarked", e
);
840 function getSelectedArticleIds2() {
844 $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
846 rv
.push(child
.id
.replace("RROW-", ""));
852 function getLoadedArticleIds() {
855 var children
= $$("#headlines-frame > div[id*=RROW-]");
857 children
.each(function(child
) {
858 rv
.push(child
.id
.replace("RROW-", ""));
865 // mode = all,none,unread,invert,marked,published
866 function selectArticles(mode
) {
869 var children
= $$("#headlines-frame > div[id*=RROW]");
871 children
.each(function(child
) {
872 var id
= child
.id
.replace("RROW-", "");
873 var cb
= dijit
.byId("RCHK-" + id
);
876 child
.addClassName("Selected");
877 if (cb
) cb
.attr("checked", true);
878 } else if (mode
== "unread") {
879 if (child
.hasClassName("Unread")) {
880 child
.addClassName("Selected");
881 if (cb
) cb
.attr("checked", true);
883 child
.removeClassName("Selected");
884 if (cb
) cb
.attr("checked", false);
886 } else if (mode
== "marked") {
887 var img
= $("FMPIC-" + child
.id
.replace("RROW-", ""));
889 if (img
&& img
.src
.match("mark_set")) {
890 child
.addClassName("Selected");
891 if (cb
) cb
.attr("checked", true);
893 child
.removeClassName("Selected");
894 if (cb
) cb
.attr("checked", false);
896 } else if (mode
== "published") {
897 var img
= $("FPPIC-" + child
.id
.replace("RROW-", ""));
899 if (img
&& img
.src
.match("pub_set")) {
900 child
.addClassName("Selected");
901 if (cb
) cb
.attr("checked", true);
903 child
.removeClassName("Selected");
904 if (cb
) cb
.attr("checked", false);
907 } else if (mode
== "invert") {
908 if (child
.hasClassName("Selected")) {
909 child
.removeClassName("Selected");
910 if (cb
) cb
.attr("checked", false);
912 child
.addClassName("Selected");
913 if (cb
) cb
.attr("checked", true);
917 child
.removeClassName("Selected");
918 if (cb
) cb
.attr("checked", false);
923 exception_error("selectArticles", e
);
927 function catchupPage() {
929 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
931 var str
= __("Mark all visible articles in %s as read?");
933 str
= str
.replace("%s", fn
);
935 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
939 selectArticles('all');
940 selectionToggleUnread(false, 'viewCurrentFeed()', true);
941 selectArticles('none');
944 function deleteSelection() {
948 var rows
= getSelectedArticleIds2();
950 if (rows
.length
== 0) {
951 alert(__("No articles are selected."));
955 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
958 if (getActiveFeedId() != 0) {
959 str
= __("Delete %d selected articles in %s?");
961 str
= __("Delete %d selected articles?");
964 str
= str
.replace("%d", rows
.length
);
965 str
= str
.replace("%s", fn
);
967 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
971 query
= "?op=rpc&method=delete&ids=" + param_escape(rows
);
975 new Ajax
.Request("backend.php", {
977 onComplete: function(transport
) {
978 handle_rpc_json(transport
);
983 exception_error("deleteSelection", e
);
987 function archiveSelection() {
991 var rows
= getSelectedArticleIds2();
993 if (rows
.length
== 0) {
994 alert(__("No articles are selected."));
998 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1002 if (getActiveFeedId() != 0) {
1003 str
= __("Archive %d selected articles in %s?");
1006 str
= __("Move %d archived articles back?");
1010 str
= str
.replace("%d", rows
.length
);
1011 str
= str
.replace("%s", fn
);
1013 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1017 query
= "?op=rpc&method="+op
+"&ids=" + param_escape(rows
);
1021 for (var i
= 0; i
< rows
.length
; i
++) {
1022 cache_delete("article:" + rows
[i
]);
1025 new Ajax
.Request("backend.php", {
1027 onComplete: function(transport
) {
1028 handle_rpc_json(transport
);
1033 exception_error("archiveSelection", e
);
1037 function catchupSelection() {
1041 var rows
= getSelectedArticleIds2();
1043 if (rows
.length
== 0) {
1044 alert(__("No articles are selected."));
1048 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
1050 var str
= __("Mark %d selected articles in %s as read?");
1052 str
= str
.replace("%d", rows
.length
);
1053 str
= str
.replace("%s", fn
);
1055 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str
)) {
1059 selectionToggleUnread(false, 'viewCurrentFeed()', true);
1062 exception_error("catchupSelection", e
);
1066 function editArticleTags(id
) {
1067 var query
= "backend.php?op=dlg&method=editArticleTags¶m=" + param_escape(id
);
1069 if (dijit
.byId("editTagsDlg"))
1070 dijit
.byId("editTagsDlg").destroyRecursive();
1072 dialog
= new dijit
.Dialog({
1074 title
: __("Edit article Tags"),
1075 style
: "width: 600px",
1076 execute: function() {
1077 if (this.validate()) {
1078 var query
= dojo
.objectToQuery(this.attr('value'));
1080 notify_progress("Saving article tags...", true);
1082 new Ajax
.Request("backend.php", {
1084 onComplete: function(transport
) {
1088 var data
= JSON
.parse(transport
.responseText
);
1091 var tags_str
= article
.tags
;
1092 var id
= tags_str
.id
;
1094 var tags
= $("ATSTR-" + id
);
1095 var tooltip
= dijit
.byId("ATSTRTIP-" + id
);
1097 if (tags
) tags
.innerHTML
= tags_str
.content
;
1098 if (tooltip
) tooltip
.attr('label', tags_str
.content_full
);
1100 cache_delete("article:" + id
);
1109 var tmph
= dojo
.connect(dialog
, 'onLoad', function() {
1110 dojo
.disconnect(tmph
);
1112 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1113 "backend.php?op=rpc&method=completeTags",
1114 { tokens
: ',', paramName
: "search" });
1121 function cdmScrollToArticleId(id
) {
1123 var ctr
= $("headlines-frame");
1124 var e
= $("RROW-" + id
);
1126 if (!e
|| !ctr
) return;
1128 ctr
.scrollTop
= e
.offsetTop
;
1131 exception_error("cdmScrollToArticleId", e
);
1135 function getActiveArticleId() {
1136 return active_post_id
;
1139 function postMouseIn(id
) {
1140 post_under_pointer
= id
;
1143 function postMouseOut(id
) {
1144 post_under_pointer
= false;
1147 function headlines_scroll_handler(e
) {
1149 var hsp
= $("headlines-spacer");
1151 if (!_infscroll_disable
) {
1152 if ((hsp
&& e
.scrollTop
+ e
.offsetHeight
>= hsp
.offsetTop
- hsp
.offsetHeight
) ||
1153 (e
.scrollHeight
!= 0 &&
1154 ((e
.scrollTop
+ e
.offsetHeight
) / e
.scrollHeight
>= 0.7))) {
1157 hsp
.innerHTML
= "<img src='images/indicator_tiny.gif'> " +
1158 __("Loading, please wait...");
1160 loadMoreHeadlines();
1165 if (hsp
) hsp
.innerHTML
= "";
1168 if (getInitParam("cdm_auto_catchup") == 1) {
1170 $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
1172 if ($("headlines-frame").scrollTop
>
1173 (child
.offsetTop
+ child
.offsetHeight
/2)) {
1175 var id
= child
.id
.replace("RROW-", "");
1177 if (catchup_id_batch
.indexOf(id
) == -1)
1178 catchup_id_batch
.push(id
);
1180 //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
1184 if (catchup_id_batch
.length
> 0) {
1185 window
.clearTimeout(catchup_timeout_id
);
1187 if (!_infscroll_request_sent
) {
1188 catchup_timeout_id
= window
.setTimeout('catchupBatchedArticles()',
1195 console
.warn("headlines_scroll_handler: " + e
);
1199 function catchupBatchedArticles() {
1201 if (catchup_id_batch
.length
> 0 && !_infscroll_request_sent
) {
1203 // make a copy of the array
1204 var batch
= catchup_id_batch
.slice();
1205 var query
= "?op=rpc&method=catchupSelected" +
1206 "&cmode=0&ids=" + param_escape(batch
.toString());
1210 new Ajax
.Request("backend.php", {
1212 onComplete: function(transport
) {
1213 handle_rpc_json(transport
);
1215 batch
.each(function(id
) {
1216 var elem
= $("RROW-" + id
);
1217 if (elem
) elem
.removeClassName("Unread");
1218 catchup_id_batch
.remove(id
);
1225 exception_error("catchupBatchedArticles", e
);
1229 function catchupRelativeToArticle(below
, id
) {
1233 if (!id
) id
= getActiveArticleId();
1236 alert(__("No article is selected."));
1240 var visible_ids
= getVisibleArticleIds();
1242 var ids_to_mark
= new Array();
1245 for (var i
= 0; i
< visible_ids
.length
; i
++) {
1246 if (visible_ids
[i
] != id
) {
1247 var e
= $("RROW-" + visible_ids
[i
]);
1249 if (e
&& e
.hasClassName("Unread")) {
1250 ids_to_mark
.push(visible_ids
[i
]);
1257 for (var i
= visible_ids
.length
-1; i
>= 0; i
--) {
1258 if (visible_ids
[i
] != id
) {
1259 var e
= $("RROW-" + visible_ids
[i
]);
1261 if (e
&& e
.hasClassName("Unread")) {
1262 ids_to_mark
.push(visible_ids
[i
]);
1270 if (ids_to_mark
.length
== 0) {
1271 alert(__("No articles found to mark"));
1273 var msg
= __("Mark %d article(s) as read?").replace("%d", ids_to_mark
.length
);
1275 if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg
)) {
1277 for (var i
= 0; i
< ids_to_mark
.length
; i
++) {
1278 var e
= $("RROW-" + ids_to_mark
[i
]);
1279 e
.removeClassName("Unread");
1282 var query
= "?op=rpc&method=catchupSelected" +
1283 "&cmode=0" + "&ids=" + param_escape(ids_to_mark
.toString());
1285 new Ajax
.Request("backend.php", {
1287 onComplete: function(transport
) {
1288 handle_rpc_json(transport
);
1295 exception_error("catchupRelativeToArticle", e
);
1299 function cdmExpandArticle(id
) {
1304 var elem
= $("CICD-" + active_post_id
);
1306 if (id
== active_post_id
&& Element
.visible(elem
))
1309 selectArticles("none");
1311 var old_offset
= $("RROW-" + id
).offsetTop
;
1313 if (active_post_id
&& elem
&& !getInitParam("cdm_expanded")) {
1315 Element
.show("CEXC-" + active_post_id
);
1318 active_post_id
= id
;
1320 elem
= $("CICD-" + id
);
1322 if (!Element
.visible(elem
)) {
1324 Element
.hide("CEXC-" + id
);
1327 var new_offset
= $("RROW-" + id
).offsetTop
;
1329 $("headlines-frame").scrollTop
+= (new_offset
-old_offset
);
1331 if ($("RROW-" + id
).offsetTop
!= old_offset
)
1332 $("headlines-frame").scrollTop
= new_offset
;
1334 toggleUnread(id
, 0, true);
1338 exception_error("cdmExpandArticle", e
);
1344 function fixHeadlinesOrder(ids
) {
1346 for (var i
= 0; i
< ids
.length
; i
++) {
1347 var e
= $("RROW-" + ids
[i
]);
1351 e
.removeClassName("even");
1352 e
.addClassName("odd");
1354 e
.removeClassName("odd");
1355 e
.addClassName("even");
1360 exception_error("fixHeadlinesOrder", e
);
1364 function getArticleUnderPointer() {
1365 return post_under_pointer
;
1368 function zoomToArticle(event
, id
) {
1370 var cached_article
= cache_get("article: " + id
);
1372 if (dijit
.byId("ATAB-" + id
))
1373 if (!event
|| !event
.shiftKey
)
1374 return dijit
.byId("content-tabs").selectChild(dijit
.byId("ATAB-" + id
));
1376 if (dijit
.byId("ATSTRTIP-" + id
))
1377 dijit
.byId("ATSTRTIP-" + id
).destroyRecursive();
1379 if (cached_article
) {
1380 //closeArticlePanel();
1382 var article_pane
= new dijit
.layout
.ContentPane({
1383 title
: __("Loading...") , content
: cached_article
,
1384 style
: 'padding : 0px;',
1388 dijit
.byId("content-tabs").addChild(article_pane
);
1390 if (!event
|| !event
.shiftKey
)
1391 dijit
.byId("content-tabs").selectChild(article_pane
);
1393 if ($("PTITLE-" + id
))
1394 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1398 var query
= "?op=rpc&method=getArticles&ids=" + param_escape(id
);
1400 notify_progress("Loading, please wait...", true);
1402 new Ajax
.Request("backend.php", {
1404 onComplete: function(transport
) {
1407 var reply
= JSON
.parse(transport
.responseText
);
1410 //closeArticlePanel();
1412 var content
= reply
[0]['content'];
1414 var article_pane
= new dijit
.layout
.ContentPane({
1415 title
: "article-" + id
, content
: content
,
1416 style
: 'padding : 0px;',
1420 dijit
.byId("content-tabs").addChild(article_pane
);
1422 if (!event
|| !event
.shiftKey
)
1423 dijit
.byId("content-tabs").selectChild(article_pane
);
1425 if ($("PTITLE-" + id
))
1426 article_pane
.attr('title', $("PTITLE-" + id
).innerHTML
);
1433 exception_error("zoomToArticle", e
);
1437 function scrollArticle(offset
) {
1440 var ci
= $("content-insert");
1442 ci
.scrollTop
+= offset
;
1445 var hi
= $("headlines-frame");
1447 hi
.scrollTop
+= offset
;
1452 exception_error("scrollArticle", e
);
1456 function show_labels_in_headlines(transport
) {
1458 var data
= JSON
.parse(transport
.responseText
);
1461 data
['info-for-headlines'].each(function(elem
) {
1462 var ctr
= $("HLLCTR-" + elem
.id
);
1464 if (ctr
) ctr
.innerHTML
= elem
.labels
;
1467 cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML
);
1471 exception_error("show_labels_in_headlines", e
);
1475 /* function toggleHeadlineActions() {
1477 var e = $("headlineActionsBody");
1478 var p = $("headlineActionsDrop");
1480 if (!Element.visible(e)) {
1487 e.style.left = (p.offsetLeft + 1) + "px";
1488 e.style.top = (p.offsetTop + p.offsetHeight + 2) + "px";
1491 exception_error("toggleHeadlineActions", e);
1495 /* function publishWithNote(id, def_note) {
1497 if (!def_note) def_note = '';
1499 var note = prompt(__("Please enter a note for this article:"), def_note);
1501 if (note != undefined) {
1502 togglePub(id, false, false, note);
1506 exception_error("publishWithNote", e);
1510 function dismissArticle(id
) {
1512 var elem
= $("RROW-" + id
);
1514 toggleUnread(id
, 0, true);
1516 new Effect
.Fade(elem
, {duration
: 0.5});
1518 active_post_id
= false;
1521 exception_error("dismissArticle", e
);
1525 function dismissSelectedArticles() {
1528 var ids
= getVisibleArticleIds();
1532 for (var i
= 0; i
< ids
.length
; i
++) {
1533 var elem
= $("RROW-" + ids
[i
]);
1535 if (elem
.className
&& elem
.hasClassName("Selected") &&
1536 ids
[i
] != active_post_id
) {
1537 new Effect
.Fade(elem
, {duration
: 0.5});
1545 selectionToggleUnread(false);
1547 fixHeadlinesOrder(tmp
);
1550 exception_error("dismissSelectedArticles", e
);
1554 function dismissReadArticles() {
1557 var ids
= getVisibleArticleIds();
1560 for (var i
= 0; i
< ids
.length
; i
++) {
1561 var elem
= $("RROW-" + ids
[i
]);
1563 if (elem
.className
&& !elem
.hasClassName("Unread") &&
1564 !elem
.hasClassName("Selected")) {
1566 new Effect
.Fade(elem
, {duration
: 0.5});
1572 fixHeadlinesOrder(tmp
);
1575 exception_error("dismissSelectedArticles", e
);
1579 function getVisibleArticleIds() {
1584 getLoadedArticleIds().each(function(id
) {
1585 var elem
= $("RROW-" + id
);
1586 if (elem
&& Element
.visible(elem
))
1591 exception_error("getVisibleArticleIds", e
);
1597 function cdmClicked(event
, id
) {
1599 //var shift_key = event.shiftKey;
1603 if (!event
.ctrlKey
) {
1605 if (!getInitParam("cdm_expanded")) {
1606 return cdmExpandArticle(id
);
1609 selectArticles("none");
1612 var elem
= $("RROW-" + id
);
1613 var article_is_unread
= elem
.hasClassName("Unread");
1616 elem
.removeClassName("Unread");
1618 active_post_id
= id
;
1620 if (article_is_unread
) {
1621 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1624 var query
= "?op=rpc&method=catchupSelected" +
1625 "&cmode=0&ids=" + param_escape(id
);
1627 new Ajax
.Request("backend.php", {
1629 onComplete: function(transport
) {
1630 handle_rpc_json(transport
);
1637 toggleSelected(id
, true);
1639 var elem
= $("RROW-" + id
);
1640 var article_is_unread
= elem
.hasClassName("Unread");
1642 if (article_is_unread
) {
1643 decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
1646 toggleUnread(id
, 0, false);
1647 zoomToArticle(event
, id
);
1651 exception_error("cdmClicked");
1657 function postClicked(event
, id
) {
1660 if (!event
.ctrlKey
) {
1663 postOpenInNewTab(event
, id
);
1668 exception_error("postClicked");
1672 function hlOpenInNewTab(event
, id
) {
1673 toggleUnread(id
, 0, false);
1674 zoomToArticle(event
, id
);
1677 function postOpenInNewTab(event
, id
) {
1678 closeArticlePanel(id
);
1679 zoomToArticle(event
, id
);
1682 function hlClicked(event
, id
) {
1684 if (event
.which
== 2) {
1687 } else if (event
.altKey
) {
1688 openArticleInNewWindow(id
);
1689 } else if (!event
.ctrlKey
) {
1694 toggleUnread(id
, 0, false);
1695 zoomToArticle(event
, id
);
1700 exception_error("hlClicked");
1704 function getFirstVisibleHeadlineId() {
1705 var rows
= getVisibleArticleIds();
1710 function getLastVisibleHeadlineId() {
1711 var rows
= getVisibleArticleIds();
1712 return rows
[rows
.length
-1];
1715 function openArticleInNewWindow(id
) {
1716 toggleUnread(id
, 0, false);
1717 window
.open("backend.php?op=article&method=redirect&id=" + id
);
1720 function isCdmMode() {
1721 return getInitParam("combined_display_mode");
1724 function markHeadline(id
) {
1725 var row
= $("RROW-" + id
);
1727 var check
= dijit
.byId("RCHK-" + id
);
1730 check
.attr("checked", true);
1733 row
.addClassName("Selected");
1737 function getRelativePostIds(id
, limit
) {
1743 if (!limit
) limit
= 6; //3
1745 var ids
= getVisibleArticleIds();
1747 for (var i
= 0; i
< ids
.length
; i
++) {
1749 for (var k
= 1; k
<= limit
; k
++) {
1750 //if (i > k-1) tmp.push(ids[i-k]);
1751 if (i
< ids
.length
-k
) tmp
.push(ids
[i
+k
]);
1758 exception_error("getRelativePostIds", e
);
1764 function correctHeadlinesOffset(id
) {
1768 var container
= $("headlines-frame");
1769 var row
= $("RROW-" + id
);
1771 if (!container
|| !row
) return;
1773 var viewport
= container
.offsetHeight
;
1775 var rel_offset_top
= row
.offsetTop
- container
.scrollTop
;
1776 var rel_offset_bottom
= row
.offsetTop
+ row
.offsetHeight
- container
.scrollTop
;
1778 //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
1779 //console.log("Vport: " + viewport);
1781 if (rel_offset_top
<= 0 || rel_offset_top
> viewport
) {
1782 container
.scrollTop
= row
.offsetTop
;
1783 } else if (rel_offset_bottom
> viewport
) {
1785 /* doesn't properly work with Opera in some cases because
1786 Opera fucks up element scrolling */
1788 container
.scrollTop
= row
.offsetTop
+ row
.offsetHeight
- viewport
;
1792 exception_error("correctHeadlinesOffset", e
);
1797 function headlineActionsChange(elem
) {
1800 elem
.attr('value', 'false');
1802 exception_error("headlineActionsChange", e
);
1806 function closeArticlePanel() {
1808 var tabs
= dijit
.byId("content-tabs");
1809 var child
= tabs
.selectedChildWidget
;
1811 if (child
&& tabs
.getIndexOfChild(child
) > 0) {
1812 tabs
.removeChild(child
);
1815 if (dijit
.byId("content-insert"))
1816 dijit
.byId("headlines-wrap-inner").removeChild(
1817 dijit
.byId("content-insert"));
1821 function initHeadlinesMenu() {
1823 if (dijit
.byId("headlinesMenu"))
1824 dijit
.byId("headlinesMenu").destroyRecursive();
1829 nodes
= $$("#headlines-frame > div[id*=RROW]");
1831 nodes
= $$("#headlines-frame span[id*=RTITLE]");
1834 nodes
.each(function(node
) {
1838 var menu
= new dijit
.Menu({
1839 id
: "headlinesMenu",
1843 var tmph
= dojo
.connect(menu
, '_openMyself', function (event
) {
1844 var callerNode
= event
.target
, match
= null, tries
= 0;
1846 while (match
== null && callerNode
&& tries
<= 3) {
1847 match
= callerNode
.id
.match("^[A-Z]+[-]([0-9]+)$");
1848 callerNode
= callerNode
.parentNode
;
1852 if (match
) this.callerRowId
= parseInt(match
[1]);
1856 /* if (!isCdmMode())
1857 menu.addChild(new dijit.MenuItem({
1858 label: __("View article"),
1859 onClick: function(event) {
1860 view(this.getParent().callerRowId);
1863 menu
.addChild(new dijit
.MenuItem({
1864 label
: __("Open original article"),
1865 onClick: function(event
) {
1866 openArticleInNewWindow(this.getParent().callerRowId
);
1869 menu
.addChild(new dijit
.MenuItem({
1870 label
: __("View in a tt-rss tab"),
1871 onClick: function(event
) {
1872 hlOpenInNewTab(event
, this.getParent().callerRowId
);
1875 menu
.addChild(new dijit
.MenuSeparator());
1877 menu
.addChild(new dijit
.MenuItem({
1878 label
: __("Mark above as read"),
1879 onClick: function(event
) {
1880 catchupRelativeToArticle(0, this.getParent().callerRowId
);
1883 menu
.addChild(new dijit
.MenuItem({
1884 label
: __("Mark below as read"),
1885 onClick: function(event
) {
1886 catchupRelativeToArticle(1, this.getParent().callerRowId
);
1890 var labels
= dijit
.byId("feedTree").model
.getItemsInCategory(-2);
1894 menu
.addChild(new dijit
.MenuSeparator());
1896 var labelAddMenu
= new dijit
.Menu({ownerMenu
: menu
});
1897 var labelDelMenu
= new dijit
.Menu({ownerMenu
: menu
});
1899 labels
.each(function(label
) {
1900 var id
= label
.id
[0];
1901 var bare_id
= id
.substr(id
.indexOf(":")+1);
1902 var name
= label
.name
[0];
1904 bare_id
= -11-bare_id
;
1906 labelAddMenu
.addChild(new dijit
.MenuItem({
1909 onClick: function(event
) {
1910 var ids
= getSelectedArticleIds2();
1912 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
1914 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1916 selectionAssignLabel(this.labelId
, ids
);
1919 labelDelMenu
.addChild(new dijit
.MenuItem({
1922 onClick: function(event
) {
1923 var ids
= getSelectedArticleIds2();
1925 var id
= this.getParent().ownerMenu
.callerRowId
+ "";
1927 ids
= ids
.size() != 0 && ids
.indexOf(id
) != -1 ? ids
: [id
];
1929 selectionRemoveLabel(this.labelId
, ids
);
1934 menu
.addChild(new dijit
.PopupMenuItem({
1935 label
: __("Assign label"),
1936 popup
: labelAddMenu
,
1939 menu
.addChild(new dijit
.PopupMenuItem({
1940 label
: __("Remove label"),
1941 popup
: labelDelMenu
,
1949 exception_error("initHeadlinesMenu", e
);
1954 function player(elem
) {
1955 var aid
= elem
.getAttribute("audio-id");
1956 var status
= elem
.getAttribute("status");
1964 elem
.innerHTML
= __("Playing...");
1965 elem
.title
= __("Click to pause");
1966 elem
.addClassName("playing");
1970 elem
.innerHTML
= __("Play");
1971 elem
.title
= __("Click to play");
1972 elem
.removeClassName("playing");
1975 elem
.setAttribute("status", status
);
1977 alert("Your browser doesn't seem to support HTML5 audio.");
1981 function cache_set(id
, obj
) {
1982 //console.log("cache_set: " + id);
1985 sessionStorage
[id
] = obj
;
1987 sessionStorage
.clear();
1991 function cache_get(id
) {
1993 return sessionStorage
[id
];
1996 function cache_clear() {
1998 sessionStorage
.clear();
2001 function cache_delete(id
) {
2003 sessionStorage
.removeItem(id
);
2006 function cache_headlines(feed
, is_cat
, toolbar_obj
, content_obj
) {
2007 if (toolbar_obj
&& content_obj
) {
2008 cache_set("feed:" + feed
+ ":" + is_cat
,
2009 JSON
.stringify({toolbar
: toolbar_obj
, content
: content_obj
}));
2012 obj
= cache_get("feed:" + feed
+ ":" + is_cat
);
2015 obj
= JSON
.parse(obj
);
2017 if (toolbar_obj
) obj
.toolbar
= toolbar_obj
;
2018 if (content_obj
) obj
.content
= content_obj
;
2020 cache_set("feed:" + feed
+ ":" + is_cat
, JSON
.stringify(obj
));
2024 console
.warn("cache_headlines failed: " + e
);
2029 function render_local_headlines(feed
, is_cat
, obj
) {
2032 dijit
.byId("headlines-toolbar").attr('content',
2035 dijit
.byId("headlines-frame").attr('content',
2038 dojo
.parser
.parse('headlines-toolbar');
2040 $("headlines-frame").scrollTop
= 0;
2041 selectArticles('none');
2042 setActiveFeedId(feed
, is_cat
);
2043 initHeadlinesMenu();
2045 dijit
.getEnclosingWidget(
2046 document
.forms
["main_toolbar_form"].update
).attr('disabled',
2047 is_cat
|| feed
<= 0);
2049 precache_headlines();
2052 exception_error("render_local_headlines", e
);
2056 function precache_headlines_idle() {
2058 if (!feed_precache_timeout_id
) {
2059 if (get_timestamp() - _viewfeed_last
> 120) {
2061 var feeds
= dijit
.byId("feedTree").getVisibleUnreadFeeds();
2064 feeds
.each(function(item
) {
2065 if (parseInt(item
[0]) > 0 && !cache_get("feed:" + item
[0] + ":" + item
[1]))
2066 uncached
.push(item
);
2069 if (uncached
.length
> 0) {
2070 var rf
= uncached
[Math
.floor(Math
.random()*uncached
.length
)];
2071 viewfeed(rf
[0], '', rf
[1], 0, true);
2075 precache_idle_timeout_id
= setTimeout("precache_headlines_idle()", 1000*30);
2078 exception_error("precache_headlines_idle", e
);
2082 function precache_headlines() {
2085 if (!feed_precache_timeout_id
) {
2086 feed_precache_timeout_id
= window
.setTimeout(function() {
2087 var nuf
= getNextUnreadFeed(getActiveFeedId(), activeFeedIsCat());
2088 var nf
= dijit
.byId("feedTree").getNextFeed(getActiveFeedId(), activeFeedIsCat());
2090 if (nuf
&& !cache_get("feed:" + nuf
+ ":" + activeFeedIsCat()))
2091 viewfeed(nuf
, '', activeFeedIsCat(), 0, true);
2093 if (nf
&& nf
[0] != nuf
&& !cache_get("feed:" + nf
[0] + ":" + nf
[1]))
2094 viewfeed(nf
[0], '', nf
[1], 0, true);
2096 window
.setTimeout(function() {
2097 feed_precache_timeout_id
= false;
2103 exception_error("precache_headlines", e
);
2107 function cancelSearch() {
2112 exception_error("cancelSearch", e
);
2116 function setSelectionScore() {
2118 var ids
= getSelectedArticleIds2();
2120 if (ids
.length
> 0) {
2123 var score
= prompt(__("Please enter new score for selected articles:"), score
);
2125 if (score
!= undefined) {
2126 var query
= "op=rpc&method=setScore&id=" + param_escape(ids
.toString()) +
2127 "&score=" + param_escape(score
);
2129 new Ajax
.Request("backend.php", {
2131 onComplete: function(transport
) {
2132 var reply
= JSON
.parse(transport
.responseText
);
2136 ids
.each(function(id
) {
2137 var row
= $("RROW-" + id
);
2140 var pic
= row
.getElementsByClassName("hlScorePic")[0];
2143 pic
.src
= pic
.src
.replace(/score_.*?\.png/,
2144 reply
["score_pic"]);
2145 pic
.setAttribute("score", score
);
2154 alert(__("No articles are selected."));
2157 exception_error("setSelectionScore", e
);
2161 function changeScore(id
, pic
) {
2163 var score
= pic
.getAttribute("score");
2165 var new_score
= prompt(__("Please enter new score for this article:"), score
);
2167 if (new_score
!= undefined) {
2169 var query
= "op=rpc&method=setScore&id=" + param_escape(id
) +
2170 "&score=" + param_escape(new_score
);
2172 new Ajax
.Request("backend.php", {
2174 onComplete: function(transport
) {
2175 var reply
= JSON
.parse(transport
.responseText
);
2178 pic
.src
= pic
.src
.replace(/score_.*?\.png/, reply
["score_pic"]);
2179 pic
.setAttribute("score", new_score
);
2184 exception_error("changeScore", e
);