]>
Commit | Line | Data |
---|---|---|
76798ff3 | 1 | var total_unread = 0; |
525116d4 | 2 | var first_run = true; |
8143ae1f | 3 | var display_tags = false; |
806a3d14 | 4 | var global_unread = -1; |
21703604 | 5 | var active_title_text = ""; |
21703604 | 6 | var current_subtitle = ""; |
c6784aea | 7 | var daemon_enabled = false; |
0d51e25d | 8 | var daemon_refresh_only = false; |
f3c6bf6e | 9 | //var _qfd_deleted_feed = 0; |
2bf6e0a8 | 10 | var firsttime_update = true; |
76b4eae1 | 11 | var cookie_lifetime = 0; |
33d13e72 | 12 | var active_feed_id = 0; |
0a6c4846 | 13 | var active_feed_is_cat = false; |
9e397d0f | 14 | var number_of_feeds = 0; |
7a09510c | 15 | var sanity_check_done = false; |
8b557634 | 16 | var _hfd_scrolltop = 0; |
15da5cc1 | 17 | |
1035fcec | 18 | var init_params = new Object(); |
3ac2b520 | 19 | |
0b126ac2 AD |
20 | function tagsAreDisplayed() { |
21 | return display_tags; | |
22 | } | |
23 | ||
0979b696 | 24 | function toggleTags(show_all) { |
8143ae1f | 25 | |
17a756d1 AD |
26 | try { |
27 | ||
28 | debug("toggleTags: " + show_all + "; " + display_tags); | |
29 | ||
8143ae1f AD |
30 | var p = document.getElementById("dispSwitchPrompt"); |
31 | ||
0979b696 AD |
32 | if (!show_all && !display_tags) { |
33 | displayDlg("printTagCloud"); | |
34 | } else if (show_all) { | |
35 | closeInfoBox(); | |
36 | display_tags = true; | |
709e7dc2 | 37 | p.innerHTML = __("display feeds"); |
35a03bdd | 38 | notify_progress("Loading, please wait...", true); |
0979b696 AD |
39 | updateFeedList(); |
40 | } else if (display_tags) { | |
41 | display_tags = false; | |
42 | p.innerHTML = __("tag cloud"); | |
35a03bdd | 43 | notify_progress("Loading, please wait...", true); |
0979b696 | 44 | updateFeedList(); |
8143ae1f | 45 | } |
17a756d1 AD |
46 | |
47 | } catch (e) { | |
48 | exception_error("toggleTags", e); | |
49 | } | |
8143ae1f AD |
50 | } |
51 | ||
f3c6bf6e AD |
52 | function dlg_frefresh_callback(transport, deleted_feed) { |
53 | if (getActiveFeedId() == deleted_feed) { | |
54 | var h = document.getElementById("headlines-frame"); | |
55 | if (h) { | |
56 | h.innerHTML = "<div class='whiteBox'>" + __('No feed selected.') + "</div>"; | |
abbe0154 | 57 | } |
f3c6bf6e | 58 | } |
abbe0154 | 59 | |
f3c6bf6e AD |
60 | setTimeout('updateFeedList(false, false)', 50); |
61 | closeInfoBox(); | |
1cd17194 | 62 | } |
e2f8f7b4 | 63 | |
c20fd463 AD |
64 | function refetch_callback2(transport) { |
65 | try { | |
c441662f | 66 | |
c20fd463 | 67 | var date = new Date(); |
c441662f | 68 | |
c20fd463 | 69 | parse_counters_reply(transport, true); |
71ad883b | 70 | |
c20fd463 | 71 | debug("refetch_callback2: done"); |
0ee1d1a0 | 72 | |
e9753ab4 | 73 | /* if (!daemon_enabled && !daemon_refresh_only) { |
c20fd463 | 74 | notify_info("All feeds updated."); |
e2cb4c6d | 75 | updateTitle(""); |
c20fd463 AD |
76 | } else { |
77 | //notify(""); | |
e9753ab4 | 78 | } */ |
c20fd463 AD |
79 | } catch (e) { |
80 | exception_error("refetch_callback", e); | |
81 | updateTitle(""); | |
090e250b AD |
82 | } |
83 | } | |
1a66d16e | 84 | |
f3c6bf6e | 85 | function backend_sanity_check_callback(transport) { |
295f9b42 | 86 | |
f3c6bf6e | 87 | try { |
295f9b42 | 88 | |
f3c6bf6e AD |
89 | if (sanity_check_done) { |
90 | fatalError(11, "Sanity check request received twice. This can indicate "+ | |
91 | "presence of Firebug or some other disrupting extension. "+ | |
92 | "Please disable it and try again."); | |
93 | return; | |
94 | } | |
7a09510c | 95 | |
f3c6bf6e AD |
96 | if (!transport.responseXML) { |
97 | fatalError(3, "[D001, Received reply is not XML]: " + transport.responseText); | |
98 | return; | |
99 | } | |
100 | ||
101 | var reply = transport.responseXML.firstChild.firstChild; | |
102 | ||
103 | if (!reply) { | |
104 | fatalError(3, "[D002, Invalid RPC reply]: " + transport.responseText); | |
105 | return; | |
106 | } | |
107 | ||
108 | var error_code = reply.getAttribute("error-code"); | |
7719618b | 109 | |
f3c6bf6e AD |
110 | if (error_code && error_code != 0) { |
111 | return fatalError(error_code, reply.getAttribute("error-msg")); | |
112 | } | |
0ee1d1a0 | 113 | |
f3c6bf6e | 114 | debug("sanity check ok"); |
3ac2b520 | 115 | |
f3c6bf6e | 116 | var params = reply.nextSibling; |
3ac2b520 | 117 | |
f3c6bf6e AD |
118 | if (params) { |
119 | debug('reading init-params...'); | |
120 | var param = params.firstChild; | |
121 | ||
122 | while (param) { | |
123 | var k = param.getAttribute("key"); | |
124 | var v = param.getAttribute("value"); | |
125 | debug(k + " => " + v); | |
126 | init_params[k] = v; | |
127 | param = param.nextSibling; | |
3ac2b520 | 128 | } |
f3c6bf6e | 129 | } |
3ac2b520 | 130 | |
f3c6bf6e | 131 | sanity_check_done = true; |
7a09510c | 132 | |
f3c6bf6e | 133 | init_second_stage(); |
295f9b42 | 134 | |
f3c6bf6e AD |
135 | } catch (e) { |
136 | exception_error("backend_sanity_check_callback", e); | |
295f9b42 AD |
137 | } |
138 | } | |
139 | ||
cb246176 | 140 | function scheduleFeedUpdate(force) { |
525116d4 | 141 | |
c20fd463 AD |
142 | debug("in scheduleFeedUpdate"); |
143 | ||
d8432ff5 | 144 | /* if (!daemon_enabled && !daemon_refresh_only) { |
c20fd463 | 145 | notify_progress("Updating feeds...", true); |
d8432ff5 | 146 | } */ |
55193822 | 147 | |
cb246176 AD |
148 | var query_str = "backend.php?op=rpc&subop="; |
149 | ||
150 | if (force) { | |
c3b81db0 | 151 | query_str = query_str + "forceUpdateAllFeeds"; |
cb246176 | 152 | } else { |
c3b81db0 | 153 | query_str = query_str + "updateAllFeeds"; |
cb246176 | 154 | } |
525116d4 | 155 | |
9826bd2e AD |
156 | var omode; |
157 | ||
b6104dee | 158 | if (firsttime_update && !navigator.userAgent.match("Opera")) { |
2bf6e0a8 AD |
159 | firsttime_update = false; |
160 | omode = "T"; | |
9826bd2e | 161 | } else { |
2bf6e0a8 | 162 | if (display_tags) { |
cf4d339c | 163 | omode = "tl"; |
2bf6e0a8 AD |
164 | } else { |
165 | omode = "flc"; | |
166 | } | |
9826bd2e | 167 | } |
2bf6e0a8 | 168 | |
9826bd2e | 169 | query_str = query_str + "&omode=" + omode; |
78ea1de0 | 170 | query_str = query_str + "&uctr=" + global_unread; |
9826bd2e | 171 | |
c441662f | 172 | var date = new Date(); |
89fbb3bc AD |
173 | var timestamp = Math.round(date.getTime() / 1000); |
174 | query_str = query_str + "&ts=" + timestamp | |
175 | ||
52db9978 AD |
176 | debug("REFETCH query: " + query_str); |
177 | ||
c20fd463 AD |
178 | new Ajax.Request(query_str, { |
179 | onComplete: function(transport) { | |
180 | refetch_callback2(transport); | |
181 | } }); | |
525116d4 | 182 | } |
1cd17194 | 183 | |
525116d4 | 184 | function updateFeedList(silent, fetch) { |
c0e5a40e | 185 | |
1a66d16e AD |
186 | // if (silent != true) { |
187 | // notify("Loading feed list..."); | |
188 | // } | |
82baad4a | 189 | |
cf4d339c AD |
190 | debug("<b>updateFeedList</b>"); |
191 | ||
331900c6 AD |
192 | var query_str = "backend.php?op=feeds"; |
193 | ||
8143ae1f AD |
194 | if (display_tags) { |
195 | query_str = query_str + "&tags=1"; | |
196 | } | |
197 | ||
5c365f60 | 198 | if (getActiveFeedId() && !activeFeedIsCat()) { |
86741347 | 199 | query_str = query_str + "&actid=" + getActiveFeedId(); |
175847de AD |
200 | } |
201 | ||
86173d9a AD |
202 | var date = new Date(); |
203 | var timestamp = Math.round(date.getTime() / 1000); | |
204 | query_str = query_str + "&ts=" + timestamp | |
59b8192f | 205 | |
1a66d16e | 206 | if (fetch) query_str = query_str + "&fetch=yes"; |
e1123aee | 207 | |
6b4163cb AD |
208 | // var feeds_frame = document.getElementById("feeds-frame"); |
209 | // feeds_frame.src = query_str; | |
210 | ||
0e9dd1ba | 211 | debug("updateFeedList Q=" + query_str); |
6b4163cb | 212 | |
0df398da AD |
213 | new Ajax.Request(query_str, { |
214 | onComplete: function(transport) { | |
215 | feedlist_callback2(transport); | |
216 | } }); | |
e1123aee | 217 | |
1a66d16e | 218 | } |
175847de | 219 | |
476cac42 | 220 | function catchupAllFeeds() { |
076682aa | 221 | |
f8232151 | 222 | var str = __("Mark all articles as read?"); |
476cac42 | 223 | |
f8232151 | 224 | if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { |
476cac42 | 225 | |
f8232151 | 226 | var query_str = "backend.php?op=feeds&subop=catchupAll"; |
1a66d16e | 227 | |
f8232151 | 228 | notify_progress("Marking all feeds as read..."); |
476cac42 | 229 | |
f8232151 | 230 | debug("catchupAllFeeds Q=" + query_str); |
fc69e641 | 231 | |
f8232151 AD |
232 | new Ajax.Request(query_str, { |
233 | onComplete: function(transport) { | |
234 | feedlist_callback2(transport); | |
235 | } }); | |
236 | ||
237 | global_unread = 0; | |
238 | updateTitle(""); | |
239 | } | |
476cac42 | 240 | } |
1cd17194 | 241 | |
767e2486 | 242 | function viewCurrentFeed(subop) { |
1a66d16e | 243 | |
ec6e2fd3 AD |
244 | // if (getActiveFeedId()) { |
245 | if (getActiveFeedId() != undefined) { | |
d73071b1 | 246 | viewfeed(getActiveFeedId(), subop, active_feed_is_cat); |
033e47e0 AD |
247 | } else { |
248 | disableContainerChildren("headlinesToolbar", false, document); | |
ec6e2fd3 | 249 | // viewfeed(-1, subop); // FIXME |
f0601b87 | 250 | } |
164f4738 | 251 | return false; // block unneeded form submits |
f0601b87 AD |
252 | } |
253 | ||
767e2486 | 254 | function viewfeed(feed, subop) { |
db8d6f67 | 255 | var f = window.frames["feeds-frame"]; |
767e2486 | 256 | f.viewfeed(feed, subop); |
9cfc649a AD |
257 | } |
258 | ||
40d13c28 | 259 | function timeout() { |
05732aa0 | 260 | scheduleFeedUpdate(false); |
f5de0d8d | 261 | |
3ac2b520 | 262 | var refresh_time = getInitParam("feeds_frame_refresh"); |
f5de0d8d | 263 | |
3ac2b520 | 264 | if (!refresh_time) refresh_time = 600; |
f5de0d8d AD |
265 | |
266 | setTimeout("timeout()", refresh_time*1000); | |
ac53063a AD |
267 | } |
268 | ||
c374a3fe | 269 | function resetSearch() { |
64c620ce AD |
270 | var searchbox = document.getElementById("searchbox") |
271 | ||
86741347 | 272 | if (searchbox.value != "" && getActiveFeedId()) { |
64c620ce | 273 | searchbox.value = ""; |
767e2486 | 274 | viewfeed(getActiveFeedId(), ""); |
ac43eba1 | 275 | } |
c374a3fe | 276 | } |
ac53063a | 277 | |
86b682ce AD |
278 | function searchCancel() { |
279 | closeInfoBox(true); | |
280 | } | |
281 | ||
f0601b87 | 282 | function search() { |
eff4997c | 283 | closeInfoBox(); |
4ce19859 | 284 | viewCurrentFeed(0, ""); |
76798ff3 | 285 | } |
1cd17194 | 286 | |
806a3d14 AD |
287 | // if argument is undefined, current subtitle is not updated |
288 | // use blank string to clear subtitle | |
fc69e641 AD |
289 | function updateTitle(s) { |
290 | var tmp = "Tiny Tiny RSS"; | |
21703604 | 291 | |
5a494a0b | 292 | if (s != undefined) { |
21703604 AD |
293 | current_subtitle = s; |
294 | } | |
295 | ||
fc69e641 AD |
296 | if (global_unread > 0) { |
297 | tmp = tmp + " (" + global_unread + ")"; | |
298 | } | |
299 | ||
5a494a0b | 300 | if (current_subtitle) { |
21703604 | 301 | tmp = tmp + " - " + current_subtitle; |
fc69e641 | 302 | } |
21703604 AD |
303 | |
304 | if (active_title_text.length > 0) { | |
305 | tmp = tmp + " > " + active_title_text; | |
306 | } | |
307 | ||
fc69e641 AD |
308 | document.title = tmp; |
309 | } | |
310 | ||
22a93ad8 | 311 | function genericSanityCheck() { |
ac43eba1 | 312 | |
f3c6bf6e | 313 | // if (!Ajax.getTransport()) fatalError(1); |
295f9b42 AD |
314 | |
315 | setCookie("ttrss_vf_test", "TEST"); | |
316 | ||
317 | if (getCookie("ttrss_vf_test") != "TEST") { | |
318 | fatalError(2); | |
319 | } | |
320 | ||
22a93ad8 AD |
321 | return true; |
322 | } | |
323 | ||
324 | function init() { | |
325 | ||
7719618b | 326 | try { |
fe2f1970 | 327 | |
97dcd654 AD |
328 | // this whole shebang is based on http://www.birnamdesigns.com/misc/busted2.html |
329 | ||
330 | if (arguments.callee.done) return; | |
331 | arguments.callee.done = true; | |
332 | ||
7719618b | 333 | disableContainerChildren("headlinesToolbar", true); |
70830c87 | 334 | |
86b682ce AD |
335 | Form.disable("main_toolbar_form"); |
336 | ||
7719618b AD |
337 | if (!genericSanityCheck()) |
338 | return; | |
ac43eba1 | 339 | |
0ee1d1a0 AD |
340 | if (getURLParam('debug')) { |
341 | document.getElementById('debug_output').style.display = 'block'; | |
342 | debug('debug mode activated'); | |
343 | } | |
344 | ||
4220d6b0 AD |
345 | var params = "&ua=" + param_escape(navigator.userAgent); |
346 | ||
f3c6bf6e AD |
347 | new Ajax.Request("backend.php?op=rpc&subop=sanityCheck" + params, { |
348 | onComplete: function(transport) { | |
349 | backend_sanity_check_callback(transport); | |
350 | } }); | |
47179952 | 351 | |
7719618b AD |
352 | } catch (e) { |
353 | exception_error("init", e); | |
a8d28f48 | 354 | } |
7719618b | 355 | } |
86741347 | 356 | |
a9d42cf7 | 357 | function resize_headlines() { |
770bbb02 | 358 | |
a9d42cf7 AD |
359 | var h_frame = document.getElementById("headlines-frame"); |
360 | var c_frame = document.getElementById("content-frame"); | |
586822fd AD |
361 | var f_frame = document.getElementById("footer"); |
362 | ||
363 | if (!c_frame || !h_frame) return; | |
a9d42cf7 | 364 | |
20361063 AD |
365 | if (getInitParam("theme") == "3pane") { |
366 | debug("resize_headlines: HOR-mode"); | |
a9d42cf7 | 367 | |
21f0db71 | 368 | c_frame.style.width = '35%'; |
20361063 | 369 | h_frame.style.right = c_frame.offsetWidth - 1 + "px"; |
586822fd | 370 | |
20361063 AD |
371 | } else { |
372 | debug("resize_headlines: VER-mode"); | |
586822fd | 373 | |
20361063 AD |
374 | if (!is_msie()) { |
375 | h_frame.style.height = 30 + "%"; | |
376 | c_frame.style.top = h_frame.offsetTop + h_frame.offsetHeight + 1 + "px"; | |
377 | h_frame.style.height = h_frame.offsetHeight + "px"; | |
378 | } else { | |
379 | h_frame.style.height = document.documentElement.clientHeight * 0.3 + "px"; | |
380 | c_frame.style.top = h_frame.offsetTop + h_frame.offsetHeight + 1 + "px"; | |
381 | ||
382 | var c_bottom = document.documentElement.clientHeight; | |
383 | ||
384 | if (f_frame) { | |
385 | c_bottom = f_frame.offsetTop; | |
386 | } | |
387 | ||
388 | c_frame.style.height = c_bottom - (h_frame.offsetTop + | |
389 | h_frame.offsetHeight + 1) + "px"; | |
390 | h_frame.style.height = h_frame.offsetHeight + "px"; | |
391 | ||
586822fd AD |
392 | } |
393 | ||
a9d42cf7 | 394 | } |
20361063 | 395 | |
a9d42cf7 AD |
396 | } |
397 | ||
7719618b | 398 | function init_second_stage() { |
295f9b42 | 399 | |
7719618b | 400 | try { |
2f587484 | 401 | |
76b4eae1 AD |
402 | cookie_lifetime = getCookie("ttrss_cltime"); |
403 | ||
404 | delCookie("ttrss_vf_test"); | |
770bbb02 | 405 | |
586822fd AD |
406 | // document.onresize = resize_headlines; |
407 | resize_headlines(); | |
1b0809ae | 408 | |
40496720 | 409 | var toolbar = document.forms["main_toolbar_form"]; |
f31673f7 | 410 | |
40496720 AD |
411 | dropboxSelect(toolbar.view_mode, getInitParam("default_view_mode")); |
412 | dropboxSelect(toolbar.limit, getInitParam("default_view_limit")); | |
c6784aea | 413 | |
0d51e25d AD |
414 | daemon_enabled = getInitParam("daemon_enabled") == 1; |
415 | daemon_refresh_only = getInitParam("daemon_refresh_only") == 1; | |
5f136c9a | 416 | |
0e9dd1ba | 417 | setTimeout('updateFeedList(false, false)', 50); |
0ee1d1a0 AD |
418 | |
419 | debug("second stage ok"); | |
7719618b | 420 | |
7719618b AD |
421 | } catch (e) { |
422 | exception_error("init_second_stage", e); | |
2f587484 | 423 | } |
1cd17194 | 424 | } |
ac43eba1 | 425 | |
c09ec856 | 426 | function quickMenuChange() { |
cbe45fa8 | 427 | var chooser = document.getElementById("quickMenuChooser"); |
86b682ce | 428 | var opid = chooser[chooser.selectedIndex].value; |
e2f8f7b4 | 429 | |
c09ec856 AD |
430 | chooser.selectedIndex = 0; |
431 | quickMenuGo(opid); | |
432 | } | |
433 | ||
434 | function quickMenuGo(opid) { | |
bb3423cf | 435 | try { |
c09ec856 | 436 | |
bb3423cf AD |
437 | if (opid == "qmcPrefs") { |
438 | gotoPreferences(); | |
439 | } | |
440 | ||
441 | if (opid == "qmcSearch") { | |
0a6c4846 | 442 | displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat()); |
6de5d056 AD |
443 | return; |
444 | } | |
bb3423cf AD |
445 | |
446 | if (opid == "qmcAddFeed") { | |
447 | displayDlg("quickAddFeed"); | |
448 | return; | |
69668465 | 449 | } |
7086277c AD |
450 | |
451 | if (opid == "qmcEditFeed") { | |
452 | editFeedDlg(getActiveFeedId()); | |
453 | } | |
6de5d056 | 454 | |
bb3423cf AD |
455 | if (opid == "qmcRemoveFeed") { |
456 | var actid = getActiveFeedId(); | |
442d77f1 AD |
457 | |
458 | if (activeFeedIsCat()) { | |
89cb787e | 459 | alert(__("You can't unsubscribe from the category.")); |
442d77f1 AD |
460 | return; |
461 | } | |
462 | ||
463 | if (!actid) { | |
89cb787e | 464 | alert(__("Please select some feed first.")); |
bb3423cf AD |
465 | return; |
466 | } | |
64a2875d AD |
467 | |
468 | var fn = getFeedName(actid); | |
89cb787e AD |
469 | |
470 | var pr = __("Unsubscribe from %s?").replace("%s", fn); | |
471 | ||
472 | if (confirm(pr)) { | |
e978f78d | 473 | unsubscribeFeed(actid); |
bb3423cf AD |
474 | } |
475 | ||
476 | return; | |
477 | } | |
d1f0c584 AD |
478 | |
479 | if (opid == "qmcClearFeed") { | |
480 | var actid = getActiveFeedId(); | |
481 | ||
482 | if (!actid) { | |
483 | alert(__("Please select some feed first.")); | |
484 | return; | |
485 | } | |
486 | ||
487 | if (activeFeedIsCat() || actid < 0) { | |
488 | alert(__("You can't clear this type of feed.")); | |
489 | return; | |
490 | } | |
491 | ||
492 | var fn = getFeedName(actid); | |
493 | ||
2d936cd1 | 494 | var pr = __("Erase all non-starred articles in %s?").replace("%s", fn); |
d1f0c584 AD |
495 | |
496 | if (confirm(pr)) { | |
497 | clearFeedArticles(actid); | |
498 | } | |
499 | ||
500 | return; | |
501 | } | |
bb3423cf | 502 | |
d1f0c584 | 503 | |
bb3423cf AD |
504 | if (opid == "qmcUpdateFeeds") { |
505 | scheduleFeedUpdate(true); | |
506 | return; | |
507 | } | |
508 | ||
509 | if (opid == "qmcCatchupAll") { | |
510 | catchupAllFeeds(); | |
511 | return; | |
512 | } | |
513 | ||
514 | if (opid == "qmcShowOnlyUnread") { | |
515 | toggleDispRead(); | |
516 | return; | |
517 | } | |
518 | ||
519 | if (opid == "qmcAddFilter") { | |
520 | displayDlg("quickAddFilter", getActiveFeedId()); | |
521 | } | |
0979b696 | 522 | |
bb3423cf AD |
523 | } catch (e) { |
524 | exception_error("quickMenuGo", e); | |
a24f525c | 525 | } |
e2f8f7b4 AD |
526 | } |
527 | ||
e978f78d | 528 | function unsubscribeFeed(feed_id) { |
6de5d056 | 529 | |
42c32916 | 530 | notify_progress("Removing feed..."); |
6de5d056 | 531 | |
f3c6bf6e | 532 | var query = "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id; |
7f123cda | 533 | |
f3c6bf6e AD |
534 | new Ajax.Request(query, { |
535 | onComplete: function(transport) { | |
536 | dlg_frefresh_callback(transport, feed_id); | |
537 | } }); | |
15da5cc1 | 538 | |
7bc4f251 AD |
539 | |
540 | return false; | |
6de5d056 | 541 | } |
033e47e0 | 542 | |
3745788e | 543 | |
21703604 AD |
544 | function updateFeedTitle(t) { |
545 | active_title_text = t; | |
546 | updateTitle(); | |
547 | } | |
548 | ||
3745788e | 549 | function toggleDispRead() { |
7f123cda | 550 | try { |
3745788e | 551 | |
e8bd0da9 | 552 | var hide_read_feeds = (getInitParam("hide_read_feeds") == "1"); |
3745788e | 553 | |
7f123cda | 554 | hide_read_feeds = !hide_read_feeds; |
e8bd0da9 AD |
555 | |
556 | debug("toggle_disp_read => " + hide_read_feeds); | |
557 | ||
558 | hideOrShowFeeds(getFeedsContext().document, hide_read_feeds); | |
559 | ||
e8bd0da9 | 560 | storeInitParam("hide_read_feeds", hide_read_feeds, true); |
5158ced9 | 561 | |
7f123cda AD |
562 | } catch (e) { |
563 | exception_error("toggleDispRead", e); | |
3745788e | 564 | } |
3745788e | 565 | } |
295f9b42 | 566 | |
71ad883b | 567 | function parse_runtime_info(elem) { |
4724a093 AD |
568 | if (!elem) { |
569 | debug("parse_runtime_info: elem is null, aborting"); | |
570 | return; | |
571 | } | |
572 | ||
71ad883b AD |
573 | var param = elem.firstChild; |
574 | ||
52db9978 | 575 | debug("parse_runtime_info: " + param); |
1cb7492d | 576 | |
71ad883b AD |
577 | while (param) { |
578 | var k = param.getAttribute("key"); | |
579 | var v = param.getAttribute("value"); | |
3ac2b520 | 580 | |
1cb7492d AD |
581 | debug("RI: " + k + " => " + v); |
582 | ||
d9fa39f1 AD |
583 | if (k == "new_version_available") { |
584 | var icon = document.getElementById("newVersionIcon"); | |
585 | if (icon) { | |
586 | if (v == "1") { | |
587 | icon.style.display = "inline"; | |
588 | } else { | |
589 | icon.style.display = "none"; | |
590 | } | |
591 | } | |
592 | } | |
593 | ||
8e00ae9b AD |
594 | var error_flag; |
595 | ||
ef16ae37 | 596 | if (k == "daemon_is_running" && v != 1) { |
8e00ae9b AD |
597 | notify_error("<span onclick=\"javascript:explainError(1)\">Update daemon is not running.</span>", true); |
598 | error_flag = true; | |
599 | } | |
600 | ||
601 | if (k == "daemon_stamp_ok" && v != 1) { | |
602 | notify_error("<span onclick=\"javascript:explainError(3)\">Update daemon is not updating feeds.</span>", true); | |
603 | error_flag = true; | |
604 | } | |
605 | ||
606 | if (!error_flag) { | |
d00bfb5f | 607 | notify(''); |
ef16ae37 AD |
608 | } |
609 | ||
610 | /* var w = document.getElementById("noDaemonWarning"); | |
71ad883b AD |
611 | |
612 | if (w) { | |
613 | if (k == "daemon_is_running" && v != 1) { | |
614 | w.style.display = "block"; | |
615 | } else { | |
616 | w.style.display = "none"; | |
617 | } | |
ef16ae37 | 618 | } */ |
71ad883b AD |
619 | param = param.nextSibling; |
620 | } | |
621 | } | |
fce24838 AD |
622 | |
623 | function catchupCurrentFeed() { | |
624 | ||
234e467c | 625 | var fn = getFeedName(getActiveFeedId(), active_feed_is_cat); |
fce24838 | 626 | |
2d936cd1 | 627 | var str = __("Mark all articles in %s as read?").replace("%s", fn); |
234e467c AD |
628 | |
629 | /* if (active_feed_is_cat) { | |
630 | str = "Mark all articles in this category as read?"; | |
631 | } */ | |
632 | ||
f6d6e22f | 633 | if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { |
28de3732 | 634 | return viewCurrentFeed('MarkAllRead') |
fce24838 AD |
635 | } |
636 | } | |
88040f57 | 637 | |
7086277c | 638 | function editFeedDlg(feed) { |
2a8504cd | 639 | try { |
7086277c | 640 | |
2a8504cd AD |
641 | if (!feed) { |
642 | alert(__("Please select some feed first.")); | |
643 | return; | |
644 | } | |
645 | ||
646 | if ((feed <= 0 && feed > -10) || activeFeedIsCat() || tagsAreDisplayed()) { | |
647 | alert(__("You can't edit this kind of feed.")); | |
648 | return; | |
649 | } | |
650 | ||
651 | var query = ""; | |
652 | ||
6f151277 | 653 | if (feed > 0) { |
2a8504cd | 654 | query = "backend.php?op=pref-feeds&subop=editfeed&id=" + param_escape(feed); |
6f151277 | 655 | } else { |
2a8504cd | 656 | query = "backend.php?op=pref-labels&subop=edit&id=" + param_escape(-feed-11); |
6f151277 | 657 | } |
c67d2990 AD |
658 | |
659 | disableHotkeys(); | |
660 | ||
2a8504cd AD |
661 | new Ajax.Request(query, { |
662 | onComplete: function(transport) { | |
663 | infobox_callback2(transport); | |
664 | } }); | |
665 | ||
666 | } catch (e) { | |
667 | exception_error("editFeedDlg", e); | |
7086277c AD |
668 | } |
669 | } | |
670 | ||
671 | /* this functions duplicate those of prefs.js feed editor, with | |
672 | some differences because there is no feedlist */ | |
673 | ||
674 | function feedEditCancel() { | |
675 | closeInfoBox(); | |
676 | return false; | |
677 | } | |
678 | ||
679 | function feedEditSave() { | |
680 | ||
681 | try { | |
682 | ||
7086277c AD |
683 | // FIXME: add parameter validation |
684 | ||
685 | var query = Form.serialize("edit_feed_form"); | |
686 | ||
42c32916 | 687 | notify_progress("Saving feed..."); |
7086277c | 688 | |
f3c6bf6e AD |
689 | new Ajax.Request("backend.php", { |
690 | parameters: query, | |
691 | onComplete: function(transport) { | |
692 | dlg_frefresh_callback(transport); | |
693 | } }); | |
694 | ||
7086277c AD |
695 | |
696 | closeInfoBox(); | |
697 | ||
698 | return false; | |
699 | ||
700 | } catch (e) { | |
701 | exception_error("feedEditSave (main)", e); | |
702 | } | |
703 | } | |
1dc8dba0 | 704 | |
6f151277 AD |
705 | function labelEditCancel() { |
706 | closeInfoBox(); | |
707 | return false; | |
708 | } | |
709 | ||
710 | function labelEditSave() { | |
711 | ||
712 | try { | |
713 | ||
6f151277 AD |
714 | closeInfoBox(); |
715 | ||
716 | notify_progress("Saving label..."); | |
717 | ||
718 | query = Form.serialize("label_edit_form"); | |
719 | ||
f3c6bf6e AD |
720 | new Ajax.Request("backend.php?" + query, { |
721 | onComplete: function(transport) { | |
722 | dlg_frefresh_callback(transport); | |
723 | } }); | |
724 | ||
6f151277 AD |
725 | return false; |
726 | ||
727 | } catch (e) { | |
728 | exception_error("feedEditSave (main)", e); | |
729 | } | |
730 | ||
731 | } | |
e4914b62 | 732 | |
c4a36709 AD |
733 | function clearFeedArticles(feed_id) { |
734 | ||
735 | notify_progress("Clearing feed..."); | |
736 | ||
737 | var query = "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id; | |
738 | ||
739 | new Ajax.Request(query, { | |
740 | onComplete: function(transport) { | |
741 | dlg_frefresh_callback(transport, feed_id); | |
742 | } }); | |
743 | ||
744 | return false; | |
745 | } | |
746 | ||
0b6cffa8 | 747 | /* |
24c1e1c1 AD |
748 | function toggle_feedlist() { |
749 | try { | |
750 | debug("toggle_feedlist"); | |
751 | ||
752 | var fl = document.getElementById("feeds-holder"); | |
c4a36709 | 753 | |
24c1e1c1 AD |
754 | if (!Element.visible(fl)) { |
755 | Element.show(fl); | |
756 | fl.style.zIndex = 30; | |
8b557634 | 757 | fl.scrollTop = _hfd_scrolltop; |
24c1e1c1 | 758 | } else { |
8b557634 AD |
759 | _hfd_scrolltop = fl.scrollTop; |
760 | Element.hide(fl); | |
1924fa1b AD |
761 | // Effect.Fade(fl, {duration : 0.2, |
762 | // queue: { position: 'end', scope: 'FLFADEQ', limit: 1 }}); | |
24c1e1c1 AD |
763 | } |
764 | } catch (e) { | |
765 | exception_error(e, "toggle_feedlist"); | |
766 | } | |
0b6cffa8 | 767 | } */ |
8389b150 AD |
768 | |
769 | function collapse_feedlist() { | |
770 | try { | |
771 | debug("toggle_feedlist"); | |
58daed52 AD |
772 | |
773 | var theme = getInitParam("theme"); | |
33aeea94 AD |
774 | if (theme != "" && theme != "compact" && theme != "graycube" && |
775 | theme != "compat") return; | |
8389b150 AD |
776 | |
777 | var fl = document.getElementById("feeds-holder"); | |
778 | var fh = document.getElementById("headlines-frame"); | |
779 | var fc = document.getElementById("content-frame"); | |
780 | var ft = document.getElementById("toolbar"); | |
781 | var ff = document.getElementById("footer"); | |
58daed52 | 782 | var fhdr = document.getElementById("header"); |
8389b150 AD |
783 | var fbtn = document.getElementById("collapse_feeds_btn"); |
784 | ||
785 | if (!Element.visible(fl)) { | |
786 | Element.show(fl); | |
787 | fbtn.value = "<<"; | |
788 | ||
f0e8468b | 789 | if (theme != "graycube") { |
8389b150 | 790 | |
f0e8468b AD |
791 | fh.style.left = fl.offsetWidth + "px"; |
792 | ft.style.left = fl.offsetWidth + "px"; | |
793 | if (fc) fc.style.left = fl.offsetWidth + "px"; | |
03177e82 | 794 | if (ff && theme != "compat") ff.style.left = (fl.offsetWidth-1) + "px"; |
f0e8468b AD |
795 | |
796 | if (theme == "compact") fhdr.style.left = (fl.offsetWidth + 10) + "px"; | |
797 | } else { | |
798 | fh.style.left = fl.offsetWidth + 40 + "px"; | |
799 | ft.style.left = fl.offsetWidth + 40 +"px"; | |
800 | if (fc) fc.style.left = fl.offsetWidth + 40 + "px"; | |
801 | } | |
58daed52 | 802 | |
22936abb AD |
803 | setCookie("ttrss_vf_fclps", "0"); |
804 | ||
8389b150 AD |
805 | } else { |
806 | Element.hide(fl); | |
807 | fbtn.value = ">>"; | |
808 | ||
f0e8468b AD |
809 | if (theme != "graycube") { |
810 | ||
811 | fh.style.left = "0px"; | |
812 | ft.style.left = "0px"; | |
813 | if (fc) fc.style.left = "0px"; | |
814 | if (ff) ff.style.left = "0px"; | |
22936abb | 815 | |
f0e8468b AD |
816 | if (theme == "compact") fhdr.style.left = "10px"; |
817 | ||
818 | } else { | |
819 | fh.style.left = "20px"; | |
820 | ft.style.left = "20px"; | |
821 | if (fc) fc.style.left = "20px"; | |
822 | ||
823 | } | |
58daed52 | 824 | |
22936abb | 825 | setCookie("ttrss_vf_fclps", "1"); |
8389b150 AD |
826 | } |
827 | } catch (e) { | |
828 | exception_error(e, "toggle_feedlist"); | |
829 | } | |
3c2d7945 | 830 | } |
8389b150 | 831 | |
3c2d7945 AD |
832 | function viewModeChanged() { |
833 | cache_empty(); | |
834 | return viewCurrentFeed(0, '') | |
835 | } | |
8389b150 | 836 | |
3c2d7945 AD |
837 | function viewLimitChanged() { |
838 | cache_empty(); | |
839 | return viewCurrentFeed(0, '') | |
8389b150 | 840 | } |