]>
Commit | Line | Data |
---|---|---|
1cd17194 | 1 | var xmlhttp = false; |
76798ff3 | 2 | var total_unread = 0; |
525116d4 | 3 | var first_run = true; |
8143ae1f | 4 | var display_tags = false; |
806a3d14 | 5 | var global_unread = -1; |
21703604 | 6 | var active_title_text = ""; |
21703604 | 7 | var current_subtitle = ""; |
c6784aea | 8 | var daemon_enabled = false; |
0d51e25d | 9 | var daemon_refresh_only = false; |
15da5cc1 | 10 | var _qfd_deleted_feed = 0; |
2bf6e0a8 | 11 | var firsttime_update = true; |
c441662f | 12 | var last_refetch = 0; |
76b4eae1 | 13 | var cookie_lifetime = 0; |
33d13e72 | 14 | var active_feed_id = 0; |
0a6c4846 | 15 | var active_feed_is_cat = false; |
9e397d0f | 16 | var number_of_feeds = 0; |
15da5cc1 | 17 | |
a58069db | 18 | var xmlhttp = Ajax.getTransport(); |
abbe0154 | 19 | var xmlhttp_ctr = Ajax.getTransport(); |
1cd17194 | 20 | |
1035fcec | 21 | var init_params = new Object(); |
3ac2b520 | 22 | |
8143ae1f AD |
23 | function toggleTags() { |
24 | display_tags = !display_tags; | |
25 | ||
26 | var p = document.getElementById("dispSwitchPrompt"); | |
27 | ||
28 | if (display_tags) { | |
29 | p.innerHTML = "display feeds"; | |
30 | } else { | |
31 | p.innerHTML = "display tags"; | |
32 | } | |
33 | ||
807f452a AD |
34 | notify("Loading, please wait..."); |
35 | ||
8143ae1f AD |
36 | updateFeedList(); |
37 | } | |
38 | ||
6de5d056 | 39 | function dlg_frefresh_callback() { |
abbe0154 | 40 | if (xmlhttp.readyState == 4) { |
a58d997c | 41 | // notify(xmlhttp.responseText); |
abbe0154 AD |
42 | |
43 | if (getActiveFeedId() == _qfd_deleted_feed) { | |
44 | var h = document.getElementById("headlines-frame"); | |
45 | if (h) { | |
46 | h.innerHTML = "<div class='whiteBox'>No feed selected.</div>"; | |
47 | } | |
48 | } | |
49 | ||
0e9dd1ba | 50 | setTimeout('updateFeedList(false, false)', 50); |
eff4997c | 51 | closeInfoBox(); |
c0e5a40e | 52 | } |
1cd17194 | 53 | } |
e2f8f7b4 | 54 | |
8158c57a | 55 | function refetch_callback() { |
abbe0154 | 56 | if (xmlhttp_ctr.readyState == 4) { |
7719618b | 57 | try { |
310da49d | 58 | |
c441662f AD |
59 | var date = new Date(); |
60 | ||
61 | last_refetch = date.getTime() / 1000; | |
62 | ||
abbe0154 | 63 | if (!xmlhttp_ctr.responseXML) { |
0530ddd8 | 64 | notify("refetch_callback: backend did not return valid XML", true, true); |
7719618b AD |
65 | return; |
66 | } | |
67 | ||
abbe0154 | 68 | var reply = xmlhttp_ctr.responseXML.firstChild; |
262bd8ea | 69 | |
7719618b | 70 | if (!reply) { |
0530ddd8 | 71 | notify("refetch_callback: backend did not return expected XML object", true, true); |
e2cb4c6d | 72 | updateTitle(""); |
7719618b AD |
73 | return; |
74 | } | |
262bd8ea | 75 | |
4724a093 AD |
76 | var error_code = false; |
77 | var error_msg = false; | |
78 | ||
79 | if (reply.firstChild) { | |
80 | error_code = reply.firstChild.getAttribute("error-code"); | |
81 | error_msg = reply.firstChild.getAttribute("error-msg"); | |
82 | } | |
83 | ||
84 | if (!error_code) { | |
85 | error_code = reply.getAttribute("error-code"); | |
86 | error_msg = reply.getAttribute("error-msg"); | |
87 | } | |
88 | ||
7719618b | 89 | if (error_code && error_code != 0) { |
4724a093 AD |
90 | debug("refetch_callback: got error code " + error_code); |
91 | return fatalError(error_code, error_msg); | |
7719618b | 92 | } |
f54f515f AD |
93 | |
94 | var counters = reply.firstChild; | |
7719618b | 95 | |
f54f515f | 96 | parse_counters(counters, true); |
c6784aea | 97 | |
71ad883b AD |
98 | var runtime_info = counters.nextSibling; |
99 | ||
100 | parse_runtime_info(runtime_info); | |
101 | ||
0ee1d1a0 AD |
102 | debug("refetch_callback: done"); |
103 | ||
0d51e25d | 104 | if (!daemon_enabled && !daemon_refresh_only) { |
c6784aea | 105 | notify("All feeds updated."); |
5a180505 | 106 | updateTitle(""); |
4c059b7b AD |
107 | } else { |
108 | notify(""); | |
c6784aea | 109 | } |
7719618b AD |
110 | } catch (e) { |
111 | exception_error("refetch_callback", e); | |
e2cb4c6d | 112 | updateTitle(""); |
7719618b | 113 | } |
090e250b AD |
114 | } |
115 | } | |
1a66d16e | 116 | |
295f9b42 AD |
117 | function backend_sanity_check_callback() { |
118 | ||
119 | if (xmlhttp.readyState == 4) { | |
295f9b42 | 120 | |
7719618b AD |
121 | try { |
122 | ||
123 | if (!xmlhttp.responseXML) { | |
462a192b | 124 | fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText); |
7719618b AD |
125 | return; |
126 | } | |
295f9b42 | 127 | |
3ac2b520 | 128 | var reply = xmlhttp.responseXML.firstChild.firstChild; |
7719618b AD |
129 | |
130 | if (!reply) { | |
af106b0e | 131 | fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText); |
7719618b AD |
132 | return; |
133 | } | |
134 | ||
135 | var error_code = reply.getAttribute("error-code"); | |
136 | ||
137 | if (error_code && error_code != 0) { | |
af106b0e | 138 | return fatalError(error_code, reply.getAttribute("error-msg")); |
7719618b AD |
139 | } |
140 | ||
0ee1d1a0 AD |
141 | debug("sanity check ok"); |
142 | ||
3ac2b520 AD |
143 | var params = reply.nextSibling; |
144 | ||
145 | if (params) { | |
146 | debug('reading init-params...'); | |
147 | var param = params.firstChild; | |
148 | ||
149 | while (param) { | |
150 | var k = param.getAttribute("key"); | |
151 | var v = param.getAttribute("value"); | |
152 | debug(k + " => " + v); | |
153 | init_params[k] = v; | |
154 | param = param.nextSibling; | |
155 | } | |
156 | } | |
157 | ||
7719618b | 158 | init_second_stage(); |
295f9b42 | 159 | |
7719618b AD |
160 | } catch (e) { |
161 | exception_error("backend_sanity_check_callback", e); | |
162 | } | |
295f9b42 AD |
163 | } |
164 | } | |
165 | ||
cb246176 | 166 | function scheduleFeedUpdate(force) { |
525116d4 | 167 | |
0d51e25d | 168 | if (!daemon_enabled && !daemon_refresh_only) { |
4d4200a8 | 169 | notify("Updating feeds, please wait.", true); |
c6784aea AD |
170 | updateTitle("Updating"); |
171 | } | |
55193822 | 172 | |
cb246176 AD |
173 | var query_str = "backend.php?op=rpc&subop="; |
174 | ||
175 | if (force) { | |
c3b81db0 | 176 | query_str = query_str + "forceUpdateAllFeeds"; |
cb246176 | 177 | } else { |
c3b81db0 | 178 | query_str = query_str + "updateAllFeeds"; |
cb246176 | 179 | } |
525116d4 | 180 | |
9826bd2e AD |
181 | var omode; |
182 | ||
b6104dee | 183 | if (firsttime_update && !navigator.userAgent.match("Opera")) { |
2bf6e0a8 AD |
184 | firsttime_update = false; |
185 | omode = "T"; | |
9826bd2e | 186 | } else { |
2bf6e0a8 AD |
187 | if (display_tags) { |
188 | omode = "t"; | |
189 | } else { | |
190 | omode = "flc"; | |
191 | } | |
9826bd2e | 192 | } |
2bf6e0a8 | 193 | |
9826bd2e | 194 | query_str = query_str + "&omode=" + omode; |
78ea1de0 | 195 | query_str = query_str + "&uctr=" + global_unread; |
9826bd2e | 196 | |
0ee1d1a0 | 197 | debug("in scheduleFeedUpdate"); |
2bf6e0a8 | 198 | |
c441662f AD |
199 | var date = new Date(); |
200 | ||
abbe0154 | 201 | if (!xmlhttp_ready(xmlhttp_ctr) && last_refetch < date.getTime() / 1000 - 60) { |
a7565293 | 202 | debug("<b>xmlhttp seems to be stuck, aborting</b>"); |
abbe0154 | 203 | xmlhttp_ctr.abort(); |
c441662f AD |
204 | } |
205 | ||
52db9978 AD |
206 | debug("REFETCH query: " + query_str); |
207 | ||
abbe0154 AD |
208 | if (xmlhttp_ready(xmlhttp_ctr)) { |
209 | xmlhttp_ctr.open("GET", query_str, true); | |
210 | xmlhttp_ctr.onreadystatechange=refetch_callback; | |
211 | xmlhttp_ctr.send(null); | |
525116d4 | 212 | } else { |
abbe0154 | 213 | debug("xmlhttp_ctr busy"); |
bed0f18f | 214 | //printLockingError(); |
c0e5a40e | 215 | } |
525116d4 | 216 | } |
1cd17194 | 217 | |
525116d4 | 218 | function updateFeedList(silent, fetch) { |
c0e5a40e | 219 | |
1a66d16e AD |
220 | // if (silent != true) { |
221 | // notify("Loading feed list..."); | |
222 | // } | |
82baad4a | 223 | |
331900c6 AD |
224 | var query_str = "backend.php?op=feeds"; |
225 | ||
8143ae1f AD |
226 | if (display_tags) { |
227 | query_str = query_str + "&tags=1"; | |
228 | } | |
229 | ||
5c365f60 | 230 | if (getActiveFeedId() && !activeFeedIsCat()) { |
86741347 | 231 | query_str = query_str + "&actid=" + getActiveFeedId(); |
175847de AD |
232 | } |
233 | ||
59b8192f AD |
234 | if (navigator.userAgent.match("Opera")) { |
235 | var date = new Date(); | |
236 | var timestamp = Math.round(date.getTime() / 1000); | |
237 | query_str = query_str + "&ts=" + timestamp | |
238 | } | |
239 | ||
1a66d16e | 240 | if (fetch) query_str = query_str + "&fetch=yes"; |
e1123aee | 241 | |
6b4163cb AD |
242 | // var feeds_frame = document.getElementById("feeds-frame"); |
243 | // feeds_frame.src = query_str; | |
244 | ||
0e9dd1ba | 245 | debug("updateFeedList Q=" + query_str); |
6b4163cb AD |
246 | |
247 | if (xmlhttp_ready(xmlhttp)) { | |
248 | xmlhttp.open("GET", query_str, true); | |
249 | xmlhttp.onreadystatechange=feedlist_callback; | |
250 | xmlhttp.send(null); | |
251 | } else { | |
252 | debug("xmlhttp busy"); | |
253 | //printLockingError(); | |
254 | } | |
e1123aee | 255 | |
1a66d16e | 256 | } |
175847de | 257 | |
476cac42 | 258 | function catchupAllFeeds() { |
076682aa | 259 | |
476cac42 AD |
260 | var query_str = "backend.php?op=feeds&subop=catchupAll"; |
261 | ||
262 | notify("Marking all feeds as read..."); | |
263 | ||
ca2f46a7 | 264 | debug("catchupAllFeeds Q=" + query_str); |
1a66d16e | 265 | |
ca2f46a7 AD |
266 | if (xmlhttp_ready(xmlhttp)) { |
267 | xmlhttp.open("GET", query_str, true); | |
268 | xmlhttp.onreadystatechange=feedlist_callback; | |
269 | xmlhttp.send(null); | |
270 | } else { | |
271 | debug("xmlhttp busy"); | |
272 | //printLockingError(); | |
273 | } | |
476cac42 | 274 | |
fc69e641 | 275 | global_unread = 0; |
21703604 | 276 | updateTitle(""); |
fc69e641 | 277 | |
476cac42 | 278 | } |
1cd17194 | 279 | |
767e2486 | 280 | function viewCurrentFeed(subop) { |
1a66d16e | 281 | |
ec6e2fd3 AD |
282 | // if (getActiveFeedId()) { |
283 | if (getActiveFeedId() != undefined) { | |
767e2486 | 284 | viewfeed(getActiveFeedId(), subop); |
033e47e0 AD |
285 | } else { |
286 | disableContainerChildren("headlinesToolbar", false, document); | |
ec6e2fd3 | 287 | // viewfeed(-1, subop); // FIXME |
f0601b87 | 288 | } |
164f4738 | 289 | return false; // block unneeded form submits |
f0601b87 AD |
290 | } |
291 | ||
767e2486 | 292 | function viewfeed(feed, subop) { |
db8d6f67 | 293 | var f = window.frames["feeds-frame"]; |
767e2486 | 294 | f.viewfeed(feed, subop); |
9cfc649a AD |
295 | } |
296 | ||
40d13c28 | 297 | function timeout() { |
05732aa0 | 298 | scheduleFeedUpdate(false); |
f5de0d8d | 299 | |
3ac2b520 | 300 | var refresh_time = getInitParam("feeds_frame_refresh"); |
f5de0d8d | 301 | |
3ac2b520 | 302 | if (!refresh_time) refresh_time = 600; |
f5de0d8d AD |
303 | |
304 | setTimeout("timeout()", refresh_time*1000); | |
ac53063a AD |
305 | } |
306 | ||
c374a3fe | 307 | function resetSearch() { |
64c620ce AD |
308 | var searchbox = document.getElementById("searchbox") |
309 | ||
86741347 | 310 | if (searchbox.value != "" && getActiveFeedId()) { |
64c620ce | 311 | searchbox.value = ""; |
767e2486 | 312 | viewfeed(getActiveFeedId(), ""); |
ac43eba1 | 313 | } |
c374a3fe | 314 | } |
ac53063a | 315 | |
86b682ce AD |
316 | function searchCancel() { |
317 | closeInfoBox(true); | |
318 | } | |
319 | ||
f0601b87 | 320 | function search() { |
eff4997c | 321 | closeInfoBox(); |
4ce19859 | 322 | viewCurrentFeed(0, ""); |
76798ff3 | 323 | } |
1cd17194 | 324 | |
13ad9102 AD |
325 | function localPiggieFunction(enable) { |
326 | if (enable) { | |
327 | var query_str = "backend.php?op=feeds&subop=piggie"; | |
328 | ||
c0e5a40e | 329 | if (xmlhttp_ready(xmlhttp)) { |
13ad9102 AD |
330 | |
331 | xmlhttp.open("GET", query_str, true); | |
332 | xmlhttp.onreadystatechange=feedlist_callback; | |
333 | xmlhttp.send(null); | |
334 | } | |
335 | } | |
336 | } | |
337 | ||
806a3d14 AD |
338 | // if argument is undefined, current subtitle is not updated |
339 | // use blank string to clear subtitle | |
fc69e641 AD |
340 | function updateTitle(s) { |
341 | var tmp = "Tiny Tiny RSS"; | |
21703604 | 342 | |
5a494a0b | 343 | if (s != undefined) { |
21703604 AD |
344 | current_subtitle = s; |
345 | } | |
346 | ||
fc69e641 AD |
347 | if (global_unread > 0) { |
348 | tmp = tmp + " (" + global_unread + ")"; | |
349 | } | |
350 | ||
5a494a0b | 351 | if (current_subtitle) { |
21703604 | 352 | tmp = tmp + " - " + current_subtitle; |
fc69e641 | 353 | } |
21703604 AD |
354 | |
355 | if (active_title_text.length > 0) { | |
356 | tmp = tmp + " > " + active_title_text; | |
357 | } | |
358 | ||
fc69e641 AD |
359 | document.title = tmp; |
360 | } | |
361 | ||
22a93ad8 | 362 | function genericSanityCheck() { |
ac43eba1 | 363 | |
295f9b42 AD |
364 | if (!xmlhttp) fatalError(1); |
365 | ||
366 | setCookie("ttrss_vf_test", "TEST"); | |
367 | ||
368 | if (getCookie("ttrss_vf_test") != "TEST") { | |
369 | fatalError(2); | |
370 | } | |
371 | ||
22a93ad8 AD |
372 | return true; |
373 | } | |
374 | ||
375 | function init() { | |
376 | ||
7719618b | 377 | try { |
fe2f1970 | 378 | |
97dcd654 AD |
379 | // this whole shebang is based on http://www.birnamdesigns.com/misc/busted2.html |
380 | ||
381 | if (arguments.callee.done) return; | |
382 | arguments.callee.done = true; | |
383 | ||
7719618b | 384 | disableContainerChildren("headlinesToolbar", true); |
70830c87 | 385 | |
86b682ce AD |
386 | Form.disable("main_toolbar_form"); |
387 | ||
7719618b AD |
388 | if (!genericSanityCheck()) |
389 | return; | |
ac43eba1 | 390 | |
0ee1d1a0 AD |
391 | if (getURLParam('debug')) { |
392 | document.getElementById('debug_output').style.display = 'block'; | |
393 | debug('debug mode activated'); | |
394 | } | |
395 | ||
7719618b AD |
396 | xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true); |
397 | xmlhttp.onreadystatechange=backend_sanity_check_callback; | |
398 | xmlhttp.send(null); | |
47179952 | 399 | |
7719618b AD |
400 | } catch (e) { |
401 | exception_error("init", e); | |
a8d28f48 | 402 | } |
7719618b | 403 | } |
86741347 | 404 | |
7719618b | 405 | function init_second_stage() { |
295f9b42 | 406 | |
7719618b | 407 | try { |
2f587484 | 408 | |
76b4eae1 AD |
409 | cookie_lifetime = getCookie("ttrss_cltime"); |
410 | ||
411 | delCookie("ttrss_vf_test"); | |
7719618b | 412 | |
7719618b | 413 | document.onkeydown = hotkey_handler; |
1b0809ae | 414 | |
f31673f7 AD |
415 | var tb = parent.document.forms["main_toolbar_form"]; |
416 | ||
9f10e152 AD |
417 | // dropboxSelect(tb.view_mode, getInitParam("toolbar_view_mode")); |
418 | // dropboxSelect(tb.limit, getInitParam("toolbar_limit")); | |
c6784aea | 419 | |
0d51e25d AD |
420 | daemon_enabled = getInitParam("daemon_enabled") == 1; |
421 | daemon_refresh_only = getInitParam("daemon_refresh_only") == 1; | |
5f136c9a | 422 | |
0e9dd1ba | 423 | setTimeout('updateFeedList(false, false)', 50); |
0ee1d1a0 AD |
424 | |
425 | debug("second stage ok"); | |
7719618b | 426 | |
7719618b AD |
427 | } catch (e) { |
428 | exception_error("init_second_stage", e); | |
2f587484 | 429 | } |
1cd17194 | 430 | } |
ac43eba1 | 431 | |
c09ec856 | 432 | function quickMenuChange() { |
cbe45fa8 | 433 | var chooser = document.getElementById("quickMenuChooser"); |
86b682ce | 434 | var opid = chooser[chooser.selectedIndex].value; |
e2f8f7b4 | 435 | |
c09ec856 AD |
436 | chooser.selectedIndex = 0; |
437 | quickMenuGo(opid); | |
438 | } | |
439 | ||
440 | function quickMenuGo(opid) { | |
bb3423cf | 441 | try { |
c09ec856 | 442 | |
bb3423cf AD |
443 | if (opid == "qmcPrefs") { |
444 | gotoPreferences(); | |
445 | } | |
446 | ||
447 | if (opid == "qmcSearch") { | |
0a6c4846 | 448 | displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat()); |
6de5d056 AD |
449 | return; |
450 | } | |
bb3423cf AD |
451 | |
452 | if (opid == "qmcAddFeed") { | |
453 | displayDlg("quickAddFeed"); | |
454 | return; | |
69668465 | 455 | } |
7086277c AD |
456 | |
457 | if (opid == "qmcEditFeed") { | |
458 | editFeedDlg(getActiveFeedId()); | |
459 | } | |
6de5d056 | 460 | |
bb3423cf AD |
461 | if (opid == "qmcRemoveFeed") { |
462 | var actid = getActiveFeedId(); | |
463 | ||
5c365f60 | 464 | if (!actid || activeFeedIsCat()) { |
0530ddd8 | 465 | alert("Please select some feed first."); |
bb3423cf AD |
466 | return; |
467 | } | |
64a2875d AD |
468 | |
469 | var fn = getFeedName(actid); | |
bb3423cf | 470 | |
64a2875d | 471 | if (confirm("Unsubscribe from " + fn + "?")) { |
bb3423cf AD |
472 | qfdDelete(actid); |
473 | } | |
474 | ||
475 | return; | |
476 | } | |
477 | ||
478 | if (opid == "qmcUpdateFeeds") { | |
479 | scheduleFeedUpdate(true); | |
480 | return; | |
481 | } | |
482 | ||
483 | if (opid == "qmcCatchupAll") { | |
484 | catchupAllFeeds(); | |
485 | return; | |
486 | } | |
487 | ||
488 | if (opid == "qmcShowOnlyUnread") { | |
489 | toggleDispRead(); | |
490 | return; | |
491 | } | |
492 | ||
493 | if (opid == "qmcAddFilter") { | |
494 | displayDlg("quickAddFilter", getActiveFeedId()); | |
495 | } | |
496 | } catch (e) { | |
497 | exception_error("quickMenuGo", e); | |
a24f525c | 498 | } |
e2f8f7b4 AD |
499 | } |
500 | ||
6de5d056 AD |
501 | function qfdDelete(feed_id) { |
502 | ||
503 | notify("Removing feed..."); | |
504 | ||
7f123cda AD |
505 | if (!xmlhttp_ready(xmlhttp)) { |
506 | printLockingError(); | |
507 | return | |
508 | } | |
509 | ||
15da5cc1 AD |
510 | _qfd_deleted_feed = feed_id; |
511 | ||
69668465 | 512 | xmlhttp.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id); |
6de5d056 AD |
513 | xmlhttp.onreadystatechange=dlg_frefresh_callback; |
514 | xmlhttp.send(null); | |
7bc4f251 AD |
515 | |
516 | return false; | |
6de5d056 | 517 | } |
033e47e0 | 518 | |
3745788e | 519 | |
21703604 AD |
520 | function updateFeedTitle(t) { |
521 | active_title_text = t; | |
522 | updateTitle(); | |
523 | } | |
524 | ||
3745788e | 525 | function toggleDispRead() { |
7f123cda | 526 | try { |
3745788e | 527 | |
7f123cda AD |
528 | if (!xmlhttp_ready(xmlhttp)) { |
529 | printLockingError(); | |
530 | return | |
531 | } | |
3745788e | 532 | |
e8bd0da9 | 533 | var hide_read_feeds = (getInitParam("hide_read_feeds") == "1"); |
3745788e | 534 | |
7f123cda | 535 | hide_read_feeds = !hide_read_feeds; |
e8bd0da9 AD |
536 | |
537 | debug("toggle_disp_read => " + hide_read_feeds); | |
538 | ||
539 | hideOrShowFeeds(getFeedsContext().document, hide_read_feeds); | |
540 | ||
7f123cda AD |
541 | var query = "backend.php?op=rpc&subop=setpref" + |
542 | "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds); | |
3745788e | 543 | |
e8bd0da9 AD |
544 | storeInitParam("hide_read_feeds", hide_read_feeds, true); |
545 | ||
546 | new Ajax.Request(query); | |
7f123cda AD |
547 | |
548 | } catch (e) { | |
549 | exception_error("toggleDispRead", e); | |
3745788e | 550 | } |
3745788e | 551 | } |
295f9b42 | 552 | |
71ad883b | 553 | function parse_runtime_info(elem) { |
4724a093 AD |
554 | if (!elem) { |
555 | debug("parse_runtime_info: elem is null, aborting"); | |
556 | return; | |
557 | } | |
558 | ||
71ad883b AD |
559 | var param = elem.firstChild; |
560 | ||
52db9978 | 561 | debug("parse_runtime_info: " + param); |
1cb7492d | 562 | |
71ad883b AD |
563 | while (param) { |
564 | var k = param.getAttribute("key"); | |
565 | var v = param.getAttribute("value"); | |
3ac2b520 | 566 | |
1cb7492d AD |
567 | debug("RI: " + k + " => " + v); |
568 | ||
71ad883b AD |
569 | var w = document.getElementById("noDaemonWarning"); |
570 | ||
571 | if (w) { | |
572 | if (k == "daemon_is_running" && v != 1) { | |
573 | w.style.display = "block"; | |
574 | } else { | |
575 | w.style.display = "none"; | |
576 | } | |
577 | } | |
578 | param = param.nextSibling; | |
579 | } | |
580 | } | |
fce24838 AD |
581 | |
582 | function catchupCurrentFeed() { | |
583 | ||
234e467c | 584 | var fn = getFeedName(getActiveFeedId(), active_feed_is_cat); |
fce24838 | 585 | |
234e467c AD |
586 | var str = "Mark all articles in " + fn + " as read?"; |
587 | ||
588 | /* if (active_feed_is_cat) { | |
589 | str = "Mark all articles in this category as read?"; | |
590 | } */ | |
591 | ||
f6d6e22f | 592 | if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { |
28de3732 | 593 | return viewCurrentFeed('MarkAllRead') |
fce24838 AD |
594 | } |
595 | } | |
88040f57 | 596 | |
461766f3 AD |
597 | function userSwitch() { |
598 | var chooser = document.getElementById("userSwitch"); | |
599 | var user = chooser[chooser.selectedIndex].value; | |
600 | window.location = "tt-rss.php?swu=" + user; | |
601 | } | |
6e6504bc | 602 | |
7086277c AD |
603 | function editFeedDlg(feed) { |
604 | ||
605 | if (!feed) { | |
606 | alert("Please select some feed first."); | |
607 | return; | |
608 | } | |
609 | ||
610 | if (xmlhttp_ready(xmlhttp)) { | |
611 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" + | |
612 | param_escape(feed), true); | |
613 | xmlhttp.onreadystatechange=infobox_callback; | |
614 | xmlhttp.send(null); | |
615 | } else { | |
616 | printLockingError(); | |
617 | } | |
618 | } | |
619 | ||
620 | /* this functions duplicate those of prefs.js feed editor, with | |
621 | some differences because there is no feedlist */ | |
622 | ||
623 | function feedEditCancel() { | |
624 | closeInfoBox(); | |
625 | return false; | |
626 | } | |
627 | ||
628 | function feedEditSave() { | |
629 | ||
630 | try { | |
631 | ||
632 | if (!xmlhttp_ready(xmlhttp)) { | |
633 | printLockingError(); | |
634 | return | |
635 | } | |
636 | ||
637 | // FIXME: add parameter validation | |
638 | ||
639 | var query = Form.serialize("edit_feed_form"); | |
640 | ||
641 | notify("Saving feed..."); | |
642 | ||
643 | xmlhttp.open("POST", "backend.php", true); | |
644 | xmlhttp.onreadystatechange=dlg_frefresh_callback; | |
645 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
646 | xmlhttp.send(query); | |
647 | ||
648 | closeInfoBox(); | |
649 | ||
650 | return false; | |
651 | ||
652 | } catch (e) { | |
653 | exception_error("feedEditSave (main)", e); | |
654 | } | |
655 | } | |
6e6504bc | 656 |