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