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 _qfd_deleted_feed
= 0;
12 /*@if (@_jscript_version >= 5)
13 // JScript gives us Conditional compilation, we can cope with old IE versions.
14 // and security blocked creation of the objects.
16 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
19 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
26 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
27 xmlhttp
= new XMLHttpRequest();
30 function toggleTags() {
31 display_tags
= !display_tags
;
33 var p
= document
.getElementById("dispSwitchPrompt");
36 p
.innerHTML
= "display feeds";
38 p
.innerHTML
= "display tags";
44 function dlg_frefresh_callback() {
45 if (xmlhttp
.readyState
== 4) {
46 notify(xmlhttp
.responseText
);
47 updateFeedList(false, false);
48 if (_qfd_deleted_feed
) {
49 var hframe
= document
.getElementById("headlines-frame");
51 hframe
.src
= "backend.php?op=error&msg=No%20feed%20selected.";
58 function dlg_submit_callback() {
59 if (xmlhttp
.readyState
== 4) {
60 notify(xmlhttp
.responseText
);
65 function dlg_display_callback() {
66 if (xmlhttp
.readyState
== 4) {
67 var dlg
= document
.getElementById("userDlg");
68 var dlg_s
= document
.getElementById("userDlgShadow");
70 dlg
.innerHTML
= xmlhttp
.responseText
;
71 dlg_s
.style
.display
= "block";
75 function hide_unread_callback() {
76 if (xmlhttp
.readyState
== 4) {
80 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
81 var value
= reply
.getAttribute("value");
82 var hide_read_feeds
= (value
!= "false")
83 var feeds_doc
= window
.frames
["feeds-frame"].document
;
85 hideOrShowFeeds(feeds_doc
, hide_read_feeds
);
87 if (hide_read_feeds
) {
88 setCookie("ttrss_vf_hreadf", 1);
90 setCookie("ttrss_vf_hreadf", 0);
94 exception_error("hide_unread_callback", e
);
100 function refetch_callback() {
101 if (xmlhttp
.readyState
== 4) {
104 if (!xmlhttp
.responseXML
) {
105 notify("refetch_callback: backend did not return valid XML");
109 var reply
= xmlhttp
.responseXML
.firstChild
;
112 notify("refetch_callback: backend did not return expected XML object");
117 var error_code
= reply
.getAttribute("error-code");
119 if (error_code
&& error_code
!= 0) {
120 return fatalError(error_code
);
123 var f_document
= window
.frames
["feeds-frame"].document
;
125 parse_counters(reply
, f_document
, window
);
127 if (!daemon_enabled
) {
128 notify("All feeds updated.");
132 exception_error("refetch_callback", e
);
138 function backend_sanity_check_callback() {
140 if (xmlhttp
.readyState
== 4) {
144 if (!xmlhttp
.responseXML
) {
149 var reply
= xmlhttp
.responseXML
.firstChild
;
156 var error_code
= reply
.getAttribute("error-code");
158 if (error_code
&& error_code
!= 0) {
159 return fatalError(error_code
);
165 exception_error("backend_sanity_check_callback", e
);
170 function scheduleFeedUpdate(force
) {
172 if (!daemon_enabled
) {
173 notify("Updating feeds, please wait.");
174 updateTitle("Updating");
177 var query_str
= "backend.php?op=rpc&subop=";
180 query_str
= query_str
+ "forceUpdateAllFeeds";
182 query_str
= query_str
+ "updateAllFeeds";
193 query_str
= query_str
+ "&omode=" + omode
;
194 query_str
= query_str
+ "&uctr=" + global_unread
;
196 if (xmlhttp_ready(xmlhttp
)) {
197 xmlhttp
.open("GET", query_str
, true);
198 xmlhttp
.onreadystatechange
=refetch_callback
;
205 function updateFeedList(silent
, fetch
) {
207 // if (silent != true) {
208 // notify("Loading feed list...");
211 var query_str
= "backend.php?op=feeds";
214 query_str
= query_str
+ "&tags=1";
217 if (getActiveFeedId()) {
218 query_str
= query_str
+ "&actid=" + getActiveFeedId();
221 if (fetch
) query_str
= query_str
+ "&fetch=yes";
223 var feeds_frame
= document
.getElementById("feeds-frame");
225 feeds_frame
.src
= query_str
;
228 function catchupAllFeeds() {
230 var query_str
= "backend.php?op=feeds&subop=catchupAll";
232 notify("Marking all feeds as read...");
234 var feeds_frame
= document
.getElementById("feeds-frame");
236 feeds_frame
.src
= query_str
;
243 function viewCurrentFeed(skip
, subop
) {
245 if (getActiveFeedId()) {
246 viewfeed(getActiveFeedId(), skip
, subop
);
248 disableContainerChildren("headlinesToolbar", false, document
);
249 viewfeed(-1, skip
, subop
); // FIXME
253 function viewfeed(feed
, skip
, subop
) {
254 var f
= window
.frames
["feeds-frame"];
255 f
.viewfeed(feed
, skip
, subop
);
259 scheduleFeedUpdate(false);
261 var refresh_time
= getCookie('ttrss_vf_refresh');
263 if (!refresh_time
) refresh_time
= 600;
265 setTimeout("timeout()", refresh_time
*1000);
268 function resetSearch() {
269 var searchbox
= document
.getElementById("searchbox")
271 if (searchbox
.value
!= "" && getActiveFeedId()) {
272 searchbox
.value
= "";
273 viewfeed(getActiveFeedId(), 0, "");
279 viewCurrentFeed(0, "");
282 function localPiggieFunction(enable
) {
284 var query_str
= "backend.php?op=feeds&subop=piggie";
286 if (xmlhttp_ready(xmlhttp
)) {
288 xmlhttp
.open("GET", query_str
, true);
289 xmlhttp
.onreadystatechange
=feedlist_callback
;
295 function localHotkeyHandler(keycode
) {
297 /* if (keycode == 78) {
298 return moveToPost('next');
302 return moveToPost('prev');
305 if (keycode
== 82) { // r
306 return scheduleFeedUpdate(true);
309 if (keycode
== 85) { // u
310 if (getActiveFeedId()) {
311 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
315 if (keycode
== 65) { // a
316 return toggleDispRead();
319 var f_doc
= window
.frames
["feeds-frame"].document
;
320 var feedlist
= f_doc
.getElementById('feedList');
322 if (keycode
== 74) { // j
323 var feed
= getActiveFeedId();
324 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
325 if (new_feed
) viewfeed(new_feed
, 0, '');
328 if (keycode
== 75) { // k
329 var feed
= getActiveFeedId();
330 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
331 if (new_feed
) viewfeed(new_feed
, 0, '');
334 // notify("KC: " + keycode);
338 // if argument is undefined, current subtitle is not updated
339 // use blank string to clear subtitle
340 function updateTitle(s
) {
341 var tmp
= "Tiny Tiny RSS";
343 if (s
!= undefined) {
344 current_subtitle
= s
;
347 if (global_unread
> 0) {
348 tmp
= tmp
+ " (" + global_unread
+ ")";
351 if (current_subtitle
) {
352 tmp
= tmp
+ " - " + current_subtitle
;
355 if (active_title_text
.length
> 0) {
356 tmp
= tmp
+ " > " + active_title_text
;
359 document
.title
= tmp
;
362 function genericSanityCheck() {
364 if (!xmlhttp
) fatalError(1);
366 setCookie("ttrss_vf_test", "TEST");
368 if (getCookie("ttrss_vf_test") != "TEST") {
379 disableContainerChildren("headlinesToolbar", true);
381 if (!genericSanityCheck())
384 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
385 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
389 exception_error("init", e
);
393 function init_second_stage() {
397 setCookie("ttrss_vf_actfeed", "");
399 updateFeedList(false, false);
400 document
.onkeydown
= hotkey_handler
;
402 var viewbox
= document
.getElementById("viewbox");
403 var limitbox
= document
.getElementById("limitbox");
405 dropboxSelect(viewbox
, getCookie("ttrss_vf_vmode"));
406 dropboxSelect(limitbox
, getCookie("ttrss_vf_limit"));
408 daemon_enabled
= getCookie("ttrss_vf_daemon");
411 exception_error("init_second_stage", e
);
415 function quickMenuChange() {
416 var chooser
= document
.getElementById("quickMenuChooser");
417 var opid
= chooser
[chooser
.selectedIndex
].id
;
419 chooser
.selectedIndex
= 0;
423 function quickMenuGo(opid
) {
426 if (opid
== "qmcPrefs") {
430 if (opid
== "qmcSearch") {
431 displayDlg("search", getActiveFeedId());
435 if (opid
== "qmcAddFeed") {
436 displayDlg("quickAddFeed");
440 if (opid
== "qmcRemoveFeed") {
441 var actid
= getActiveFeedId();
444 notify("Please select some feed first.");
448 if (confirm("Remove current feed?")) {
455 if (opid
== "qmcUpdateFeeds") {
456 scheduleFeedUpdate(true);
460 if (opid
== "qmcCatchupAll") {
465 if (opid
== "qmcShowOnlyUnread") {
470 if (opid
== "qmcAddFilter") {
471 displayDlg("quickAddFilter", getActiveFeedId());
478 if (!xmlhttp_ready(xmlhttp
)) {
483 var link
= document
.getElementById("qafInput");
485 if (link
.value
.length
== 0) {
486 notify("Missing feed URL.");
488 notify("Adding feed...");
490 var cat
= document
.getElementById("qafCat");
494 cat_id
= cat
[cat
.selectedIndex
].id
;
499 var feeds_doc
= window
.frames
["feeds-frame"].document
;
501 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
503 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" +
504 param_escape(link
.value
) + "&cid=" + param_escape(cat_id
), true);
505 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
513 function qaddFilter() {
515 if (!xmlhttp_ready(xmlhttp
)) {
520 var regexp
= document
.getElementById("fadd_regexp");
521 var match
= document
.getElementById("fadd_match");
522 var feed
= document
.getElementById("fadd_feed");
523 var action
= document
.getElementById("fadd_action");
525 if (regexp
.value
.length
== 0) {
526 notify("Missing filter expression.");
528 notify("Adding filter...");
530 var v_match
= match
[match
.selectedIndex
].text
;
531 var feed_id
= feed
[feed
.selectedIndex
].id
;
532 var action_id
= action
[action
.selectedIndex
].id
;
534 xmlhttp
.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add®exp=" +
535 param_escape(regexp
.value
) + "&match=" + v_match
+
536 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
538 xmlhttp
.onreadystatechange
=dlg_submit_callback
;
547 function displayDlg(id
, param
) {
549 if (!xmlhttp_ready(xmlhttp
)) {
556 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
557 param_escape(id
) + "¶m=" + param_escape(param
), true);
558 xmlhttp
.onreadystatechange
=dlg_display_callback
;
564 function closeDlg() {
565 var dlg
= document
.getElementById("userDlgShadow");
566 dlg
.style
.display
= "none";
570 function qfdDelete(feed_id
) {
572 notify("Removing feed...");
574 if (!xmlhttp_ready(xmlhttp
)) {
579 // var feeds_doc = window.frames["feeds-frame"].document;
580 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
582 _qfd_deleted_feed
= feed_id
;
584 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
);
585 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
590 function allFeedsMenuChange() {
591 var chooser
= document
.getElementById("allFeedsChooser");
593 var opname
= chooser
[chooser
.selectedIndex
].text
;
595 chooser
.selectedIndex
= 0;
597 if (opname
== "Update") {
598 scheduleFeedUpdate(true);
602 if (opname
== "Mark as read") {
607 if (opname
== "Show only unread") {
614 function updateFeedTitle(t
) {
615 active_title_text
= t
;
619 function toggleDispRead() {
622 if (!xmlhttp_ready(xmlhttp
)) {
627 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
629 hide_read_feeds
= !hide_read_feeds
;
631 var query
= "backend.php?op=rpc&subop=setpref" +
632 "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds
);
634 xmlhttp
.open("GET", query
);
635 xmlhttp
.onreadystatechange
=hide_unread_callback
;
639 exception_error("toggleDispRead", e
);