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