]>
Commit | Line | Data |
---|---|---|
1 | var hotkeys_enabled = true; | |
2 | ||
3 | function browser_has_opacity() { | |
4 | return navigator.userAgent.match("Gecko") != null || | |
5 | navigator.userAgent.match("Opera") != null; | |
6 | } | |
7 | ||
8 | function exception_error(location, e) { | |
9 | var msg; | |
10 | ||
11 | if (e.fileName) { | |
12 | var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1); | |
13 | ||
14 | msg = "Exception: " + e.name + ", " + e.message + | |
15 | "\nFunction: " + location + "()" + | |
16 | "\nLocation: " + base_fname + ":" + e.lineNumber; | |
17 | } else { | |
18 | msg = "Exception: " + e + "\nFunction: " + location + "()"; | |
19 | } | |
20 | ||
21 | alert(msg); | |
22 | } | |
23 | ||
24 | function disableHotkeys() { | |
25 | hotkeys_enabled = false; | |
26 | } | |
27 | ||
28 | function enableHotkeys() { | |
29 | hotkeys_enabled = true; | |
30 | } | |
31 | ||
32 | function xmlhttp_ready(obj) { | |
33 | return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState; | |
34 | } | |
35 | ||
36 | function notify_callback() { | |
37 | var container = document.getElementById('notify'); | |
38 | if (xmlhttp.readyState == 4) { | |
39 | container.innerHTML=xmlhttp.responseText; | |
40 | } | |
41 | } | |
42 | ||
43 | function rpc_notify_callback() { | |
44 | var container = document.getElementById('notify'); | |
45 | if (xmlhttp_rpc.readyState == 4) { | |
46 | container.innerHTML=xmlhttp_rpc.responseText; | |
47 | } | |
48 | } | |
49 | ||
50 | function rpc_pnotify_callback() { | |
51 | var container = parent.document.getElementById('notify'); | |
52 | if (xmlhttp_rpc.readyState == 4) { | |
53 | container.innerHTML=xmlhttp_rpc.responseText; | |
54 | } | |
55 | } | |
56 | ||
57 | function param_escape(arg) { | |
58 | if (typeof encodeURIComponent != 'undefined') | |
59 | return encodeURIComponent(arg); | |
60 | else | |
61 | return escape(arg); | |
62 | } | |
63 | ||
64 | function param_unescape(arg) { | |
65 | if (typeof decodeURIComponent != 'undefined') | |
66 | return decodeURIComponent(arg); | |
67 | else | |
68 | return unescape(arg); | |
69 | } | |
70 | ||
71 | function delay(gap) { | |
72 | var then,now; | |
73 | then=new Date().getTime(); | |
74 | now=then; | |
75 | while((now-then)<gap) { | |
76 | now=new Date().getTime(); | |
77 | } | |
78 | } | |
79 | ||
80 | var notify_hide_timerid = false; | |
81 | var notify_last_doc = false; | |
82 | ||
83 | var notify_effect = false; | |
84 | ||
85 | function hide_notify() { | |
86 | if (notify_last_doc) { | |
87 | var n = notify_last_doc.getElementById("notify"); | |
88 | if (browser_has_opacity()) { | |
89 | if (notify_opacity >= 0) { | |
90 | notify_opacity = notify_opacity - 0.1; | |
91 | n.style.opacity = notify_opacity; | |
92 | notify_hide_timerid = window.setTimeout("hide_notify()", 20); | |
93 | } else { | |
94 | n.style.display = "none"; | |
95 | n.style.opacity = 1; | |
96 | } | |
97 | } else { | |
98 | n.style.display = "none"; | |
99 | } | |
100 | } | |
101 | } | |
102 | ||
103 | function notify_real(msg, doc, no_hide, is_err) { | |
104 | ||
105 | var n = doc.getElementById("notify"); | |
106 | var nb = doc.getElementById("notify_body"); | |
107 | ||
108 | if (!n || !nb) return; | |
109 | ||
110 | if (notify_hide_timerid) { | |
111 | window.clearTimeout(notify_hide_timerid); | |
112 | } | |
113 | ||
114 | notify_last_doc = doc; | |
115 | notify_opacity = 1; | |
116 | ||
117 | if (msg == "") { | |
118 | if (n.style.display == "block") { | |
119 | notify_hide_timerid = window.setTimeout("hide_notify()", 0); | |
120 | } | |
121 | return; | |
122 | } else { | |
123 | n.style.display = "block"; | |
124 | } | |
125 | ||
126 | if (is_err) { | |
127 | n.style.backgroundColor = "#ffcccc"; | |
128 | n.style.color = "black"; | |
129 | n.style.borderColor = "#ff0000"; | |
130 | } else { | |
131 | n.style.backgroundColor = "#fff7d5"; | |
132 | n.style.borderColor = "#d7c47a"; | |
133 | n.style.color = "black"; | |
134 | } | |
135 | ||
136 | nb.innerHTML = msg; | |
137 | ||
138 | if (!no_hide) { | |
139 | notify_hide_timerid = window.setTimeout("hide_notify()", 3000); | |
140 | } | |
141 | } | |
142 | ||
143 | function p_notify(msg, no_hide, is_err) { | |
144 | notify_real(msg, parent.document, no_hide, is_err); | |
145 | } | |
146 | ||
147 | function notify(msg, no_hide, is_err) { | |
148 | notify_real(msg, document, no_hide, is_err); | |
149 | } | |
150 | ||
151 | function printLockingError() { | |
152 | notify("Please wait until operation finishes");} | |
153 | ||
154 | var seq = ""; | |
155 | ||
156 | function hotkey_handler(e) { | |
157 | ||
158 | var keycode; | |
159 | ||
160 | if (!hotkeys_enabled) return; | |
161 | ||
162 | if (window.event) { | |
163 | keycode = window.event.keyCode; | |
164 | } else if (e) { | |
165 | keycode = e.which; | |
166 | } | |
167 | ||
168 | if (keycode == 13 || keycode == 27) { | |
169 | seq = ""; | |
170 | } else { | |
171 | seq = seq + "" + keycode; | |
172 | } | |
173 | ||
174 | if (document.getElementById("piggie")) { | |
175 | ||
176 | if (seq.match("807371717369")) { | |
177 | seq = ""; | |
178 | localPiggieFunction(true); | |
179 | } else { | |
180 | localPiggieFunction(false); | |
181 | } | |
182 | } | |
183 | ||
184 | if (typeof localHotkeyHandler != 'undefined') { | |
185 | try { | |
186 | localHotkeyHandler(keycode); | |
187 | } catch (e) { | |
188 | exception_error("hotkey_handler", e); | |
189 | } | |
190 | } | |
191 | ||
192 | } | |
193 | ||
194 | function cleanSelectedList(element) { | |
195 | var content = document.getElementById(element); | |
196 | ||
197 | if (!document.getElementById("feedCatHolder")) { | |
198 | for (i = 0; i < content.childNodes.length; i++) { | |
199 | var child = content.childNodes[i]; | |
200 | try { | |
201 | child.className = child.className.replace("Selected", ""); | |
202 | } catch (e) { | |
203 | // | |
204 | } | |
205 | } | |
206 | } else { | |
207 | for (i = 0; i < content.childNodes.length; i++) { | |
208 | var child = content.childNodes[i]; | |
209 | if (child.id == "feedCatHolder") { | |
210 | parent.debug(child.id); | |
211 | var fcat = child.lastChild; | |
212 | for (j = 0; j < fcat.childNodes.length; j++) { | |
213 | var feed = fcat.childNodes[j]; | |
214 | feed.className = feed.className.replace("Selected", ""); | |
215 | } | |
216 | } | |
217 | } | |
218 | } | |
219 | } | |
220 | ||
221 | ||
222 | function cleanSelected(element) { | |
223 | var content = document.getElementById(element); | |
224 | ||
225 | for (i = 0; i < content.rows.length; i++) { | |
226 | content.rows[i].className = content.rows[i].className.replace("Selected", ""); | |
227 | } | |
228 | } | |
229 | ||
230 | function getVisibleUnreadHeadlines() { | |
231 | var content = document.getElementById("headlinesList"); | |
232 | ||
233 | var rows = new Array(); | |
234 | ||
235 | for (i = 0; i < content.rows.length; i++) { | |
236 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
237 | if (row_id.length > 0 && content.rows[i].className.match("Unread")) { | |
238 | rows.push(row_id); | |
239 | } | |
240 | } | |
241 | return rows; | |
242 | } | |
243 | ||
244 | function getVisibleHeadlineIds() { | |
245 | ||
246 | var content = document.getElementById("headlinesList"); | |
247 | ||
248 | var rows = new Array(); | |
249 | ||
250 | for (i = 0; i < content.rows.length; i++) { | |
251 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
252 | if (row_id.length > 0) { | |
253 | rows.push(row_id); | |
254 | } | |
255 | } | |
256 | return rows; | |
257 | } | |
258 | ||
259 | function getFirstVisibleHeadlineId() { | |
260 | var rows = getVisibleHeadlineIds(); | |
261 | return rows[0]; | |
262 | } | |
263 | ||
264 | function getLastVisibleHeadlineId() { | |
265 | var rows = getVisibleHeadlineIds(); | |
266 | return rows[rows.length-1]; | |
267 | } | |
268 | ||
269 | function markHeadline(id) { | |
270 | var row = document.getElementById("RROW-" + id); | |
271 | if (row) { | |
272 | var is_active = false; | |
273 | ||
274 | if (row.className.match("Active")) { | |
275 | is_active = true; | |
276 | } | |
277 | row.className = row.className.replace("Selected", ""); | |
278 | row.className = row.className.replace("Active", ""); | |
279 | row.className = row.className.replace("Insensitive", ""); | |
280 | ||
281 | if (is_active) { | |
282 | row.className = row.className = "Active"; | |
283 | } | |
284 | ||
285 | var check = document.getElementById("RCHK-" + id); | |
286 | ||
287 | if (check) { | |
288 | check.checked = true; | |
289 | } | |
290 | ||
291 | row.className = row.className + "Selected"; | |
292 | ||
293 | } | |
294 | } | |
295 | ||
296 | function getFeedIds() { | |
297 | var content = document.getElementById("feedsList"); | |
298 | ||
299 | var rows = new Array(); | |
300 | ||
301 | for (i = 0; i < content.rows.length; i++) { | |
302 | var id = content.rows[i].id.replace("FEEDR-", ""); | |
303 | if (id.length > 0) { | |
304 | rows.push(id); | |
305 | } | |
306 | } | |
307 | ||
308 | return rows; | |
309 | } | |
310 | ||
311 | function setCookie(name, value, lifetime, path, domain, secure) { | |
312 | ||
313 | var d = false; | |
314 | ||
315 | if (lifetime) { | |
316 | d = new Date(); | |
317 | d.setTime(lifetime * 1000); | |
318 | } | |
319 | ||
320 | int_setCookie(name, value, d, path, domain, secure); | |
321 | ||
322 | } | |
323 | ||
324 | function int_setCookie(name, value, expires, path, domain, secure) { | |
325 | document.cookie= name + "=" + escape(value) + | |
326 | ((expires) ? "; expires=" + expires.toGMTString() : "") + | |
327 | ((path) ? "; path=" + path : "") + | |
328 | ((domain) ? "; domain=" + domain : "") + | |
329 | ((secure) ? "; secure" : ""); | |
330 | } | |
331 | ||
332 | function delCookie(name, path, domain) { | |
333 | if (getCookie(name)) { | |
334 | document.cookie = name + "=" + | |
335 | ((path) ? ";path=" + path : "") + | |
336 | ((domain) ? ";domain=" + domain : "" ) + | |
337 | ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; | |
338 | } | |
339 | } | |
340 | ||
341 | ||
342 | function getCookie(name) { | |
343 | ||
344 | var dc = document.cookie; | |
345 | var prefix = name + "="; | |
346 | var begin = dc.indexOf("; " + prefix); | |
347 | if (begin == -1) { | |
348 | begin = dc.indexOf(prefix); | |
349 | if (begin != 0) return null; | |
350 | } | |
351 | else { | |
352 | begin += 2; | |
353 | } | |
354 | var end = document.cookie.indexOf(";", begin); | |
355 | if (end == -1) { | |
356 | end = dc.length; | |
357 | } | |
358 | return unescape(dc.substring(begin + prefix.length, end)); | |
359 | } | |
360 | ||
361 | function disableContainerChildren(id, disable, doc) { | |
362 | ||
363 | if (!doc) doc = document; | |
364 | ||
365 | var container = doc.getElementById(id); | |
366 | ||
367 | if (!container) { | |
368 | //alert("disableContainerChildren: element " + id + " not found"); | |
369 | return; | |
370 | } | |
371 | ||
372 | for (var i = 0; i < container.childNodes.length; i++) { | |
373 | var child = container.childNodes[i]; | |
374 | ||
375 | try { | |
376 | child.disabled = disable; | |
377 | } catch (E) { | |
378 | ||
379 | } | |
380 | ||
381 | if (disable) { | |
382 | if (child.className && child.className.match("button")) { | |
383 | child.className = "disabledButton"; | |
384 | } | |
385 | } else { | |
386 | if (child.className && child.className.match("disabledButton")) { | |
387 | child.className = "button"; | |
388 | } | |
389 | } | |
390 | } | |
391 | ||
392 | } | |
393 | ||
394 | function gotoPreferences() { | |
395 | document.location.href = "prefs.php"; | |
396 | } | |
397 | ||
398 | function gotoMain() { | |
399 | document.location.href = "tt-rss.php"; | |
400 | } | |
401 | ||
402 | function gotoExportOpml() { | |
403 | document.location.href = "opml.php?op=Export"; | |
404 | } | |
405 | ||
406 | function getActiveFeedId() { | |
407 | return getCookie("ttrss_vf_actfeed"); | |
408 | } | |
409 | ||
410 | function setActiveFeedId(id) { | |
411 | return setCookie("ttrss_vf_actfeed", id); | |
412 | } | |
413 | ||
414 | var xmlhttp_rpc = Ajax.getTransport(); | |
415 | ||
416 | function parse_counters(reply, scheduled_call) { | |
417 | try { | |
418 | var f_document = getMainContext().frames["feeds-frame"].document; | |
419 | var title_obj = getMainContext(); | |
420 | ||
421 | debug("F_DOC: " + f_document + ", T_OBJ: " + title_obj); | |
422 | ||
423 | for (var l = 0; l < reply.childNodes.length; l++) { | |
424 | if (!reply.childNodes[l] || | |
425 | typeof(reply.childNodes[l].getAttribute) == "undefined") { | |
426 | // where did this come from? | |
427 | continue; | |
428 | } | |
429 | ||
430 | var id = reply.childNodes[l].getAttribute("id"); | |
431 | var t = reply.childNodes[l].getAttribute("type"); | |
432 | var ctr = reply.childNodes[l].getAttribute("counter"); | |
433 | var error = reply.childNodes[l].getAttribute("error"); | |
434 | var has_img = reply.childNodes[l].getAttribute("hi"); | |
435 | var updated = reply.childNodes[l].getAttribute("updated"); | |
436 | ||
437 | if (id == "global-unread") { | |
438 | title_obj.global_unread = ctr; | |
439 | title_obj.updateTitle(); | |
440 | continue; | |
441 | } | |
442 | ||
443 | if (t == "category") { | |
444 | var catctr = f_document.getElementById("FCATCTR-" + id); | |
445 | if (catctr) { | |
446 | catctr.innerHTML = "(" + ctr + " unread)"; | |
447 | } | |
448 | continue; | |
449 | } | |
450 | ||
451 | var feedctr = f_document.getElementById("FEEDCTR-" + id); | |
452 | var feedu = f_document.getElementById("FEEDU-" + id); | |
453 | var feedr = f_document.getElementById("FEEDR-" + id); | |
454 | var feed_img = f_document.getElementById("FIMG-" + id); | |
455 | var feedlink = f_document.getElementById("FEEDL-" + id); | |
456 | ||
457 | if (updated && feedlink) { | |
458 | if (error) { | |
459 | feedlink.title = "Error: " + error + " (" + updated + ")"; | |
460 | } else { | |
461 | feedlink.title = "Updated: " + updated; | |
462 | } | |
463 | } | |
464 | ||
465 | if (feedctr && feedu && feedr) { | |
466 | ||
467 | if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) { | |
468 | var hf = title_obj.parent.frames["headlines-frame"]; | |
469 | hf.location.reload(true); | |
470 | } | |
471 | ||
472 | feedu.innerHTML = ctr; | |
473 | ||
474 | if (error) { | |
475 | feedr.className = feedr.className.replace("feed", "error"); | |
476 | } else if (id > 0) { | |
477 | feedr.className = feedr.className.replace("error", "feed"); | |
478 | } | |
479 | ||
480 | if (ctr > 0) { | |
481 | feedctr.className = "odd"; | |
482 | if (!feedr.className.match("Unread")) { | |
483 | var is_selected = feedr.className.match("Selected"); | |
484 | ||
485 | feedr.className = feedr.className.replace("Selected", ""); | |
486 | feedr.className = feedr.className.replace("Unread", ""); | |
487 | ||
488 | feedr.className = feedr.className + "Unread"; | |
489 | ||
490 | if (is_selected) { | |
491 | feedr.className = feedr.className + "Selected"; | |
492 | } | |
493 | ||
494 | } | |
495 | } else { | |
496 | feedctr.className = "invisible"; | |
497 | feedr.className = feedr.className.replace("Unread", ""); | |
498 | } | |
499 | } | |
500 | } | |
501 | } catch (e) { | |
502 | exception_error("parse_counters", e); | |
503 | } | |
504 | } | |
505 | ||
506 | function all_counters_callback() { | |
507 | if (xmlhttp_rpc.readyState == 4) { | |
508 | try { | |
509 | if (!xmlhttp_rpc.responseXML || !xmlhttp_rpc.responseXML.firstChild) { | |
510 | notify("[all_counters_callback] backend did not return valid XML"); | |
511 | return; | |
512 | } | |
513 | ||
514 | if (!parent.frames["feeds-frame"]) { | |
515 | notify("[all_counters_callback] no parent feeds-frame"); | |
516 | return; | |
517 | } | |
518 | ||
519 | var reply = xmlhttp_rpc.responseXML.firstChild; | |
520 | // var f_document = parent.frames["feeds-frame"].document; | |
521 | ||
522 | parse_counters(reply); | |
523 | ||
524 | } catch (e) { | |
525 | exception_error("all_counters_callback", e); | |
526 | } | |
527 | } | |
528 | } | |
529 | ||
530 | function update_all_counters(feed) { | |
531 | if (xmlhttp_ready(xmlhttp_rpc)) { | |
532 | var query = "backend.php?op=rpc&subop=getAllCounters"; | |
533 | ||
534 | if (feed > 0) { | |
535 | query = query + "&aid=" + feed; | |
536 | } | |
537 | ||
538 | xmlhttp_rpc.open("GET", query, true); | |
539 | xmlhttp_rpc.onreadystatechange=all_counters_callback; | |
540 | xmlhttp_rpc.send(null); | |
541 | } | |
542 | } | |
543 | ||
544 | function popupHelp(tid) { | |
545 | var w = window.open("backend.php?op=help&tid=" + tid, | |
546 | "Popup Help", | |
547 | "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no"); | |
548 | } | |
549 | ||
550 | /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj | |
551 | * * @author Sundar Dorai-Raj | |
552 | * * Email: sdoraira@vt.edu | |
553 | * * This program is free software; you can redistribute it and/or | |
554 | * * modify it under the terms of the GNU General Public License | |
555 | * * as published by the Free Software Foundation; either version 2 | |
556 | * * of the License, or (at your option) any later version, | |
557 | * * provided that any use properly credits the author. | |
558 | * * This program is distributed in the hope that it will be useful, | |
559 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
560 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
561 | * * GNU General Public License for more details at http://www.gnu.org * * */ | |
562 | ||
563 | var numbers=".0123456789"; | |
564 | function isNumeric(x) { | |
565 | // is x a String or a character? | |
566 | if(x.length>1) { | |
567 | // remove negative sign | |
568 | x=Math.abs(x)+""; | |
569 | for(j=0;j<x.length;j++) { | |
570 | // call isNumeric recursively for each character | |
571 | number=isNumeric(x.substring(j,j+1)); | |
572 | if(!number) return number; | |
573 | } | |
574 | return number; | |
575 | } | |
576 | else { | |
577 | // if x is number return true | |
578 | if(numbers.indexOf(x)>=0) return true; | |
579 | return false; | |
580 | } | |
581 | } | |
582 | ||
583 | ||
584 | function hideOrShowFeeds(doc, hide) { | |
585 | ||
586 | if (!doc.styleSheets) return; | |
587 | ||
588 | var css_rules = doc.styleSheets[0].cssRules; | |
589 | ||
590 | if (!css_rules || !css_rules.length) return; | |
591 | ||
592 | for (i = 0; i < css_rules.length; i++) { | |
593 | var rule = css_rules[i]; | |
594 | ||
595 | if (rule.selectorText == "ul.feedList li.feed") { | |
596 | if (!hide) { | |
597 | rule.style.display = "block"; | |
598 | } else { | |
599 | rule.style.display = "none"; | |
600 | } | |
601 | } | |
602 | ||
603 | } | |
604 | ||
605 | } | |
606 | ||
607 | function selectTableRow(r, do_select) { | |
608 | r.className = r.className.replace("Selected", ""); | |
609 | ||
610 | if (do_select) { | |
611 | r.className = r.className + "Selected"; | |
612 | } | |
613 | } | |
614 | ||
615 | function selectTableRowById(elem_id, check_id, do_select) { | |
616 | ||
617 | try { | |
618 | ||
619 | var row = document.getElementById(elem_id); | |
620 | ||
621 | if (row) { | |
622 | selectTableRow(row, do_select); | |
623 | } | |
624 | ||
625 | var check = document.getElementById(check_id); | |
626 | ||
627 | if (check) { | |
628 | check.checked = do_select; | |
629 | } | |
630 | } catch (e) { | |
631 | exception_error("selectTableRowById", e); | |
632 | } | |
633 | } | |
634 | ||
635 | function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select, | |
636 | classcheck, reset_others) { | |
637 | ||
638 | var content = document.getElementById(content_id); | |
639 | ||
640 | if (!content) { | |
641 | alert("[selectTableRows] Element " + content_id + " not found."); | |
642 | return; | |
643 | } | |
644 | ||
645 | for (i = 0; i < content.rows.length; i++) { | |
646 | if (!classcheck || content.rows[i].className.match(classcheck)) { | |
647 | ||
648 | if (content.rows[i].id.match(prefix)) { | |
649 | selectTableRow(content.rows[i], do_select); | |
650 | ||
651 | var row_id = content.rows[i].id.replace(prefix, ""); | |
652 | var check = document.getElementById(check_prefix + row_id); | |
653 | ||
654 | if (check) { | |
655 | check.checked = do_select; | |
656 | } | |
657 | } else if (reset_others) { | |
658 | selectTableRow(content.rows[i], false); | |
659 | ||
660 | var row_id = content.rows[i].id.replace(prefix, ""); | |
661 | var check = document.getElementById(check_prefix + row_id); | |
662 | ||
663 | if (check) { | |
664 | check.checked = false; | |
665 | } | |
666 | ||
667 | } | |
668 | } else if (reset_others) { | |
669 | selectTableRow(content.rows[i], false); | |
670 | ||
671 | var row_id = content.rows[i].id.replace(prefix, ""); | |
672 | var check = document.getElementById(check_prefix + row_id); | |
673 | ||
674 | if (check) { | |
675 | check.checked = false; | |
676 | } | |
677 | ||
678 | } | |
679 | } | |
680 | } | |
681 | ||
682 | function getSelectedTableRowIds(content_id, prefix) { | |
683 | ||
684 | var content = document.getElementById(content_id); | |
685 | ||
686 | if (!content) { | |
687 | alert("[getSelectedTableRowIds] Element " + content_id + " not found."); | |
688 | return; | |
689 | } | |
690 | ||
691 | var sel_rows = new Array(); | |
692 | ||
693 | for (i = 0; i < content.rows.length; i++) { | |
694 | if (content.rows[i].id.match(prefix) && | |
695 | content.rows[i].className.match("Selected")) { | |
696 | ||
697 | var row_id = content.rows[i].id.replace(prefix + "-", ""); | |
698 | sel_rows.push(row_id); | |
699 | } | |
700 | } | |
701 | ||
702 | return sel_rows; | |
703 | ||
704 | } | |
705 | ||
706 | function toggleSelectRowById(sender, id) { | |
707 | var row = document.getElementById(id); | |
708 | ||
709 | if (sender.checked) { | |
710 | if (!row.className.match("Selected")) { | |
711 | row.className = row.className + "Selected"; | |
712 | } | |
713 | } else { | |
714 | if (row.className.match("Selected")) { | |
715 | row.className = row.className.replace("Selected", ""); | |
716 | } | |
717 | } | |
718 | } | |
719 | ||
720 | function toggleSelectListRow(sender) { | |
721 | var parent_row = sender.parentNode; | |
722 | ||
723 | if (sender.checked) { | |
724 | if (!parent_row.className.match("Selected")) { | |
725 | parent_row.className = parent_row.className + "Selected"; | |
726 | } | |
727 | } else { | |
728 | if (parent_row.className.match("Selected")) { | |
729 | parent_row.className = parent_row.className.replace("Selected", ""); | |
730 | } | |
731 | } | |
732 | } | |
733 | ||
734 | ||
735 | function toggleSelectRow(sender) { | |
736 | var parent_row = sender.parentNode.parentNode; | |
737 | ||
738 | if (sender.checked) { | |
739 | if (!parent_row.className.match("Selected")) { | |
740 | parent_row.className = parent_row.className + "Selected"; | |
741 | } | |
742 | } else { | |
743 | if (parent_row.className.match("Selected")) { | |
744 | parent_row.className = parent_row.className.replace("Selected", ""); | |
745 | } | |
746 | } | |
747 | } | |
748 | ||
749 | function openExternalUrl(url) { | |
750 | var w = window.open(url); | |
751 | } | |
752 | ||
753 | function getRelativeFeedId(list, id, direction, unread_only) { | |
754 | if (!id) { | |
755 | if (direction == "next") { | |
756 | for (i = 0; i < list.childNodes.length; i++) { | |
757 | var child = list.childNodes[i]; | |
758 | if (child.id && child.id == "feedCatHolder") { | |
759 | if (child.lastChild) { | |
760 | var cr = getRelativeFeedId(child.firstChild, id, direction); | |
761 | if (cr) return cr; | |
762 | } | |
763 | } else if (child.id && child.id.match("FEEDR-")) { | |
764 | return child.id.replace('FEEDR-', ''); | |
765 | } | |
766 | } | |
767 | } | |
768 | ||
769 | // FIXME select last feed doesn't work when only unread feeds are visible | |
770 | ||
771 | if (direction == "prev") { | |
772 | for (i = list.childNodes.length-1; i >= 0; i--) { | |
773 | var child = list.childNodes[i]; | |
774 | if (child.id == "feedCatHolder") { | |
775 | if (child.firstChild) { | |
776 | var cr = getRelativeFeedId(child.firstChild, id, direction); | |
777 | if (cr) return cr; | |
778 | } | |
779 | } else if (child.id.match("FEEDR-")) { | |
780 | ||
781 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
782 | if (child.className != "feed") { | |
783 | alert(child.className); | |
784 | return child.id.replace('FEEDR-', ''); | |
785 | } | |
786 | } else { | |
787 | return child.id.replace('FEEDR-', ''); | |
788 | } | |
789 | } | |
790 | } | |
791 | } | |
792 | } else { | |
793 | ||
794 | var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId()); | |
795 | ||
796 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
797 | unread_only = true; | |
798 | } | |
799 | ||
800 | if (direction == "next") { | |
801 | ||
802 | var e = feed; | |
803 | ||
804 | while (e) { | |
805 | ||
806 | if (e.nextSibling) { | |
807 | ||
808 | e = e.nextSibling; | |
809 | ||
810 | } else if (e.parentNode.parentNode.nextSibling) { | |
811 | ||
812 | var this_cat = e.parentNode.parentNode; | |
813 | ||
814 | e = false; | |
815 | ||
816 | if (this_cat && this_cat.nextSibling) { | |
817 | while (!e && this_cat.nextSibling) { | |
818 | this_cat = this_cat.nextSibling; | |
819 | if (this_cat.id == "feedCatHolder") { | |
820 | e = this_cat.firstChild.firstChild; | |
821 | } | |
822 | } | |
823 | } | |
824 | ||
825 | } else { | |
826 | e = false; | |
827 | } | |
828 | ||
829 | if (e) { | |
830 | if (!unread_only || (unread_only && e.className != "feed" && | |
831 | e.className != "error")) { | |
832 | return e.id.replace("FEEDR-", ""); | |
833 | } | |
834 | } | |
835 | } | |
836 | ||
837 | } else if (direction == "prev") { | |
838 | ||
839 | var e = feed; | |
840 | ||
841 | while (e) { | |
842 | ||
843 | if (e.previousSibling) { | |
844 | ||
845 | e = e.previousSibling; | |
846 | ||
847 | } else if (e.parentNode.parentNode.previousSibling) { | |
848 | ||
849 | var this_cat = e.parentNode.parentNode; | |
850 | ||
851 | e = false; | |
852 | ||
853 | if (this_cat && this_cat.previousSibling) { | |
854 | while (!e && this_cat.previousSibling) { | |
855 | this_cat = this_cat.previousSibling; | |
856 | if (this_cat.id == "feedCatHolder") { | |
857 | e = this_cat.firstChild.lastChild; | |
858 | } | |
859 | } | |
860 | } | |
861 | ||
862 | } else { | |
863 | e = false; | |
864 | } | |
865 | ||
866 | if (e) { | |
867 | if (!unread_only || (unread_only && e.className != "feed" && | |
868 | e.className != "error")) { | |
869 | return e.id.replace("FEEDR-", ""); | |
870 | } | |
871 | } | |
872 | } | |
873 | } | |
874 | } | |
875 | } | |
876 | ||
877 | function showBlockElement(id) { | |
878 | var elem = document.getElementById(id); | |
879 | ||
880 | if (elem) { | |
881 | elem.style.display = "block"; | |
882 | } else { | |
883 | alert("[showBlockElement] can't find element with id " + id); | |
884 | } | |
885 | } | |
886 | ||
887 | function hideParentElement(e) { | |
888 | e.parentNode.style.display = "none"; | |
889 | } | |
890 | ||
891 | function dropboxSelect(e, v) { | |
892 | for (i = 0; i < e.length; i++) { | |
893 | if (e[i].value == v) { | |
894 | e.selectedIndex = i; | |
895 | break; | |
896 | } | |
897 | } | |
898 | } | |
899 | ||
900 | // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z | |
901 | // bugfixed just a little bit :-) | |
902 | function getURLParam(strParamName){ | |
903 | var strReturn = ""; | |
904 | var strHref = window.location.href; | |
905 | ||
906 | if (strHref.indexOf("#") == strHref.length-1) { | |
907 | strHref = strHref.substring(0, strHref.length-1); | |
908 | } | |
909 | ||
910 | if ( strHref.indexOf("?") > -1 ){ | |
911 | var strQueryString = strHref.substr(strHref.indexOf("?")); | |
912 | var aQueryString = strQueryString.split("&"); | |
913 | for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){ | |
914 | if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){ | |
915 | var aParam = aQueryString[iParam].split("="); | |
916 | strReturn = aParam[1]; | |
917 | break; | |
918 | } | |
919 | } | |
920 | } | |
921 | return strReturn; | |
922 | } | |
923 | ||
924 | function leading_zero(p) { | |
925 | var s = String(p); | |
926 | if (s.length == 1) s = "0" + s; | |
927 | return s; | |
928 | } | |
929 | ||
930 | function closeInfoBox(cleanup) { | |
931 | var box = document.getElementById('infoBox'); | |
932 | var shadow = document.getElementById('infoBoxShadow'); | |
933 | ||
934 | if (shadow) { | |
935 | shadow.style.display = "none"; | |
936 | } else if (box) { | |
937 | box.style.display = "none"; | |
938 | } | |
939 | ||
940 | if (cleanup) box.innerHTML = " "; | |
941 | ||
942 | enableHotkeys(); | |
943 | ||
944 | } | |
945 | ||
946 | ||
947 | function displayDlg(id, param) { | |
948 | ||
949 | if (!xmlhttp_ready(xmlhttp)) { | |
950 | printLockingError(); | |
951 | return | |
952 | } | |
953 | ||
954 | notify(""); | |
955 | ||
956 | xmlhttp.open("GET", "backend.php?op=dlg&id=" + | |
957 | param_escape(id) + "¶m=" + param_escape(param), true); | |
958 | xmlhttp.onreadystatechange=infobox_callback; | |
959 | xmlhttp.send(null); | |
960 | ||
961 | disableHotkeys(); | |
962 | ||
963 | } | |
964 | ||
965 | function infobox_submit_callback() { | |
966 | if (xmlhttp.readyState == 4) { | |
967 | closeInfoBox(); | |
968 | ||
969 | // called from prefs, reload tab | |
970 | if (active_tab) { | |
971 | selectTab(active_tab, false); | |
972 | } | |
973 | ||
974 | notify(xmlhttp.responseText); | |
975 | ||
976 | } | |
977 | } | |
978 | ||
979 | function infobox_callback() { | |
980 | if (xmlhttp.readyState == 4) { | |
981 | var box = document.getElementById('infoBox'); | |
982 | var shadow = document.getElementById('infoBoxShadow'); | |
983 | if (box) { | |
984 | box.innerHTML=xmlhttp.responseText; | |
985 | if (shadow) { | |
986 | shadow.style.display = "block"; | |
987 | } else { | |
988 | box.style.display = "block"; | |
989 | } | |
990 | } | |
991 | } | |
992 | } | |
993 | ||
994 | function qaddFilter() { | |
995 | ||
996 | if (!xmlhttp_ready(xmlhttp)) { | |
997 | printLockingError(); | |
998 | return | |
999 | } | |
1000 | ||
1001 | var query = Form.serialize("filter_add_form"); | |
1002 | ||
1003 | xmlhttp.open("GET", "backend.php?" + query, true); | |
1004 | xmlhttp.onreadystatechange=infobox_submit_callback; | |
1005 | xmlhttp.send(null); | |
1006 | ||
1007 | return true; | |
1008 | } | |
1009 | ||
1010 | function toggleSubmitNotEmpty(e, submit_id) { | |
1011 | try { | |
1012 | document.getElementById(submit_id).disabled = (e.value == "") | |
1013 | } catch (e) { | |
1014 | exception_error("toggleSubmitNotEmpty", e); | |
1015 | } | |
1016 | } | |
1017 | ||
1018 | function isValidURL(s) { | |
1019 | return s.match("http://") != null || s.match("https://") != null; | |
1020 | } | |
1021 | ||
1022 | function qafAdd() { | |
1023 | ||
1024 | if (!xmlhttp_ready(xmlhttp)) { | |
1025 | printLockingError(); | |
1026 | return | |
1027 | } | |
1028 | ||
1029 | notify("Adding feed..."); | |
1030 | ||
1031 | closeInfoBox(); | |
1032 | ||
1033 | var feeds_doc = window.frames["feeds-frame"].document; | |
1034 | ||
1035 | feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait..."; | |
1036 | ||
1037 | var query = Form.serialize("feed_add_form"); | |
1038 | ||
1039 | xmlhttp.open("GET", "backend.php?" + query, true); | |
1040 | xmlhttp.onreadystatechange=dlg_frefresh_callback; | |
1041 | xmlhttp.send(null); | |
1042 | } | |
1043 | ||
1044 | function filterCR(e) | |
1045 | { | |
1046 | var key; | |
1047 | ||
1048 | if(window.event) | |
1049 | key = window.event.keyCode; //IE | |
1050 | else | |
1051 | key = e.which; //firefox | |
1052 | ||
1053 | if(key == 13) | |
1054 | return false; | |
1055 | else | |
1056 | return true; | |
1057 | } | |
1058 | ||
1059 | function getMainContext() { | |
1060 | if (parent.window != window) { | |
1061 | return parent.window; | |
1062 | } else { | |
1063 | return this.window; | |
1064 | } | |
1065 | } | |
1066 | ||
1067 | function debug(msg) { | |
1068 | var ctx = getMainContext(); | |
1069 | ||
1070 | var c = ctx.document.getElementById('debug_output'); | |
1071 | if (c && c.style.display == "block") { | |
1072 | while (c.lastChild != 'undefined' && c.childNodes.length > 20) { | |
1073 | c.removeChild(c.lastChild); | |
1074 | } | |
1075 | ||
1076 | var d = new Date(); | |
1077 | var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) + | |
1078 | ":" + leading_zero(d.getSeconds()); | |
1079 | c.innerHTML = "<li>[" + ts + "] " + msg + "</li>" + c.innerHTML; | |
1080 | } | |
1081 | } | |
1082 | ||
1083 |