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");
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 /* 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.");
122 exception_error("refetch_callback", e
);
127 function backend_sanity_check_callback() {
129 if (xmlhttp
.readyState
== 4) {
133 if (!xmlhttp
.responseXML
) {
138 var reply
= xmlhttp
.responseXML
.firstChild
;
145 var error_code
= reply
.getAttribute("error-code");
147 if (error_code
&& error_code
!= 0) {
148 return fatalError(error_code
);
154 exception_error("backend_sanity_check_callback", e
);
159 function scheduleFeedUpdate(force
) {
161 notify("Updating feeds in background...");
163 // document.title = "Tiny Tiny RSS - Updating...";
165 updateTitle("Updating");
167 var query_str
= "backend.php?op=rpc&subop=";
170 query_str
= query_str
+ "forceUpdateAllFeeds";
172 query_str
= query_str
+ "updateAllFeeds";
183 query_str
= query_str
+ "&omode=" + omode
;
185 if (xmlhttp_ready(xmlhttp
)) {
186 xmlhttp
.open("GET", query_str
, true);
187 xmlhttp
.onreadystatechange
=refetch_callback
;
194 function updateFeedList(silent
, fetch
) {
196 // if (silent != true) {
197 // notify("Loading feed list...");
200 var query_str
= "backend.php?op=feeds";
203 query_str
= query_str
+ "&tags=1";
206 if (getActiveFeedId()) {
207 query_str
= query_str
+ "&actid=" + getActiveFeedId();
210 if (fetch
) query_str
= query_str
+ "&fetch=yes";
212 var feeds_frame
= document
.getElementById("feeds-frame");
214 feeds_frame
.src
= query_str
;
217 function catchupAllFeeds() {
219 var query_str
= "backend.php?op=feeds&subop=catchupAll";
221 notify("Marking all feeds as read...");
223 var feeds_frame
= document
.getElementById("feeds-frame");
225 feeds_frame
.src
= query_str
;
232 function viewCurrentFeed(skip
, subop
) {
234 if (getActiveFeedId()) {
235 viewfeed(getActiveFeedId(), skip
, subop
);
237 disableContainerChildren("headlinesToolbar", false, document
);
238 viewfeed(-1, skip
, subop
); // FIXME
242 function viewfeed(feed
, skip
, subop
) {
243 var f
= window
.frames
["feeds-frame"];
244 f
.viewfeed(feed
, skip
, subop
);
248 scheduleFeedUpdate(false);
249 setTimeout("timeout()", 1800*1000);
252 function resetSearch() {
253 var searchbox
= document
.getElementById("searchbox")
255 if (searchbox
.value
!= "" && getActiveFeedId()) {
256 searchbox
.value
= "";
257 viewfeed(getActiveFeedId(), 0, "");
262 viewCurrentFeed(0, "");
265 function localPiggieFunction(enable
) {
267 var query_str
= "backend.php?op=feeds&subop=piggie";
269 if (xmlhttp_ready(xmlhttp
)) {
271 xmlhttp
.open("GET", query_str
, true);
272 xmlhttp
.onreadystatechange
=feedlist_callback
;
278 function localHotkeyHandler(keycode
) {
280 /* if (keycode == 78) {
281 return moveToPost('next');
285 return moveToPost('prev');
288 if (keycode
== 82) { // r
289 return scheduleFeedUpdate(true);
292 if (keycode
== 85) { // u
293 if (getActiveFeedId()) {
294 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
298 if (keycode
== 65) { // a
299 return toggleDispRead();
302 // notify("KC: " + keycode);
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 content
= document
.getElementById("content");
370 if (getCookie("ttrss_vf_vmode")) {
371 var viewbox
= document
.getElementById("viewbox");
372 viewbox
.value
= getCookie("ttrss_vf_vmode");
375 if (getCookie("ttrss_vf_limit")) {
376 var limitbox
= document
.getElementById("limitbox");
377 limitbox
.value
= getCookie("ttrss_vf_limit");
380 // if (getCookie("ttrss_vf_actfeed")) {
381 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
384 // setTimeout("timeout()", 2*1000);
385 // scheduleFeedUpdate(true);
388 exception_error("init_second_stage", e
);
392 function quickMenuGo() {
394 var chooser
= document
.getElementById("quickMenuChooser");
395 var opid
= chooser
[chooser
.selectedIndex
].id
;
397 if (opid
== "qmcPrefs") {
401 if (opid
== "qmcAdvSearch") {
402 displayDlg("search");
406 if (opid
== "qmcAddFeed") {
407 displayDlg("quickAddFeed");
411 if (opid
== "qmcRemoveFeed") {
412 var actid
= getActiveFeedId();
415 notify("Please select some feed first.");
419 displayDlg("quickDelFeed", actid
);
423 if (opid
== "qmcUpdateFeeds") {
424 scheduleFeedUpdate(true);
428 if (opid
== "qmcCatchupAll") {
433 if (opid
== "qmcShowOnlyUnread") {
442 if (!xmlhttp_ready(xmlhttp
)) {
447 var link
= document
.getElementById("qafInput");
449 if (link
.value
.length
== 0) {
450 notify("Missing feed URL.");
452 notify("Adding feed...");
454 var feeds_doc
= window
.frames
["feeds-frame"].document
;
456 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
458 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
459 param_escape(link
.value
), true);
460 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
468 function displayDlg(id
, param
) {
472 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
473 param_escape(id
) + "¶m=" + param_escape(param
), true);
474 xmlhttp
.onreadystatechange
=dialog_refresh_callback
;
479 function closeDlg() {
480 var dlg
= document
.getElementById("userDlgShadow");
481 dlg
.style
.display
= "none";
484 function qfdDelete(feed_id
) {
486 notify("Removing feed...");
488 var feeds_doc
= window
.frames
["feeds-frame"].document
;
489 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
491 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids=" + feed_id
);
492 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
497 function allFeedsMenuGo() {
498 var chooser
= document
.getElementById("allFeedsChooser");
500 var opname
= chooser
[chooser
.selectedIndex
].text
;
502 if (opname
== "Update") {
503 scheduleFeedUpdate(true);
507 if (opname
== "Mark as read") {
512 if (opname
== "Show only unread") {
519 function updateFeedTitle(t
) {
520 active_title_text
= t
;
524 function toggleDispRead() {
525 var hide_read_feeds
= (getCookie("ttrss_vf_hreadf") == 1);
527 hide_read_feeds
= !hide_read_feeds
;
529 var feeds_doc
= window
.frames
["feeds-frame"].document
;
531 hideOrShowFeeds(feeds_doc
, hide_read_feeds
);
533 if (hide_read_feeds
) {
534 setCookie("ttrss_vf_hreadf", 1);
536 setCookie("ttrss_vf_hreadf", 0);