4 var display_tags
= false;
5 var global_unread
= -1;
6 var active_title_text
= "";
7 var current_subtitle
= "";
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");
116 var error_code
= reply
.getAttribute("error-code");
118 if (error_code
&& error_code
!= 0) {
119 return fatalError(error_code
);
122 var f_document
= window
.frames
["feeds-frame"].document
;
124 parse_counters(reply
, f_document
, window
);
127 notify("All feeds updated.");
129 exception_error("refetch_callback", e
);
134 function backend_sanity_check_callback() {
136 if (xmlhttp
.readyState
== 4) {
140 if (!xmlhttp
.responseXML
) {
145 var reply
= xmlhttp
.responseXML
.firstChild
;
152 var error_code
= reply
.getAttribute("error-code");
154 if (error_code
&& error_code
!= 0) {
155 return fatalError(error_code
);
161 exception_error("backend_sanity_check_callback", e
);
166 function scheduleFeedUpdate(force
) {
168 notify("Updating feeds, please wait.");
170 // document.title = "Tiny Tiny RSS - Updating...";
172 updateTitle("Updating");
174 var query_str
= "backend.php?op=rpc&subop=";
177 query_str
= query_str
+ "forceUpdateAllFeeds";
179 query_str
= query_str
+ "updateAllFeeds";
190 query_str
= query_str
+ "&omode=" + omode
;
192 if (xmlhttp_ready(xmlhttp
)) {
193 xmlhttp
.open("GET", query_str
, true);
194 xmlhttp
.onreadystatechange
=refetch_callback
;
201 function updateFeedList(silent
, fetch
) {
203 // if (silent != true) {
204 // notify("Loading feed list...");
207 var query_str
= "backend.php?op=feeds";
210 query_str
= query_str
+ "&tags=1";
213 if (getActiveFeedId()) {
214 query_str
= query_str
+ "&actid=" + getActiveFeedId();
217 if (fetch
) query_str
= query_str
+ "&fetch=yes";
219 var feeds_frame
= document
.getElementById("feeds-frame");
221 feeds_frame
.src
= query_str
;
224 function catchupAllFeeds() {
226 var query_str
= "backend.php?op=feeds&subop=catchupAll";
228 notify("Marking all feeds as read...");
230 var feeds_frame
= document
.getElementById("feeds-frame");
232 feeds_frame
.src
= query_str
;
239 function viewCurrentFeed(skip
, subop
) {
241 if (getActiveFeedId()) {
242 viewfeed(getActiveFeedId(), skip
, subop
);
244 disableContainerChildren("headlinesToolbar", false, document
);
245 viewfeed(-1, skip
, subop
); // FIXME
249 function viewfeed(feed
, skip
, subop
) {
250 var f
= window
.frames
["feeds-frame"];
251 f
.viewfeed(feed
, skip
, subop
);
255 scheduleFeedUpdate(false);
256 setTimeout("timeout()", 900*1000);
259 function resetSearch() {
260 var searchbox
= document
.getElementById("searchbox")
262 if (searchbox
.value
!= "" && getActiveFeedId()) {
263 searchbox
.value
= "";
264 viewfeed(getActiveFeedId(), 0, "");
270 viewCurrentFeed(0, "");
273 function localPiggieFunction(enable
) {
275 var query_str
= "backend.php?op=feeds&subop=piggie";
277 if (xmlhttp_ready(xmlhttp
)) {
279 xmlhttp
.open("GET", query_str
, true);
280 xmlhttp
.onreadystatechange
=feedlist_callback
;
286 function localHotkeyHandler(keycode
) {
288 /* if (keycode == 78) {
289 return moveToPost('next');
293 return moveToPost('prev');
296 if (keycode
== 82) { // r
297 return scheduleFeedUpdate(true);
300 if (keycode
== 85) { // u
301 if (getActiveFeedId()) {
302 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
306 if (keycode
== 65) { // a
307 return toggleDispRead();
310 var f_doc
= window
.frames
["feeds-frame"].document
;
311 var feedlist
= f_doc
.getElementById('feedList');
313 if (keycode
== 74) { // j
314 var feed
= getActiveFeedId();
315 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
316 if (new_feed
) viewfeed(new_feed
, 0, '');
319 if (keycode
== 75) { // k
320 var feed
= getActiveFeedId();
321 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
322 if (new_feed
) viewfeed(new_feed
, 0, '');
325 // notify("KC: " + keycode);
329 // if argument is undefined, current subtitle is not updated
330 // use blank string to clear subtitle
331 function updateTitle(s
) {
332 var tmp
= "Tiny Tiny RSS";
334 if (s
&& s
.length
> 0) {
335 current_subtitle
= s
;
338 if (global_unread
> 0) {
339 tmp
= tmp
+ " (" + global_unread
+ ")";
343 tmp
= tmp
+ " - " + current_subtitle
;
346 if (active_title_text
.length
> 0) {
347 tmp
= tmp
+ " > " + active_title_text
;
350 document
.title
= tmp
;
353 function genericSanityCheck() {
355 if (!xmlhttp
) fatalError(1);
357 setCookie("ttrss_vf_test", "TEST");
359 if (getCookie("ttrss_vf_test") != "TEST") {
370 disableContainerChildren("headlinesToolbar", true);
372 if (!genericSanityCheck())
375 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
376 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
380 exception_error("init", e
);
384 function init_second_stage() {
388 setCookie("ttrss_vf_actfeed", "");
390 updateFeedList(false, false);
391 document
.onkeydown
= hotkey_handler
;
393 var viewbox
= document
.getElementById("viewbox");
394 var limitbox
= document
.getElementById("limitbox");
396 dropboxSelect(viewbox
, getCookie("ttrss_vf_vmode"));
397 dropboxSelect(limitbox
, getCookie("ttrss_vf_limit"));
400 exception_error("init_second_stage", e
);
404 function quickMenuChange() {
405 var chooser
= document
.getElementById("quickMenuChooser");
406 var opid
= chooser
[chooser
.selectedIndex
].id
;
408 chooser
.selectedIndex
= 0;
412 function quickMenuGo(opid
) {
415 if (opid
== "qmcPrefs") {
419 if (opid
== "qmcSearch") {
420 displayDlg("search", getActiveFeedId());
424 if (opid
== "qmcAddFeed") {
425 displayDlg("quickAddFeed");
429 if (opid
== "qmcRemoveFeed") {
430 var actid
= getActiveFeedId();
433 notify("Please select some feed first.");
437 if (confirm("Remove current feed?")) {
444 if (opid
== "qmcUpdateFeeds") {
445 scheduleFeedUpdate(true);
449 if (opid
== "qmcCatchupAll") {
454 if (opid
== "qmcShowOnlyUnread") {
459 if (opid
== "qmcAddFilter") {
460 displayDlg("quickAddFilter", getActiveFeedId());
467 if (!xmlhttp_ready(xmlhttp
)) {
472 var link
= document
.getElementById("qafInput");
474 if (link
.value
.length
== 0) {
475 notify("Missing feed URL.");
477 notify("Adding feed...");
479 var cat
= document
.getElementById("qafCat");
483 cat_id
= cat
[cat
.selectedIndex
].id
;
488 var feeds_doc
= window
.frames
["feeds-frame"].document
;
490 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
492 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" +
493 param_escape(link
.value
) + "&cid=" + param_escape(cat_id
), true);
494 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
502 function qaddFilter() {
504 if (!xmlhttp_ready(xmlhttp
)) {
509 var regexp
= document
.getElementById("fadd_regexp");
510 var match
= document
.getElementById("fadd_match");
511 var feed
= document
.getElementById("fadd_feed");
512 var action
= document
.getElementById("fadd_action");
514 if (regexp
.value
.length
== 0) {
515 notify("Missing filter expression.");
517 notify("Adding filter...");
519 var v_match
= match
[match
.selectedIndex
].text
;
520 var feed_id
= feed
[feed
.selectedIndex
].id
;
521 var action_id
= action
[action
.selectedIndex
].id
;
523 xmlhttp
.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add®exp=" +
524 param_escape(regexp
.value
) + "&match=" + v_match
+
525 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
527 xmlhttp
.onreadystatechange
=dlg_submit_callback
;
536 function displayDlg(id
, param
) {
538 if (!xmlhttp_ready(xmlhttp
)) {
545 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
546 param_escape(id
) + "¶m=" + param_escape(param
), true);
547 xmlhttp
.onreadystatechange
=dlg_display_callback
;
553 function closeDlg() {
554 var dlg
= document
.getElementById("userDlgShadow");
555 dlg
.style
.display
= "none";
559 function qfdDelete(feed_id
) {
561 notify("Removing feed...");
563 if (!xmlhttp_ready(xmlhttp
)) {
568 // var feeds_doc = window.frames["feeds-frame"].document;
569 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
571 _qfd_deleted_feed
= feed_id
;
573 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
);
574 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
579 function allFeedsMenuChange() {
580 var chooser
= document
.getElementById("allFeedsChooser");
582 var opname
= chooser
[chooser
.selectedIndex
].text
;
584 chooser
.selectedIndex
= 0;
586 if (opname
== "Update") {
587 scheduleFeedUpdate(true);
591 if (opname
== "Mark as read") {
596 if (opname
== "Show only unread") {
603 function updateFeedTitle(t
) {
604 active_title_text
= t
;
608 function toggleDispRead() {
611 if (!xmlhttp_ready(xmlhttp
)) {
616 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
618 hide_read_feeds
= !hide_read_feeds
;
620 var query
= "backend.php?op=rpc&subop=setpref" +
621 "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds
);
623 xmlhttp
.open("GET", query
);
624 xmlhttp
.onreadystatechange
=hide_unread_callback
;
628 exception_error("toggleDispRead", e
);