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 viewbox
= document
.getElementById("viewbox");
368 var limitbox
= document
.getElementById("limitbox");
370 dropboxSelect(viewbox
, getCookie("ttrss_vf_vmode"));
371 dropboxSelect(limitbox
, getCookie("ttrss_vf_limit"));
374 exception_error("init_second_stage", e
);
378 function quickMenuGo() {
380 var chooser
= document
.getElementById("quickMenuChooser");
381 var opid
= chooser
[chooser
.selectedIndex
].id
;
383 if (opid
== "qmcPrefs") {
387 if (opid
== "qmcAdvSearch") {
388 displayDlg("search");
392 if (opid
== "qmcAddFeed") {
393 displayDlg("quickAddFeed");
397 if (opid
== "qmcRemoveFeed") {
398 var actid
= getActiveFeedId();
401 notify("Please select some feed first.");
405 if (confirm("Remove current feed?")) {
412 if (opid
== "qmcUpdateFeeds") {
413 scheduleFeedUpdate(true);
417 if (opid
== "qmcCatchupAll") {
422 if (opid
== "qmcShowOnlyUnread") {
427 if (opid
== "qmcAddFilter") {
428 displayDlg("quickAddFilter", getActiveFeedId());
435 if (!xmlhttp_ready(xmlhttp
)) {
440 var link
= document
.getElementById("qafInput");
442 if (link
.value
.length
== 0) {
443 notify("Missing feed URL.");
445 notify("Adding feed...");
447 var cat
= document
.getElementById("qafCat");
451 cat_id
= cat
[cat
.selectedIndex
].id
;
456 var feeds_doc
= window
.frames
["feeds-frame"].document
;
458 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
460 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" +
461 param_escape(link
.value
) + "&cid=" + param_escape(cat_id
), true);
462 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
470 function qaddFilter() {
472 if (!xmlhttp_ready(xmlhttp
)) {
477 var regexp
= document
.getElementById("fadd_regexp");
478 var match
= document
.getElementById("fadd_match");
479 var feed
= document
.getElementById("fadd_feed");
480 var action
= document
.getElementById("fadd_action");
482 if (regexp
.value
.length
== 0) {
483 notify("Missing filter expression.");
485 notify("Adding filter...");
487 var v_match
= match
[match
.selectedIndex
].text
;
488 var feed_id
= feed
[feed
.selectedIndex
].id
;
489 var action_id
= action
[action
.selectedIndex
].id
;
491 xmlhttp
.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add®exp=" +
492 param_escape(regexp
.value
) + "&match=" + v_match
+
493 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
495 xmlhttp
.onreadystatechange
=dlg_submit_callback
;
504 function displayDlg(id
, param
) {
508 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
509 param_escape(id
) + "¶m=" + param_escape(param
), true);
510 xmlhttp
.onreadystatechange
=dlg_display_callback
;
516 function closeDlg() {
517 var dlg
= document
.getElementById("userDlgShadow");
518 dlg
.style
.display
= "none";
522 function qfdDelete(feed_id
) {
524 notify("Removing feed...");
526 // var feeds_doc = window.frames["feeds-frame"].document;
527 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
529 _qfd_deleted_feed
= feed_id
;
531 xmlhttp
.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id
);
532 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
537 function allFeedsMenuGo() {
538 var chooser
= document
.getElementById("allFeedsChooser");
540 var opname
= chooser
[chooser
.selectedIndex
].text
;
542 if (opname
== "Update") {
543 scheduleFeedUpdate(true);
547 if (opname
== "Mark as read") {
552 if (opname
== "Show only unread") {
559 function updateFeedTitle(t
) {
560 active_title_text
= t
;
564 function toggleDispRead() {
565 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
567 hide_read_feeds
= !hide_read_feeds
;
569 var feeds_doc
= window
.frames
["feeds-frame"].document
;
571 hideOrShowFeeds(feeds_doc
, hide_read_feeds
);
573 if (hide_read_feeds
) {
574 setCookie("ttrss_vf_hreadf", 1);
576 setCookie("ttrss_vf_hreadf", 0);