2 var display_tags
= false;
3 var global_unread
= -1;
4 var firsttime_update
= true;
5 var _active_feed_id
= 0;
6 var _active_feed_is_cat
= false;
7 var number_of_feeds
= 0;
8 var hotkey_prefix
= false;
9 var hotkey_prefix_pressed
= false;
13 var _force_scheduled_update
= false;
14 var last_scheduled_update
= false;
27 function activeFeedIsCat() {
28 return _active_feed_is_cat
;
31 function getActiveFeedId() {
33 //console.log("gAFID: " + _active_feed_id);
34 return _active_feed_id
;
36 exception_error("getActiveFeedId", e
);
40 function setActiveFeedId(id
, is_cat
) {
42 //console.log("sAFID(" + id + ", " + is_cat + ")");
45 if (is_cat
!= undefined) {
46 _active_feed_is_cat
= is_cat
;
50 exception_error("setActiveFeedId", e
);
55 function isFeedlistSortable() {
56 return feedlist_sortable_enabled
;
59 function tagsAreDisplayed() {
63 function toggleTags(show_all
) {
67 console
.log("toggleTags: " + show_all
+ "; " + display_tags
);
69 var p
= $("dispSwitchPrompt");
71 if (!show_all
&& !display_tags
) {
72 displayDlg("printTagCloud");
73 } else if (show_all
) {
76 p
.innerHTML
= __("display feeds");
77 notify_progress("Loading, please wait...", true);
79 } else if (display_tags
) {
81 p
.innerHTML
= __("tag cloud");
82 notify_progress("Loading, please wait...", true);
87 exception_error("toggleTags", e
);
91 function dlg_frefresh_callback(transport
, deleted_feed
) {
92 if (getActiveFeedId() == deleted_feed
) {
93 setTimeout("viewfeed(-5)", 100);
96 setTimeout('updateFeedList(false, false)', 50);
100 function updateFeedList() {
102 //console.log("updateFeedList");
104 if (offline_mode
) return render_offline_feedlist();
106 var query_str
= "backend.php?op=feeds";
109 query_str
= query_str
+ "&tags=1";
112 if (getActiveFeedId() && !activeFeedIsCat()) {
113 query_str
= query_str
+ "&actid=" + getActiveFeedId();
116 new Ajax
.Request("backend.php", {
117 parameters
: query_str
,
118 onComplete: function(transport
) {
119 render_feedlist(transport
.responseText
);
123 exception_error("updateFeedList", e
);
127 function catchupAllFeeds() {
129 var str
= __("Mark all articles as read?");
131 if (getInitParam("confirm_feed_catchup") != 1 || confirm(str
)) {
133 var query_str
= "backend.php?op=feeds&subop=catchupAll";
135 notify_progress("Marking all feeds as read...");
137 //console.log("catchupAllFeeds Q=" + query_str);
139 new Ajax
.Request("backend.php", {
140 parameters
: query_str
,
141 onComplete: function(transport
) {
142 feedlist_callback2(transport
);
150 function viewCurrentFeed(subop
) {
152 if (getActiveFeedId() != undefined) {
153 viewfeed(getActiveFeedId(), subop
, activeFeedIsCat());
155 return false; // block unneeded form submits
159 if (getInitParam("bw_limit") == "1") return;
162 var date
= new Date();
163 var ts
= Math
.round(date
.getTime() / 1000);
165 if (ts
- last_scheduled_update
> 10 || _force_scheduled_update
) {
167 //console.log("timeout()");
169 window
.clearTimeout(counter_timeout_id
);
171 var query_str
= "?op=rpc&subop=getAllCounters&seq=" + next_seq();
175 if (firsttime_update
&& !navigator
.userAgent
.match("Opera")) {
176 firsttime_update
= false;
186 query_str
= query_str
+ "&omode=" + omode
;
188 if (!_force_scheduled_update
)
189 query_str
= query_str
+ "&last_article_id=" + getInitParam("last_article_id");
191 //console.log("[timeout]" + query_str);
193 new Ajax
.Request("backend.php", {
194 parameters
: query_str
,
195 onComplete: function(transport
) {
196 handle_rpc_reply(transport
, !_force_scheduled_update
);
197 _force_scheduled_update
= false;
200 last_scheduled_update
= ts
;
204 exception_error("timeout", e
);
207 setTimeout("timeout()", 3000);
215 function updateTitle() {
216 var tmp
= "Tiny Tiny RSS";
218 if (global_unread
> 0) {
219 tmp
= tmp
+ " (" + global_unread
+ ")";
223 if (global_unread
> 0) {
224 window
.fluid
.dockBadge
= global_unread
;
226 window
.fluid
.dockBadge
= "";
230 document
.title
= tmp
;
233 function genericSanityCheck() {
234 setCookie("ttrss_test", "TEST");
236 if (getCookie("ttrss_test") != "TEST") {
249 Form
.disable("main_toolbar_form");
251 if (!genericSanityCheck())
254 var params
= "&ua=" + param_escape(navigator
.userAgent
);
256 loading_set_progress(30);
258 new Ajax
.Request("backend.php", {
259 parameters
: "backend.php?op=rpc&subop=sanityCheck" + params
,
260 onComplete: function(transport
) {
261 backend_sanity_check_callback(transport
);
265 exception_error("init", e
);
269 function resize_headlines(delta_x
, delta_y
) {
273 console
.log("resize_headlines: " + delta_x
+ ":" + delta_y
);
275 var h_frame
= $("headlines-frame");
276 var c_frame
= $("content-frame");
277 var f_frame
= $("footer");
278 var feeds_frame
= $("feeds-holder");
279 var resize_grab
= $("resize-grabber");
280 var resize_handle
= $("resize-handle");
282 if (!c_frame
|| !h_frame
) return;
284 if (feeds_frame
&& getInitParam("theme") == "old-skool") {
285 feeds_frame
.style
.bottom
= f_frame
.offsetHeight
+ "px";
288 if (getInitParam("theme_options").match("horiz_resize")) {
290 if (delta_x
!= undefined) {
291 if (c_frame
.offsetLeft
- delta_x
> feeds_frame
.offsetWidth
+ feeds_frame
.offsetLeft
+ 100 && c_frame
.offsetWidth
+ delta_x
> 100) {
292 hor_offset
= hor_offset
+ delta_x
;
296 console
.log("resize_headlines: HOR-mode: " + hor_offset
);
298 c_frame
.style
.width
= (400 + hor_offset
) + "px";
299 h_frame
.style
.right
= c_frame
.offsetWidth
- 1 + "px";
301 resize_grab
.style
.top
= (h_frame
.offsetTop
+ h_frame
.offsetHeight
- 60) + "px";
302 resize_grab
.style
.left
= (h_frame
.offsetLeft
+ h_frame
.offsetWidth
-
304 resize_grab
.style
.display
= "block";
306 //resize_handle.src = "themes/"+getInitParam('theme')+"/images/resize_handle_vert.png";
307 resize_handle
.style
.paddingTop
= (resize_grab
.offsetHeight
/ 2 - 7) + "px";
311 if (delta_y
!= undefined) {
312 if (c_frame
.offsetHeight
+ delta_y
> 100 && h_frame
.offsetHeight
- delta_y
> 100) {
313 ver_offset
= ver_offset
+ delta_y
;
317 console
.log("resize_headlines: VER-mode: " + ver_offset
);
319 h_frame
.style
.height
= (300 - ver_offset
) + "px";
321 c_frame
.style
.top
= (h_frame
.offsetTop
+ h_frame
.offsetHeight
+ 0) + "px";
322 h_frame
.style
.height
= h_frame
.offsetHeight
+ "px";
324 // Workaround for Opera: force the content page to be re-rendered,
325 // so it is not truncated:
326 var content_pane
= $("content-insert");
327 content_pane
.innerHTML
= content_pane
.innerHTML
;
330 if (getInitParam("cookie_lifetime") != 0) {
331 setCookie("ttrss_offset_ver", ver_offset
,
332 getInitParam("cookie_lifetime"));
333 setCookie("ttrss_offset_hor", hor_offset
,
334 getInitParam("cookie_lifetime"));
336 setCookie("ttrss_offset_ver", ver_offset
);
337 setCookie("ttrss_offset_hor", hor_offset
);
341 exception_error("resize_headlines", e
);
346 function init_second_stage() {
350 delCookie("ttrss_test");
352 window
.onresize
=resize_headlines
;
354 var toolbar
= document
.forms
["main_toolbar_form"];
356 dropboxSelect(toolbar
.view_mode
, getInitParam("default_view_mode"));
357 dropboxSelect(toolbar
.order_by
, getInitParam("default_view_order_by"));
359 feeds_sort_by_unread
= getInitParam("feeds_sort_by_unread") == 1;
361 setTimeout('updateFeedList(false, false)', 50);
363 console
.log("second stage ok");
365 loading_set_progress(60);
367 ver_offset
= parseInt(getCookie("ttrss_offset_ver"));
368 hor_offset
= parseInt(getCookie("ttrss_offset_hor"));
370 console
.log("got offsets from cookies: ver " + ver_offset
+ " hor " + hor_offset
);
374 if (isNaN(hor_offset
)) hor_offset
= 0;
375 if (isNaN(ver_offset
)) ver_offset
= 0;
377 console
.log("offsets from cookies [x:y]: " + hor_offset
+ ":" + ver_offset
);
381 enable_offline_reading();
383 if (has_local_storage())
384 localStorage
.clear();
387 exception_error("init_second_stage", e
);
391 function quickMenuChange() {
392 var chooser
= $("quickMenuChooser");
393 var opid
= chooser
[chooser
.selectedIndex
].value
;
395 chooser
.selectedIndex
= 0;
399 function quickMenuGo(opid
) {
402 if (opid
== "qmcPrefs") {
406 if (opid
== "qmcSearch") {
407 displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat(),
409 document
.forms
['search_form'].query
.focus();
414 if (opid
== "qmcAddFeed") {
419 if (opid
== "qmcEditFeed") {
420 editFeedDlg(getActiveFeedId());
423 if (opid
== "qmcRemoveFeed") {
424 var actid
= getActiveFeedId();
426 if (activeFeedIsCat()) {
427 alert(__("You can't unsubscribe from the category."));
432 alert(__("Please select some feed first."));
436 var fn
= getFeedName(actid
);
438 var pr
= __("Unsubscribe from %s?").replace("%s", fn
);
441 unsubscribeFeed(actid
);
447 if (opid
== "qmcCatchupAll") {
452 if (opid
== "qmcShowOnlyUnread") {
457 if (opid
== "qmcAddFilter") {
458 displayDlg('quickAddFilter', '',
459 function () {document
.forms
['filter_add_form'].reg_exp
.focus();});
462 if (opid
== "qmcAddLabel") {
466 if (opid
== "qmcRescoreFeed") {
467 rescoreCurrentFeed();
470 if (opid
== "qmcHKhelp") {
471 //Element.show("hotkey_help_overlay");
472 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
475 if (opid
== "qmcResetUI") {
481 if (opid
== "qmcToggleReorder") {
482 feedlist_sortable_enabled
= !feedlist_sortable_enabled
;
484 if (feedlist_sortable_enabled
) {
485 notify_info("Category reordering enabled");
486 toggle_sortable_feedlist(true);
488 notify_info("Category reordering disabled");
489 toggle_sortable_feedlist(false);
493 if (opid
== "qmcResetCats") {
495 if (confirm(__("Reset category order?"))) {
497 var query
= "?op=feeds&subop=catsortreset";
499 notify_progress("Loading, please wait...", true);
501 new Ajax
.Request("backend.php", {
503 onComplete: function(transport
) {
504 window
.setTimeout('updateFeedList(false, false)', 50);
510 exception_error("quickMenuGo", e
);
514 function toggleDispRead() {
517 var hide
= !(getInitParam("hide_read_feeds") == "1");
519 hideOrShowFeeds(hide
);
521 var query
= "?op=rpc&subop=setpref&key=HIDE_READ_FEEDS&value=" +
524 new Ajax
.Request("backend.php", {
526 onComplete: function(transport
) {
527 setInitParam("hide_read_feeds", hide
);
531 exception_error("toggleDispRead", e
);
535 function parse_runtime_info(elem
) {
537 if (!elem
|| !elem
.firstChild
) {
538 console
.warn("parse_runtime_info: invalid node passed");
542 var data
= JSON
.parse(elem
.firstChild
.nodeValue
);
544 //console.log("parsing runtime info...");
549 // console.log("RI: " + k + " => " + v);
551 if (k
== "new_version_available") {
552 var icon
= $("newVersionIcon");
555 icon
.style
.display
= "inline";
557 icon
.style
.display
= "none";
565 if (k
== "daemon_is_running" && v
!= 1) {
566 notify_error("<span onclick=\"javascript:explainError(1)\">Update daemon is not running.</span>", true);
570 if (k
== "daemon_stamp_ok" && v
!= 1) {
571 notify_error("<span onclick=\"javascript:explainError(3)\">Update daemon is not updating feeds.</span>", true);
580 function catchupCurrentFeed() {
582 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
584 var str
= __("Mark all articles in %s as read?").replace("%s", fn
);
586 if (getInitParam("confirm_feed_catchup") != 1 || confirm(str
)) {
587 return viewCurrentFeed('MarkAllRead')
591 function catchupFeedInGroup(id
) {
595 var title
= getFeedName(id
);
597 var str
= __("Mark all articles in %s as read?").replace("%s", title
);
599 if (getInitParam("confirm_feed_catchup") != 1 || confirm(str
)) {
600 return viewCurrentFeed('MarkAllReadGR:' + id
)
604 exception_error("catchupFeedInGroup", e
);
608 function editFeedDlg(feed
) {
612 alert(__("Please select some feed first."));
616 if ((feed
<= 0) || activeFeedIsCat() || tagsAreDisplayed()) {
617 alert(__("You can't edit this kind of feed."));
624 query
= "?op=pref-feeds&subop=editfeed&id=" + param_escape(feed
);
626 query
= "?op=pref-labels&subop=edit&id=" + param_escape(-feed
-11);
631 notify_progress("Loading, please wait...", true);
633 new Ajax
.Request("backend.php", {
635 onComplete: function(transport
) {
636 infobox_callback2(transport
);
637 document
.forms
["edit_feed_form"].title
.focus();
641 exception_error("editFeedDlg", e
);
645 /* this functions duplicate those of prefs.js feed editor, with
646 some differences because there is no feedlist */
648 function feedEditCancel() {
653 function feedEditSave() {
657 // FIXME: add parameter validation
659 var query
= Form
.serialize("edit_feed_form");
661 notify_progress("Saving feed...");
663 new Ajax
.Request("backend.php", {
665 onComplete: function(transport
) {
666 dlg_frefresh_callback(transport
);
675 exception_error("feedEditSave (main)", e
);
679 function collapse_feedlist() {
681 //console.log("collapse_feedlist");
683 var theme
= getInitParam("theme");
685 !getInitParam("theme_options").match("collapse_feedlist")) return;
687 var fl
= $("feeds-holder");
688 var fh
= $("headlines-frame");
689 var fc
= $("content-frame");
690 var ft
= $("toolbar");
691 var ff
= $("footer");
692 var fhdr
= $("header");
693 var fbtn
= $("collapse_feeds_btn");
695 if (!Element
.visible(fl
)) {
697 fbtn
.innerHTML
= "<<";
699 if (theme
!= "graycube") {
701 fh
.style
.left
= fl
.offsetWidth
+ "px";
702 ft
.style
.left
= fl
.offsetWidth
+ "px";
703 if (fc
) fc
.style
.left
= fl
.offsetWidth
+ "px";
704 if (ff
&& theme
!= "compat") ff
.style
.left
= (fl
.offsetWidth
-1) + "px";
706 if (theme
== "compact") fhdr
.style
.left
= (fl
.offsetWidth
+ 10) + "px";
708 fh
.style
.left
= fl
.offsetWidth
+ 40 + "px";
709 ft
.style
.left
= fl
.offsetWidth
+ 40 +"px";
710 if (fc
) fc
.style
.left
= fl
.offsetWidth
+ 40 + "px";
713 query
= "?op=rpc&subop=setpref&key=_COLLAPSED_FEEDLIST&value=false";
715 new Ajax
.Request("backend.php", { parameters
: query
});
719 fbtn
.innerHTML
= ">>";
721 if (theme
!= "graycube") {
723 fh
.style
.left
= "0px";
724 ft
.style
.left
= "0px";
725 if (fc
) fc
.style
.left
= "0px";
726 if (ff
) ff
.style
.left
= "0px";
728 if (theme
== "compact") fhdr
.style
.left
= "10px";
731 fh
.style
.left
= "20px";
732 ft
.style
.left
= "20px";
733 if (fc
) fc
.style
.left
= "20px";
737 query
= "?op=rpc&subop=setpref&key=_COLLAPSED_FEEDLIST&value=true";
739 new Ajax
.Request("backend.php", { parameters
: query
});
743 exception_error("collapse_feedlist", e
);
747 function viewModeChanged() {
749 return viewCurrentFeed('')
752 function viewLimitChanged() {
754 return viewCurrentFeed('')
757 /* function adjustArticleScore(id, score) {
760 var pr = prompt(__("Assign score to article:"), score);
762 if (pr != undefined) {
763 var query = "?op=rpc&subop=setScore&id=" + id + "&score=" + pr;
765 new Ajax.Request("backend.php", {
767 onComplete: function(transport) {
773 exception_error("adjustArticleScore", e);
777 function rescoreCurrentFeed() {
779 var actid
= getActiveFeedId();
781 if (activeFeedIsCat() || actid
< 0 || tagsAreDisplayed()) {
782 alert(__("You can't rescore this kind of feed."));
787 alert(__("Please select some feed first."));
791 var fn
= getFeedName(actid
);
792 var pr
= __("Rescore articles in %s?").replace("%s", fn
);
795 notify_progress("Rescoring articles...");
797 var query
= "?op=pref-feeds&subop=rescore&quiet=1&ids=" + actid
;
799 new Ajax
.Request("backend.php", {
801 onComplete: function(transport
) {
807 function hotkey_handler(e
) {
812 var shift_key
= false;
814 var cmdline
= $('cmdline');
817 shift_key
= e
.shiftKey
;
823 keycode
= window
.event
.keyCode
;
828 var keychar
= String
.fromCharCode(keycode
);
830 if (keycode
== 27) { // escape
831 if (Element
.visible("hotkey_help_overlay")) {
832 Element
.hide("hotkey_help_overlay");
834 hotkey_prefix
= false;
838 if (!hotkeys_enabled
) {
839 console
.log("hotkeys disabled");
843 if (keycode
== 16) return; // ignore lone shift
845 if ((keycode
== 70 || keycode
== 67 || keycode
== 71)
848 var date
= new Date();
849 var ts
= Math
.round(date
.getTime() / 1000);
851 hotkey_prefix
= keycode
;
852 hotkey_prefix_pressed
= ts
;
854 cmdline
.innerHTML
= keychar
;
855 Element
.show(cmdline
);
857 console
.log("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
+ " TS=" + ts
);
861 if (Element
.visible("hotkey_help_overlay")) {
862 Element
.hide("hotkey_help_overlay");
867 Element
.hide(cmdline
);
869 if (!hotkey_prefix
) {
871 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
872 if (!Element
.visible("hotkey_help_overlay")) {
873 //Element.show("hotkey_help_overlay");
874 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
876 Element
.hide("hotkey_help_overlay");
881 if (keycode
== 191 || keychar
== '/') { // /
882 displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat(),
884 document
.forms
['search_form'].query
.focus();
889 /* if (keycode == 82 && shift_key) { // R
890 scheduleFeedUpdate(true);
894 if (keycode
== 74) { // j
895 var feed
= getActiveFeedId();
896 var new_feed
= getRelativeFeedId2(feed
, activeFeedIsCat(), 'prev');
897 // alert(feed + " IC: " + activeFeedIsCat() + " => " + new_feed);
899 var is_cat
= new_feed
.match("CAT:");
901 new_feed
= new_feed
.replace("CAT:", "");
902 viewCategory(new_feed
);
904 viewfeed(new_feed
, '', false);
910 if (keycode
== 75) { // k
911 var feed
= getActiveFeedId();
912 var new_feed
= getRelativeFeedId2(feed
, activeFeedIsCat(), 'next');
913 // alert(feed + " IC: " + activeFeedIsCat() + " => " + new_feed);
915 var is_cat
= new_feed
.match("CAT:");
916 if (is_cat
== "CAT:") {
917 new_feed
= new_feed
.replace("CAT:", "");
918 viewCategory(new_feed
);
920 viewfeed(new_feed
, '', false);
926 if (shift_key
&& keycode
== 40) { // shift-down
927 catchupRelativeToArticle(1);
931 if (shift_key
&& keycode
== 38) { // shift-up
932 catchupRelativeToArticle(0);
936 if (shift_key
&& keycode
== 78) { // N
941 if (shift_key
&& keycode
== 80) { // P
946 if (keycode
== 68 && shift_key
) { // shift-D
947 dismissSelectedArticles();
950 if (keycode
== 88 && shift_key
) { // shift-X
951 dismissReadArticles();
954 if (keycode
== 78 || keycode
== 40) { // n, down
955 if (typeof moveToPost
!= 'undefined') {
961 if (keycode
== 80 || keycode
== 38) { // p, up
962 if (typeof moveToPost
!= 'undefined') {
968 if (keycode
== 83 && shift_key
) { // S
969 var id
= getActiveArticleId();
976 if (keycode
== 83) { // s
977 var id
= getActiveArticleId();
985 if (keycode
== 85) { // u
986 var id
= getActiveArticleId();
993 if (keycode
== 84 && shift_key
) { // T
994 var id
= getActiveArticleId();
996 editArticleTags(id
, getActiveFeedId(), isCdmMode());
1001 if (keycode
== 9) { // tab
1002 var id
= getArticleUnderPointer();
1004 var cb
= $("RCHK-" + id
);
1007 cb
.checked
= !cb
.checked
;
1008 toggleSelectRowById(cb
, "RROW-" + id
);
1014 if (keycode
== 79) { // o
1015 if (getActiveArticleId()) {
1016 openArticleInNewWindow(getActiveArticleId());
1021 if (keycode
== 81 && shift_key
) { // Q
1022 if (typeof catchupAllFeeds
!= 'undefined') {
1028 if (keycode
== 88) { // x
1029 if (activeFeedIsCat()) {
1030 toggleCollapseCat(getActiveFeedId());
1037 if (hotkey_prefix
== 70) { // f
1039 hotkey_prefix
= false;
1041 if (keycode
== 81) { // q
1042 if (getActiveFeedId()) {
1043 catchupCurrentFeed();
1048 if (keycode
== 82) { // r
1049 if (getActiveFeedId()) {
1050 viewfeed(getActiveFeedId(), "ForceUpdate", activeFeedIsCat());
1055 if (keycode
== 65) { // a
1060 /* if (keycode == 85 && shift_key) { // U
1061 scheduleFeedUpdate(true);
1065 if (keycode
== 85) { // u
1066 if (getActiveFeedId()) {
1067 viewfeed(getActiveFeedId(), "ForceUpdate");
1072 if (keycode
== 69) { // e
1073 editFeedDlg(getActiveFeedId());
1077 if (keycode
== 83) { // s
1082 if (keycode
== 67 && shift_key
) { // C
1083 if (typeof catchupAllFeeds
!= 'undefined') {
1089 if (keycode
== 67) { // c
1090 if (getActiveFeedId()) {
1091 catchupCurrentFeed();
1096 if (keycode
== 87) { // w
1097 feeds_sort_by_unread
= !feeds_sort_by_unread
;
1098 return resort_feedlist();
1101 if (keycode
== 88) { // x
1102 reverseHeadlineOrder();
1109 if (hotkey_prefix
== 67) { // c
1110 hotkey_prefix
= false;
1112 if (keycode
== 70) { // f
1113 displayDlg('quickAddFilter', '',
1114 function () {document
.forms
['filter_add_form'].reg_exp
.focus();});
1118 if (keycode
== 76) { // l
1123 if (keycode
== 83) { // s
1124 if (typeof collapse_feedlist
!= 'undefined') {
1125 collapse_feedlist();
1130 if (keycode
== 77) { // m
1131 feedlist_sortable_enabled
= !feedlist_sortable_enabled
;
1132 if (feedlist_sortable_enabled
) {
1133 notify_info("Category reordering enabled");
1134 toggle_sortable_feedlist(true);
1136 notify_info("Category reordering disabled");
1137 toggle_sortable_feedlist(false);
1141 if (keycode
== 78) { // n
1142 catchupRelativeToArticle(1);
1146 if (keycode
== 80) { // p
1147 catchupRelativeToArticle(0);
1156 if (hotkey_prefix
== 71) { // g
1158 hotkey_prefix
= false;
1161 if (keycode
== 65) { // a
1166 if (keycode
== 83) { // s
1171 if (keycode
== 80 && shift_key
) { // P
1176 if (keycode
== 80) { // p
1181 if (keycode
== 70) { // f
1186 if (keycode
== 84 && shift_key
) { // T
1194 if (hotkey_prefix
== 224 || hotkey_prefix
== 91) { // f
1195 hotkey_prefix
= false;
1199 if (hotkey_prefix
) {
1200 console
.log("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1202 console
.log("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1207 exception_error("hotkey_handler", e
);
1211 function inPreferences() {
1215 function reverseHeadlineOrder() {
1218 var query_str
= "?op=rpc&subop=togglepref&key=REVERSE_HEADLINES";
1220 new Ajax
.Request("backend.php", {
1221 parameters
: query_str
,
1222 onComplete: function(transport
) {
1227 exception_error("reverseHeadlineOrder", e
);
1231 function showFeedsWithErrors() {
1232 displayDlg('feedUpdateErrors');
1235 function handle_rpc_reply(transport
, scheduled_call
) {
1237 if (offline_mode
) return false;
1239 if (!transport
.responseText
&& db
) {
1240 offlineConfirmModeChange();
1244 if (transport
.responseXML
) {
1246 if (!transport_error_check(transport
)) return false;
1248 var seq
= transport
.responseXML
.getElementsByTagName("seq")[0];
1251 seq
= seq
.firstChild
.nodeValue
;
1253 if (get_seq() != seq
) {
1254 //console.log("[handle_rpc_reply] sequence mismatch: " + seq);
1259 var message
= transport
.responseXML
.getElementsByTagName("message")[0];
1262 message
= message
.firstChild
.nodeValue
;
1264 if (message
== "UPDATE_COUNTERS") {
1265 console
.log("need to refresh counters...");
1266 setInitParam("last_article_id", -1);
1267 _force_scheduled_update
= true;
1271 var counters
= transport
.responseXML
.getElementsByTagName("counters")[0];
1274 parse_counters(counters
, scheduled_call
);
1276 var runtime_info
= transport
.responseXML
.getElementsByTagName("runtime-info")[0];
1279 parse_runtime_info(runtime_info
);
1281 if (feedsSortByUnread())
1284 hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
1287 notify_error("Error communicating with server.");
1291 exception_error("handle_rpc_reply", e
, transport
);