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 refetch_callback() {
76 if (xmlhttp
.readyState
== 4) {
79 if (!xmlhttp
.responseXML
) {
80 notify("refetch_callback: backend did not return valid XML");
84 var reply
= xmlhttp
.responseXML
.firstChild
;
87 notify("refetch_callback: backend did not return expected XML object");
91 var error_code
= reply
.getAttribute("error-code");
93 if (error_code
&& error_code
!= 0) {
94 return fatalError(error_code
);
97 var f_document
= window
.frames
["feeds-frame"].document
;
99 parse_counters(reply
, f_document
, window
);
102 notify("All feeds updated.");
104 exception_error("refetch_callback", e
);
109 function backend_sanity_check_callback() {
111 if (xmlhttp
.readyState
== 4) {
115 alert(xmlhttp
.responseText
);
117 if (!xmlhttp
.responseXML
) {
122 var reply
= xmlhttp
.responseXML
.firstChild
;
129 var error_code
= reply
.getAttribute("error-code");
131 if (error_code
&& error_code
!= 0) {
132 return fatalError(error_code
);
138 exception_error("backend_sanity_check_callback", e
);
143 function scheduleFeedUpdate(force
) {
145 notify("Updating feeds, please wait.");
147 // document.title = "Tiny Tiny RSS - Updating...";
149 updateTitle("Updating");
151 var query_str
= "backend.php?op=rpc&subop=";
154 query_str
= query_str
+ "forceUpdateAllFeeds";
156 query_str
= query_str
+ "updateAllFeeds";
167 query_str
= query_str
+ "&omode=" + omode
;
169 if (xmlhttp_ready(xmlhttp
)) {
170 xmlhttp
.open("GET", query_str
, true);
171 xmlhttp
.onreadystatechange
=refetch_callback
;
178 function updateFeedList(silent
, fetch
) {
180 // if (silent != true) {
181 // notify("Loading feed list...");
184 var query_str
= "backend.php?op=feeds";
187 query_str
= query_str
+ "&tags=1";
190 if (getActiveFeedId()) {
191 query_str
= query_str
+ "&actid=" + getActiveFeedId();
194 if (fetch
) query_str
= query_str
+ "&fetch=yes";
196 var feeds_frame
= document
.getElementById("feeds-frame");
198 feeds_frame
.src
= query_str
;
201 function catchupAllFeeds() {
203 var query_str
= "backend.php?op=feeds&subop=catchupAll";
205 notify("Marking all feeds as read...");
207 var feeds_frame
= document
.getElementById("feeds-frame");
209 feeds_frame
.src
= query_str
;
216 function viewCurrentFeed(skip
, subop
) {
218 if (getActiveFeedId()) {
219 viewfeed(getActiveFeedId(), skip
, subop
);
221 disableContainerChildren("headlinesToolbar", false, document
);
222 viewfeed(-1, skip
, subop
); // FIXME
226 function viewfeed(feed
, skip
, subop
) {
227 var f
= window
.frames
["feeds-frame"];
228 f
.viewfeed(feed
, skip
, subop
);
232 scheduleFeedUpdate(false);
233 setTimeout("timeout()", 900*1000);
236 function resetSearch() {
237 var searchbox
= document
.getElementById("searchbox")
239 if (searchbox
.value
!= "" && getActiveFeedId()) {
240 searchbox
.value
= "";
241 viewfeed(getActiveFeedId(), 0, "");
247 viewCurrentFeed(0, "");
250 function localPiggieFunction(enable
) {
252 var query_str
= "backend.php?op=feeds&subop=piggie";
254 if (xmlhttp_ready(xmlhttp
)) {
256 xmlhttp
.open("GET", query_str
, true);
257 xmlhttp
.onreadystatechange
=feedlist_callback
;
263 function localHotkeyHandler(keycode
) {
265 /* if (keycode == 78) {
266 return moveToPost('next');
270 return moveToPost('prev');
273 if (keycode
== 82) { // r
274 return scheduleFeedUpdate(true);
277 if (keycode
== 85) { // u
278 if (getActiveFeedId()) {
279 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
283 if (keycode
== 65) { // a
284 return toggleDispRead();
287 var f_doc
= window
.frames
["feeds-frame"].document
;
288 var feedlist
= f_doc
.getElementById('feedList');
290 if (keycode
== 74) { // j
291 var feed
= getActiveFeedId();
292 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
293 if (new_feed
) viewfeed(new_feed
, 0, '');
296 if (keycode
== 75) { // k
297 var feed
= getActiveFeedId();
298 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
299 if (new_feed
) viewfeed(new_feed
, 0, '');
302 // notify("KC: " + keycode);
306 // if argument is undefined, current subtitle is not updated
307 // use blank string to clear subtitle
308 function updateTitle(s
) {
309 var tmp
= "Tiny Tiny RSS";
311 if (s
&& s
.length
> 0) {
312 current_subtitle
= s
;
315 if (global_unread
> 0) {
316 tmp
= tmp
+ " (" + global_unread
+ ")";
320 tmp
= tmp
+ " - " + current_subtitle
;
323 if (active_title_text
.length
> 0) {
324 tmp
= tmp
+ " > " + active_title_text
;
327 document
.title
= tmp
;
330 function genericSanityCheck() {
332 if (!xmlhttp
) fatalError(1);
334 setCookie("ttrss_vf_test", "TEST");
336 if (getCookie("ttrss_vf_test") != "TEST") {
347 disableContainerChildren("headlinesToolbar", true);
349 if (!genericSanityCheck())
352 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
353 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
357 exception_error("init", e
);
361 function init_second_stage() {
365 setCookie("ttrss_vf_actfeed", "");
367 updateFeedList(false, false);
368 document
.onkeydown
= hotkey_handler
;
370 var viewbox
= document
.getElementById("viewbox");
371 var limitbox
= document
.getElementById("limitbox");
373 dropboxSelect(viewbox
, getCookie("ttrss_vf_vmode"));
374 dropboxSelect(limitbox
, getCookie("ttrss_vf_limit"));
377 exception_error("init_second_stage", e
);
381 function quickMenuGo() {
383 var chooser
= document
.getElementById("quickMenuChooser");
384 var opid
= chooser
[chooser
.selectedIndex
].id
;
386 if (opid
== "qmcPrefs") {
390 if (opid
== "qmcSearch") {
391 displayDlg("search");
395 if (opid
== "qmcAddFeed") {
396 displayDlg("quickAddFeed");
400 if (opid
== "qmcRemoveFeed") {
401 var actid
= getActiveFeedId();
404 notify("Please select some feed first.");
408 if (confirm("Remove current feed?")) {
415 if (opid
== "qmcUpdateFeeds") {
416 scheduleFeedUpdate(true);
420 if (opid
== "qmcCatchupAll") {
425 if (opid
== "qmcShowOnlyUnread") {
430 if (opid
== "qmcAddFilter") {
431 displayDlg("quickAddFilter", getActiveFeedId());
438 if (!xmlhttp_ready(xmlhttp
)) {
443 var link
= document
.getElementById("qafInput");
445 if (link
.value
.length
== 0) {
446 notify("Missing feed URL.");
448 notify("Adding feed...");
450 var cat
= document
.getElementById("qafCat");
454 cat_id
= cat
[cat
.selectedIndex
].id
;
459 var feeds_doc
= window
.frames
["feeds-frame"].document
;
461 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
463 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" +
464 param_escape(link
.value
) + "&cid=" + param_escape(cat_id
), true);
465 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
473 function qaddFilter() {
475 if (!xmlhttp_ready(xmlhttp
)) {
480 var regexp
= document
.getElementById("fadd_regexp");
481 var match
= document
.getElementById("fadd_match");
482 var feed
= document
.getElementById("fadd_feed");
483 var action
= document
.getElementById("fadd_action");
485 if (regexp
.value
.length
== 0) {
486 notify("Missing filter expression.");
488 notify("Adding filter...");
490 var v_match
= match
[match
.selectedIndex
].text
;
491 var feed_id
= feed
[feed
.selectedIndex
].id
;
492 var action_id
= action
[action
.selectedIndex
].id
;
494 xmlhttp
.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add®exp=" +
495 param_escape(regexp
.value
) + "&match=" + v_match
+
496 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
498 xmlhttp
.onreadystatechange
=dlg_submit_callback
;
507 function displayDlg(id
, param
) {
511 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
512 param_escape(id
) + "¶m=" + param_escape(param
), true);
513 xmlhttp
.onreadystatechange
=dlg_display_callback
;
519 function closeDlg() {
520 var dlg
= document
.getElementById("userDlgShadow");
521 dlg
.style
.display
= "none";
525 function qfdDelete(feed_id
) {
527 notify("Removing feed...");
529 // var feeds_doc = window.frames["feeds-frame"].document;
530 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
532 _qfd_deleted_feed
= feed_id
;
534 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
);
535 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
540 function allFeedsMenuGo() {
541 var chooser
= document
.getElementById("allFeedsChooser");
543 var opname
= chooser
[chooser
.selectedIndex
].text
;
545 if (opname
== "Update") {
546 scheduleFeedUpdate(true);
550 if (opname
== "Mark as read") {
555 if (opname
== "Show only unread") {
562 function updateFeedTitle(t
) {
563 active_title_text
= t
;
567 function toggleDispRead() {
568 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
570 hide_read_feeds
= !hide_read_feeds
;
572 var feeds_doc
= window
.frames
["feeds-frame"].document
;
574 hideOrShowFeeds(feeds_doc
, hide_read_feeds
);
576 if (hide_read_feeds
) {
577 setCookie("ttrss_vf_hreadf", 1);
579 setCookie("ttrss_vf_hreadf", 0);