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.");
134 exception_error("refetch_callback", e
);
140 function backend_sanity_check_callback() {
142 if (xmlhttp
.readyState
== 4) {
146 if (!xmlhttp
.responseXML
) {
151 var reply
= xmlhttp
.responseXML
.firstChild
;
158 var error_code
= reply
.getAttribute("error-code");
160 if (error_code
&& error_code
!= 0) {
161 return fatalError(error_code
);
167 exception_error("backend_sanity_check_callback", e
);
172 function scheduleFeedUpdate(force
) {
174 if (!daemon_enabled
) {
175 notify("Updating feeds, please wait.");
176 updateTitle("Updating");
179 var query_str
= "backend.php?op=rpc&subop=";
182 query_str
= query_str
+ "forceUpdateAllFeeds";
184 query_str
= query_str
+ "updateAllFeeds";
195 query_str
= query_str
+ "&omode=" + omode
;
196 query_str
= query_str
+ "&uctr=" + global_unread
;
198 if (xmlhttp_ready(xmlhttp
)) {
199 xmlhttp
.open("GET", query_str
, true);
200 xmlhttp
.onreadystatechange
=refetch_callback
;
207 function updateFeedList(silent
, fetch
) {
209 // if (silent != true) {
210 // notify("Loading feed list...");
213 var query_str
= "backend.php?op=feeds";
216 query_str
= query_str
+ "&tags=1";
219 if (getActiveFeedId()) {
220 query_str
= query_str
+ "&actid=" + getActiveFeedId();
223 if (fetch
) query_str
= query_str
+ "&fetch=yes";
225 var feeds_frame
= document
.getElementById("feeds-frame");
227 feeds_frame
.src
= query_str
;
230 function catchupAllFeeds() {
232 var query_str
= "backend.php?op=feeds&subop=catchupAll";
234 notify("Marking all feeds as read...");
236 var feeds_frame
= document
.getElementById("feeds-frame");
238 feeds_frame
.src
= query_str
;
245 function viewCurrentFeed(skip
, subop
) {
247 if (getActiveFeedId()) {
248 viewfeed(getActiveFeedId(), skip
, subop
);
250 disableContainerChildren("headlinesToolbar", false, document
);
251 viewfeed(-1, skip
, subop
); // FIXME
255 function viewfeed(feed
, skip
, subop
) {
256 var f
= window
.frames
["feeds-frame"];
257 f
.viewfeed(feed
, skip
, subop
);
261 scheduleFeedUpdate(false);
263 var refresh_time
= getCookie('ttrss_vf_refresh');
265 if (!refresh_time
) refresh_time
= 600;
267 setTimeout("timeout()", refresh_time
*1000);
270 function resetSearch() {
271 var searchbox
= document
.getElementById("searchbox")
273 if (searchbox
.value
!= "" && getActiveFeedId()) {
274 searchbox
.value
= "";
275 viewfeed(getActiveFeedId(), 0, "");
281 viewCurrentFeed(0, "");
284 function localPiggieFunction(enable
) {
286 var query_str
= "backend.php?op=feeds&subop=piggie";
288 if (xmlhttp_ready(xmlhttp
)) {
290 xmlhttp
.open("GET", query_str
, true);
291 xmlhttp
.onreadystatechange
=feedlist_callback
;
297 function localHotkeyHandler(keycode
) {
299 /* if (keycode == 78) {
300 return moveToPost('next');
304 return moveToPost('prev');
307 if (keycode
== 82) { // r
308 return scheduleFeedUpdate(true);
311 if (keycode
== 85) { // u
312 if (getActiveFeedId()) {
313 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
317 if (keycode
== 65) { // a
318 return toggleDispRead();
321 var f_doc
= window
.frames
["feeds-frame"].document
;
322 var feedlist
= f_doc
.getElementById('feedList');
324 if (keycode
== 74) { // j
325 var feed
= getActiveFeedId();
326 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
327 if (new_feed
) viewfeed(new_feed
, 0, '');
330 if (keycode
== 75) { // k
331 var feed
= getActiveFeedId();
332 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
333 if (new_feed
) viewfeed(new_feed
, 0, '');
336 // notify("KC: " + keycode);
340 // if argument is undefined, current subtitle is not updated
341 // use blank string to clear subtitle
342 function updateTitle(s
) {
343 var tmp
= "Tiny Tiny RSS";
345 if (s
!= undefined) {
346 current_subtitle
= s
;
349 if (global_unread
> 0) {
350 tmp
= tmp
+ " (" + global_unread
+ ")";
353 if (current_subtitle
) {
354 tmp
= tmp
+ " - " + current_subtitle
;
357 if (active_title_text
.length
> 0) {
358 tmp
= tmp
+ " > " + active_title_text
;
361 document
.title
= tmp
;
364 function genericSanityCheck() {
366 if (!xmlhttp
) fatalError(1);
368 setCookie("ttrss_vf_test", "TEST");
370 if (getCookie("ttrss_vf_test") != "TEST") {
381 disableContainerChildren("headlinesToolbar", true);
383 if (!genericSanityCheck())
386 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
387 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
391 exception_error("init", e
);
395 function init_second_stage() {
399 setCookie("ttrss_vf_actfeed", "");
401 updateFeedList(false, false);
402 document
.onkeydown
= hotkey_handler
;
404 var viewbox
= document
.getElementById("viewbox");
405 var limitbox
= document
.getElementById("limitbox");
407 dropboxSelect(viewbox
, getCookie("ttrss_vf_vmode"));
408 dropboxSelect(limitbox
, getCookie("ttrss_vf_limit"));
410 daemon_enabled
= getCookie("ttrss_vf_daemon");
413 exception_error("init_second_stage", e
);
417 function quickMenuChange() {
418 var chooser
= document
.getElementById("quickMenuChooser");
419 var opid
= chooser
[chooser
.selectedIndex
].id
;
421 chooser
.selectedIndex
= 0;
425 function quickMenuGo(opid
) {
428 if (opid
== "qmcPrefs") {
432 if (opid
== "qmcSearch") {
433 displayDlg("search", getActiveFeedId());
437 if (opid
== "qmcAddFeed") {
438 displayDlg("quickAddFeed");
442 if (opid
== "qmcRemoveFeed") {
443 var actid
= getActiveFeedId();
446 notify("Please select some feed first.");
450 if (confirm("Remove current feed?")) {
457 if (opid
== "qmcUpdateFeeds") {
458 scheduleFeedUpdate(true);
462 if (opid
== "qmcCatchupAll") {
467 if (opid
== "qmcShowOnlyUnread") {
472 if (opid
== "qmcAddFilter") {
473 displayDlg("quickAddFilter", getActiveFeedId());
480 if (!xmlhttp_ready(xmlhttp
)) {
485 var link
= document
.getElementById("qafInput");
487 if (link
.value
.length
== 0) {
488 notify("Missing feed URL.");
490 notify("Adding feed...");
492 var cat
= document
.getElementById("qafCat");
496 cat_id
= cat
[cat
.selectedIndex
].id
;
501 var feeds_doc
= window
.frames
["feeds-frame"].document
;
503 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
505 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" +
506 param_escape(link
.value
) + "&cid=" + param_escape(cat_id
), true);
507 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
515 function qaddFilter() {
517 if (!xmlhttp_ready(xmlhttp
)) {
522 var regexp
= document
.getElementById("fadd_regexp");
523 var match
= document
.getElementById("fadd_match");
524 var feed
= document
.getElementById("fadd_feed");
525 var action
= document
.getElementById("fadd_action");
527 if (regexp
.value
.length
== 0) {
528 notify("Missing filter expression.");
530 notify("Adding filter...");
532 var v_match
= match
[match
.selectedIndex
].text
;
533 var feed_id
= feed
[feed
.selectedIndex
].id
;
534 var action_id
= action
[action
.selectedIndex
].id
;
536 xmlhttp
.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add®exp=" +
537 param_escape(regexp
.value
) + "&match=" + v_match
+
538 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
540 xmlhttp
.onreadystatechange
=dlg_submit_callback
;
549 function displayDlg(id
, param
) {
551 if (!xmlhttp_ready(xmlhttp
)) {
558 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
559 param_escape(id
) + "¶m=" + param_escape(param
), true);
560 xmlhttp
.onreadystatechange
=dlg_display_callback
;
566 function closeDlg() {
567 var dlg
= document
.getElementById("userDlgShadow");
568 dlg
.style
.display
= "none";
572 function qfdDelete(feed_id
) {
574 notify("Removing feed...");
576 if (!xmlhttp_ready(xmlhttp
)) {
581 // var feeds_doc = window.frames["feeds-frame"].document;
582 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
584 _qfd_deleted_feed
= feed_id
;
586 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
);
587 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
592 function allFeedsMenuChange() {
593 var chooser
= document
.getElementById("allFeedsChooser");
595 var opname
= chooser
[chooser
.selectedIndex
].text
;
597 chooser
.selectedIndex
= 0;
599 if (opname
== "Update") {
600 scheduleFeedUpdate(true);
604 if (opname
== "Mark as read") {
609 if (opname
== "Show only unread") {
616 function updateFeedTitle(t
) {
617 active_title_text
= t
;
621 function toggleDispRead() {
624 if (!xmlhttp_ready(xmlhttp
)) {
629 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
631 hide_read_feeds
= !hide_read_feeds
;
633 var query
= "backend.php?op=rpc&subop=setpref" +
634 "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds
);
636 xmlhttp
.open("GET", query
);
637 xmlhttp
.onreadystatechange
=hide_unread_callback
;
641 exception_error("toggleDispRead", e
);