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