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 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, please wait.");
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, "");
245 viewCurrentFeed(0, "");
248 function localPiggieFunction(enable
) {
250 var query_str
= "backend.php?op=feeds&subop=piggie";
252 if (xmlhttp_ready(xmlhttp
)) {
254 xmlhttp
.open("GET", query_str
, true);
255 xmlhttp
.onreadystatechange
=feedlist_callback
;
261 function localHotkeyHandler(keycode
) {
263 /* if (keycode == 78) {
264 return moveToPost('next');
268 return moveToPost('prev');
271 if (keycode
== 82) { // r
272 return scheduleFeedUpdate(true);
275 if (keycode
== 85) { // u
276 if (getActiveFeedId()) {
277 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
281 if (keycode
== 65) { // a
282 return toggleDispRead();
285 var f_doc
= window
.frames
["feeds-frame"].document
;
286 var feedlist
= f_doc
.getElementById('feedList');
288 if (keycode
== 74) { // j
289 var feed
= getActiveFeedId();
290 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
291 if (new_feed
) viewfeed(new_feed
, 0, '');
294 if (keycode
== 75) { // k
295 var feed
= getActiveFeedId();
296 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
297 if (new_feed
) viewfeed(new_feed
, 0, '');
300 // notify("KC: " + keycode);
304 // if argument is undefined, current subtitle is not updated
305 // use blank string to clear subtitle
306 function updateTitle(s
) {
307 var tmp
= "Tiny Tiny RSS";
309 if (s
&& s
.length
> 0) {
310 current_subtitle
= s
;
313 if (global_unread
> 0) {
314 tmp
= tmp
+ " (" + global_unread
+ ")";
318 tmp
= tmp
+ " - " + current_subtitle
;
321 if (active_title_text
.length
> 0) {
322 tmp
= tmp
+ " > " + active_title_text
;
325 document
.title
= tmp
;
328 function genericSanityCheck() {
330 if (!xmlhttp
) fatalError(1);
332 setCookie("ttrss_vf_test", "TEST");
334 if (getCookie("ttrss_vf_test") != "TEST") {
345 disableContainerChildren("headlinesToolbar", true);
347 if (!genericSanityCheck())
350 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
351 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
355 exception_error("init", e
);
359 function init_second_stage() {
363 setCookie("ttrss_vf_actfeed", "");
365 updateFeedList(false, false);
366 document
.onkeydown
= hotkey_handler
;
368 var viewbox
= document
.getElementById("viewbox");
369 var limitbox
= document
.getElementById("limitbox");
371 dropboxSelect(viewbox
, getCookie("ttrss_vf_vmode"));
372 dropboxSelect(limitbox
, getCookie("ttrss_vf_limit"));
375 exception_error("init_second_stage", e
);
379 function quickMenuGo() {
381 var chooser
= document
.getElementById("quickMenuChooser");
382 var opid
= chooser
[chooser
.selectedIndex
].id
;
384 if (opid
== "qmcPrefs") {
388 if (opid
== "qmcSearch") {
389 displayDlg("search");
393 if (opid
== "qmcAddFeed") {
394 displayDlg("quickAddFeed");
398 if (opid
== "qmcRemoveFeed") {
399 var actid
= getActiveFeedId();
402 notify("Please select some feed first.");
406 if (confirm("Remove current feed?")) {
413 if (opid
== "qmcUpdateFeeds") {
414 scheduleFeedUpdate(true);
418 if (opid
== "qmcCatchupAll") {
423 if (opid
== "qmcShowOnlyUnread") {
428 if (opid
== "qmcAddFilter") {
429 displayDlg("quickAddFilter", getActiveFeedId());
436 if (!xmlhttp_ready(xmlhttp
)) {
441 var link
= document
.getElementById("qafInput");
443 if (link
.value
.length
== 0) {
444 notify("Missing feed URL.");
446 notify("Adding feed...");
448 var cat
= document
.getElementById("qafCat");
452 cat_id
= cat
[cat
.selectedIndex
].id
;
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
) + "&cid=" + param_escape(cat_id
), 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 _qfd_deleted_feed
= feed_id
;
532 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
);
533 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
538 function allFeedsMenuGo() {
539 var chooser
= document
.getElementById("allFeedsChooser");
541 var opname
= chooser
[chooser
.selectedIndex
].text
;
543 if (opname
== "Update") {
544 scheduleFeedUpdate(true);
548 if (opname
== "Mark as read") {
553 if (opname
== "Show only unread") {
560 function updateFeedTitle(t
) {
561 active_title_text
= t
;
565 function toggleDispRead() {
566 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
568 hide_read_feeds
= !hide_read_feeds
;
570 var feeds_doc
= window
.frames
["feeds-frame"].document
;
572 hideOrShowFeeds(feeds_doc
, hide_read_feeds
);
574 if (hide_read_feeds
) {
575 setCookie("ttrss_vf_hreadf", 1);
577 setCookie("ttrss_vf_hreadf", 0);