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 updateFeedList(false, false);
54 function dialog_refresh_callback() {
55 if (xmlhttp
.readyState
== 4) {
56 var dlg
= document
.getElementById("userDlg");
57 var dlg_s
= document
.getElementById("userDlgShadow");
59 dlg
.innerHTML
= xmlhttp
.responseText
;
60 dlg_s
.style
.display
= "block";
64 function refetch_callback() {
65 if (xmlhttp
.readyState
== 4) {
68 if (!xmlhttp
.responseXML
) {
69 notify("refetch_callback: backend did not return valid XML");
73 var reply
= xmlhttp
.responseXML
.firstChild
;
76 notify("refetch_callback: backend did not return expected XML object");
80 var error_code
= reply
.getAttribute("error-code");
82 if (error_code
&& error_code
!= 0) {
83 return fatalError(error_code
);
86 var f_document
= window
.frames
["feeds-frame"].document
;
88 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
89 var id
= reply
.childNodes
[l
].getAttribute("id");
90 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
92 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
93 var feedu
= f_document
.getElementById("FEEDU-" + id
);
94 var feedr
= f_document
.getElementById("FEEDR-" + id
);
96 if (id
== "global-unread") {
101 if (feedctr
&& feedu
&& feedr
) {
103 feedu
.innerHTML
= ctr
;
106 feedctr
.className
= "odd";
107 if (!feedr
.className
.match("Unread")) {
108 feedr
.className
= feedr
.className
+ "Unread";
111 feedctr
.className
= "invisible";
112 feedr
.className
= feedr
.className
.replace("Unread", "");
118 notify("All feeds updated.");
120 exception_error("refetch_callback", e
);
125 function backend_sanity_check_callback() {
127 if (xmlhttp
.readyState
== 4) {
131 if (!xmlhttp
.responseXML
) {
136 var reply
= xmlhttp
.responseXML
.firstChild
;
143 var error_code
= reply
.getAttribute("error-code");
145 if (error_code
&& error_code
!= 0) {
146 return fatalError(error_code
);
152 exception_error("backend_sanity_check_callback", e
);
157 function scheduleFeedUpdate(force
) {
159 notify("Updating feeds in background...");
161 // document.title = "Tiny Tiny RSS - Updating...";
163 updateTitle("Updating");
165 var query_str
= "backend.php?op=rpc&subop=";
168 query_str
= query_str
+ "forceUpdateAllFeeds";
170 query_str
= query_str
+ "updateAllFeeds";
181 query_str
= query_str
+ "&omode=" + omode
;
183 if (xmlhttp_ready(xmlhttp
)) {
184 xmlhttp
.open("GET", query_str
, true);
185 xmlhttp
.onreadystatechange
=refetch_callback
;
192 function updateFeedList(silent
, fetch
) {
194 // if (silent != true) {
195 // notify("Loading feed list...");
198 var query_str
= "backend.php?op=feeds";
201 query_str
= query_str
+ "&tags=1";
204 if (getActiveFeedId()) {
205 query_str
= query_str
+ "&actid=" + getActiveFeedId();
208 if (fetch
) query_str
= query_str
+ "&fetch=yes";
210 var feeds_frame
= document
.getElementById("feeds-frame");
212 feeds_frame
.src
= query_str
;
215 function catchupAllFeeds() {
217 var query_str
= "backend.php?op=feeds&subop=catchupAll";
219 notify("Marking all feeds as read...");
221 var feeds_frame
= document
.getElementById("feeds-frame");
223 feeds_frame
.src
= query_str
;
230 function viewCurrentFeed(skip
, subop
) {
232 if (getActiveFeedId()) {
233 viewfeed(getActiveFeedId(), skip
, subop
);
235 disableContainerChildren("headlinesToolbar", false, document
);
236 viewfeed(-1, skip
, subop
); // FIXME
240 function viewfeed(feed
, skip
, subop
) {
241 var f
= window
.frames
["feeds-frame"];
242 f
.viewfeed(feed
, skip
, subop
);
246 scheduleFeedUpdate(false);
247 setTimeout("timeout()", 1800*1000);
250 function resetSearch() {
251 var searchbox
= document
.getElementById("searchbox")
253 if (searchbox
.value
!= "" && getActiveFeedId()) {
254 searchbox
.value
= "";
255 viewfeed(getActiveFeedId(), 0, "");
260 viewCurrentFeed(0, "");
263 function localPiggieFunction(enable
) {
265 var query_str
= "backend.php?op=feeds&subop=piggie";
267 if (xmlhttp_ready(xmlhttp
)) {
269 xmlhttp
.open("GET", query_str
, true);
270 xmlhttp
.onreadystatechange
=feedlist_callback
;
276 function localHotkeyHandler(keycode
) {
278 /* if (keycode == 78) {
279 return moveToPost('next');
283 return moveToPost('prev');
286 if (keycode
== 82) { // r
287 return scheduleFeedUpdate(true);
290 if (keycode
== 85) { // u
291 if (getActiveFeedId()) {
292 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
296 if (keycode
== 65) { // a
297 return toggleDispRead();
300 var f_doc
= window
.frames
["feeds-frame"].document
;
301 var feedlist
= f_doc
.getElementById('feedList');
303 if (keycode
== 74) { // j
304 var feed
= getActiveFeedId();
305 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
306 if (new_feed
) viewfeed(new_feed
, 0, '');
309 if (keycode
== 75) { // k
310 var feed
= getActiveFeedId();
311 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
312 if (new_feed
) viewfeed(new_feed
, 0, '');
315 // notify("KC: " + keycode);
319 // if argument is undefined, current subtitle is not updated
320 // use blank string to clear subtitle
321 function updateTitle(s
) {
322 var tmp
= "Tiny Tiny RSS";
324 if (s
&& s
.length
> 0) {
325 current_subtitle
= s
;
328 if (global_unread
> 0) {
329 tmp
= tmp
+ " (" + global_unread
+ ")";
333 tmp
= tmp
+ " - " + current_subtitle
;
336 if (active_title_text
.length
> 0) {
337 tmp
= tmp
+ " > " + active_title_text
;
340 document
.title
= tmp
;
343 function genericSanityCheck() {
345 if (!xmlhttp
) fatalError(1);
347 setCookie("ttrss_vf_test", "TEST");
349 if (getCookie("ttrss_vf_test") != "TEST") {
360 disableContainerChildren("headlinesToolbar", true);
362 if (!genericSanityCheck())
365 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
366 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
370 exception_error("init", e
);
374 function init_second_stage() {
378 setCookie("ttrss_vf_actfeed", "");
380 updateFeedList(false, false);
381 document
.onkeydown
= hotkey_handler
;
383 var content
= document
.getElementById("content");
385 if (getCookie("ttrss_vf_vmode")) {
386 var viewbox
= document
.getElementById("viewbox");
387 viewbox
.value
= getCookie("ttrss_vf_vmode");
390 if (getCookie("ttrss_vf_limit")) {
391 var limitbox
= document
.getElementById("limitbox");
392 limitbox
.value
= getCookie("ttrss_vf_limit");
395 // if (getCookie("ttrss_vf_actfeed")) {
396 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
399 // setTimeout("timeout()", 2*1000);
400 // scheduleFeedUpdate(true);
403 exception_error("init_second_stage", e
);
407 function quickMenuGo() {
409 var chooser
= document
.getElementById("quickMenuChooser");
410 var opid
= chooser
[chooser
.selectedIndex
].id
;
412 if (opid
== "qmcPrefs") {
416 if (opid
== "qmcAdvSearch") {
417 displayDlg("search");
421 if (opid
== "qmcAddFeed") {
422 displayDlg("quickAddFeed");
426 if (opid
== "qmcRemoveFeed") {
427 var actid
= getActiveFeedId();
430 notify("Please select some feed first.");
434 displayDlg("quickDelFeed", actid
);
438 if (opid
== "qmcUpdateFeeds") {
439 scheduleFeedUpdate(true);
443 if (opid
== "qmcCatchupAll") {
448 if (opid
== "qmcShowOnlyUnread") {
457 if (!xmlhttp_ready(xmlhttp
)) {
462 var link
= document
.getElementById("qafInput");
464 if (link
.value
.length
== 0) {
465 notify("Missing feed URL.");
467 notify("Adding feed...");
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&subop=add&link=" +
474 param_escape(link
.value
), true);
475 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
483 function displayDlg(id
, param
) {
487 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
488 param_escape(id
) + "¶m=" + param_escape(param
), true);
489 xmlhttp
.onreadystatechange
=dialog_refresh_callback
;
494 function closeDlg() {
495 var dlg
= document
.getElementById("userDlgShadow");
496 dlg
.style
.display
= "none";
499 function qfdDelete(feed_id
) {
501 notify("Removing feed...");
503 var feeds_doc
= window
.frames
["feeds-frame"].document
;
504 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
506 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids=" + feed_id
);
507 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
512 function allFeedsMenuGo() {
513 var chooser
= document
.getElementById("allFeedsChooser");
515 var opname
= chooser
[chooser
.selectedIndex
].text
;
517 if (opname
== "Update") {
518 scheduleFeedUpdate(true);
522 if (opname
== "Mark as read") {
527 if (opname
== "Show only unread") {
534 function updateFeedTitle(t
) {
535 active_title_text
= t
;
539 function toggleDispRead() {
540 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
542 hide_read_feeds
= !hide_read_feeds
;
544 var feeds_doc
= window
.frames
["feeds-frame"].document
;
546 hideOrShowFeeds(feeds_doc
, hide_read_feeds
);
548 if (hide_read_feeds
) {
549 setCookie("ttrss_vf_hreadf", 1);
551 setCookie("ttrss_vf_hreadf", 0);