6 var display_tags
= false;
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");
58 dlg
.innerHTML
= xmlhttp
.responseText
;
59 dlg
.style
.display
= "block";
63 function refetch_callback() {
64 if (xmlhttp
.readyState
== 4) {
66 // document.title = "Tiny Tiny RSS";
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 /* TODO figure out how to update this from viewfeed.js->view()
99 if (id == "global-unread") {
103 if (feedctr
&& feedu
&& feedr
) {
105 feedu
.innerHTML
= ctr
;
108 feedctr
.className
= "odd";
109 if (!feedr
.className
.match("Unread")) {
110 feedr
.className
= feedr
.className
+ "Unread";
113 feedctr
.className
= "invisible";
114 feedr
.className
= feedr
.className
.replace("Unread", "");
120 notify("All feeds updated.");
125 function backend_sanity_check_callback() {
127 if (xmlhttp
.readyState
== 4) {
129 if (!xmlhttp
.responseXML
) {
134 var reply
= xmlhttp
.responseXML
.firstChild
;
141 var error_code
= reply
.getAttribute("error-code");
143 if (error_code
&& error_code
!= 0) {
144 return fatalError(error_code
);
151 /* wtf this is obsolete
152 function updateFeed(feed_id) {
154 var query_str = "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id;
156 if (xmlhttp_ready(xmlhttp)) {
157 xmlhttp.open("GET", query_str, true);
158 xmlhttp.onreadystatechange=feed_update_callback;
167 function scheduleFeedUpdate(force
) {
169 notify("Updating feeds in background...");
171 // document.title = "Tiny Tiny RSS - Updating...";
173 updateTitle("Updating");
175 var query_str
= "backend.php?op=rpc&subop=";
178 query_str
= query_str
+ "forceUpdateAllFeeds";
180 query_str
= query_str
+ "updateAllFeeds";
191 query_str
= query_str
+ "&omode=" + omode
;
193 if (xmlhttp_ready(xmlhttp
)) {
194 xmlhttp
.open("GET", query_str
, true);
195 xmlhttp
.onreadystatechange
=refetch_callback
;
202 function updateFeedList(silent
, fetch
) {
204 // if (silent != true) {
205 // notify("Loading feed list...");
208 var query_str
= "backend.php?op=feeds";
211 query_str
= query_str
+ "&tags=1";
214 if (getActiveFeedId()) {
215 query_str
= query_str
+ "&actid=" + getActiveFeedId();
218 if (fetch
) query_str
= query_str
+ "&fetch=yes";
220 var feeds_frame
= document
.getElementById("feeds-frame");
222 feeds_frame
.src
= query_str
;
225 function catchupAllFeeds() {
227 var query_str
= "backend.php?op=feeds&subop=catchupAll";
229 notify("Marking all feeds as read...");
231 var feeds_frame
= document
.getElementById("feeds-frame");
233 feeds_frame
.src
= query_str
;
240 function viewCurrentFeed(skip
, subop
) {
242 if (getActiveFeedId()) {
243 viewfeed(getActiveFeedId(), skip
, subop
);
245 disableContainerChildren("headlinesToolbar", false, document
);
246 viewfeed(-1, skip
, subop
); // FIXME
250 function viewfeed(feed
, skip
, subop
) {
251 var f
= window
.frames
["feeds-frame"];
252 f
.viewfeed(feed
, skip
, subop
);
256 scheduleFeedUpdate(false);
257 setTimeout("timeout()", 1800*1000);
260 function resetSearch() {
261 var searchbox
= document
.getElementById("searchbox")
263 if (searchbox
.value
!= "" && getActiveFeedId()) {
264 searchbox
.value
= "";
265 viewfeed(getActiveFeedId(), 0, "");
270 viewCurrentFeed(0, "");
273 function localPiggieFunction(enable
) {
275 var query_str
= "backend.php?op=feeds&subop=piggie";
277 if (xmlhttp_ready(xmlhttp
)) {
279 xmlhttp
.open("GET", query_str
, true);
280 xmlhttp
.onreadystatechange
=feedlist_callback
;
286 function localHotkeyHandler(keycode
) {
288 /* if (keycode == 78) {
289 return moveToPost('next');
293 return moveToPost('prev');
296 if (keycode
== 82) { // r
297 return scheduleFeedUpdate(true);
300 if (keycode
== 85) { // u
301 if (getActiveFeedId()) {
302 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
306 if (keycode
== 65) { // a
307 return toggleDispRead();
310 // notify("KC: " + keycode);
314 function updateTitle(s
) {
315 var tmp
= "Tiny Tiny RSS";
317 if (s
&& s
.length
> 0) {
318 current_subtitle
= s
;
321 if (global_unread
> 0) {
322 tmp
= tmp
+ " (" + global_unread
+ ")";
326 tmp
= tmp
+ " - " + current_subtitle
;
329 if (active_title_text
.length
> 0) {
330 tmp
= tmp
+ " > " + active_title_text
;
333 document
.title
= tmp
;
336 function genericSanityCheck() {
338 if (!xmlhttp
) fatalError(1);
340 setCookie("ttrss_vf_test", "TEST");
342 if (getCookie("ttrss_vf_test") != "TEST") {
347 document.getElementById("headlines").innerHTML =
348 "<b>Fatal error:</b> This program requires XmlHttpRequest " +
349 "to function properly. Your browser doesn't seem to support it.";
353 setCookie("ttrss_vf_test", "TEST");
354 if (getCookie("ttrss_vf_test") != "TEST") {
356 document.getElementById("headlines").innerHTML =
357 "<b>Fatal error:</b> This program requires cookies " +
358 "to function properly. Your browser doesn't seem to support them.";
368 disableContainerChildren("headlinesToolbar", true);
370 if (!genericSanityCheck())
373 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
374 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
379 function init_second_stage() {
381 setCookie("ttrss_vf_actfeed", "");
383 updateFeedList(false, false);
384 document
.onkeydown
= hotkey_handler
;
386 var content
= document
.getElementById("content");
388 if (getCookie("ttrss_vf_vmode")) {
389 var viewbox
= document
.getElementById("viewbox");
390 viewbox
.value
= getCookie("ttrss_vf_vmode");
393 if (getCookie("ttrss_vf_limit")) {
394 var limitbox
= document
.getElementById("limitbox");
395 limitbox
.value
= getCookie("ttrss_vf_limit");
398 // if (getCookie("ttrss_vf_actfeed")) {
399 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
402 // setTimeout("timeout()", 2*1000);
403 // scheduleFeedUpdate(true);
405 var splash
= document
.getElementById("splash");
408 splash
.style
.display
= "none";
413 function quickMenuGo() {
415 var chooser
= document
.getElementById("quickMenuChooser");
416 var opid
= chooser
[chooser
.selectedIndex
].id
;
418 if (opid
== "qmcPrefs") {
422 if (opid
== "qmcAdvSearch") {
423 displayDlg("search");
427 if (opid
== "qmcAddFeed") {
428 displayDlg("quickAddFeed");
432 if (opid
== "qmcRemoveFeed") {
433 var actid
= getActiveFeedId();
436 notify("Please select some feed first.");
440 displayDlg("quickDelFeed", actid
);
444 if (opid
== "qmcUpdateFeeds") {
445 scheduleFeedUpdate(true);
449 if (opid
== "qmcCatchupAll") {
454 if (opid
== "qmcShowOnlyUnread") {
463 if (!xmlhttp_ready(xmlhttp
)) {
468 var link
= document
.getElementById("qafInput");
470 if (link
.value
.length
== 0) {
471 notify("Missing feed URL.");
473 notify("Adding feed...");
475 var feeds_doc
= window
.frames
["feeds-frame"].document
;
477 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
479 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
480 param_escape(link
.value
), true);
481 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
489 function displayDlg(id
, param
) {
493 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
494 param_escape(id
) + "¶m=" + param_escape(param
), true);
495 xmlhttp
.onreadystatechange
=dialog_refresh_callback
;
500 function closeDlg() {
501 var dlg
= document
.getElementById("userDlg");
502 dlg
.style
.display
= "none";
505 function qfdDelete(feed_id
) {
507 notify("Removing feed...");
509 var feeds_doc
= window
.frames
["feeds-frame"].document
;
510 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
512 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids=" + feed_id
);
513 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
518 function allFeedsMenuGo() {
519 var chooser
= document
.getElementById("allFeedsChooser");
521 var opname
= chooser
[chooser
.selectedIndex
].text
;
523 if (opname
== "Update") {
524 scheduleFeedUpdate(true);
528 if (opname
== "Mark as read") {
533 if (opname
== "Show only unread") {
540 function updateFeedTitle(t
) {
541 active_title_text
= t
;
545 function toggleDispRead() {
546 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
548 hide_read_feeds
= !hide_read_feeds
;
550 var feeds_doc
= window
.frames
["feeds-frame"].document
;
552 hideOrShowFeeds(feeds_doc
, hide_read_feeds
);
554 if (hide_read_feeds
) {
555 setCookie("ttrss_vf_hreadf", 1);
557 setCookie("ttrss_vf_hreadf", 0);