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
);
102 notify("All feeds updated.");
104 exception_error("refetch_callback", e
);
109 function backend_sanity_check_callback() {
111 if (xmlhttp
.readyState
== 4) {
115 if (!xmlhttp
.responseXML
) {
120 var reply
= xmlhttp
.responseXML
.firstChild
;
127 var error_code
= reply
.getAttribute("error-code");
129 if (error_code
&& error_code
!= 0) {
130 return fatalError(error_code
);
136 exception_error("backend_sanity_check_callback", e
);
141 function scheduleFeedUpdate(force
) {
143 notify("Updating feeds in background...");
145 // document.title = "Tiny Tiny RSS - Updating...";
147 updateTitle("Updating");
149 var query_str
= "backend.php?op=rpc&subop=";
152 query_str
= query_str
+ "forceUpdateAllFeeds";
154 query_str
= query_str
+ "updateAllFeeds";
165 query_str
= query_str
+ "&omode=" + omode
;
167 if (xmlhttp_ready(xmlhttp
)) {
168 xmlhttp
.open("GET", query_str
, true);
169 xmlhttp
.onreadystatechange
=refetch_callback
;
176 function updateFeedList(silent
, fetch
) {
178 // if (silent != true) {
179 // notify("Loading feed list...");
182 var query_str
= "backend.php?op=feeds";
185 query_str
= query_str
+ "&tags=1";
188 if (getActiveFeedId()) {
189 query_str
= query_str
+ "&actid=" + getActiveFeedId();
192 if (fetch
) query_str
= query_str
+ "&fetch=yes";
194 var feeds_frame
= document
.getElementById("feeds-frame");
196 feeds_frame
.src
= query_str
;
199 function catchupAllFeeds() {
201 var query_str
= "backend.php?op=feeds&subop=catchupAll";
203 notify("Marking all feeds as read...");
205 var feeds_frame
= document
.getElementById("feeds-frame");
207 feeds_frame
.src
= query_str
;
214 function viewCurrentFeed(skip
, subop
) {
216 if (getActiveFeedId()) {
217 viewfeed(getActiveFeedId(), skip
, subop
);
219 disableContainerChildren("headlinesToolbar", false, document
);
220 viewfeed(-1, skip
, subop
); // FIXME
224 function viewfeed(feed
, skip
, subop
) {
225 var f
= window
.frames
["feeds-frame"];
226 f
.viewfeed(feed
, skip
, subop
);
230 scheduleFeedUpdate(false);
231 setTimeout("timeout()", 900*1000);
234 function resetSearch() {
235 var searchbox
= document
.getElementById("searchbox")
237 if (searchbox
.value
!= "" && getActiveFeedId()) {
238 searchbox
.value
= "";
239 viewfeed(getActiveFeedId(), 0, "");
244 viewCurrentFeed(0, "");
247 function localPiggieFunction(enable
) {
249 var query_str
= "backend.php?op=feeds&subop=piggie";
251 if (xmlhttp_ready(xmlhttp
)) {
253 xmlhttp
.open("GET", query_str
, true);
254 xmlhttp
.onreadystatechange
=feedlist_callback
;
260 function localHotkeyHandler(keycode
) {
262 /* if (keycode == 78) {
263 return moveToPost('next');
267 return moveToPost('prev');
270 if (keycode
== 82) { // r
271 return scheduleFeedUpdate(true);
274 if (keycode
== 85) { // u
275 if (getActiveFeedId()) {
276 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
280 if (keycode
== 65) { // a
281 return toggleDispRead();
284 var f_doc
= window
.frames
["feeds-frame"].document
;
285 var feedlist
= f_doc
.getElementById('feedList');
287 if (keycode
== 74) { // j
288 var feed
= getActiveFeedId();
289 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
290 if (new_feed
) viewfeed(new_feed
, 0, '');
293 if (keycode
== 75) { // k
294 var feed
= getActiveFeedId();
295 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
296 if (new_feed
) viewfeed(new_feed
, 0, '');
299 // notify("KC: " + keycode);
303 // if argument is undefined, current subtitle is not updated
304 // use blank string to clear subtitle
305 function updateTitle(s
) {
306 var tmp
= "Tiny Tiny RSS";
308 if (s
&& s
.length
> 0) {
309 current_subtitle
= s
;
312 if (global_unread
> 0) {
313 tmp
= tmp
+ " (" + global_unread
+ ")";
317 tmp
= tmp
+ " - " + current_subtitle
;
320 if (active_title_text
.length
> 0) {
321 tmp
= tmp
+ " > " + active_title_text
;
324 document
.title
= tmp
;
327 function genericSanityCheck() {
329 if (!xmlhttp
) fatalError(1);
331 setCookie("ttrss_vf_test", "TEST");
333 if (getCookie("ttrss_vf_test") != "TEST") {
344 disableContainerChildren("headlinesToolbar", true);
346 if (!genericSanityCheck())
349 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
350 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
354 exception_error("init", e
);
358 function init_second_stage() {
362 setCookie("ttrss_vf_actfeed", "");
364 updateFeedList(false, false);
365 document
.onkeydown
= hotkey_handler
;
367 var content
= document
.getElementById("content");
369 if (getCookie("ttrss_vf_vmode")) {
370 var viewbox
= document
.getElementById("viewbox");
371 viewbox
.value
= getCookie("ttrss_vf_vmode");
374 if (getCookie("ttrss_vf_limit")) {
375 var limitbox
= document
.getElementById("limitbox");
376 limitbox
.value
= getCookie("ttrss_vf_limit");
379 // if (getCookie("ttrss_vf_actfeed")) {
380 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
383 // setTimeout("timeout()", 2*1000);
384 // scheduleFeedUpdate(true);
387 exception_error("init_second_stage", e
);
391 function quickMenuGo() {
393 var chooser
= document
.getElementById("quickMenuChooser");
394 var opid
= chooser
[chooser
.selectedIndex
].id
;
396 if (opid
== "qmcPrefs") {
400 if (opid
== "qmcAdvSearch") {
401 displayDlg("search");
405 if (opid
== "qmcAddFeed") {
406 displayDlg("quickAddFeed");
410 if (opid
== "qmcRemoveFeed") {
411 var actid
= getActiveFeedId();
414 notify("Please select some feed first.");
418 if (confirm("Remove current feed?")) {
425 if (opid
== "qmcUpdateFeeds") {
426 scheduleFeedUpdate(true);
430 if (opid
== "qmcCatchupAll") {
435 if (opid
== "qmcShowOnlyUnread") {
440 if (opid
== "qmcAddFilter") {
441 displayDlg("quickAddFilter", getActiveFeedId());
448 if (!xmlhttp_ready(xmlhttp
)) {
453 var link
= document
.getElementById("qafInput");
455 if (link
.value
.length
== 0) {
456 notify("Missing feed URL.");
458 notify("Adding feed...");
460 var cat
= document
.getElementById("qafCat");
464 cat_id
= cat
[cat
.selectedIndex
].id
;
469 var feeds_doc
= window
.frames
["feeds-frame"].document
;
471 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
473 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" +
474 param_escape(link
.value
) + "&cid=" + param_escape(cat_id
), true);
475 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
483 function qaddFilter() {
485 if (!xmlhttp_ready(xmlhttp
)) {
490 var regexp
= document
.getElementById("fadd_regexp");
491 var match
= document
.getElementById("fadd_match");
492 var feed
= document
.getElementById("fadd_feed");
493 var action
= document
.getElementById("fadd_action");
495 if (regexp
.value
.length
== 0) {
496 notify("Missing filter expression.");
498 notify("Adding filter...");
500 var v_match
= match
[match
.selectedIndex
].text
;
501 var feed_id
= feed
[feed
.selectedIndex
].id
;
502 var action_id
= action
[action
.selectedIndex
].id
;
504 xmlhttp
.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add®exp=" +
505 param_escape(regexp
.value
) + "&match=" + v_match
+
506 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
508 xmlhttp
.onreadystatechange
=dlg_submit_callback
;
517 function displayDlg(id
, param
) {
521 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
522 param_escape(id
) + "¶m=" + param_escape(param
), true);
523 xmlhttp
.onreadystatechange
=dlg_display_callback
;
529 function closeDlg() {
530 var dlg
= document
.getElementById("userDlgShadow");
531 dlg
.style
.display
= "none";
535 function qfdDelete(feed_id
) {
537 notify("Removing feed...");
539 // var feeds_doc = window.frames["feeds-frame"].document;
540 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
542 _qfd_deleted_feed
= feed_id
;
544 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
);
545 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
550 function allFeedsMenuGo() {
551 var chooser
= document
.getElementById("allFeedsChooser");
553 var opname
= chooser
[chooser
.selectedIndex
].text
;
555 if (opname
== "Update") {
556 scheduleFeedUpdate(true);
560 if (opname
== "Mark as read") {
565 if (opname
== "Show only unread") {
572 function updateFeedTitle(t
) {
573 active_title_text
= t
;
577 function toggleDispRead() {
578 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
580 hide_read_feeds
= !hide_read_feeds
;
582 var feeds_doc
= window
.frames
["feeds-frame"].document
;
584 hideOrShowFeeds(feeds_doc
, hide_read_feeds
);
586 if (hide_read_feeds
) {
587 setCookie("ttrss_vf_hreadf", 1);
589 setCookie("ttrss_vf_hreadf", 0);