]>
Commit | Line | Data |
---|---|---|
1 | var hotkeys_enabled = true; | |
2 | var xmlhttp_rpc = Ajax.getTransport(); | |
3 | var notify_silent = false; | |
4 | var last_progress_point = 0; | |
5 | var async_counters_work = false; | |
6 | ||
7 | /* add method to remove element from array */ | |
8 | ||
9 | Array.prototype.remove = function(s) { | |
10 | for (var i=0; i < this.length; i++) { | |
11 | if (s == this[i]) this.splice(i, 1); | |
12 | } | |
13 | } | |
14 | ||
15 | function is_opera() { | |
16 | return window.opera; | |
17 | } | |
18 | ||
19 | function exception_error(location, e, ext_info) { | |
20 | var msg = format_exception_error(location, e); | |
21 | ||
22 | disableHotkeys(); | |
23 | ||
24 | try { | |
25 | ||
26 | var ebc = document.getElementById("xebContent"); | |
27 | ||
28 | if (ebc) { | |
29 | ||
30 | Element.show("dialog_overlay"); | |
31 | Element.show("errorBoxShadow"); | |
32 | ||
33 | if (ext_info) { | |
34 | if (ext_info.responseText) { | |
35 | ext_info = ext_info.responseText; | |
36 | } | |
37 | } | |
38 | ||
39 | ebc.innerHTML = | |
40 | "<div><b>Error message:</b></div>" + | |
41 | "<pre>" + msg + "</pre>" + | |
42 | "<div><b>Additional information:</b></div>" + | |
43 | "<textarea readonly=\"1\">" + ext_info + "</textarea>"; | |
44 | ||
45 | } else { | |
46 | alert(msg); | |
47 | } | |
48 | ||
49 | } catch (e) { | |
50 | alert(msg); | |
51 | ||
52 | } | |
53 | ||
54 | } | |
55 | ||
56 | function format_exception_error(location, e) { | |
57 | var msg; | |
58 | ||
59 | if (e.fileName) { | |
60 | var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1); | |
61 | ||
62 | msg = "Exception: " + e.name + ", " + e.message + | |
63 | "\nFunction: " + location + "()" + | |
64 | "\nLocation: " + base_fname + ":" + e.lineNumber; | |
65 | ||
66 | } else if (e.description) { | |
67 | msg = "Exception: " + e.description + "\nFunction: " + location + "()"; | |
68 | } else { | |
69 | msg = "Exception: " + e + "\nFunction: " + location + "()"; | |
70 | } | |
71 | ||
72 | debug("<b>EXCEPTION: " + msg + "</b>"); | |
73 | ||
74 | return msg; | |
75 | } | |
76 | ||
77 | ||
78 | function disableHotkeys() { | |
79 | hotkeys_enabled = false; | |
80 | } | |
81 | ||
82 | function enableHotkeys() { | |
83 | hotkeys_enabled = true; | |
84 | } | |
85 | ||
86 | function xmlhttp_ready(obj) { | |
87 | return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState; | |
88 | } | |
89 | ||
90 | function open_article_callback(transport) { | |
91 | try { | |
92 | ||
93 | if (transport.responseXML) { | |
94 | ||
95 | var link = transport.responseXML.getElementsByTagName("link")[0]; | |
96 | var id = transport.responseXML.getElementsByTagName("id")[0]; | |
97 | ||
98 | debug("open_article_callback, received link: " + link); | |
99 | ||
100 | if (link && id) { | |
101 | ||
102 | var wname = "ttrss_article_" + id.firstChild.nodeValue; | |
103 | ||
104 | debug("link url: " + link.firstChild.nodeValue + ", wname " + wname); | |
105 | ||
106 | var w = window.open(link.firstChild.nodeValue, wname); | |
107 | ||
108 | if (!w) { notify_error("Failed to load article in new window"); } | |
109 | ||
110 | if (id) { | |
111 | id = id.firstChild.nodeValue; | |
112 | if (!document.getElementById("headlinesList")) { | |
113 | window.setTimeout("toggleUnread(" + id + ", 0)", 100); | |
114 | } | |
115 | } | |
116 | } else { | |
117 | notify_error("Can't open article: received invalid article link"); | |
118 | } | |
119 | } else { | |
120 | notify_error("Can't open article: received invalid XML"); | |
121 | } | |
122 | ||
123 | } catch (e) { | |
124 | exception_error("open_article_callback", e); | |
125 | } | |
126 | } | |
127 | ||
128 | function param_escape(arg) { | |
129 | if (typeof encodeURIComponent != 'undefined') | |
130 | return encodeURIComponent(arg); | |
131 | else | |
132 | return escape(arg); | |
133 | } | |
134 | ||
135 | function param_unescape(arg) { | |
136 | if (typeof decodeURIComponent != 'undefined') | |
137 | return decodeURIComponent(arg); | |
138 | else | |
139 | return unescape(arg); | |
140 | } | |
141 | ||
142 | function delay(gap) { | |
143 | var then,now; | |
144 | then=new Date().getTime(); | |
145 | now=then; | |
146 | while((now-then)<gap) { | |
147 | now=new Date().getTime(); | |
148 | } | |
149 | } | |
150 | ||
151 | var notify_hide_timerid = false; | |
152 | ||
153 | function hide_notify() { | |
154 | var n = document.getElementById("notify"); | |
155 | if (n) { | |
156 | n.style.display = "none"; | |
157 | } | |
158 | } | |
159 | ||
160 | function notify_silent_next() { | |
161 | notify_silent = true; | |
162 | } | |
163 | ||
164 | function notify_real(msg, no_hide, n_type) { | |
165 | ||
166 | if (notify_silent) { | |
167 | notify_silent = false; | |
168 | return; | |
169 | } | |
170 | ||
171 | var n = document.getElementById("notify"); | |
172 | var nb = document.getElementById("notify_body"); | |
173 | ||
174 | if (!n || !nb) return; | |
175 | ||
176 | if (notify_hide_timerid) { | |
177 | window.clearTimeout(notify_hide_timerid); | |
178 | } | |
179 | ||
180 | if (msg == "") { | |
181 | if (n.style.display == "block") { | |
182 | notify_hide_timerid = window.setTimeout("hide_notify()", 0); | |
183 | } | |
184 | return; | |
185 | } else { | |
186 | n.style.display = "block"; | |
187 | } | |
188 | ||
189 | /* types: | |
190 | ||
191 | 1 - generic | |
192 | 2 - progress | |
193 | 3 - error | |
194 | 4 - info | |
195 | ||
196 | */ | |
197 | ||
198 | if (typeof __ != 'undefined') { | |
199 | msg = __(msg); | |
200 | } | |
201 | ||
202 | if (n_type == 1) { | |
203 | n.className = "notify"; | |
204 | } else if (n_type == 2) { | |
205 | n.className = "notifyProgress"; | |
206 | msg = "<img src='images/indicator_white.gif'> " + msg; | |
207 | } else if (n_type == 3) { | |
208 | n.className = "notifyError"; | |
209 | msg = "<img src='images/sign_excl.gif'> " + msg; | |
210 | } else if (n_type == 4) { | |
211 | n.className = "notifyInfo"; | |
212 | msg = "<img src='images/sign_info.gif'> " + msg; | |
213 | } | |
214 | ||
215 | // msg = "<img src='images/live_com_loading.gif'> " + msg; | |
216 | ||
217 | nb.innerHTML = msg; | |
218 | ||
219 | if (!no_hide) { | |
220 | notify_hide_timerid = window.setTimeout("hide_notify()", 3000); | |
221 | } | |
222 | } | |
223 | ||
224 | function notify(msg, no_hide) { | |
225 | notify_real(msg, no_hide, 1); | |
226 | } | |
227 | ||
228 | function notify_progress(msg, no_hide) { | |
229 | notify_real(msg, no_hide, 2); | |
230 | } | |
231 | ||
232 | function notify_error(msg, no_hide) { | |
233 | notify_real(msg, no_hide, 3); | |
234 | ||
235 | } | |
236 | ||
237 | function notify_info(msg, no_hide) { | |
238 | notify_real(msg, no_hide, 4); | |
239 | } | |
240 | ||
241 | function printLockingError() { | |
242 | notify_info("Please wait until operation finishes."); | |
243 | } | |
244 | ||
245 | function cleanSelected(element) { | |
246 | var content = document.getElementById(element); | |
247 | ||
248 | for (i = 0; i < content.rows.length; i++) { | |
249 | content.rows[i].className = content.rows[i].className.replace("Selected", ""); | |
250 | } | |
251 | } | |
252 | ||
253 | function getVisibleUnreadHeadlines() { | |
254 | var content = document.getElementById("headlinesList"); | |
255 | ||
256 | var rows = new Array(); | |
257 | ||
258 | if (!content) return rows; | |
259 | ||
260 | for (i = 0; i < content.rows.length; i++) { | |
261 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
262 | if (row_id.length > 0 && content.rows[i].className.match("Unread")) { | |
263 | rows.push(row_id); | |
264 | } | |
265 | } | |
266 | return rows; | |
267 | } | |
268 | ||
269 | function getVisibleHeadlineIds() { | |
270 | ||
271 | var content = document.getElementById("headlinesList"); | |
272 | ||
273 | var rows = new Array(); | |
274 | ||
275 | if (!content) return rows; | |
276 | ||
277 | for (i = 0; i < content.rows.length; i++) { | |
278 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
279 | if (row_id.length > 0) { | |
280 | rows.push(row_id); | |
281 | } | |
282 | } | |
283 | return rows; | |
284 | } | |
285 | ||
286 | function getFirstVisibleHeadlineId() { | |
287 | if (isCdmMode()) { | |
288 | var rows = cdmGetVisibleArticles(); | |
289 | return rows[0]; | |
290 | } else { | |
291 | var rows = getVisibleHeadlineIds(); | |
292 | return rows[0]; | |
293 | } | |
294 | } | |
295 | ||
296 | function getLastVisibleHeadlineId() { | |
297 | if (isCdmMode()) { | |
298 | var rows = cdmGetVisibleArticles(); | |
299 | return rows[rows.length-1]; | |
300 | } else { | |
301 | var rows = getVisibleHeadlineIds(); | |
302 | return rows[rows.length-1]; | |
303 | } | |
304 | } | |
305 | ||
306 | function markHeadline(id) { | |
307 | var row = document.getElementById("RROW-" + id); | |
308 | if (row) { | |
309 | var is_active = false; | |
310 | ||
311 | if (row.className.match("Active")) { | |
312 | is_active = true; | |
313 | } | |
314 | row.className = row.className.replace("Selected", ""); | |
315 | row.className = row.className.replace("Active", ""); | |
316 | row.className = row.className.replace("Insensitive", ""); | |
317 | ||
318 | if (is_active) { | |
319 | row.className = row.className = "Active"; | |
320 | } | |
321 | ||
322 | var check = document.getElementById("RCHK-" + id); | |
323 | ||
324 | if (check) { | |
325 | check.checked = true; | |
326 | } | |
327 | ||
328 | row.className = row.className + "Selected"; | |
329 | ||
330 | } | |
331 | } | |
332 | ||
333 | function getFeedIds() { | |
334 | var content = document.getElementById("feedsList"); | |
335 | ||
336 | var rows = new Array(); | |
337 | ||
338 | for (i = 0; i < content.rows.length; i++) { | |
339 | var id = content.rows[i].id.replace("FEEDR-", ""); | |
340 | if (id.length > 0) { | |
341 | rows.push(id); | |
342 | } | |
343 | } | |
344 | ||
345 | return rows; | |
346 | } | |
347 | ||
348 | function setCookie(name, value, lifetime, path, domain, secure) { | |
349 | ||
350 | var d = false; | |
351 | ||
352 | if (lifetime) { | |
353 | d = new Date(); | |
354 | d.setTime(d.getTime() + (lifetime * 1000)); | |
355 | } | |
356 | ||
357 | debug("setCookie: " + name + " => " + value + ": " + d); | |
358 | ||
359 | int_setCookie(name, value, d, path, domain, secure); | |
360 | ||
361 | } | |
362 | ||
363 | function int_setCookie(name, value, expires, path, domain, secure) { | |
364 | document.cookie= name + "=" + escape(value) + | |
365 | ((expires) ? "; expires=" + expires.toGMTString() : "") + | |
366 | ((path) ? "; path=" + path : "") + | |
367 | ((domain) ? "; domain=" + domain : "") + | |
368 | ((secure) ? "; secure" : ""); | |
369 | } | |
370 | ||
371 | function delCookie(name, path, domain) { | |
372 | if (getCookie(name)) { | |
373 | document.cookie = name + "=" + | |
374 | ((path) ? ";path=" + path : "") + | |
375 | ((domain) ? ";domain=" + domain : "" ) + | |
376 | ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; | |
377 | } | |
378 | } | |
379 | ||
380 | ||
381 | function getCookie(name) { | |
382 | ||
383 | var dc = document.cookie; | |
384 | var prefix = name + "="; | |
385 | var begin = dc.indexOf("; " + prefix); | |
386 | if (begin == -1) { | |
387 | begin = dc.indexOf(prefix); | |
388 | if (begin != 0) return null; | |
389 | } | |
390 | else { | |
391 | begin += 2; | |
392 | } | |
393 | var end = document.cookie.indexOf(";", begin); | |
394 | if (end == -1) { | |
395 | end = dc.length; | |
396 | } | |
397 | return unescape(dc.substring(begin + prefix.length, end)); | |
398 | } | |
399 | ||
400 | function disableContainerChildren(id, disable, doc) { | |
401 | ||
402 | if (!doc) doc = document; | |
403 | ||
404 | var container = doc.getElementById(id); | |
405 | ||
406 | if (!container) { | |
407 | //alert("disableContainerChildren: element " + id + " not found"); | |
408 | return; | |
409 | } | |
410 | ||
411 | for (var i = 0; i < container.childNodes.length; i++) { | |
412 | var child = container.childNodes[i]; | |
413 | ||
414 | try { | |
415 | child.disabled = disable; | |
416 | } catch (E) { | |
417 | ||
418 | } | |
419 | ||
420 | if (disable) { | |
421 | if (child.className && child.className.match("button")) { | |
422 | child.className = "disabledButton"; | |
423 | } | |
424 | } else { | |
425 | if (child.className && child.className.match("disabledButton")) { | |
426 | child.className = "button"; | |
427 | } | |
428 | } | |
429 | } | |
430 | ||
431 | } | |
432 | ||
433 | function gotoPreferences() { | |
434 | document.location.href = "prefs.php"; | |
435 | } | |
436 | ||
437 | function gotoMain() { | |
438 | document.location.href = "tt-rss.php"; | |
439 | } | |
440 | ||
441 | function gotoExportOpml() { | |
442 | document.location.href = "opml.php?op=Export"; | |
443 | } | |
444 | ||
445 | function parse_counters(reply, scheduled_call) { | |
446 | try { | |
447 | ||
448 | var feeds_found = 0; | |
449 | ||
450 | var elems = reply.getElementsByTagName("counter"); | |
451 | ||
452 | for (var l = 0; l < elems.length; l++) { | |
453 | ||
454 | var id = elems[l].getAttribute("id"); | |
455 | var t = elems[l].getAttribute("type"); | |
456 | var ctr = elems[l].getAttribute("counter"); | |
457 | var error = elems[l].getAttribute("error"); | |
458 | var has_img = elems[l].getAttribute("hi"); | |
459 | var updated = elems[l].getAttribute("updated"); | |
460 | var title = elems[l].getAttribute("title"); | |
461 | var xmsg = elems[l].getAttribute("xmsg"); | |
462 | ||
463 | if (id == "global-unread") { | |
464 | global_unread = ctr; | |
465 | updateTitle(); | |
466 | continue; | |
467 | } | |
468 | ||
469 | if (id == "subscribed-feeds") { | |
470 | feeds_found = ctr; | |
471 | continue; | |
472 | } | |
473 | ||
474 | if (t == "category") { | |
475 | var catctr = document.getElementById("FCATCTR-" + id); | |
476 | if (catctr) { | |
477 | catctr.innerHTML = "(" + ctr + ")"; | |
478 | if (ctr > 0) { | |
479 | catctr.className = "catCtrHasUnread"; | |
480 | } else { | |
481 | catctr.className = "catCtrNoUnread"; | |
482 | } | |
483 | } | |
484 | continue; | |
485 | } | |
486 | ||
487 | var feedctr = document.getElementById("FEEDCTR-" + id); | |
488 | var feedu = document.getElementById("FEEDU-" + id); | |
489 | var feedr = document.getElementById("FEEDR-" + id); | |
490 | var feed_img = document.getElementById("FIMG-" + id); | |
491 | var feedlink = document.getElementById("FEEDL-" + id); | |
492 | var feedupd = document.getElementById("FLUPD-" + id); | |
493 | ||
494 | if (updated && feedlink) { | |
495 | if (error) { | |
496 | feedlink.title = "Error: " + error + " (" + updated + ")"; | |
497 | } else { | |
498 | feedlink.title = "Updated: " + updated; | |
499 | } | |
500 | } | |
501 | ||
502 | if (feedupd) { | |
503 | if (!updated) updated = ""; | |
504 | ||
505 | if (error) { | |
506 | if (xmsg) { | |
507 | feedupd.innerHTML = updated + " " + xmsg + " (Error)"; | |
508 | } else { | |
509 | feedupd.innerHTML = updated + " (Error)"; | |
510 | } | |
511 | } else { | |
512 | if (xmsg) { | |
513 | feedupd.innerHTML = updated + " " + xmsg; | |
514 | } else { | |
515 | feedupd.innerHTML = updated; | |
516 | } | |
517 | } | |
518 | } | |
519 | ||
520 | if (has_img && feed_img) { | |
521 | if (!feed_img.src.match(id + ".ico")) { | |
522 | feed_img.src = getInitParam("icons_location") + "/" + id + ".ico"; | |
523 | } | |
524 | } | |
525 | ||
526 | if (feedlink && title) { | |
527 | feedlink.innerHTML = title; | |
528 | } | |
529 | ||
530 | if (feedctr && feedu && feedr) { | |
531 | ||
532 | if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) { | |
533 | viewCurrentFeed(); | |
534 | } | |
535 | ||
536 | var row_needs_hl = (ctr > 0 && ctr > parseInt(feedu.innerHTML)); | |
537 | ||
538 | feedu.innerHTML = ctr; | |
539 | ||
540 | if (error) { | |
541 | feedr.className = feedr.className.replace("feed", "error"); | |
542 | } else if (id > 0) { | |
543 | feedr.className = feedr.className.replace("error", "feed"); | |
544 | } | |
545 | ||
546 | if (ctr > 0) { | |
547 | feedctr.className = "feedCtrHasUnread"; | |
548 | if (!feedr.className.match("Unread")) { | |
549 | var is_selected = feedr.className.match("Selected"); | |
550 | ||
551 | feedr.className = feedr.className.replace("Selected", ""); | |
552 | feedr.className = feedr.className.replace("Unread", ""); | |
553 | ||
554 | feedr.className = feedr.className + "Unread"; | |
555 | ||
556 | if (is_selected) { | |
557 | feedr.className = feedr.className + "Selected"; | |
558 | } | |
559 | ||
560 | } | |
561 | ||
562 | if (row_needs_hl) { | |
563 | new Effect.Highlight(feedr, {duration: 1, startcolor: "#fff7d5", | |
564 | queue: { position:'end', scope: 'EFQ-' + id, limit: 1 } } ); | |
565 | } | |
566 | } else { | |
567 | feedctr.className = "feedCtrNoUnread"; | |
568 | feedr.className = feedr.className.replace("Unread", ""); | |
569 | } | |
570 | } | |
571 | } | |
572 | ||
573 | hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); | |
574 | ||
575 | var feeds_stored = number_of_feeds; | |
576 | ||
577 | debug("Feed counters, C: " + feeds_found + ", S:" + feeds_stored); | |
578 | ||
579 | if (feeds_stored != feeds_found) { | |
580 | number_of_feeds = feeds_found; | |
581 | ||
582 | if (feeds_stored != 0 && feeds_found != 0) { | |
583 | debug("Subscribed feed number changed, refreshing feedlist"); | |
584 | setTimeout('updateFeedList(false, false)', 50); | |
585 | } | |
586 | } | |
587 | ||
588 | } catch (e) { | |
589 | exception_error("parse_counters", e); | |
590 | } | |
591 | } | |
592 | ||
593 | function parse_counters_reply(transport, scheduled_call) { | |
594 | ||
595 | if (!transport.responseXML) { | |
596 | notify_error("Backend did not return valid XML", true); | |
597 | return; | |
598 | } | |
599 | ||
600 | var reply = transport.responseXML.firstChild; | |
601 | ||
602 | if (!reply) { | |
603 | notify_error("Backend did not return expected XML object", true); | |
604 | updateTitle(""); | |
605 | return; | |
606 | } | |
607 | ||
608 | var error_code = false; | |
609 | var error_msg = false; | |
610 | ||
611 | if (reply.firstChild) { | |
612 | error_code = reply.firstChild.getAttribute("error-code"); | |
613 | error_msg = reply.firstChild.getAttribute("error-msg"); | |
614 | } | |
615 | ||
616 | if (!error_code) { | |
617 | error_code = reply.getAttribute("error-code"); | |
618 | error_msg = reply.getAttribute("error-msg"); | |
619 | } | |
620 | ||
621 | if (error_code && error_code != 0) { | |
622 | debug("refetch_callback: got error code " + error_code); | |
623 | return fatalError(error_code, error_msg); | |
624 | } | |
625 | ||
626 | var counters = reply.getElementsByTagName("counters")[0]; | |
627 | ||
628 | parse_counters(counters, scheduled_call); | |
629 | ||
630 | var runtime_info = reply.getElementsByTagName("runtime-info")[0]; | |
631 | ||
632 | parse_runtime_info(runtime_info); | |
633 | ||
634 | if (feedsSortByUnread()) { | |
635 | resort_feedlist(); | |
636 | } | |
637 | ||
638 | hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); | |
639 | ||
640 | } | |
641 | ||
642 | function all_counters_callback2(transport, async_call) { | |
643 | try { | |
644 | if (async_call) async_counters_work = true; | |
645 | ||
646 | debug("<b>all_counters_callback2 IN: " + transport + "</b>"); | |
647 | parse_counters_reply(transport); | |
648 | debug("<b>all_counters_callback2 OUT: " + transport + "</b>"); | |
649 | ||
650 | } catch (e) { | |
651 | exception_error("all_counters_callback2", e, transport); | |
652 | } | |
653 | } | |
654 | ||
655 | function get_feed_unread(id) { | |
656 | try { | |
657 | return parseInt(document.getElementById("FEEDU-" + id).innerHTML); | |
658 | } catch (e) { | |
659 | return -1; | |
660 | } | |
661 | } | |
662 | ||
663 | function get_cat_unread(id) { | |
664 | try { | |
665 | var ctr = document.getElementById("FCATCTR-" + id).innerHTML; | |
666 | ctr = ctr.replace("(", ""); | |
667 | ctr = ctr.replace(")", ""); | |
668 | return parseInt(ctr); | |
669 | } catch (e) { | |
670 | return -1; | |
671 | } | |
672 | } | |
673 | ||
674 | function get_feed_entry_unread(elem) { | |
675 | ||
676 | var id = elem.id.replace("FEEDR-", ""); | |
677 | ||
678 | if (id <= 0) { | |
679 | return -1; | |
680 | } | |
681 | ||
682 | try { | |
683 | return parseInt(document.getElementById("FEEDU-" + id).innerHTML); | |
684 | } catch (e) { | |
685 | return -1; | |
686 | } | |
687 | } | |
688 | ||
689 | function get_feed_entry_name(elem) { | |
690 | var id = elem.id.replace("FEEDR-", ""); | |
691 | return getFeedName(id); | |
692 | } | |
693 | ||
694 | ||
695 | function resort_category(node) { | |
696 | ||
697 | try { | |
698 | ||
699 | debug("resort_category: " + node); | |
700 | ||
701 | var by_unread = feedsSortByUnread(); | |
702 | ||
703 | var list = node.getElementsByTagName("LI"); | |
704 | ||
705 | for (i = 0; i < list.length; i++) { | |
706 | ||
707 | for (j = i+1; j < list.length; j++) { | |
708 | ||
709 | var tmp_val = get_feed_entry_unread(list[i]); | |
710 | var cur_val = get_feed_entry_unread(list[j]); | |
711 | ||
712 | var tmp_name = get_feed_entry_name(list[i]); | |
713 | var cur_name = get_feed_entry_name(list[j]); | |
714 | ||
715 | if ((by_unread && (cur_val > tmp_val)) || (!by_unread && (cur_name < tmp_name))) { | |
716 | tempnode_i = list[i].cloneNode(true); | |
717 | tempnode_j = list[j].cloneNode(true); | |
718 | node.replaceChild(tempnode_i, list[j]); | |
719 | node.replaceChild(tempnode_j, list[i]); | |
720 | } | |
721 | } | |
722 | } | |
723 | ||
724 | } catch (e) { | |
725 | exception_error("resort_category", e); | |
726 | } | |
727 | ||
728 | } | |
729 | ||
730 | function resort_feedlist() { | |
731 | debug("resort_feedlist"); | |
732 | ||
733 | if (document.getElementById("FCATLIST--1")) { | |
734 | ||
735 | var lists = document.getElementsByTagName("UL"); | |
736 | ||
737 | for (var i = 0; i < lists.length; i++) { | |
738 | if (lists[i].id && lists[i].id.match("FCATLIST-")) { | |
739 | resort_category(lists[i]); | |
740 | } | |
741 | } | |
742 | ||
743 | } else { | |
744 | resort_category(document.getElementById("feedList")); | |
745 | } | |
746 | } | |
747 | ||
748 | /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj | |
749 | * * @author Sundar Dorai-Raj | |
750 | * * Email: sdoraira@vt.edu | |
751 | * * This program is free software; you can redistribute it and/or | |
752 | * * modify it under the terms of the GNU General Public License | |
753 | * * as published by the Free Software Foundation; either version 2 | |
754 | * * of the License, or (at your option) any later version, | |
755 | * * provided that any use properly credits the author. | |
756 | * * This program is distributed in the hope that it will be useful, | |
757 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
758 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
759 | * * GNU General Public License for more details at http://www.gnu.org * * */ | |
760 | ||
761 | var numbers=".0123456789"; | |
762 | function isNumeric(x) { | |
763 | // is x a String or a character? | |
764 | if(x.length>1) { | |
765 | // remove negative sign | |
766 | x=Math.abs(x)+""; | |
767 | for(j=0;j<x.length;j++) { | |
768 | // call isNumeric recursively for each character | |
769 | number=isNumeric(x.substring(j,j+1)); | |
770 | if(!number) return number; | |
771 | } | |
772 | return number; | |
773 | } | |
774 | else { | |
775 | // if x is number return true | |
776 | if(numbers.indexOf(x)>=0) return true; | |
777 | return false; | |
778 | } | |
779 | } | |
780 | ||
781 | ||
782 | function hideOrShowFeeds(hide) { | |
783 | ||
784 | try { | |
785 | ||
786 | debug("hideOrShowFeeds: " + hide); | |
787 | ||
788 | if (document.getElementById("FCATLIST--1")) { | |
789 | ||
790 | var lists = document.getElementsByTagName("UL"); | |
791 | ||
792 | for (var i = 0; i < lists.length; i++) { | |
793 | if (lists[i].id && lists[i].id.match("FCATLIST-")) { | |
794 | ||
795 | var id = lists[i].id.replace("FCATLIST-", ""); | |
796 | hideOrShowFeedsCategory(id, hide); | |
797 | } | |
798 | } | |
799 | ||
800 | } else { | |
801 | hideOrShowFeedsCategory(null, hide); | |
802 | } | |
803 | ||
804 | } catch (e) { | |
805 | exception_error("hideOrShowFeeds", e); | |
806 | } | |
807 | } | |
808 | ||
809 | function hideOrShowFeedsCategory(id, hide) { | |
810 | ||
811 | try { | |
812 | ||
813 | var node = null; | |
814 | var cat_node = null; | |
815 | ||
816 | if (id) { | |
817 | node = document.getElementById("FCATLIST-" + id); | |
818 | cat_node = document.getElementById("FCAT-" + id); | |
819 | } else { | |
820 | node = document.getElementById("feedList"); // no categories | |
821 | } | |
822 | ||
823 | // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")"); | |
824 | ||
825 | var cat_unread = 0; | |
826 | ||
827 | if (!node) { | |
828 | debug("hideOrShowFeeds: passed node is null, aborting"); | |
829 | return; | |
830 | } | |
831 | ||
832 | // debug("cat: " + node.id); | |
833 | ||
834 | if (node.hasChildNodes() && node.firstChild.nextSibling != false) { | |
835 | for (i = 0; i < node.childNodes.length; i++) { | |
836 | if (node.childNodes[i].nodeName != "LI") { continue; } | |
837 | ||
838 | if (node.childNodes[i].style != undefined) { | |
839 | ||
840 | var has_unread = (node.childNodes[i].className != "feed" && | |
841 | node.childNodes[i].className != "label" && | |
842 | !(!getInitParam("hide_read_shows_special") && | |
843 | node.childNodes[i].className == "virt") && | |
844 | node.childNodes[i].className != "error" && | |
845 | node.childNodes[i].className != "tag"); | |
846 | ||
847 | // debug(node.childNodes[i].id + " --> " + has_unread); | |
848 | ||
849 | if (hide && !has_unread) { | |
850 | //node.childNodes[i].style.display = "none"; | |
851 | var id = node.childNodes[i].id; | |
852 | Effect.Fade(node.childNodes[i], {duration : 0.3, | |
853 | queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }}); | |
854 | } | |
855 | ||
856 | if (!hide) { | |
857 | node.childNodes[i].style.display = "list-item"; | |
858 | //Effect.Appear(node.childNodes[i], {duration : 0.3}); | |
859 | } | |
860 | ||
861 | if (has_unread) { | |
862 | node.childNodes[i].style.display = "list-item"; | |
863 | cat_unread++; | |
864 | //Effect.Appear(node.childNodes[i], {duration : 0.3}); | |
865 | //Effect.Highlight(node.childNodes[i]); | |
866 | } | |
867 | } | |
868 | } | |
869 | } | |
870 | ||
871 | // debug("end cat: " + node.id + " unread " + cat_unread); | |
872 | ||
873 | if (cat_unread == 0) { | |
874 | if (cat_node.style == undefined) { | |
875 | debug("ERROR: supplied cat_node " + cat_node + | |
876 | " has no styles. WTF?"); | |
877 | return; | |
878 | } | |
879 | if (hide) { | |
880 | //cat_node.style.display = "none"; | |
881 | Effect.Fade(cat_node, {duration : 0.3, | |
882 | queue: { position: 'end', scope: 'CFADE-' + node.id, limit: 1 }}); | |
883 | } else { | |
884 | cat_node.style.display = "list-item"; | |
885 | } | |
886 | } else { | |
887 | try { | |
888 | cat_node.style.display = "list-item"; | |
889 | } catch (e) { | |
890 | debug(e); | |
891 | } | |
892 | } | |
893 | ||
894 | // debug("unread for category: " + cat_unread); | |
895 | ||
896 | } catch (e) { | |
897 | exception_error("hideOrShowFeedsCategory", e); | |
898 | } | |
899 | } | |
900 | ||
901 | function selectTableRow(r, do_select) { | |
902 | r.className = r.className.replace("Selected", ""); | |
903 | ||
904 | if (do_select) { | |
905 | r.className = r.className + "Selected"; | |
906 | } | |
907 | } | |
908 | ||
909 | function selectTableRowById(elem_id, check_id, do_select) { | |
910 | ||
911 | try { | |
912 | ||
913 | var row = document.getElementById(elem_id); | |
914 | ||
915 | if (row) { | |
916 | selectTableRow(row, do_select); | |
917 | } | |
918 | ||
919 | var check = document.getElementById(check_id); | |
920 | ||
921 | if (check) { | |
922 | check.checked = do_select; | |
923 | } | |
924 | } catch (e) { | |
925 | exception_error("selectTableRowById", e); | |
926 | } | |
927 | } | |
928 | ||
929 | function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select, | |
930 | classcheck, reset_others) { | |
931 | ||
932 | var content = document.getElementById(content_id); | |
933 | ||
934 | if (!content) { | |
935 | alert("[selectTableRows] Element " + content_id + " not found."); | |
936 | return; | |
937 | } | |
938 | ||
939 | for (i = 0; i < content.rows.length; i++) { | |
940 | if (Element.visible(content.rows[i])) { | |
941 | if (!classcheck || content.rows[i].className.match(classcheck)) { | |
942 | ||
943 | if (content.rows[i].id.match(prefix)) { | |
944 | selectTableRow(content.rows[i], do_select); | |
945 | ||
946 | var row_id = content.rows[i].id.replace(prefix, ""); | |
947 | var check = document.getElementById(check_prefix + row_id); | |
948 | ||
949 | if (check) { | |
950 | check.checked = do_select; | |
951 | } | |
952 | } else if (reset_others) { | |
953 | selectTableRow(content.rows[i], false); | |
954 | ||
955 | var row_id = content.rows[i].id.replace(prefix, ""); | |
956 | var check = document.getElementById(check_prefix + row_id); | |
957 | ||
958 | if (check) { | |
959 | check.checked = false; | |
960 | } | |
961 | ||
962 | } | |
963 | } else if (reset_others) { | |
964 | selectTableRow(content.rows[i], false); | |
965 | ||
966 | var row_id = content.rows[i].id.replace(prefix, ""); | |
967 | var check = document.getElementById(check_prefix + row_id); | |
968 | ||
969 | if (check) { | |
970 | check.checked = false; | |
971 | } | |
972 | ||
973 | } | |
974 | } | |
975 | } | |
976 | } | |
977 | ||
978 | function getSelectedTableRowIds(content_id, prefix) { | |
979 | ||
980 | var content = document.getElementById(content_id); | |
981 | ||
982 | if (!content) { | |
983 | alert("[getSelectedTableRowIds] Element " + content_id + " not found."); | |
984 | return; | |
985 | } | |
986 | ||
987 | var sel_rows = new Array(); | |
988 | ||
989 | for (i = 0; i < content.rows.length; i++) { | |
990 | if (content.rows[i].id.match(prefix) && | |
991 | content.rows[i].className.match("Selected")) { | |
992 | ||
993 | var row_id = content.rows[i].id.replace(prefix + "-", ""); | |
994 | sel_rows.push(row_id); | |
995 | } | |
996 | } | |
997 | ||
998 | return sel_rows; | |
999 | ||
1000 | } | |
1001 | ||
1002 | function toggleSelectRowById(sender, id) { | |
1003 | var row = document.getElementById(id); | |
1004 | ||
1005 | if (sender.checked) { | |
1006 | if (!row.className.match("Selected")) { | |
1007 | row.className = row.className + "Selected"; | |
1008 | } | |
1009 | } else { | |
1010 | if (row.className.match("Selected")) { | |
1011 | row.className = row.className.replace("Selected", ""); | |
1012 | } | |
1013 | } | |
1014 | } | |
1015 | ||
1016 | function toggleSelectListRow(sender) { | |
1017 | var parent_row = sender.parentNode; | |
1018 | ||
1019 | if (sender.checked) { | |
1020 | if (!parent_row.className.match("Selected")) { | |
1021 | parent_row.className = parent_row.className + "Selected"; | |
1022 | } | |
1023 | } else { | |
1024 | if (parent_row.className.match("Selected")) { | |
1025 | parent_row.className = parent_row.className.replace("Selected", ""); | |
1026 | } | |
1027 | } | |
1028 | } | |
1029 | ||
1030 | function tSR(sender) { | |
1031 | return toggleSelectRow(sender); | |
1032 | } | |
1033 | ||
1034 | function toggleSelectRow(sender) { | |
1035 | var parent_row = sender.parentNode.parentNode; | |
1036 | ||
1037 | if (sender.checked) { | |
1038 | if (!parent_row.className.match("Selected")) { | |
1039 | parent_row.className = parent_row.className + "Selected"; | |
1040 | } | |
1041 | } else { | |
1042 | if (parent_row.className.match("Selected")) { | |
1043 | parent_row.className = parent_row.className.replace("Selected", ""); | |
1044 | } | |
1045 | } | |
1046 | } | |
1047 | ||
1048 | function getNextUnreadCat(id) { | |
1049 | try { | |
1050 | var rows = document.getElementById("feedList").getElementsByTagName("LI"); | |
1051 | var feeds = new Array(); | |
1052 | ||
1053 | var unread_only = true; | |
1054 | var is_cat = true; | |
1055 | ||
1056 | for (var i = 0; i < rows.length; i++) { | |
1057 | if (rows[i].id.match("FCAT-")) { | |
1058 | if (rows[i].id == "FCAT-" + id && is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) { | |
1059 | ||
1060 | var cat_id = parseInt(rows[i].id.replace("FCAT-", "")); | |
1061 | ||
1062 | if (cat_id >= 0) { | |
1063 | if (!unread_only || get_cat_unread(cat_id) > 0) { | |
1064 | feeds.push(cat_id); | |
1065 | } | |
1066 | } | |
1067 | } | |
1068 | } | |
1069 | } | |
1070 | ||
1071 | var idx = feeds.indexOf(id); | |
1072 | if (idx != -1 && idx < feeds.length) { | |
1073 | return feeds[idx+1]; | |
1074 | } else { | |
1075 | return feeds.shift(); | |
1076 | } | |
1077 | ||
1078 | } catch (e) { | |
1079 | exception_error("getNextUnreadCat", e); | |
1080 | } | |
1081 | } | |
1082 | ||
1083 | function getRelativeFeedId2(id, is_cat, direction, unread_only) { | |
1084 | try { | |
1085 | ||
1086 | // alert(id + " IC: " + is_cat + " D: " + direction + " U: " + unread_only); | |
1087 | ||
1088 | var rows = document.getElementById("feedList").getElementsByTagName("LI"); | |
1089 | var feeds = new Array(); | |
1090 | ||
1091 | for (var i = 0; i < rows.length; i++) { | |
1092 | if (rows[i].id.match("FEEDR-")) { | |
1093 | ||
1094 | if (rows[i].id == "FEEDR-" + id && !is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) { | |
1095 | ||
1096 | if (!unread_only || | |
1097 | (rows[i].className.match("Unread") || rows[i].id == "FEEDR-" + id)) { | |
1098 | feeds.push(rows[i].id.replace("FEEDR-", "")); | |
1099 | } | |
1100 | } | |
1101 | } | |
1102 | ||
1103 | if (rows[i].id.match("FCAT-")) { | |
1104 | if (rows[i].id == "FCAT-" + id && is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) { | |
1105 | ||
1106 | var cat_id = parseInt(rows[i].id.replace("FCAT-", "")); | |
1107 | ||
1108 | if (cat_id >= 0) { | |
1109 | if (!unread_only || get_cat_unread(cat_id) > 0) { | |
1110 | feeds.push("CAT:"+cat_id); | |
1111 | } | |
1112 | } | |
1113 | } | |
1114 | } | |
1115 | } | |
1116 | ||
1117 | // alert(feeds.toString()); | |
1118 | ||
1119 | if (!id) { | |
1120 | if (direction == "next") { | |
1121 | return feeds.shift(); | |
1122 | } else { | |
1123 | return feeds.pop(); | |
1124 | } | |
1125 | } else { | |
1126 | if (direction == "next") { | |
1127 | if (is_cat) id = "CAT:" + id; | |
1128 | var idx = feeds.indexOf(id); | |
1129 | if (idx != -1 && idx < feeds.length) { | |
1130 | return feeds[idx+1]; | |
1131 | } else { | |
1132 | return getRelativeFeedId2(false, is_cat, direction, unread_only); | |
1133 | } | |
1134 | } else { | |
1135 | if (is_cat) id = "CAT:" + id; | |
1136 | var idx = feeds.indexOf(id); | |
1137 | if (idx > 0) { | |
1138 | return feeds[idx-1]; | |
1139 | } else { | |
1140 | return getRelativeFeedId2(false, is_cat, direction, unread_only); | |
1141 | } | |
1142 | } | |
1143 | ||
1144 | } | |
1145 | ||
1146 | } catch (e) { | |
1147 | exception_error("getRelativeFeedId2", e); | |
1148 | } | |
1149 | } | |
1150 | ||
1151 | ||
1152 | function getRelativeFeedId(list, id, direction, unread_only) { | |
1153 | var rows = list.getElementsByTagName("LI"); | |
1154 | var feeds = new Array(); | |
1155 | ||
1156 | for (var i = 0; i < rows.length; i++) { | |
1157 | if (rows[i].id.match("FEEDR-")) { | |
1158 | ||
1159 | if (rows[i].id == "FEEDR-" + id || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) { | |
1160 | ||
1161 | if (!unread_only || | |
1162 | (rows[i].className.match("Unread") || rows[i].id == "FEEDR-" + id)) { | |
1163 | feeds.push(rows[i].id.replace("FEEDR-", "")); | |
1164 | } | |
1165 | } | |
1166 | } | |
1167 | } | |
1168 | ||
1169 | if (!id) { | |
1170 | if (direction == "next") { | |
1171 | return feeds.shift(); | |
1172 | } else { | |
1173 | return feeds.pop(); | |
1174 | } | |
1175 | } else { | |
1176 | if (direction == "next") { | |
1177 | var idx = feeds.indexOf(id); | |
1178 | if (idx != -1 && idx < feeds.length) { | |
1179 | return feeds[idx+1]; | |
1180 | } else { | |
1181 | return getRelativeFeedId(list, false, direction, unread_only); | |
1182 | } | |
1183 | } else { | |
1184 | var idx = feeds.indexOf(id); | |
1185 | if (idx > 0) { | |
1186 | return feeds[idx-1]; | |
1187 | } else { | |
1188 | return getRelativeFeedId(list, false, direction, unread_only); | |
1189 | } | |
1190 | } | |
1191 | ||
1192 | } | |
1193 | } | |
1194 | ||
1195 | function showBlockElement(id, h_id) { | |
1196 | var elem = document.getElementById(id); | |
1197 | ||
1198 | if (elem) { | |
1199 | elem.style.display = "block"; | |
1200 | ||
1201 | if (h_id) { | |
1202 | elem = document.getElementById(h_id); | |
1203 | if (elem) { | |
1204 | elem.style.display = "none"; | |
1205 | } | |
1206 | } | |
1207 | } else { | |
1208 | alert("[showBlockElement] can't find element with id " + id); | |
1209 | } | |
1210 | } | |
1211 | ||
1212 | function appearBlockElement_afh(effect) { | |
1213 | ||
1214 | } | |
1215 | ||
1216 | function checkboxToggleElement(elem, id) { | |
1217 | if (elem.checked) { | |
1218 | Effect.Appear(id, {duration : 0.5}); | |
1219 | } else { | |
1220 | Effect.Fade(id, {duration : 0.5}); | |
1221 | } | |
1222 | } | |
1223 | ||
1224 | function appearBlockElement(id, h_id) { | |
1225 | ||
1226 | try { | |
1227 | if (h_id) { | |
1228 | Effect.Fade(h_id); | |
1229 | } | |
1230 | Effect.SlideDown(id, {duration : 1.0, afterFinish: appearBlockElement_afh}); | |
1231 | } catch (e) { | |
1232 | exception_error("appearBlockElement", e); | |
1233 | } | |
1234 | ||
1235 | } | |
1236 | ||
1237 | function hideParentElement(e) { | |
1238 | e.parentNode.style.display = "none"; | |
1239 | } | |
1240 | ||
1241 | function dropboxSelect(e, v) { | |
1242 | for (i = 0; i < e.length; i++) { | |
1243 | if (e[i].value == v) { | |
1244 | e.selectedIndex = i; | |
1245 | break; | |
1246 | } | |
1247 | } | |
1248 | } | |
1249 | ||
1250 | // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z | |
1251 | // bugfixed just a little bit :-) | |
1252 | function getURLParam(strParamName){ | |
1253 | var strReturn = ""; | |
1254 | var strHref = window.location.href; | |
1255 | ||
1256 | if (strHref.indexOf("#") == strHref.length-1) { | |
1257 | strHref = strHref.substring(0, strHref.length-1); | |
1258 | } | |
1259 | ||
1260 | if ( strHref.indexOf("?") > -1 ){ | |
1261 | var strQueryString = strHref.substr(strHref.indexOf("?")); | |
1262 | var aQueryString = strQueryString.split("&"); | |
1263 | for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){ | |
1264 | if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){ | |
1265 | var aParam = aQueryString[iParam].split("="); | |
1266 | strReturn = aParam[1]; | |
1267 | break; | |
1268 | } | |
1269 | } | |
1270 | } | |
1271 | return strReturn; | |
1272 | } | |
1273 | ||
1274 | function leading_zero(p) { | |
1275 | var s = String(p); | |
1276 | if (s.length == 1) s = "0" + s; | |
1277 | return s; | |
1278 | } | |
1279 | ||
1280 | function closeErrorBox() { | |
1281 | ||
1282 | if (Element.visible("errorBoxShadow")) { | |
1283 | Element.hide("dialog_overlay"); | |
1284 | Element.hide("errorBoxShadow"); | |
1285 | ||
1286 | enableHotkeys(); | |
1287 | } | |
1288 | ||
1289 | return false; | |
1290 | } | |
1291 | ||
1292 | function closeInfoBox(cleanup) { | |
1293 | ||
1294 | if (Element.visible("infoBoxShadow")) { | |
1295 | Element.hide("dialog_overlay"); | |
1296 | ||
1297 | var shadow = document.getElementById('infoBoxShadow'); | |
1298 | var box = document.getElementById('infoBoxShadow'); | |
1299 | ||
1300 | Element.hide(shadow); | |
1301 | ||
1302 | if (cleanup) box.innerHTML = " "; | |
1303 | ||
1304 | enableHotkeys(); | |
1305 | } | |
1306 | ||
1307 | return false; | |
1308 | } | |
1309 | ||
1310 | ||
1311 | function displayDlg(id, param) { | |
1312 | ||
1313 | notify_progress("Loading, please wait...", true); | |
1314 | ||
1315 | disableHotkeys(); | |
1316 | ||
1317 | var query = "backend.php?op=dlg&id=" + | |
1318 | param_escape(id) + "¶m=" + param_escape(param); | |
1319 | ||
1320 | new Ajax.Request(query, { | |
1321 | onComplete: function (transport) { | |
1322 | infobox_callback2(transport); | |
1323 | } }); | |
1324 | ||
1325 | return false; | |
1326 | } | |
1327 | ||
1328 | function infobox_submit_callback2(transport) { | |
1329 | closeInfoBox(); | |
1330 | ||
1331 | try { | |
1332 | // called from prefs, reload tab | |
1333 | if (typeof active_tab != 'undefined' && active_tab) { | |
1334 | selectTab(active_tab, false); | |
1335 | } | |
1336 | } catch (e) { } | |
1337 | ||
1338 | if (transport.responseText) { | |
1339 | notify_info(transport.responseText); | |
1340 | } | |
1341 | } | |
1342 | ||
1343 | function infobox_callback2(transport) { | |
1344 | try { | |
1345 | ||
1346 | debug("infobox_callback2"); | |
1347 | ||
1348 | if (!getInitParam("infobox_disable_overlay")) { | |
1349 | Element.show("dialog_overlay"); | |
1350 | } | |
1351 | ||
1352 | var box = document.getElementById('infoBox'); | |
1353 | var shadow = document.getElementById('infoBoxShadow'); | |
1354 | if (box) { | |
1355 | ||
1356 | box.innerHTML=transport.responseText; | |
1357 | if (shadow) { | |
1358 | shadow.style.display = "block"; | |
1359 | } else { | |
1360 | box.style.display = "block"; | |
1361 | } | |
1362 | } | |
1363 | ||
1364 | /* FIXME this needs to be moved out somewhere */ | |
1365 | ||
1366 | if (document.getElementById("tags_choices")) { | |
1367 | new Ajax.Autocompleter('tags_str', 'tags_choices', | |
1368 | "backend.php?op=rpc&subop=completeTags", | |
1369 | { tokens: ',', paramName: "search" }); | |
1370 | } | |
1371 | ||
1372 | disableHotkeys(); | |
1373 | ||
1374 | notify(""); | |
1375 | } catch (e) { | |
1376 | exception_error("infobox_callback2", e); | |
1377 | } | |
1378 | } | |
1379 | ||
1380 | function createFilter() { | |
1381 | ||
1382 | try { | |
1383 | ||
1384 | var form = document.forms['filter_add_form']; | |
1385 | var reg_exp = form.reg_exp.value; | |
1386 | ||
1387 | if (reg_exp == "") { | |
1388 | alert(__("Can't add filter: nothing to match on.")); | |
1389 | return false; | |
1390 | } | |
1391 | ||
1392 | var query = Form.serialize("filter_add_form"); | |
1393 | ||
1394 | // we can be called from some other tab in Prefs | |
1395 | if (typeof active_tab != 'undefined' && active_tab) { | |
1396 | active_tab = "filterConfig"; | |
1397 | } | |
1398 | ||
1399 | new Ajax.Request("backend.php?" + query, { | |
1400 | onComplete: function (transport) { | |
1401 | infobox_submit_callback2(transport); | |
1402 | } }); | |
1403 | ||
1404 | return true; | |
1405 | ||
1406 | } catch (e) { | |
1407 | exception_error("createFilter", e); | |
1408 | } | |
1409 | } | |
1410 | ||
1411 | function toggleSubmitNotEmpty(e, submit_id) { | |
1412 | try { | |
1413 | document.getElementById(submit_id).disabled = (e.value == "") | |
1414 | } catch (e) { | |
1415 | exception_error("toggleSubmitNotEmpty", e); | |
1416 | } | |
1417 | } | |
1418 | ||
1419 | function isValidURL(s) { | |
1420 | return s.match("http://") != null || s.match("https://") != null || s.match("feed://") != null; | |
1421 | } | |
1422 | ||
1423 | function subscribeToFeed() { | |
1424 | ||
1425 | var form = document.forms['feed_add_form']; | |
1426 | var feed_url = form.feed_url.value; | |
1427 | ||
1428 | if (feed_url == "") { | |
1429 | alert(__("Can't subscribe: no feed URL given.")); | |
1430 | return false; | |
1431 | } | |
1432 | ||
1433 | notify_progress(__("Subscribing to feed..."), true); | |
1434 | ||
1435 | closeInfoBox(); | |
1436 | ||
1437 | var feeds_doc = document; | |
1438 | ||
1439 | // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait..."; | |
1440 | ||
1441 | var query = Form.serialize("feed_add_form"); | |
1442 | ||
1443 | debug("subscribe q: " + query); | |
1444 | ||
1445 | new Ajax.Request("backend.php", { | |
1446 | parameters: query, | |
1447 | onComplete: function(transport) { | |
1448 | dlg_frefresh_callback(transport); | |
1449 | } }); | |
1450 | ||
1451 | return false; | |
1452 | } | |
1453 | ||
1454 | function filterCR(e, f) | |
1455 | { | |
1456 | var key; | |
1457 | ||
1458 | if(window.event) | |
1459 | key = window.event.keyCode; //IE | |
1460 | else | |
1461 | key = e.which; //firefox | |
1462 | ||
1463 | if (key == 13) { | |
1464 | if (typeof f != 'undefined') { | |
1465 | f(); | |
1466 | return false; | |
1467 | } else { | |
1468 | return false; | |
1469 | } | |
1470 | } else { | |
1471 | return true; | |
1472 | } | |
1473 | } | |
1474 | ||
1475 | var debug_last_class = "even"; | |
1476 | ||
1477 | function debug(msg) { | |
1478 | ||
1479 | if (debug_last_class == "even") { | |
1480 | debug_last_class = "odd"; | |
1481 | } else { | |
1482 | debug_last_class = "even"; | |
1483 | } | |
1484 | ||
1485 | var c = document.getElementById('debug_output'); | |
1486 | if (c && Element.visible(c)) { | |
1487 | while (c.lastChild != 'undefined' && c.childNodes.length > 100) { | |
1488 | c.removeChild(c.lastChild); | |
1489 | } | |
1490 | ||
1491 | var d = new Date(); | |
1492 | var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) + | |
1493 | ":" + leading_zero(d.getSeconds()); | |
1494 | c.innerHTML = "<li class=\"" + debug_last_class + "\"><span class=\"debugTS\">[" + ts + "]</span> " + | |
1495 | msg + "</li>" + c.innerHTML; | |
1496 | } | |
1497 | } | |
1498 | ||
1499 | function getInitParam(key) { | |
1500 | return init_params[key]; | |
1501 | } | |
1502 | ||
1503 | function storeInitParam(key, value) { | |
1504 | debug("<b>storeInitParam is OBSOLETE: " + key + " => " + value + "</b>"); | |
1505 | init_params[key] = value; | |
1506 | } | |
1507 | ||
1508 | function fatalError(code, msg, ext_info) { | |
1509 | try { | |
1510 | ||
1511 | if (code == 6) { | |
1512 | window.location.href = "tt-rss.php"; | |
1513 | } else if (code == 5) { | |
1514 | window.location.href = "update.php"; | |
1515 | } else { | |
1516 | ||
1517 | if (msg == "") msg = "Unknown error"; | |
1518 | ||
1519 | var ebc = document.getElementById("xebContent"); | |
1520 | ||
1521 | if (ebc) { | |
1522 | ||
1523 | Element.show("dialog_overlay"); | |
1524 | Element.show("errorBoxShadow"); | |
1525 | Element.hide("xebBtn"); | |
1526 | ||
1527 | if (ext_info) { | |
1528 | if (ext_info.responseText) { | |
1529 | ext_info = ext_info.responseText; | |
1530 | } | |
1531 | } | |
1532 | ||
1533 | ebc.innerHTML = | |
1534 | "<div><b>Error message:</b></div>" + | |
1535 | "<pre>" + msg + "</pre>" + | |
1536 | "<div><b>Additional information:</b></div>" + | |
1537 | "<textarea readonly=\"1\">" + ext_info + "</textarea>"; | |
1538 | } | |
1539 | } | |
1540 | ||
1541 | } catch (e) { | |
1542 | exception_error("fatalError", e); | |
1543 | } | |
1544 | } | |
1545 | ||
1546 | function getFeedName(id, is_cat) { | |
1547 | var e; | |
1548 | ||
1549 | if (is_cat) { | |
1550 | e = document.getElementById("FCATN-" + id); | |
1551 | } else { | |
1552 | e = document.getElementById("FEEDN-" + id); | |
1553 | } | |
1554 | if (e) { | |
1555 | return e.innerHTML.stripTags(); | |
1556 | } else { | |
1557 | return null; | |
1558 | } | |
1559 | } | |
1560 | ||
1561 | function filterDlgCheckType(sender) { | |
1562 | ||
1563 | try { | |
1564 | ||
1565 | var ftype = sender[sender.selectedIndex].value; | |
1566 | ||
1567 | var form = document.forms["filter_add_form"]; | |
1568 | ||
1569 | if (!form) { | |
1570 | form = document.forms["filter_edit_form"]; | |
1571 | } | |
1572 | ||
1573 | if (!form) { | |
1574 | debug("filterDlgCheckType: can't find form!"); | |
1575 | return; | |
1576 | } | |
1577 | ||
1578 | // if selected filter type is 5 (Date) enable the modifier dropbox | |
1579 | if (ftype == 5) { | |
1580 | Element.show("filter_dlg_date_mod_box"); | |
1581 | Element.show("filter_dlg_date_chk_box"); | |
1582 | } else { | |
1583 | Element.hide("filter_dlg_date_mod_box"); | |
1584 | Element.hide("filter_dlg_date_chk_box"); | |
1585 | ||
1586 | } | |
1587 | ||
1588 | } catch (e) { | |
1589 | exception_error("filterDlgCheckType", e); | |
1590 | } | |
1591 | ||
1592 | } | |
1593 | ||
1594 | function filterDlgCheckAction(sender) { | |
1595 | ||
1596 | try { | |
1597 | ||
1598 | var action = sender[sender.selectedIndex].value; | |
1599 | ||
1600 | var form = document.forms["filter_add_form"]; | |
1601 | ||
1602 | if (!form) { | |
1603 | form = document.forms["filter_edit_form"]; | |
1604 | } | |
1605 | ||
1606 | if (!form) { | |
1607 | debug("filterDlgCheckAction: can't find form!"); | |
1608 | return; | |
1609 | } | |
1610 | ||
1611 | var action_param = document.getElementById("filter_dlg_param_box"); | |
1612 | ||
1613 | if (!action_param) { | |
1614 | debug("filterDlgCheckAction: can't find action param box!"); | |
1615 | return; | |
1616 | } | |
1617 | ||
1618 | // if selected action supports parameters, enable params field | |
1619 | if (action == 4 || action == 6 || action == 7) { | |
1620 | Element.show(action_param); | |
1621 | if (action != 7) { | |
1622 | Element.show(form.action_param); | |
1623 | Element.hide(form.action_param_label); | |
1624 | } else { | |
1625 | Element.show(form.action_param_label); | |
1626 | Element.hide(form.action_param); | |
1627 | } | |
1628 | } else { | |
1629 | Element.hide(action_param); | |
1630 | } | |
1631 | ||
1632 | } catch (e) { | |
1633 | exception_error("filterDlgCheckAction", e); | |
1634 | } | |
1635 | ||
1636 | } | |
1637 | ||
1638 | function filterDlgCheckDate() { | |
1639 | try { | |
1640 | var form = document.forms["filter_add_form"]; | |
1641 | ||
1642 | if (!form) { | |
1643 | form = document.forms["filter_edit_form"]; | |
1644 | } | |
1645 | ||
1646 | if (!form) { | |
1647 | debug("filterDlgCheckAction: can't find form!"); | |
1648 | return; | |
1649 | } | |
1650 | ||
1651 | var reg_exp = form.reg_exp.value; | |
1652 | ||
1653 | var query = "backend.php?op=rpc&subop=checkDate&date=" + reg_exp; | |
1654 | ||
1655 | new Ajax.Request(query, { | |
1656 | onComplete: function(transport) { | |
1657 | ||
1658 | var form = document.forms["filter_add_form"]; | |
1659 | ||
1660 | if (!form) { | |
1661 | form = document.forms["filter_edit_form"]; | |
1662 | } | |
1663 | ||
1664 | if (transport.responseXML) { | |
1665 | var result = transport.responseXML.getElementsByTagName("result")[0]; | |
1666 | ||
1667 | if (result && result.firstChild) { | |
1668 | if (result.firstChild.nodeValue == "1") { | |
1669 | ||
1670 | new Effect.Highlight(form.reg_exp, {startcolor : '#00ff00'}); | |
1671 | ||
1672 | return; | |
1673 | } | |
1674 | } | |
1675 | } | |
1676 | ||
1677 | new Effect.Highlight(form.reg_exp, {startcolor : '#ff0000'}); | |
1678 | ||
1679 | } }); | |
1680 | ||
1681 | ||
1682 | } catch (e) { | |
1683 | exception_error("filterDlgCheckDate", e); | |
1684 | } | |
1685 | } | |
1686 | ||
1687 | function explainError(code) { | |
1688 | return displayDlg("explainError", code); | |
1689 | } | |
1690 | ||
1691 | // this only searches loaded headlines list, not in CDM | |
1692 | function getRelativePostIds(id, limit) { | |
1693 | ||
1694 | if (!limit) limit = 3; | |
1695 | ||
1696 | debug("getRelativePostIds: " + id + " limit=" + limit); | |
1697 | ||
1698 | var ids = new Array(); | |
1699 | var container = document.getElementById("headlinesList"); | |
1700 | ||
1701 | if (container) { | |
1702 | var rows = container.rows; | |
1703 | ||
1704 | for (var i = 0; i < rows.length; i++) { | |
1705 | var r_id = rows[i].id.replace("RROW-", ""); | |
1706 | ||
1707 | if (r_id == id) { | |
1708 | for (var k = 1; k <= limit; k++) { | |
1709 | var nid = false; | |
1710 | ||
1711 | if (i > k-1) var nid = rows[i-k].id.replace("RROW-", ""); | |
1712 | if (nid) ids.push(nid); | |
1713 | ||
1714 | if (i < rows.length-k) nid = rows[i+k].id.replace("RROW-", ""); | |
1715 | if (nid) ids.push(nid); | |
1716 | } | |
1717 | ||
1718 | return ids; | |
1719 | } | |
1720 | } | |
1721 | } | |
1722 | ||
1723 | return false; | |
1724 | } | |
1725 | ||
1726 | function openArticleInNewWindow(id) { | |
1727 | try { | |
1728 | debug("openArticleInNewWindow: " + id); | |
1729 | ||
1730 | var query = "backend.php?op=rpc&subop=getArticleLink&id=" + id; | |
1731 | var wname = "ttrss_article_" + id; | |
1732 | ||
1733 | debug(query + " " + wname); | |
1734 | ||
1735 | var w = window.open("", wname); | |
1736 | ||
1737 | if (!w) notify_error("Failed to open window for the article"); | |
1738 | ||
1739 | new Ajax.Request(query, { | |
1740 | onComplete: function(transport) { | |
1741 | open_article_callback(transport); | |
1742 | } }); | |
1743 | ||
1744 | ||
1745 | } catch (e) { | |
1746 | exception_error("openArticleInNewWindow", e); | |
1747 | } | |
1748 | } | |
1749 | ||
1750 | /* http://textsnippets.com/posts/show/835 */ | |
1751 | ||
1752 | Position.GetWindowSize = function(w) { | |
1753 | w = w ? w : window; | |
1754 | var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth); | |
1755 | var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight); | |
1756 | return [width, height] | |
1757 | } | |
1758 | ||
1759 | /* http://textsnippets.com/posts/show/836 */ | |
1760 | ||
1761 | Position.Center = function(element, parent) { | |
1762 | var w, h, pw, ph; | |
1763 | var d = Element.getDimensions(element); | |
1764 | w = d.width; | |
1765 | h = d.height; | |
1766 | Position.prepare(); | |
1767 | if (!parent) { | |
1768 | var ws = Position.GetWindowSize(); | |
1769 | pw = ws[0]; | |
1770 | ph = ws[1]; | |
1771 | } else { | |
1772 | pw = parent.offsetWidth; | |
1773 | ph = parent.offsetHeight; | |
1774 | } | |
1775 | element.style.top = (ph/2) - (h/2) - Position.deltaY + "px"; | |
1776 | element.style.left = (pw/2) - (w/2) - Position.deltaX + "px"; | |
1777 | } | |
1778 | ||
1779 | ||
1780 | function labeltest_callback(transport) { | |
1781 | try { | |
1782 | var container = document.getElementById('label_test_result'); | |
1783 | ||
1784 | container.innerHTML = transport.responseText; | |
1785 | if (!Element.visible(container)) { | |
1786 | Effect.SlideDown(container, { duration : 0.5 }); | |
1787 | } | |
1788 | ||
1789 | notify(""); | |
1790 | } catch (e) { | |
1791 | exception_error("labeltest_callback", e); | |
1792 | } | |
1793 | } | |
1794 | ||
1795 | function labelTest() { | |
1796 | ||
1797 | try { | |
1798 | var container = document.getElementById('label_test_result'); | |
1799 | ||
1800 | var form = document.forms['label_edit_form']; | |
1801 | ||
1802 | var sql_exp = form.sql_exp.value; | |
1803 | var description = form.description.value; | |
1804 | ||
1805 | notify_progress("Loading, please wait..."); | |
1806 | ||
1807 | var query = "backend.php?op=pref-labels&subop=test&expr=" + | |
1808 | param_escape(sql_exp) + "&descr=" + param_escape(description); | |
1809 | ||
1810 | new Ajax.Request(query, { | |
1811 | onComplete: function (transport) { | |
1812 | labeltest_callback(transport); | |
1813 | } }); | |
1814 | ||
1815 | return false; | |
1816 | ||
1817 | } catch (e) { | |
1818 | exception_error("labelTest", e); | |
1819 | } | |
1820 | } | |
1821 | ||
1822 | function isCdmMode() { | |
1823 | return !document.getElementById("headlinesList"); | |
1824 | } | |
1825 | ||
1826 | function getSelectedArticleIds2() { | |
1827 | var rows = new Array(); | |
1828 | var cdm_mode = isCdmMode(); | |
1829 | ||
1830 | if (cdm_mode) { | |
1831 | rows = cdmGetSelectedArticles(); | |
1832 | } else { | |
1833 | rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK"); | |
1834 | } | |
1835 | ||
1836 | var ids = new Array(); | |
1837 | ||
1838 | for (var i = 0; i < rows.length; i++) { | |
1839 | var chk = document.getElementById("RCHK-" + rows[i]); | |
1840 | if (chk && chk.checked) { | |
1841 | ids.push(rows[i]); | |
1842 | } | |
1843 | } | |
1844 | ||
1845 | return ids; | |
1846 | } | |
1847 | ||
1848 | function displayHelpInfobox(topic_id) { | |
1849 | ||
1850 | var url = "backend.php?op=help&tid=" + param_escape(topic_id); | |
1851 | ||
1852 | var w = window.open(url, "ttrss_help", | |
1853 | "status=0,toolbar=0,location=0,width=450,height=500,scrollbars=1,menubar=0"); | |
1854 | ||
1855 | return false; | |
1856 | } | |
1857 | ||
1858 | function focus_element(id) { | |
1859 | try { | |
1860 | var e = document.getElementById(id); | |
1861 | if (e) e.focus(); | |
1862 | } catch (e) { | |
1863 | exception_error("focus_element", e); | |
1864 | } | |
1865 | return false; | |
1866 | } | |
1867 | ||
1868 | function loading_set_progress(p) { | |
1869 | try { | |
1870 | if (p < last_progress_point || !Element.visible("overlay")) return; | |
1871 | ||
1872 | debug("<b>loading_set_progress : " + p + " (" + last_progress_point + ")</b>"); | |
1873 | ||
1874 | var o = document.getElementById("l_progress_i"); | |
1875 | ||
1876 | // o.style.width = (p * 2) + "px"; | |
1877 | ||
1878 | new Effect.Scale(o, p, { | |
1879 | scaleY : false, | |
1880 | scaleFrom : last_progress_point, | |
1881 | scaleMode: { originalWidth : 200 }, | |
1882 | queue: { position: 'end', scope: 'LSP-Q', limit: 3 } }); | |
1883 | ||
1884 | last_progress_point = p; | |
1885 | ||
1886 | } catch (e) { | |
1887 | exception_error("loading_set_progress", e); | |
1888 | } | |
1889 | } | |
1890 | ||
1891 | function remove_splash() { | |
1892 | if (Element.visible("overlay")) { | |
1893 | debug("about to remove splash, OMG!"); | |
1894 | Element.hide("overlay"); | |
1895 | debug("removed splash!"); | |
1896 | } | |
1897 | } | |
1898 | ||
1899 | function addLabelExample() { | |
1900 | try { | |
1901 | var form = document.forms["label_edit_form"]; | |
1902 | ||
1903 | var text = form.sql_exp; | |
1904 | var op = form.label_fields[form.label_fields.selectedIndex]; | |
1905 | var p = form.label_fields_param; | |
1906 | ||
1907 | if (op) { | |
1908 | op = op.value; | |
1909 | ||
1910 | var tmp = ""; | |
1911 | ||
1912 | if (text.value != "") { | |
1913 | if (text.value.substring(text.value.length-3, 3).toUpperCase() != "AND") { | |
1914 | tmp = " AND "; | |
1915 | } else { | |
1916 | tmp = " "; | |
1917 | } | |
1918 | } | |
1919 | ||
1920 | if (op == "unread") { | |
1921 | tmp = tmp + "unread = true"; | |
1922 | } | |
1923 | ||
1924 | if (op == "updated") { | |
1925 | tmp = tmp + "last_read is null and unread = false"; | |
1926 | } | |
1927 | ||
1928 | if (op == "kw_title") { | |
1929 | if (p.value == "") { | |
1930 | alert("This action requires a parameter."); | |
1931 | return false; | |
1932 | } | |
1933 | tmp = tmp + "ttrss_entries.title like '%"+p.value+"%'"; | |
1934 | } | |
1935 | ||
1936 | if (op == "kw_content") { | |
1937 | if (p.value == "") { | |
1938 | alert("This action requires a parameter."); | |
1939 | return false; | |
1940 | } | |
1941 | ||
1942 | tmp = tmp + "ttrss_entries.content like '%"+p.value+"%'"; | |
1943 | } | |
1944 | ||
1945 | if (op == "scoreE") { | |
1946 | if (isNaN(parseInt(p.value))) { | |
1947 | alert("This action expects numeric parameter."); | |
1948 | return false; | |
1949 | } | |
1950 | tmp = tmp + "score = " + p.value; | |
1951 | } | |
1952 | ||
1953 | if (op == "scoreG") { | |
1954 | if (isNaN(parseInt(p.value))) { | |
1955 | alert("This action expects numeric parameter."); | |
1956 | return false; | |
1957 | } | |
1958 | tmp = tmp + "score > " + p.value; | |
1959 | } | |
1960 | ||
1961 | if (op == "scoreL") { | |
1962 | if (isNaN(parseInt(p.value))) { | |
1963 | alert("This action expects numeric parameter."); | |
1964 | return false; | |
1965 | } | |
1966 | tmp = tmp + "score < " + p.value; | |
1967 | } | |
1968 | ||
1969 | if (op == "newerD") { | |
1970 | if (isNaN(parseInt(p.value))) { | |
1971 | alert("This action expects numeric parameter."); | |
1972 | return false; | |
1973 | } | |
1974 | tmp = tmp + "updated > NOW() - INTERVAL '"+parseInt(p.value)+" days'"; | |
1975 | } | |
1976 | ||
1977 | if (op == "newerH") { | |
1978 | if (isNaN(parseInt(p.value))) { | |
1979 | alert("This action expects numeric parameter."); | |
1980 | return false; | |
1981 | } | |
1982 | ||
1983 | tmp = tmp + "updated > NOW() - INTERVAL '"+parseInt(p.value)+" hours'"; | |
1984 | } | |
1985 | ||
1986 | text.value = text.value + tmp; | |
1987 | ||
1988 | p.value = ""; | |
1989 | ||
1990 | } | |
1991 | ||
1992 | } catch (e) { | |
1993 | exception_error("addLabelExample", e); | |
1994 | } | |
1995 | ||
1996 | return false; | |
1997 | } | |
1998 | ||
1999 | function labelFieldsCheck(elem) { | |
2000 | try { | |
2001 | var op = elem[elem.selectedIndex].value; | |
2002 | ||
2003 | var p = document.forms["label_edit_form"].label_fields_param; | |
2004 | ||
2005 | if (op == "kw_title" || op == "kw_content" || op == "scoreL" || | |
2006 | op == "scoreG" || op == "scoreE" || op == "newerD" || | |
2007 | op == "newerH" ) { | |
2008 | Element.show(p); | |
2009 | } else { | |
2010 | Element.hide(p); | |
2011 | } | |
2012 | ||
2013 | } catch (e) { | |
2014 | exception_error("labelFieldsCheck", e); | |
2015 | ||
2016 | } | |
2017 | } | |
2018 | ||
2019 | function getSelectedFeedsFromBrowser() { | |
2020 | ||
2021 | var list = document.getElementById("browseFeedList"); | |
2022 | if (!list) list = document.getElementById("browseBigFeedList"); | |
2023 | ||
2024 | var selected = new Array(); | |
2025 | ||
2026 | for (i = 0; i < list.childNodes.length; i++) { | |
2027 | var child = list.childNodes[i]; | |
2028 | if (child.id && child.id.match("FBROW-")) { | |
2029 | var id = child.id.replace("FBROW-", ""); | |
2030 | ||
2031 | var cb = document.getElementById("FBCHK-" + id); | |
2032 | ||
2033 | if (cb.checked) { | |
2034 | selected.push(id); | |
2035 | } | |
2036 | } | |
2037 | } | |
2038 | ||
2039 | return selected; | |
2040 | } | |
2041 | ||
2042 | function updateFeedBrowser() { | |
2043 | try { | |
2044 | ||
2045 | var query = "backend.php?op=rpc&subop=feedBrowser"; | |
2046 | ||
2047 | var search = document.getElementById("feed_browser_search"); | |
2048 | var limit = document.getElementById("feed_browser_limit"); | |
2049 | ||
2050 | if (limit) { | |
2051 | query = query + "&limit=" + limit[limit.selectedIndex].value; | |
2052 | } | |
2053 | ||
2054 | if (search) { | |
2055 | query = query + "&search=" + param_escape(search.value); | |
2056 | } | |
2057 | ||
2058 | notify_progress("Loading, please wait...", true); | |
2059 | ||
2060 | new Ajax.Request(query, { | |
2061 | onComplete: function(transport) { | |
2062 | notify(''); | |
2063 | ||
2064 | var c = document.getElementById("browseFeedList"); | |
2065 | var r = transport.responseXML.getElementsByTagName("content")[0]; | |
2066 | var nr = transport.responseXML.getElementsByTagName("num-results")[0]; | |
2067 | var sb = document.getElementById("feed_browser_subscribe"); | |
2068 | ||
2069 | if (c && r) { | |
2070 | c.innerHTML = r.firstChild.nodeValue; | |
2071 | } | |
2072 | ||
2073 | if (nr && sb) { | |
2074 | if (nr.getAttribute("value") > 0) { | |
2075 | sb.disabled = false; | |
2076 | } else { | |
2077 | sb.disabled = true; | |
2078 | } | |
2079 | } | |
2080 | ||
2081 | } }); | |
2082 | ||
2083 | ||
2084 | } catch (e) { | |
2085 | exception_error("updateFeedBrowser", e); | |
2086 | } | |
2087 | } | |
2088 | ||
2089 | function browseFeeds(limit) { | |
2090 | ||
2091 | try { | |
2092 | ||
2093 | var query = "backend.php?op=pref-feeds&subop=browse"; | |
2094 | ||
2095 | notify_progress("Loading, please wait...", true); | |
2096 | ||
2097 | new Ajax.Request(query, { | |
2098 | onComplete: function(transport) { | |
2099 | infobox_callback2(transport); | |
2100 | } }); | |
2101 | ||
2102 | return false; | |
2103 | } catch (e) { | |
2104 | exception_error("browseFeeds", e); | |
2105 | } | |
2106 | } | |
2107 | ||
2108 |