]>
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()) { | |
494 | alert("You can't unsubscribe from the category."); | |
495 | return; | |
496 | } | |
497 | ||
498 | if (!actid) { | |
0530ddd8 | 499 | alert("Please select some feed first."); |
bb3423cf AD |
500 | return; |
501 | } | |
64a2875d AD |
502 | |
503 | var fn = getFeedName(actid); | |
bb3423cf | 504 | |
64a2875d | 505 | if (confirm("Unsubscribe from " + fn + "?")) { |
bb3423cf AD |
506 | qfdDelete(actid); |
507 | } | |
508 | ||
509 | return; | |
510 | } | |
511 | ||
512 | if (opid == "qmcUpdateFeeds") { | |
513 | scheduleFeedUpdate(true); | |
514 | return; | |
515 | } | |
516 | ||
517 | if (opid == "qmcCatchupAll") { | |
518 | catchupAllFeeds(); | |
519 | return; | |
520 | } | |
521 | ||
522 | if (opid == "qmcShowOnlyUnread") { | |
523 | toggleDispRead(); | |
524 | return; | |
525 | } | |
526 | ||
527 | if (opid == "qmcAddFilter") { | |
528 | displayDlg("quickAddFilter", getActiveFeedId()); | |
529 | } | |
0979b696 | 530 | |
bb3423cf AD |
531 | } catch (e) { |
532 | exception_error("quickMenuGo", e); | |
a24f525c | 533 | } |
e2f8f7b4 AD |
534 | } |
535 | ||
6de5d056 AD |
536 | function qfdDelete(feed_id) { |
537 | ||
42c32916 | 538 | notify_progress("Removing feed..."); |
6de5d056 | 539 | |
7f123cda AD |
540 | if (!xmlhttp_ready(xmlhttp)) { |
541 | printLockingError(); | |
542 | return | |
543 | } | |
544 | ||
15da5cc1 AD |
545 | _qfd_deleted_feed = feed_id; |
546 | ||
69668465 | 547 | xmlhttp.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id); |
6de5d056 AD |
548 | xmlhttp.onreadystatechange=dlg_frefresh_callback; |
549 | xmlhttp.send(null); | |
7bc4f251 AD |
550 | |
551 | return false; | |
6de5d056 | 552 | } |
033e47e0 | 553 | |
3745788e | 554 | |
21703604 AD |
555 | function updateFeedTitle(t) { |
556 | active_title_text = t; | |
557 | updateTitle(); | |
558 | } | |
559 | ||
3745788e | 560 | function toggleDispRead() { |
7f123cda | 561 | try { |
3745788e | 562 | |
7f123cda AD |
563 | if (!xmlhttp_ready(xmlhttp)) { |
564 | printLockingError(); | |
565 | return | |
5158ced9 | 566 | } |
3745788e | 567 | |
e8bd0da9 | 568 | var hide_read_feeds = (getInitParam("hide_read_feeds") == "1"); |
3745788e | 569 | |
7f123cda | 570 | hide_read_feeds = !hide_read_feeds; |
e8bd0da9 AD |
571 | |
572 | debug("toggle_disp_read => " + hide_read_feeds); | |
573 | ||
574 | hideOrShowFeeds(getFeedsContext().document, hide_read_feeds); | |
575 | ||
e8bd0da9 AD |
576 | storeInitParam("hide_read_feeds", hide_read_feeds, true); |
577 | ||
5158ced9 AD |
578 | /* var query = "backend.php?op=rpc&subop=setpref" + |
579 | "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds); | |
580 | ||
581 | new Ajax.Request(query); */ | |
582 | ||
7f123cda AD |
583 | } catch (e) { |
584 | exception_error("toggleDispRead", e); | |
3745788e | 585 | } |
3745788e | 586 | } |
295f9b42 | 587 | |
71ad883b | 588 | function parse_runtime_info(elem) { |
4724a093 AD |
589 | if (!elem) { |
590 | debug("parse_runtime_info: elem is null, aborting"); | |
591 | return; | |
592 | } | |
593 | ||
71ad883b AD |
594 | var param = elem.firstChild; |
595 | ||
52db9978 | 596 | debug("parse_runtime_info: " + param); |
1cb7492d | 597 | |
71ad883b AD |
598 | while (param) { |
599 | var k = param.getAttribute("key"); | |
600 | var v = param.getAttribute("value"); | |
3ac2b520 | 601 | |
1cb7492d AD |
602 | debug("RI: " + k + " => " + v); |
603 | ||
d9fa39f1 AD |
604 | if (k == "new_version_available") { |
605 | var icon = document.getElementById("newVersionIcon"); | |
606 | if (icon) { | |
607 | if (v == "1") { | |
608 | icon.style.display = "inline"; | |
609 | } else { | |
610 | icon.style.display = "none"; | |
611 | } | |
612 | } | |
613 | } | |
614 | ||
8e00ae9b AD |
615 | var error_flag; |
616 | ||
ef16ae37 | 617 | if (k == "daemon_is_running" && v != 1) { |
8e00ae9b AD |
618 | notify_error("<span onclick=\"javascript:explainError(1)\">Update daemon is not running.</span>", true); |
619 | error_flag = true; | |
620 | } | |
621 | ||
622 | if (k == "daemon_stamp_ok" && v != 1) { | |
623 | notify_error("<span onclick=\"javascript:explainError(3)\">Update daemon is not updating feeds.</span>", true); | |
624 | error_flag = true; | |
625 | } | |
626 | ||
627 | if (!error_flag) { | |
d00bfb5f | 628 | notify(''); |
ef16ae37 AD |
629 | } |
630 | ||
631 | /* var w = document.getElementById("noDaemonWarning"); | |
71ad883b AD |
632 | |
633 | if (w) { | |
634 | if (k == "daemon_is_running" && v != 1) { | |
635 | w.style.display = "block"; | |
636 | } else { | |
637 | w.style.display = "none"; | |
638 | } | |
ef16ae37 | 639 | } */ |
71ad883b AD |
640 | param = param.nextSibling; |
641 | } | |
642 | } | |
fce24838 AD |
643 | |
644 | function catchupCurrentFeed() { | |
645 | ||
234e467c | 646 | var fn = getFeedName(getActiveFeedId(), active_feed_is_cat); |
fce24838 | 647 | |
234e467c AD |
648 | var str = "Mark all articles in " + fn + " as read?"; |
649 | ||
650 | /* if (active_feed_is_cat) { | |
651 | str = "Mark all articles in this category as read?"; | |
652 | } */ | |
653 | ||
f6d6e22f | 654 | if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { |
28de3732 | 655 | return viewCurrentFeed('MarkAllRead') |
fce24838 AD |
656 | } |
657 | } | |
88040f57 | 658 | |
461766f3 AD |
659 | function userSwitch() { |
660 | var chooser = document.getElementById("userSwitch"); | |
661 | var user = chooser[chooser.selectedIndex].value; | |
662 | window.location = "tt-rss.php?swu=" + user; | |
663 | } | |
6e6504bc | 664 | |
7086277c AD |
665 | function editFeedDlg(feed) { |
666 | ||
729bafaa AD |
667 | disableHotkeys(); |
668 | ||
7086277c AD |
669 | if (!feed) { |
670 | alert("Please select some feed first."); | |
671 | return; | |
672 | } | |
673 | ||
442d77f1 | 674 | if (feed <= 0 || activeFeedIsCat() || tagsAreDisplayed()) { |
92f3bcae AD |
675 | alert("You can't edit this kind of feed."); |
676 | return; | |
677 | } | |
678 | ||
7086277c AD |
679 | if (xmlhttp_ready(xmlhttp)) { |
680 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" + | |
681 | param_escape(feed), true); | |
682 | xmlhttp.onreadystatechange=infobox_callback; | |
683 | xmlhttp.send(null); | |
684 | } else { | |
685 | printLockingError(); | |
686 | } | |
687 | } | |
688 | ||
689 | /* this functions duplicate those of prefs.js feed editor, with | |
690 | some differences because there is no feedlist */ | |
691 | ||
692 | function feedEditCancel() { | |
693 | closeInfoBox(); | |
694 | return false; | |
695 | } | |
696 | ||
697 | function feedEditSave() { | |
698 | ||
699 | try { | |
700 | ||
701 | if (!xmlhttp_ready(xmlhttp)) { | |
702 | printLockingError(); | |
703 | return | |
704 | } | |
705 | ||
706 | // FIXME: add parameter validation | |
707 | ||
708 | var query = Form.serialize("edit_feed_form"); | |
709 | ||
42c32916 | 710 | notify_progress("Saving feed..."); |
7086277c AD |
711 | |
712 | xmlhttp.open("POST", "backend.php", true); | |
713 | xmlhttp.onreadystatechange=dlg_frefresh_callback; | |
714 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
715 | xmlhttp.send(query); | |
716 | ||
717 | closeInfoBox(); | |
718 | ||
719 | return false; | |
720 | ||
721 | } catch (e) { | |
722 | exception_error("feedEditSave (main)", e); | |
723 | } | |
724 | } | |
1dc8dba0 | 725 | |
e4914b62 | 726 |