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);
257 var refresh_time
= getCookie('ttrss_vf_refresh');
259 if (!refresh_time
) refresh_time
= 600;
261 setTimeout("timeout()", refresh_time
*1000);
264 function resetSearch() {
265 var searchbox
= document
.getElementById("searchbox")
267 if (searchbox
.value
!= "" && getActiveFeedId()) {
268 searchbox
.value
= "";
269 viewfeed(getActiveFeedId(), 0, "");
275 viewCurrentFeed(0, "");
278 function localPiggieFunction(enable
) {
280 var query_str
= "backend.php?op=feeds&subop=piggie";
282 if (xmlhttp_ready(xmlhttp
)) {
284 xmlhttp
.open("GET", query_str
, true);
285 xmlhttp
.onreadystatechange
=feedlist_callback
;
291 function localHotkeyHandler(keycode
) {
293 /* if (keycode == 78) {
294 return moveToPost('next');
298 return moveToPost('prev');
301 if (keycode
== 82) { // r
302 return scheduleFeedUpdate(true);
305 if (keycode
== 85) { // u
306 if (getActiveFeedId()) {
307 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
311 if (keycode
== 65) { // a
312 return toggleDispRead();
315 var f_doc
= window
.frames
["feeds-frame"].document
;
316 var feedlist
= f_doc
.getElementById('feedList');
318 if (keycode
== 74) { // j
319 var feed
= getActiveFeedId();
320 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
321 if (new_feed
) viewfeed(new_feed
, 0, '');
324 if (keycode
== 75) { // k
325 var feed
= getActiveFeedId();
326 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
327 if (new_feed
) viewfeed(new_feed
, 0, '');
330 // notify("KC: " + keycode);
334 // if argument is undefined, current subtitle is not updated
335 // use blank string to clear subtitle
336 function updateTitle(s
) {
337 var tmp
= "Tiny Tiny RSS";
339 if (s
&& s
.length
> 0) {
340 current_subtitle
= s
;
343 if (global_unread
> 0) {
344 tmp
= tmp
+ " (" + global_unread
+ ")";
348 tmp
= tmp
+ " - " + current_subtitle
;
351 if (active_title_text
.length
> 0) {
352 tmp
= tmp
+ " > " + active_title_text
;
355 document
.title
= tmp
;
358 function genericSanityCheck() {
360 if (!xmlhttp
) fatalError(1);
362 setCookie("ttrss_vf_test", "TEST");
364 if (getCookie("ttrss_vf_test") != "TEST") {
375 disableContainerChildren("headlinesToolbar", true);
377 if (!genericSanityCheck())
380 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
381 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
385 exception_error("init", e
);
389 function init_second_stage() {
393 setCookie("ttrss_vf_actfeed", "");
395 updateFeedList(false, false);
396 document
.onkeydown
= hotkey_handler
;
398 var viewbox
= document
.getElementById("viewbox");
399 var limitbox
= document
.getElementById("limitbox");
401 dropboxSelect(viewbox
, getCookie("ttrss_vf_vmode"));
402 dropboxSelect(limitbox
, getCookie("ttrss_vf_limit"));
405 exception_error("init_second_stage", e
);
409 function quickMenuChange() {
410 var chooser
= document
.getElementById("quickMenuChooser");
411 var opid
= chooser
[chooser
.selectedIndex
].id
;
413 chooser
.selectedIndex
= 0;
417 function quickMenuGo(opid
) {
420 if (opid
== "qmcPrefs") {
424 if (opid
== "qmcSearch") {
425 displayDlg("search", getActiveFeedId());
429 if (opid
== "qmcAddFeed") {
430 displayDlg("quickAddFeed");
434 if (opid
== "qmcRemoveFeed") {
435 var actid
= getActiveFeedId();
438 notify("Please select some feed first.");
442 if (confirm("Remove current feed?")) {
449 if (opid
== "qmcUpdateFeeds") {
450 scheduleFeedUpdate(true);
454 if (opid
== "qmcCatchupAll") {
459 if (opid
== "qmcShowOnlyUnread") {
464 if (opid
== "qmcAddFilter") {
465 displayDlg("quickAddFilter", getActiveFeedId());
472 if (!xmlhttp_ready(xmlhttp
)) {
477 var link
= document
.getElementById("qafInput");
479 if (link
.value
.length
== 0) {
480 notify("Missing feed URL.");
482 notify("Adding feed...");
484 var cat
= document
.getElementById("qafCat");
488 cat_id
= cat
[cat
.selectedIndex
].id
;
493 var feeds_doc
= window
.frames
["feeds-frame"].document
;
495 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
497 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" +
498 param_escape(link
.value
) + "&cid=" + param_escape(cat_id
), true);
499 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
507 function qaddFilter() {
509 if (!xmlhttp_ready(xmlhttp
)) {
514 var regexp
= document
.getElementById("fadd_regexp");
515 var match
= document
.getElementById("fadd_match");
516 var feed
= document
.getElementById("fadd_feed");
517 var action
= document
.getElementById("fadd_action");
519 if (regexp
.value
.length
== 0) {
520 notify("Missing filter expression.");
522 notify("Adding filter...");
524 var v_match
= match
[match
.selectedIndex
].text
;
525 var feed_id
= feed
[feed
.selectedIndex
].id
;
526 var action_id
= action
[action
.selectedIndex
].id
;
528 xmlhttp
.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add®exp=" +
529 param_escape(regexp
.value
) + "&match=" + v_match
+
530 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
532 xmlhttp
.onreadystatechange
=dlg_submit_callback
;
541 function displayDlg(id
, param
) {
543 if (!xmlhttp_ready(xmlhttp
)) {
550 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
551 param_escape(id
) + "¶m=" + param_escape(param
), true);
552 xmlhttp
.onreadystatechange
=dlg_display_callback
;
558 function closeDlg() {
559 var dlg
= document
.getElementById("userDlgShadow");
560 dlg
.style
.display
= "none";
564 function qfdDelete(feed_id
) {
566 notify("Removing feed...");
568 if (!xmlhttp_ready(xmlhttp
)) {
573 // var feeds_doc = window.frames["feeds-frame"].document;
574 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
576 _qfd_deleted_feed
= feed_id
;
578 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
);
579 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
584 function allFeedsMenuChange() {
585 var chooser
= document
.getElementById("allFeedsChooser");
587 var opname
= chooser
[chooser
.selectedIndex
].text
;
589 chooser
.selectedIndex
= 0;
591 if (opname
== "Update") {
592 scheduleFeedUpdate(true);
596 if (opname
== "Mark as read") {
601 if (opname
== "Show only unread") {
608 function updateFeedTitle(t
) {
609 active_title_text
= t
;
613 function toggleDispRead() {
616 if (!xmlhttp_ready(xmlhttp
)) {
621 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
623 hide_read_feeds
= !hide_read_feeds
;
625 var query
= "backend.php?op=rpc&subop=setpref" +
626 "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds
);
628 xmlhttp
.open("GET", query
);
629 xmlhttp
.onreadystatechange
=hide_unread_callback
;
633 exception_error("toggleDispRead", e
);