4 var display_tags
= false;
5 var global_unread
= -1;
6 var active_title_text
= "";
7 var current_subtitle
= "";
8 var daemon_enabled
= false;
9 var daemon_refresh_only
= false;
10 //var _qfd_deleted_feed = 0;
11 var firsttime_update
= true;
12 var _active_feed_id
= 0;
13 var _active_feed_is_cat
= false;
14 var number_of_feeds
= 0;
15 var sanity_check_done
= false;
16 var _hfd_scrolltop
= 0;
17 var hotkey_prefix
= false;
18 var init_params
= new Object();
21 var feeds_sort_by_unread
= false;
22 var feedlist_sortable_enabled
= false;
24 function activeFeedIsCat() {
25 return _active_feed_is_cat
;
28 function getActiveFeedId() {
29 // return getCookie("ttrss_vf_actfeed");
31 debug("gAFID: " + _active_feed_id
);
32 return _active_feed_id
;
34 exception_error("getActiveFeedId", e
);
38 function setActiveFeedId(id
, is_cat
) {
39 // return setCookie("ttrss_vf_actfeed", id);
41 debug("sAFID(" + id
+ ", " + is_cat
+ ")");
44 if (is_cat
!= undefined) {
45 _active_feed_is_cat
= is_cat
;
49 exception_error("setActiveFeedId", e
);
54 function isFeedlistSortable() {
55 return feedlist_sortable_enabled
;
58 function tagsAreDisplayed() {
62 function toggleTags(show_all
) {
66 debug("toggleTags: " + show_all
+ "; " + display_tags
);
68 var p
= $("dispSwitchPrompt");
70 if (!show_all
&& !display_tags
) {
71 displayDlg("printTagCloud");
72 } else if (show_all
) {
75 p
.innerHTML
= __("display feeds");
76 notify_progress("Loading, please wait...", true);
78 } else if (display_tags
) {
80 p
.innerHTML
= __("tag cloud");
81 notify_progress("Loading, please wait...", true);
86 exception_error("toggleTags", e
);
90 function dlg_frefresh_callback(transport
, deleted_feed
) {
91 if (getActiveFeedId() == deleted_feed
) {
92 var h
= $("headlines-frame");
94 h
.innerHTML
= "<div class='whiteBox'>" + __('No feed selected.') + "</div>";
98 setTimeout('updateFeedList(false, false)', 50);
102 function refetch_callback2(transport
) {
105 var date
= new Date();
107 parse_counters_reply(transport
, true);
109 debug("refetch_callback2: done");
111 /* if (!daemon_enabled && !daemon_refresh_only) {
112 notify_info("All feeds updated.");
118 exception_error("refetch_callback", e
);
123 function backend_sanity_check_callback(transport
) {
127 if (sanity_check_done
) {
128 fatalError(11, "Sanity check request received twice. This can indicate "+
129 "presence of Firebug or some other disrupting extension. "+
130 "Please disable it and try again.");
134 if (!transport
.responseXML
) {
136 fatalError(3, "Sanity check: Received reply is not XML",
137 transport
.responseText
);
145 if (getURLParam("offline")) {
146 return init_offline();
149 var reply
= transport
.responseXML
.firstChild
.firstChild
;
152 fatalError(3, "Sanity check: invalid RPC reply", transport
.responseText
);
156 var error_code
= reply
.getAttribute("error-code");
158 if (error_code
&& error_code
!= 0) {
159 return fatalError(error_code
, reply
.getAttribute("error-msg"));
162 debug("sanity check ok");
164 var params
= reply
.nextSibling
;
167 debug('reading init-params...');
168 var param
= params
.firstChild
;
171 var k
= param
.getAttribute("key");
172 var v
= param
.getAttribute("value");
173 debug(k
+ " => " + v
);
177 db
.execute("DELETE FROM init_params WHERE key = ?", [k
]);
178 db
.execute("INSERT INTO init_params (key,value) VALUES (?, ?)",
182 param
= param
.nextSibling
;
186 sanity_check_done
= true;
191 exception_error("backend_sanity_check_callback", e
, transport
);
195 function scheduleFeedUpdate(force
) {
197 debug("in scheduleFeedUpdate");
199 /* if (!daemon_enabled && !daemon_refresh_only) {
200 notify_progress("Updating feeds...", true);
203 var query_str
= "backend.php?op=rpc&subop=";
206 query_str
= query_str
+ "forceUpdateAllFeeds";
208 query_str
= query_str
+ "updateAllFeeds";
213 if (firsttime_update
&& !navigator
.userAgent
.match("Opera")) {
214 firsttime_update
= false;
224 query_str
= query_str
+ "&omode=" + omode
;
225 query_str
= query_str
+ "&uctr=" + global_unread
;
227 var date
= new Date();
228 var timestamp
= Math
.round(date
.getTime() / 1000);
229 query_str
= query_str
+ "&ts=" + timestamp
231 debug("REFETCH query: " + query_str
);
233 new Ajax
.Request(query_str
, {
234 onComplete: function(transport
) {
235 refetch_callback2(transport
);
239 function updateFeedList(silent
, fetch
) {
241 // if (silent != true) {
242 // notify("Loading feed list...");
245 debug("<b>updateFeedList</b>");
247 if (offline_mode
) return render_offline_feedlist();
249 var query_str
= "backend.php?op=feeds";
252 query_str
= query_str
+ "&tags=1";
255 if (getActiveFeedId() && !activeFeedIsCat()) {
256 query_str
= query_str
+ "&actid=" + getActiveFeedId();
259 var date
= new Date();
260 var timestamp
= Math
.round(date
.getTime() / 1000);
261 query_str
= query_str
+ "&ts=" + timestamp
263 if (fetch
) query_str
= query_str
+ "&fetch=yes";
265 // var feeds_frame = $("feeds-frame");
266 // feeds_frame.src = query_str;
268 debug("updateFeedList Q=" + query_str
);
270 new Ajax
.Request(query_str
, {
271 onComplete: function(transport
) {
272 feedlist_callback2(transport
);
277 function catchupAllFeeds() {
279 var str
= __("Mark all articles as read?");
281 if (getInitParam("confirm_feed_catchup") != 1 || confirm(str
)) {
283 var query_str
= "backend.php?op=feeds&subop=catchupAll";
285 notify_progress("Marking all feeds as read...");
287 debug("catchupAllFeeds Q=" + query_str
);
289 new Ajax
.Request(query_str
, {
290 onComplete: function(transport
) {
291 feedlist_callback2(transport
);
299 function viewCurrentFeed(subop
) {
301 // if (getActiveFeedId()) {
302 if (getActiveFeedId() != undefined) {
303 viewfeed(getActiveFeedId(), subop
, activeFeedIsCat());
305 disableContainerChildren("headlinesToolbar", false, document
);
306 // viewfeed(-1, subop); // FIXME
308 return false; // block unneeded form submits
311 function viewfeed(feed
, subop
) {
312 var f
= window
.frames
["feeds-frame"];
313 f
.viewfeed(feed
, subop
);
317 if (getInitParam("bw_limit") == "1") return;
319 scheduleFeedUpdate(false);
321 var refresh_time
= getInitParam("feeds_frame_refresh");
323 if (!refresh_time
) refresh_time
= 600;
325 setTimeout("timeout()", refresh_time
*1000);
328 function resetSearch() {
329 var searchbox
= $("searchbox")
331 if (searchbox
.value
!= "" && getActiveFeedId()) {
332 searchbox
.value
= "";
333 viewfeed(getActiveFeedId(), "");
337 function searchCancel() {
343 viewCurrentFeed(0, "");
346 // if argument is undefined, current subtitle is not updated
347 // use blank string to clear subtitle
348 function updateTitle(s
) {
349 var tmp
= "Tiny Tiny RSS";
351 if (s
!= undefined) {
352 current_subtitle
= s
;
355 if (global_unread
> 0) {
356 tmp
= tmp
+ " (" + global_unread
+ ")";
359 if (current_subtitle
) {
360 tmp
= tmp
+ " - " + current_subtitle
;
363 if (active_title_text
.length
> 0) {
364 tmp
= tmp
+ " > " + active_title_text
;
367 document
.title
= tmp
;
370 function genericSanityCheck() {
372 // if (!Ajax.getTransport()) fatalError(1);
374 setCookie("ttrss_vf_test", "TEST");
376 if (getCookie("ttrss_vf_test") != "TEST") {
387 // this whole shebang is based on http://www.birnamdesigns.com/misc/busted2.html
389 if (arguments
.callee
.done
) return;
390 arguments
.callee
.done
= true;
394 disableContainerChildren("headlinesToolbar", true);
396 Form
.disable("main_toolbar_form");
398 if (!genericSanityCheck())
401 if (getURLParam('debug')) {
402 Element
.show("debug_output");
403 debug('debug mode activated');
406 var params
= "&ua=" + param_escape(navigator
.userAgent
);
408 loading_set_progress(30);
410 new Ajax
.Request("backend.php?op=rpc&subop=sanityCheck" + params
, {
411 onComplete: function(transport
) {
412 backend_sanity_check_callback(transport
);
416 exception_error("init", e
);
420 function resize_headlines(delta_x
, delta_y
) {
424 debug("resize_headlines: " + delta_x
+ ":" + delta_y
);
426 var h_frame
= $("headlines-frame");
427 var c_frame
= $("content-frame");
428 var f_frame
= $("footer");
429 var feeds_frame
= $("feeds-holder");
430 var resize_grab
= $("resize-grabber");
431 var resize_handle
= $("resize-handle");
433 if (!c_frame
|| !h_frame
) return;
435 if (feeds_frame
&& getInitParam("theme") == "compat") {
436 feeds_frame
.style
.bottom
= f_frame
.offsetHeight
+ "px";
439 if (getInitParam("theme") == "3pane") {
441 if (delta_x
!= undefined) {
442 if (c_frame
.offsetLeft
- delta_x
> feeds_frame
.offsetWidth
+ feeds_frame
.offsetLeft
+ 100 && c_frame
.offsetWidth
+ delta_x
> 100) {
443 hor_offset
= hor_offset
+ delta_x
;
447 debug("resize_headlines: HOR-mode: " + hor_offset
);
449 c_frame
.style
.width
= (400 + hor_offset
) + "px";
450 h_frame
.style
.right
= c_frame
.offsetWidth
- 1 + "px";
452 resize_grab
.style
.top
= (h_frame
.offsetTop
+ h_frame
.offsetHeight
- 60) + "px";
453 resize_grab
.style
.left
= (h_frame
.offsetLeft
+ h_frame
.offsetWidth
-
455 resize_grab
.style
.display
= "block";
457 resize_handle
.src
= "themes/3pane/images/resize_handle_vert.png";
458 resize_handle
.style
.paddingTop
= (resize_grab
.offsetHeight
/ 2 - 7) + "px";
462 if (delta_y
!= undefined) {
463 if (c_frame
.offsetHeight
+ delta_y
> 100 && h_frame
.offsetHeight
- delta_y
> 100) {
464 ver_offset
= ver_offset
+ delta_y
;
468 debug("resize_headlines: VER-mode: " + ver_offset
);
470 h_frame
.style
.height
= (300 - ver_offset
) + "px";
472 c_frame
.style
.top
= (h_frame
.offsetTop
+ h_frame
.offsetHeight
+ 0) + "px";
473 h_frame
.style
.height
= h_frame
.offsetHeight
+ "px";
477 if (getInitParam("theme") == "graycube") {
481 if (getInitParam("theme") == "graycube" || getInitParam("theme") == "compat") {
482 resize_handle
.src
= "themes/graycube/images/resize_handle_horiz.png";
485 /* resize_grab.style.top = (h_frame.offsetTop + h_frame.offsetHeight -
487 resize_grab.style.display = "block"; */
491 if (getInitParam("cookie_lifetime") != 0) {
492 setCookie("ttrss_offset_ver", ver_offset
,
493 getInitParam("cookie_lifetime"));
494 setCookie("ttrss_offset_hor", hor_offset
,
495 getInitParam("cookie_lifetime"));
497 setCookie("ttrss_offset_ver", ver_offset
);
498 setCookie("ttrss_offset_hor", hor_offset
);
502 exception_error("resize_headlines", e
);
507 function init_second_stage() {
511 delCookie("ttrss_vf_test");
513 // document.onresize = resize_headlines;
515 var toolbar
= document
.forms
["main_toolbar_form"];
517 dropboxSelect(toolbar
.view_mode
, getInitParam("default_view_mode"));
518 dropboxSelect(toolbar
.limit
, getInitParam("default_view_limit"));
519 dropboxSelect(toolbar
.order_by
, getInitParam("default_view_order_by"));
521 daemon_enabled
= getInitParam("daemon_enabled") == 1;
522 daemon_refresh_only
= getInitParam("daemon_refresh_only") == 1;
523 feeds_sort_by_unread
= getInitParam("feeds_sort_by_unread") == 1;
525 /* var fl = cache_find_param("FEEDLIST", getInitParam("num_feeds"));
532 setTimeout('updateFeedList(false, false)', 50);
535 setTimeout('updateFeedList(false, false)', 50);
538 setTimeout('updateFeedList(false, false)', 50);
540 debug("second stage ok");
542 loading_set_progress(60);
544 ver_offset
= parseInt(getCookie("ttrss_offset_ver"));
545 hor_offset
= parseInt(getCookie("ttrss_offset_hor"));
547 debug("got offsets from cookies: ver " + ver_offset
+ " hor " + hor_offset
);
551 if (isNaN(hor_offset
)) hor_offset
= 0;
552 if (isNaN(ver_offset
)) ver_offset
= 0;
554 debug("offsets from cookies [x:y]: " + hor_offset
+ ":" + ver_offset
);
558 enable_offline_reading();
561 exception_error("init_second_stage", e
);
565 function quickMenuChange() {
566 var chooser
= $("quickMenuChooser");
567 var opid
= chooser
[chooser
.selectedIndex
].value
;
569 chooser
.selectedIndex
= 0;
573 function quickMenuGo(opid
) {
576 if (opid
== "qmcPrefs") {
580 if (opid
== "qmcSearch") {
581 displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat());
585 if (opid
== "qmcAddFeed") {
586 displayDlg("quickAddFeed");
590 if (opid
== "qmcEditFeed") {
591 editFeedDlg(getActiveFeedId());
594 if (opid
== "qmcRemoveFeed") {
595 var actid
= getActiveFeedId();
597 if (activeFeedIsCat()) {
598 alert(__("You can't unsubscribe from the category."));
603 alert(__("Please select some feed first."));
607 var fn
= getFeedName(actid
);
609 var pr
= __("Unsubscribe from %s?").replace("%s", fn
);
612 unsubscribeFeed(actid
);
618 if (opid
== "qmcClearFeed") {
619 var actid
= getActiveFeedId();
622 alert(__("Please select some feed first."));
626 if (activeFeedIsCat() || actid
< 0) {
627 alert(__("You can't clear this type of feed."));
631 var fn
= getFeedName(actid
);
633 var pr
= __("Erase all non-starred articles in %s?").replace("%s", fn
);
636 clearFeedArticles(actid
);
643 if (opid
== "qmcUpdateFeeds") {
644 scheduleFeedUpdate(true);
648 if (opid
== "qmcCatchupAll") {
653 if (opid
== "qmcShowOnlyUnread") {
658 if (opid
== "qmcAddFilter") {
659 displayDlg("quickAddFilter", getActiveFeedId());
662 if (opid
== "qmcAddLabel") {
666 if (opid
== "qmcRescoreFeed") {
667 rescoreCurrentFeed();
670 if (opid
== "qmcHKhelp") {
671 //Element.show("hotkey_help_overlay");
672 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
675 if (opid
== "qmcResetUI") {
681 if (opid
== "qmcResetCats") {
683 if (confirm(__("Reset category order?"))) {
685 var query
= "backend.php?op=feeds&subop=catsortreset";
687 notify_progress("Loading, please wait...", true);
689 new Ajax
.Request(query
, {
690 onComplete: function(transport
) {
691 window
.setTimeout('updateFeedList(false, false)', 50);
697 exception_error("quickMenuGo", e
);
701 function unsubscribeFeed(feed_id
, title
) {
704 var msg
= __("Unsubscribe from %s?").replace("%s", title
);
706 if (title
== undefined || confirm(msg
)) {
707 notify_progress("Removing feed...");
709 var query
= "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
;
711 new Ajax
.Request(query
, {
712 onComplete: function(transport
) {
713 dlg_frefresh_callback(transport
, feed_id
);
721 function updateFeedTitle(t
) {
722 active_title_text
= t
;
726 function toggleDispRead() {
729 var hide_read_feeds
= (getInitParam("hide_read_feeds") == "1");
731 hide_read_feeds
= !hide_read_feeds
;
733 debug("toggle_disp_read => " + hide_read_feeds
);
735 hideOrShowFeeds(hide_read_feeds
);
737 storeInitParam("hide_read_feeds", hide_read_feeds
, true);
740 exception_error("toggleDispRead", e
);
744 function parse_runtime_info(elem
) {
746 debug("parse_runtime_info: elem is null, aborting");
750 var param
= elem
.firstChild
;
752 debug("parse_runtime_info: " + param
);
755 var k
= param
.getAttribute("key");
756 var v
= param
.getAttribute("value");
758 debug("RI: " + k
+ " => " + v
);
760 if (k
== "num_feeds") {
764 if (k
== "new_version_available") {
765 var icon
= $("newVersionIcon");
768 icon
.style
.display
= "inline";
770 icon
.style
.display
= "none";
777 if (k
== "daemon_is_running" && v
!= 1) {
778 notify_error("<span onclick=\"javascript:explainError(1)\">Update daemon is not running.</span>", true);
782 if (k
== "daemon_stamp_ok" && v
!= 1) {
783 notify_error("<span onclick=\"javascript:explainError(3)\">Update daemon is not updating feeds.</span>", true);
791 /* var w = $("noDaemonWarning");
794 if (k == "daemon_is_running" && v != 1) {
795 w.style.display = "block";
797 w.style.display = "none";
800 param
= param
.nextSibling
;
804 function catchupCurrentFeed() {
806 var fn
= getFeedName(getActiveFeedId(), activeFeedIsCat());
808 var str
= __("Mark all articles in %s as read?").replace("%s", fn
);
810 if (getInitParam("confirm_feed_catchup") != 1 || confirm(str
)) {
811 return viewCurrentFeed('MarkAllRead')
815 function catchupFeedInGroup(id
) {
819 var title
= getFeedName(id
);
821 var str
= __("Mark all articles in %s as read?").replace("%s", title
);
823 if (getInitParam("confirm_feed_catchup") != 1 || confirm(str
)) {
824 return viewCurrentFeed('MarkAllReadGR:' + id
)
828 exception_error("catchupFeedInGroup", e
);
832 function editFeedDlg(feed
) {
836 alert(__("Please select some feed first."));
840 if ((feed
<= 0) || activeFeedIsCat() || tagsAreDisplayed()) {
841 alert(__("You can't edit this kind of feed."));
848 query
= "backend.php?op=pref-feeds&subop=editfeed&id=" + param_escape(feed
);
850 query
= "backend.php?op=pref-labels&subop=edit&id=" + param_escape(-feed
-11);
855 new Ajax
.Request(query
, {
856 onComplete: function(transport
) {
857 infobox_callback2(transport
);
861 exception_error("editFeedDlg", e
);
865 /* this functions duplicate those of prefs.js feed editor, with
866 some differences because there is no feedlist */
868 function feedEditCancel() {
873 function feedEditSave() {
877 // FIXME: add parameter validation
879 var query
= Form
.serialize("edit_feed_form");
881 notify_progress("Saving feed...");
883 new Ajax
.Request("backend.php", {
885 onComplete: function(transport
) {
886 dlg_frefresh_callback(transport
);
895 exception_error("feedEditSave (main)", e
);
899 function clearFeedArticles(feed_id
) {
901 notify_progress("Clearing feed...");
903 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
905 new Ajax
.Request(query
, {
906 onComplete: function(transport
) {
907 dlg_frefresh_callback(transport
, feed_id
);
913 function collapse_feedlist() {
915 debug("toggle_feedlist");
917 var theme
= getInitParam("theme");
918 if (theme
!= "" && theme
!= "compact" && theme
!= "graycube" &&
919 theme
!= "compat") return;
921 var fl
= $("feeds-holder");
922 var fh
= $("headlines-frame");
923 var fc
= $("content-frame");
924 var ft
= $("toolbar");
925 var ff
= $("footer");
926 var fhdr
= $("header");
927 var fbtn
= $("collapse_feeds_btn");
929 if (!Element
.visible(fl
)) {
933 if (theme
!= "graycube") {
935 fh
.style
.left
= fl
.offsetWidth
+ "px";
936 ft
.style
.left
= fl
.offsetWidth
+ "px";
937 if (fc
) fc
.style
.left
= fl
.offsetWidth
+ "px";
938 if (ff
&& theme
!= "compat") ff
.style
.left
= (fl
.offsetWidth
-1) + "px";
940 if (theme
== "compact") fhdr
.style
.left
= (fl
.offsetWidth
+ 10) + "px";
942 fh
.style
.left
= fl
.offsetWidth
+ 40 + "px";
943 ft
.style
.left
= fl
.offsetWidth
+ 40 +"px";
944 if (fc
) fc
.style
.left
= fl
.offsetWidth
+ 40 + "px";
947 setCookie("ttrss_vf_fclps", "0");
953 if (theme
!= "graycube") {
955 fh
.style
.left
= "0px";
956 ft
.style
.left
= "0px";
957 if (fc
) fc
.style
.left
= "0px";
958 if (ff
) ff
.style
.left
= "0px";
960 if (theme
== "compact") fhdr
.style
.left
= "10px";
963 fh
.style
.left
= "20px";
964 ft
.style
.left
= "20px";
965 if (fc
) fc
.style
.left
= "20px";
969 setCookie("ttrss_vf_fclps", "1");
972 exception_error("toggle_feedlist", e
);
976 function viewModeChanged() {
978 return viewCurrentFeed(0, '')
981 function viewLimitChanged() {
983 return viewCurrentFeed(0, '')
986 /* function adjustArticleScore(id, score) {
989 var pr = prompt(__("Assign score to article:"), score);
991 if (pr != undefined) {
992 var query = "backend.php?op=rpc&subop=setScore&id=" + id + "&score=" + pr;
994 new Ajax.Request(query, {
995 onComplete: function(transport) {
1001 exception_error("adjustArticleScore", e);
1005 function rescoreCurrentFeed() {
1007 var actid
= getActiveFeedId();
1009 if (activeFeedIsCat() || actid
< 0 || tagsAreDisplayed()) {
1010 alert(__("You can't rescore this kind of feed."));
1015 alert(__("Please select some feed first."));
1019 var fn
= getFeedName(actid
);
1020 var pr
= __("Rescore articles in %s?").replace("%s", fn
);
1023 notify_progress("Rescoring articles...");
1025 var query
= "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids=" + actid
;
1027 new Ajax
.Request(query
, {
1028 onComplete: function(transport
) {
1034 function hotkey_handler(e
) {
1039 var shift_key
= false;
1041 var feedlist
= $('feedList');
1044 shift_key
= e
.shiftKey
;
1050 keycode
= window
.event
.keyCode
;
1055 var keychar
= String
.fromCharCode(keycode
);
1057 if (keycode
== 27) { // escape
1058 if (Element
.visible("hotkey_help_overlay")) {
1059 Element
.hide("hotkey_help_overlay");
1061 hotkey_prefix
= false;
1065 if (!hotkeys_enabled
) {
1066 debug("hotkeys disabled");
1070 if (keycode
== 16) return; // ignore lone shift
1072 if ((keycode
== 70 || keycode
== 67 || keycode
== 71)
1073 && !hotkey_prefix
) {
1075 hotkey_prefix
= keycode
;
1076 debug("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
);
1080 if (Element
.visible("hotkey_help_overlay")) {
1081 Element
.hide("hotkey_help_overlay");
1084 /* Global hotkeys */
1086 if (!hotkey_prefix
) {
1088 if (keycode
== 68 && shift_key
) { // d
1089 if (!Element
.visible("debug_output")) {
1090 Element
.show("debug_output");
1091 debug('debug mode activated');
1093 Element
.hide("debug_output");
1099 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
1100 if (!Element
.visible("hotkey_help_overlay")) {
1101 //Element.show("hotkey_help_overlay");
1102 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
1104 Element
.hide("hotkey_help_overlay");
1109 if (keycode
== 191 || keychar
== '/') { // /
1110 displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat());
1114 if (keycode
== 82 && shift_key
) { // R
1115 scheduleFeedUpdate(true);
1119 if (keycode
== 74) { // j
1120 var feed
= getActiveFeedId();
1121 var new_feed
= getRelativeFeedId2(feed
, activeFeedIsCat(), 'prev');
1122 // alert(feed + " IC: " + activeFeedIsCat() + " => " + new_feed);
1124 var is_cat
= new_feed
.match("CAT:");
1126 new_feed
= new_feed
.replace("CAT:", "");
1127 viewCategory(new_feed
);
1129 viewfeed(new_feed
, '', false);
1135 if (keycode
== 75) { // k
1136 var feed
= getActiveFeedId();
1137 var new_feed
= getRelativeFeedId2(feed
, activeFeedIsCat(), 'next');
1138 // alert(feed + " IC: " + activeFeedIsCat() + " => " + new_feed);
1140 var is_cat
= new_feed
.match("CAT:");
1141 if (is_cat
== "CAT:") {
1142 new_feed
= new_feed
.replace("CAT:", "");
1143 viewCategory(new_feed
);
1145 viewfeed(new_feed
, '', false);
1151 if (shift_key
&& keycode
== 40) { // shift-down
1152 catchupRelativeToArticle(1);
1156 if (shift_key
&& keycode
== 38) { // shift-up
1157 catchupRelativeToArticle(0);
1161 if (shift_key
&& keycode
== 78) { // N
1166 if (shift_key
&& keycode
== 80) { // P
1172 if (keycode
== 78 || keycode
== 40) { // n, down
1173 if (typeof moveToPost
!= 'undefined') {
1179 if (keycode
== 80 || keycode
== 38) { // p, up
1180 if (typeof moveToPost
!= 'undefined') {
1186 if (keycode
== 83 && shift_key
) { // S
1187 var id
= getActiveArticleId();
1194 if (keycode
== 83) { // s
1195 var id
= getActiveArticleId();
1203 if (keycode
== 85) { // u
1204 var id
= getActiveArticleId();
1211 if (keycode
== 84 && shift_key
) { // T
1212 var id
= getActiveArticleId();
1214 editArticleTags(id
, getActiveFeedId(), isCdmMode());
1219 if (keycode
== 9) { // tab
1220 var id
= getArticleUnderPointer();
1222 var cb
= $("RCHK-" + id
);
1225 cb
.checked
= !cb
.checked
;
1226 toggleSelectRowById(cb
, "RROW-" + id
);
1232 if (keycode
== 79) { // o
1233 if (getActiveArticleId()) {
1234 openArticleInNewWindow(getActiveArticleId());
1239 if (keycode
== 81 && shift_key
) { // Q
1240 if (typeof catchupAllFeeds
!= 'undefined') {
1246 if (keycode
== 88) { // x
1247 if (activeFeedIsCat()) {
1248 toggleCollapseCat(getActiveFeedId());
1255 if (hotkey_prefix
== 70) { // f
1257 hotkey_prefix
= false;
1259 if (keycode
== 81) { // q
1260 if (getActiveFeedId()) {
1261 catchupCurrentFeed();
1266 if (keycode
== 82) { // r
1267 if (getActiveFeedId()) {
1268 viewfeed(getActiveFeedId(), "ForceUpdate", activeFeedIsCat());
1273 if (keycode
== 65) { // a
1278 if (keycode
== 85 && shift_key
) { // U
1279 scheduleFeedUpdate(true);
1283 if (keycode
== 85) { // u
1284 if (getActiveFeedId()) {
1285 viewfeed(getActiveFeedId(), "ForceUpdate");
1290 if (keycode
== 69) { // e
1291 editFeedDlg(getActiveFeedId());
1295 if (keycode
== 83) { // s
1296 displayDlg("quickAddFeed");
1300 if (keycode
== 67 && shift_key
) { // C
1301 if (typeof catchupAllFeeds
!= 'undefined') {
1307 if (keycode
== 67) { // c
1308 if (getActiveFeedId()) {
1309 catchupCurrentFeed();
1314 if (keycode
== 87) { // w
1315 feeds_sort_by_unread
= !feeds_sort_by_unread
;
1316 return resort_feedlist();
1319 if (keycode
== 72) { // h
1320 hideReadHeadlines();
1328 if (hotkey_prefix
== 67) { // c
1329 hotkey_prefix
= false;
1331 if (keycode
== 70) { // f
1332 displayDlg("quickAddFilter", getActiveFeedId());
1336 if (keycode
== 76) { // l
1341 if (keycode
== 83) { // s
1342 if (typeof collapse_feedlist
!= 'undefined') {
1343 collapse_feedlist();
1348 if (keycode
== 77) { // m
1349 feedlist_sortable_enabled
= !feedlist_sortable_enabled
;
1350 if (feedlist_sortable_enabled
) {
1351 notify_info("Category reordering enabled");
1352 toggle_sortable_feedlist(true);
1354 notify_info("Category reordering disabled");
1355 toggle_sortable_feedlist(false);
1359 if (keycode
== 78) { // n
1360 catchupRelativeToArticle(1);
1364 if (keycode
== 80) { // p
1365 catchupRelativeToArticle(0);
1374 if (hotkey_prefix
== 71) { // g
1376 hotkey_prefix
= false;
1379 if (keycode
== 65) { // a
1384 if (keycode
== 83) { // s
1389 if (keycode
== 80 && shift_key
) { // P
1394 if (keycode
== 80) { // p
1399 if (keycode
== 70) { // f
1404 if (keycode
== 84 && shift_key
) { // T
1412 if (hotkey_prefix
== 224 || hotkey_prefix
== 91) { // f
1413 hotkey_prefix
= false;
1417 if (hotkey_prefix
) {
1418 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1420 debug("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1425 exception_error("hotkey_handler", e
);
1429 function feedsSortByUnread() {
1430 return feeds_sort_by_unread
;
1433 function addLabel() {
1437 var caption
= prompt(__("Please enter label caption:"), "");
1439 if (caption
!= undefined) {
1441 if (caption
== "") {
1442 alert(__("Can't create label: missing caption."));
1446 var query
= "backend.php?op=pref-labels&subop=add&caption=" +
1447 param_escape(caption
);
1449 notify_progress("Loading, please wait...", true);
1451 new Ajax
.Request(query
, {
1452 onComplete: function(transport
) {
1459 exception_error("addLabel", e
);
1463 function visitOfficialSite() {
1464 window
.open("http://tt-rss.org/");
1468 function feedBrowserSubscribe() {
1471 var selected
= getSelectedFeedsFromBrowser();
1473 if (selected
.length
> 0) {
1476 notify_progress("Loading, please wait...", true);
1478 var query
= "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1479 param_escape(selected
.toString());
1481 new Ajax
.Request(query
, {
1482 onComplete: function(transport
) {
1487 alert(__("No feeds are selected."));
1491 exception_error("feedBrowserSubscribe", e
);