6 var display_tags
= false;
8 var global_unread
= -1;
10 var active_title_text
= "";
12 var current_subtitle
= "";
15 /*@if (@_jscript_version >= 5)
16 // JScript gives us Conditional compilation, we can cope with old IE versions.
17 // and security blocked creation of the objects.
19 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
22 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
29 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
30 xmlhttp
= new XMLHttpRequest();
33 function toggleTags() {
34 display_tags
= !display_tags
;
36 var p
= document
.getElementById("dispSwitchPrompt");
39 p
.innerHTML
= "display feeds";
41 p
.innerHTML
= "display tags";
47 function dlg_frefresh_callback() {
48 if (xmlhttp
.readyState
== 4) {
49 notify(xmlhttp
.responseText
);
50 updateFeedList(false, false);
55 function dlg_submit_callback() {
56 if (xmlhttp
.readyState
== 4) {
57 notify(xmlhttp
.responseText
);
62 function dlg_display_callback() {
63 if (xmlhttp
.readyState
== 4) {
64 var dlg
= document
.getElementById("userDlg");
65 var dlg_s
= document
.getElementById("userDlgShadow");
67 dlg
.innerHTML
= xmlhttp
.responseText
;
68 dlg_s
.style
.display
= "block";
72 function refetch_callback() {
73 if (xmlhttp
.readyState
== 4) {
76 if (!xmlhttp
.responseXML
) {
77 notify("refetch_callback: backend did not return valid XML");
81 var reply
= xmlhttp
.responseXML
.firstChild
;
84 notify("refetch_callback: backend did not return expected XML object");
88 var error_code
= reply
.getAttribute("error-code");
90 if (error_code
&& error_code
!= 0) {
91 return fatalError(error_code
);
94 var f_document
= window
.frames
["feeds-frame"].document
;
96 parse_counters(reply
, f_document
);
99 notify("All feeds updated.");
101 exception_error("refetch_callback", e
);
106 function backend_sanity_check_callback() {
108 if (xmlhttp
.readyState
== 4) {
112 if (!xmlhttp
.responseXML
) {
117 var reply
= xmlhttp
.responseXML
.firstChild
;
124 var error_code
= reply
.getAttribute("error-code");
126 if (error_code
&& error_code
!= 0) {
127 return fatalError(error_code
);
133 exception_error("backend_sanity_check_callback", e
);
138 function scheduleFeedUpdate(force
) {
140 notify("Updating feeds in background...");
142 // document.title = "Tiny Tiny RSS - Updating...";
144 updateTitle("Updating");
146 var query_str
= "backend.php?op=rpc&subop=";
149 query_str
= query_str
+ "forceUpdateAllFeeds";
151 query_str
= query_str
+ "updateAllFeeds";
162 query_str
= query_str
+ "&omode=" + omode
;
164 if (xmlhttp_ready(xmlhttp
)) {
165 xmlhttp
.open("GET", query_str
, true);
166 xmlhttp
.onreadystatechange
=refetch_callback
;
173 function updateFeedList(silent
, fetch
) {
175 // if (silent != true) {
176 // notify("Loading feed list...");
179 var query_str
= "backend.php?op=feeds";
182 query_str
= query_str
+ "&tags=1";
185 if (getActiveFeedId()) {
186 query_str
= query_str
+ "&actid=" + getActiveFeedId();
189 if (fetch
) query_str
= query_str
+ "&fetch=yes";
191 var feeds_frame
= document
.getElementById("feeds-frame");
193 feeds_frame
.src
= query_str
;
196 function catchupAllFeeds() {
198 var query_str
= "backend.php?op=feeds&subop=catchupAll";
200 notify("Marking all feeds as read...");
202 var feeds_frame
= document
.getElementById("feeds-frame");
204 feeds_frame
.src
= query_str
;
211 function viewCurrentFeed(skip
, subop
) {
213 if (getActiveFeedId()) {
214 viewfeed(getActiveFeedId(), skip
, subop
);
216 disableContainerChildren("headlinesToolbar", false, document
);
217 viewfeed(-1, skip
, subop
); // FIXME
221 function viewfeed(feed
, skip
, subop
) {
222 var f
= window
.frames
["feeds-frame"];
223 f
.viewfeed(feed
, skip
, subop
);
227 scheduleFeedUpdate(false);
228 setTimeout("timeout()", 1800*1000);
231 function resetSearch() {
232 var searchbox
= document
.getElementById("searchbox")
234 if (searchbox
.value
!= "" && getActiveFeedId()) {
235 searchbox
.value
= "";
236 viewfeed(getActiveFeedId(), 0, "");
241 viewCurrentFeed(0, "");
244 function localPiggieFunction(enable
) {
246 var query_str
= "backend.php?op=feeds&subop=piggie";
248 if (xmlhttp_ready(xmlhttp
)) {
250 xmlhttp
.open("GET", query_str
, true);
251 xmlhttp
.onreadystatechange
=feedlist_callback
;
257 function localHotkeyHandler(keycode
) {
259 /* if (keycode == 78) {
260 return moveToPost('next');
264 return moveToPost('prev');
267 if (keycode
== 82) { // r
268 return scheduleFeedUpdate(true);
271 if (keycode
== 85) { // u
272 if (getActiveFeedId()) {
273 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
277 if (keycode
== 65) { // a
278 return toggleDispRead();
281 var f_doc
= window
.frames
["feeds-frame"].document
;
282 var feedlist
= f_doc
.getElementById('feedList');
284 if (keycode
== 74) { // j
285 var feed
= getActiveFeedId();
286 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
287 if (new_feed
) viewfeed(new_feed
, 0, '');
290 if (keycode
== 75) { // k
291 var feed
= getActiveFeedId();
292 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
293 if (new_feed
) viewfeed(new_feed
, 0, '');
296 // notify("KC: " + keycode);
300 // if argument is undefined, current subtitle is not updated
301 // use blank string to clear subtitle
302 function updateTitle(s
) {
303 var tmp
= "Tiny Tiny RSS";
305 if (s
&& s
.length
> 0) {
306 current_subtitle
= s
;
309 if (global_unread
> 0) {
310 tmp
= tmp
+ " (" + global_unread
+ ")";
314 tmp
= tmp
+ " - " + current_subtitle
;
317 if (active_title_text
.length
> 0) {
318 tmp
= tmp
+ " > " + active_title_text
;
321 document
.title
= tmp
;
324 function genericSanityCheck() {
326 if (!xmlhttp
) fatalError(1);
328 setCookie("ttrss_vf_test", "TEST");
330 if (getCookie("ttrss_vf_test") != "TEST") {
341 disableContainerChildren("headlinesToolbar", true);
343 if (!genericSanityCheck())
346 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
347 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
351 exception_error("init", e
);
355 function init_second_stage() {
359 setCookie("ttrss_vf_actfeed", "");
361 updateFeedList(false, false);
362 document
.onkeydown
= hotkey_handler
;
364 var content
= document
.getElementById("content");
366 if (getCookie("ttrss_vf_vmode")) {
367 var viewbox
= document
.getElementById("viewbox");
368 viewbox
.value
= getCookie("ttrss_vf_vmode");
371 if (getCookie("ttrss_vf_limit")) {
372 var limitbox
= document
.getElementById("limitbox");
373 limitbox
.value
= getCookie("ttrss_vf_limit");
376 // if (getCookie("ttrss_vf_actfeed")) {
377 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
380 // setTimeout("timeout()", 2*1000);
381 // scheduleFeedUpdate(true);
384 exception_error("init_second_stage", e
);
388 function quickMenuGo() {
390 var chooser
= document
.getElementById("quickMenuChooser");
391 var opid
= chooser
[chooser
.selectedIndex
].id
;
393 if (opid
== "qmcPrefs") {
397 if (opid
== "qmcAdvSearch") {
398 displayDlg("search");
402 if (opid
== "qmcAddFeed") {
403 displayDlg("quickAddFeed");
407 if (opid
== "qmcRemoveFeed") {
408 var actid
= getActiveFeedId();
411 notify("Please select some feed first.");
415 if (confirm("Remove current feed?")) {
422 if (opid
== "qmcUpdateFeeds") {
423 scheduleFeedUpdate(true);
427 if (opid
== "qmcCatchupAll") {
432 if (opid
== "qmcShowOnlyUnread") {
437 if (opid
== "qmcAddFilter") {
438 displayDlg("quickAddFilter", getActiveFeedId());
445 if (!xmlhttp_ready(xmlhttp
)) {
450 var link
= document
.getElementById("qafInput");
452 if (link
.value
.length
== 0) {
453 notify("Missing feed URL.");
455 notify("Adding feed...");
457 var feeds_doc
= window
.frames
["feeds-frame"].document
;
459 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
461 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" +
462 param_escape(link
.value
), true);
463 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
471 function qaddFilter() {
473 if (!xmlhttp_ready(xmlhttp
)) {
478 var regexp
= document
.getElementById("fadd_regexp");
479 var match
= document
.getElementById("fadd_match");
480 var feed
= document
.getElementById("fadd_feed");
481 var action
= document
.getElementById("fadd_action");
483 if (regexp
.value
.length
== 0) {
484 notify("Missing filter expression.");
486 notify("Adding filter...");
488 var v_match
= match
[match
.selectedIndex
].text
;
489 var feed_id
= feed
[feed
.selectedIndex
].id
;
490 var action_id
= action
[action
.selectedIndex
].id
;
492 xmlhttp
.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add®exp=" +
493 param_escape(regexp
.value
) + "&match=" + v_match
+
494 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
496 xmlhttp
.onreadystatechange
=dlg_submit_callback
;
505 function displayDlg(id
, param
) {
509 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
510 param_escape(id
) + "¶m=" + param_escape(param
), true);
511 xmlhttp
.onreadystatechange
=dlg_display_callback
;
517 function closeDlg() {
518 var dlg
= document
.getElementById("userDlgShadow");
519 dlg
.style
.display
= "none";
523 function qfdDelete(feed_id
) {
525 notify("Removing feed...");
527 // var feeds_doc = window.frames["feeds-frame"].document;
528 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
530 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
);
531 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
536 function allFeedsMenuGo() {
537 var chooser
= document
.getElementById("allFeedsChooser");
539 var opname
= chooser
[chooser
.selectedIndex
].text
;
541 if (opname
== "Update") {
542 scheduleFeedUpdate(true);
546 if (opname
== "Mark as read") {
551 if (opname
== "Show only unread") {
558 function updateFeedTitle(t
) {
559 active_title_text
= t
;
563 function toggleDispRead() {
564 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
566 hide_read_feeds
= !hide_read_feeds
;
568 var feeds_doc
= window
.frames
["feeds-frame"].document
;
570 hideOrShowFeeds(feeds_doc
, hide_read_feeds
);
572 if (hide_read_feeds
) {
573 setCookie("ttrss_vf_hreadf", 1);
575 setCookie("ttrss_vf_hreadf", 0);