]>
git.wh0rd.org - tt-rss.git/blob - functions.js
1 var hotkeys_enabled
= true;
3 var xmlhttp_rpc
= Ajax
.getTransport();
5 function browser_has_opacity() {
6 return navigator
.userAgent
.match("Gecko") != null ||
7 navigator
.userAgent
.match("Opera") != null;
11 return navigator
.userAgent
.match("Opera");
14 function exception_error(location
, e
, silent
) {
18 var base_fname
= e
.fileName
.substring(e
.fileName
.lastIndexOf("/") + 1);
20 msg
= "Exception: " + e
.name
+ ", " + e
.message
+
21 "\nFunction: " + location
+ "()" +
22 "\nLocation: " + base_fname
+ ":" + e
.lineNumber
;
25 msg
= "Exception: " + e
+ "\nFunction: " + location
+ "()";
28 debug("<b>EXCEPTION: " + msg
+ "</b>");
35 function disableHotkeys() {
36 hotkeys_enabled
= false;
39 function enableHotkeys() {
40 hotkeys_enabled
= true;
43 function xmlhttp_ready(obj
) {
44 return obj
.readyState
== 4 || obj
.readyState
== 0 || !obj
.readyState
;
47 function notify_callback() {
48 var container
= document
.getElementById('notify');
49 if (xmlhttp
.readyState
== 4) {
50 container
.innerHTML
=xmlhttp
.responseText
;
54 function rpc_notify_callback() {
55 var container
= document
.getElementById('notify');
56 if (xmlhttp_rpc
.readyState
== 4) {
57 container
.innerHTML
=xmlhttp_rpc
.responseText
;
61 function param_escape(arg
) {
62 if (typeof encodeURIComponent
!= 'undefined')
63 return encodeURIComponent(arg
);
68 function param_unescape(arg
) {
69 if (typeof decodeURIComponent
!= 'undefined')
70 return decodeURIComponent(arg
);
77 then
=new Date().getTime();
79 while((now
-then
)<gap
) {
80 now
=new Date().getTime();
84 var notify_hide_timerid
= false;
85 var notify_last_doc
= false;
87 var notify_effect
= false;
89 function hide_notify() {
90 if (notify_last_doc
) {
91 var n
= notify_last_doc
.getElementById("notify");
92 if (browser_has_opacity()) {
93 if (notify_opacity
>= 0) {
94 notify_opacity
= notify_opacity
- 0.1;
95 n
.style
.opacity
= notify_opacity
;
96 notify_hide_timerid
= window
.setTimeout("hide_notify()", 20);
98 n
.style
.display
= "none";
102 n
.style
.display
= "none";
107 function notify_real(msg
, doc
, no_hide
, is_err
) {
109 var n
= doc
.getElementById("notify");
110 var nb
= doc
.getElementById("notify_body");
112 if (!n
|| !nb
) return;
114 if (notify_hide_timerid
) {
115 window
.clearTimeout(notify_hide_timerid
);
118 notify_last_doc
= doc
;
122 if (n
.style
.display
== "block") {
123 notify_hide_timerid
= window
.setTimeout("hide_notify()", 0);
127 n
.style
.display
= "block";
131 n
.style
.backgroundColor
= "#ffcccc";
132 n
.style
.color
= "black";
133 n
.style
.borderColor
= "#ff0000";
135 n
.style
.backgroundColor
= "#fff7d5";
136 n
.style
.borderColor
= "#d7c47a";
137 n
.style
.color
= "black";
143 notify_hide_timerid
= window
.setTimeout("hide_notify()", 3000);
147 function p_notify(msg
, no_hide
, is_err
) {
148 notify_real(msg
, parent
.document
, no_hide
, is_err
);
151 function notify(msg
, no_hide
, is_err
) {
152 notify_real(msg
, document
, no_hide
, is_err
);
155 function printLockingError() {
156 notify("Please wait until operation finishes");}
158 function hotkey_handler(e
) {
164 if (!hotkeys_enabled
) return;
167 keycode
= window
.event
.keyCode
;
172 var m_ctx
= getMainContext();
173 var f_ctx
= getFeedsContext();
174 var h_ctx
= getHeadlinesContext();
176 if (keycode
== 82) { // r
177 return m_ctx
.scheduleFeedUpdate(true);
180 if (keycode
== 83) { // r
181 return m_ctx
.displayDlg("search", getActiveFeedId());
184 if (keycode
== 85) { // u
185 if (getActiveFeedId()) {
186 return f_ctx
.viewfeed(getActiveFeedId(), "ForceUpdate");
190 if (keycode
== 65) { // a
191 return m_ctx
.toggleDispRead();
194 var f_doc
= m_ctx
.frames
["feeds-frame"].document
;
195 var feedlist
= f_doc
.getElementById('feedList');
197 if (keycode
== 74) { // j
198 var feed
= getActiveFeedId();
199 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
200 if (new_feed
) viewfeed(new_feed
, '');
203 if (keycode
== 75) { // k
204 var feed
= getActiveFeedId();
205 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
206 if (new_feed
) viewfeed(new_feed
, '');
209 if (keycode
== 78 || keycode
== 40) { // n, down
210 if (typeof h_ctx
.moveToPost
!= 'undefined') {
211 return h_ctx
.moveToPost('next');
215 if (keycode
== 80 || keycode
== 38) { // p, up
216 if (typeof h_ctx
.moveToPost
!= 'undefined') {
217 return h_ctx
.moveToPost('prev');
221 if (typeof localHotkeyHandler
!= 'undefined') {
223 localHotkeyHandler(keycode
);
225 exception_error("hotkey_handler, local:", e
);
229 exception_error("hotkey_handler", e
);
233 function cleanSelectedList(element
) {
234 var content
= document
.getElementById(element
);
236 if (!document
.getElementById("feedCatHolder")) {
237 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
238 var child
= content
.childNodes
[i
];
240 child
.className
= child
.className
.replace("Selected", "");
246 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
247 var child
= content
.childNodes
[i
];
248 if (child
.id
== "feedCatHolder") {
249 parent
.debug(child
.id
);
250 var fcat
= child
.lastChild
;
251 for (j
= 0; j
< fcat
.childNodes
.length
; j
++) {
252 var feed
= fcat
.childNodes
[j
];
253 feed
.className
= feed
.className
.replace("Selected", "");
261 function cleanSelected(element
) {
262 var content
= document
.getElementById(element
);
264 for (i
= 0; i
< content
.rows
.length
; i
++) {
265 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
269 function getVisibleUnreadHeadlines() {
270 var content
= document
.getElementById("headlinesList");
272 var rows
= new Array();
274 for (i
= 0; i
< content
.rows
.length
; i
++) {
275 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
276 if (row_id
.length
> 0 && content
.rows
[i
].className
.match("Unread")) {
283 function getVisibleHeadlineIds() {
285 var content
= document
.getElementById("headlinesList");
287 var rows
= new Array();
289 for (i
= 0; i
< content
.rows
.length
; i
++) {
290 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
291 if (row_id
.length
> 0) {
298 function getFirstVisibleHeadlineId() {
299 var rows
= getVisibleHeadlineIds();
303 function getLastVisibleHeadlineId() {
304 var rows
= getVisibleHeadlineIds();
305 return rows
[rows
.length
-1];
308 function markHeadline(id
) {
309 var row
= document
.getElementById("RROW-" + id
);
311 var is_active
= false;
313 if (row
.className
.match("Active")) {
316 row
.className
= row
.className
.replace("Selected", "");
317 row
.className
= row
.className
.replace("Active", "");
318 row
.className
= row
.className
.replace("Insensitive", "");
321 row
.className
= row
.className
= "Active";
324 var check
= document
.getElementById("RCHK-" + id
);
327 check
.checked
= true;
330 row
.className
= row
.className
+ "Selected";
335 function getFeedIds() {
336 var content
= document
.getElementById("feedsList");
338 var rows
= new Array();
340 for (i
= 0; i
< content
.rows
.length
; i
++) {
341 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
350 function setCookie(name
, value
, lifetime
, path
, domain
, secure
) {
356 d
.setTime(lifetime
* 1000);
359 int_setCookie(name
, value
, d
, path
, domain
, secure
);
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" : "");
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";
381 function getCookie(name
) {
383 var dc
= document
.cookie
;
384 var prefix
= name
+ "=";
385 var begin
= dc
.indexOf("; " + prefix
);
387 begin
= dc
.indexOf(prefix
);
388 if (begin
!= 0) return null;
393 var end
= document
.cookie
.indexOf(";", begin
);
397 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
400 function disableContainerChildren(id
, disable
, doc
) {
402 if (!doc
) doc
= document
;
404 var container
= doc
.getElementById(id
);
407 //alert("disableContainerChildren: element " + id + " not found");
411 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
412 var child
= container
.childNodes
[i
];
415 child
.disabled
= disable
;
421 if (child
.className
&& child
.className
.match("button")) {
422 child
.className
= "disabledButton";
425 if (child
.className
&& child
.className
.match("disabledButton")) {
426 child
.className
= "button";
433 function gotoPreferences() {
434 document
.location
.href
= "prefs.php";
437 function gotoMain() {
438 document
.location
.href
= "tt-rss.php";
441 function gotoExportOpml() {
442 document
.location
.href
= "opml.php?op=Export";
445 function getActiveFeedId() {
446 // return getCookie("ttrss_vf_actfeed");
448 debug("gAFID: " + getMainContext().active_feed_id
);
449 return getMainContext().active_feed_id
;
451 exception_error("getActiveFeedId", e
);
455 function activeFeedIsCat() {
456 return getMainContext().active_feed_is_cat
;
459 function setActiveFeedId(id
) {
460 // return setCookie("ttrss_vf_actfeed", id);
462 debug("sAFID(" + id
+ ")");
463 getMainContext().active_feed_id
= id
;
465 exception_error("setActiveFeedId", e
);
469 function parse_counters(reply
, scheduled_call
) {
471 var f_document
= getFeedsContext().document
;
472 var title_obj
= getMainContext();
476 if (reply
.firstChild
&& reply
.firstChild
.firstChild
) {
477 debug("<b>wrong element passed to parse_counters, adjusting.</b>");
478 reply
= reply
.firstChild
;
481 debug("F_DOC: " + f_document
+ ", T_OBJ: " + title_obj
);
483 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
484 if (!reply
.childNodes
[l
] ||
485 typeof(reply
.childNodes
[l
].getAttribute
) == "undefined") {
486 // where did this come from?
490 var id
= reply
.childNodes
[l
].getAttribute("id");
491 var t
= reply
.childNodes
[l
].getAttribute("type");
492 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
493 var error
= reply
.childNodes
[l
].getAttribute("error");
494 var has_img
= reply
.childNodes
[l
].getAttribute("hi");
495 var updated
= reply
.childNodes
[l
].getAttribute("updated");
497 if (id
== "global-unread") {
498 title_obj
.global_unread
= ctr
;
499 title_obj
.updateTitle();
503 if (id
== "subscribed-feeds") {
508 if (t
== "category") {
509 var catctr
= f_document
.getElementById("FCATCTR-" + id
);
511 catctr
.innerHTML
= "(" + ctr
+ " unread)";
516 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
517 var feedu
= f_document
.getElementById("FEEDU-" + id
);
518 var feedr
= f_document
.getElementById("FEEDR-" + id
);
519 var feed_img
= f_document
.getElementById("FIMG-" + id
);
520 var feedlink
= f_document
.getElementById("FEEDL-" + id
);
521 var feedupd
= f_document
.getElementById("FLUPD-" + id
);
523 if (updated
&& feedlink
) {
525 feedlink
.title
= "Error: " + error
+ " (" + updated
+ ")";
527 feedlink
.title
= "Updated: " + updated
;
531 if (updated
&& feedupd
) {
533 feedupd
.innerHTML
= updated
+ " (Error)";
535 feedupd
.innerHTML
= updated
;
539 if (feedctr
&& feedu
&& feedr
) {
541 if (feedu
.innerHTML
!= ctr
&& id
== getActiveFeedId() && scheduled_call
) {
542 var hf
= title_obj
.parent
.frames
["headlines-frame"];
543 hf
.location
.reload(true);
546 feedu
.innerHTML
= ctr
;
549 feedr
.className
= feedr
.className
.replace("feed", "error");
551 feedr
.className
= feedr
.className
.replace("error", "feed");
555 feedctr
.className
= "odd";
556 if (!feedr
.className
.match("Unread")) {
557 var is_selected
= feedr
.className
.match("Selected");
559 feedr
.className
= feedr
.className
.replace("Selected", "");
560 feedr
.className
= feedr
.className
.replace("Unread", "");
562 feedr
.className
= feedr
.className
+ "Unread";
565 feedr
.className
= feedr
.className
+ "Selected";
570 feedctr
.className
= "invisible";
571 feedr
.className
= feedr
.className
.replace("Unread", "");
576 var feeds_stored
= getMainContext().number_of_feeds
;
578 debug("Feed counters, C: " + feeds_found
+ ", S:" + feeds_stored
);
580 if (feeds_stored
!= feeds_found
) {
581 getMainContext().number_of_feeds
= feeds_found
;
583 if (feeds_stored
!= 0) {
584 debug("Subscribed feed number changed, refreshing feedlist");
590 exception_error("parse_counters", e
);
594 function all_counters_callback() {
595 if (xmlhttp_rpc
.readyState
== 4) {
597 if (!xmlhttp_rpc
.responseXML
|| !xmlhttp_rpc
.responseXML
.firstChild
) {
598 debug("[all_counters_callback] backend did not return valid XML");
602 debug("in all_counters_callback");
604 var reply
= xmlhttp_rpc
.responseXML
.firstChild
;
606 var counters
= reply
.firstChild
;
608 parse_counters(counters
);
610 var runtime
= counters
.nextSibling
;
613 getMainContext().parse_runtime_info(runtime
);
616 if (getInitParam("feeds_sort_by_unread") == 1) {
620 hideOrShowFeeds(document
, getInitParam("hide_read_feeds") == 1);
623 exception_error("all_counters_callback", e
);
628 function get_feed_entry_unread(doc
, elem
) {
630 var id
= elem
.id
.replace("FEEDR-", "");
637 return parseInt(doc
.getElementById("FEEDU-" + id
).innerHTML
);
643 function resort_category(doc
, node
) {
644 debug("resort_category: " + node
);
646 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
647 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
648 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
650 if (get_feed_entry_unread(doc
, node
.childNodes
[i
]) < 0) {
654 for (j
= i
+1; j
< node
.childNodes
.length
; j
++) {
655 if (node
.childNodes
[j
].nodeName
!= "LI") { continue; }
657 var tmp_val
= get_feed_entry_unread(doc
, node
.childNodes
[i
]);
658 var cur_val
= get_feed_entry_unread(doc
, node
.childNodes
[j
]);
660 if (cur_val
> tmp_val
) {
661 tempnode_i
= node
.childNodes
[i
].cloneNode(true);
662 tempnode_j
= node
.childNodes
[j
].cloneNode(true);
663 node
.replaceChild(tempnode_i
, node
.childNodes
[j
]);
664 node
.replaceChild(tempnode_j
, node
.childNodes
[i
]);
673 function resort_feedlist() {
674 debug("resort_feedlist");
676 var fd
= getFeedsContext().document
;
678 if (fd
.getElementById("feedCatHolder")) {
680 var feeds
= fd
.getElementById("feedList");
681 var child
= feeds
.firstChild
;
685 if (child
.id
== "feedCatHolder") {
686 resort_category(fd
, child
.firstChild
);
689 child
= child
.nextSibling
;
693 resort_category(fd
, fd
.getElementById("feedList"));
697 function update_all_counters(feed
) {
698 if (xmlhttp_ready(xmlhttp_rpc
)) {
699 var query
= "backend.php?op=rpc&subop=getAllCounters";
702 query
= query
+ "&aid=" + feed
;
705 xmlhttp_rpc
.open("GET", query
, true);
706 xmlhttp_rpc
.onreadystatechange
=all_counters_callback
;
707 xmlhttp_rpc
.send(null);
711 function popupHelp(tid
) {
712 var w
= window
.open("backend.php?op=help&tid=" + tid
,
714 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
717 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
718 * * @author Sundar Dorai-Raj
719 * * Email: sdoraira@vt.edu
720 * * This program is free software; you can redistribute it and/or
721 * * modify it under the terms of the GNU General Public License
722 * * as published by the Free Software Foundation; either version 2
723 * * of the License, or (at your option) any later version,
724 * * provided that any use properly credits the author.
725 * * This program is distributed in the hope that it will be useful,
726 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
727 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
728 * * GNU General Public License for more details at http://www.gnu.org * * */
730 var numbers
=".0123456789";
731 function isNumeric(x
) {
732 // is x a String or a character?
734 // remove negative sign
736 for(j
=0;j
<x
.length
;j
++) {
737 // call isNumeric recursively for each character
738 number
=isNumeric(x
.substring(j
,j
+1));
739 if(!number
) return number
;
744 // if x is number return true
745 if(numbers
.indexOf(x
)>=0) return true;
751 function hideOrShowFeeds(doc
, hide
) {
753 var fd
= getFeedsContext().document
;
755 var list
= fd
.getElementById("feedList");
757 if (fd
.getElementById("feedCatHolder")) {
759 var feeds
= fd
.getElementById("feedList");
760 var child
= feeds
.firstChild
;
764 if (child
.id
== "feedCatHolder") {
765 hideOrShowFeedsCategory(fd
, child
.firstChild
, hide
, child
.previousSibling
);
768 child
= child
.nextSibling
;
772 hideOrShowFeedsCategory(fd
, fd
.getElementById("feedList"), hide
);
776 function hideOrShowFeedsCategory(doc
, node
, hide
, cat_node
) {
778 // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
782 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
783 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
784 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
786 if (node
.childNodes
[i
].style
!= undefined) {
788 var has_unread
= (node
.childNodes
[i
].className
!= "feed");
790 // debug(node.childNodes[i].id + " --> " + has_unread);
792 if (hide
&& !has_unread
) {
793 node
.childNodes
[i
].style
.display
= "none";
797 node
.childNodes
[i
].style
.display
= "list-item";
807 if (cat_unread
== 0) {
808 if (cat_node
.style
== undefined) {
809 debug("ERROR: supplied cat_node " + cat_node
+
810 " has no styles. WTF?");
814 cat_node
.style
.display
= "none";
816 cat_node
.style
.display
= "list-item";
820 // debug("unread for category: " + cat_unread);
823 function selectTableRow(r
, do_select
) {
824 r
.className
= r
.className
.replace("Selected", "");
827 r
.className
= r
.className
+ "Selected";
831 function selectTableRowById(elem_id
, check_id
, do_select
) {
835 var row
= document
.getElementById(elem_id
);
838 selectTableRow(row
, do_select
);
841 var check
= document
.getElementById(check_id
);
844 check
.checked
= do_select
;
847 exception_error("selectTableRowById", e
);
851 function selectTableRowsByIdPrefix(content_id
, prefix
, check_prefix
, do_select
,
852 classcheck
, reset_others
) {
854 var content
= document
.getElementById(content_id
);
857 alert("[selectTableRows] Element " + content_id
+ " not found.");
861 for (i
= 0; i
< content
.rows
.length
; i
++) {
862 if (!classcheck
|| content
.rows
[i
].className
.match(classcheck
)) {
864 if (content
.rows
[i
].id
.match(prefix
)) {
865 selectTableRow(content
.rows
[i
], do_select
);
867 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
868 var check
= document
.getElementById(check_prefix
+ row_id
);
871 check
.checked
= do_select
;
873 } else if (reset_others
) {
874 selectTableRow(content
.rows
[i
], false);
876 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
877 var check
= document
.getElementById(check_prefix
+ row_id
);
880 check
.checked
= false;
884 } else if (reset_others
) {
885 selectTableRow(content
.rows
[i
], false);
887 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
888 var check
= document
.getElementById(check_prefix
+ row_id
);
891 check
.checked
= false;
898 function getSelectedTableRowIds(content_id
, prefix
) {
900 var content
= document
.getElementById(content_id
);
903 alert("[getSelectedTableRowIds] Element " + content_id
+ " not found.");
907 var sel_rows
= new Array();
909 for (i
= 0; i
< content
.rows
.length
; i
++) {
910 if (content
.rows
[i
].id
.match(prefix
) &&
911 content
.rows
[i
].className
.match("Selected")) {
913 var row_id
= content
.rows
[i
].id
.replace(prefix
+ "-", "");
914 sel_rows
.push(row_id
);
922 function toggleSelectRowById(sender
, id
) {
923 var row
= document
.getElementById(id
);
925 if (sender
.checked
) {
926 if (!row
.className
.match("Selected")) {
927 row
.className
= row
.className
+ "Selected";
930 if (row
.className
.match("Selected")) {
931 row
.className
= row
.className
.replace("Selected", "");
936 function toggleSelectListRow(sender
) {
937 var parent_row
= sender
.parentNode
;
939 if (sender
.checked
) {
940 if (!parent_row
.className
.match("Selected")) {
941 parent_row
.className
= parent_row
.className
+ "Selected";
944 if (parent_row
.className
.match("Selected")) {
945 parent_row
.className
= parent_row
.className
.replace("Selected", "");
951 function toggleSelectRow(sender
) {
952 var parent_row
= sender
.parentNode
.parentNode
;
954 if (sender
.checked
) {
955 if (!parent_row
.className
.match("Selected")) {
956 parent_row
.className
= parent_row
.className
+ "Selected";
959 if (parent_row
.className
.match("Selected")) {
960 parent_row
.className
= parent_row
.className
.replace("Selected", "");
965 function openExternalUrl(url
) {
966 var w
= window
.open(url
);
969 function getRelativeFeedId(list
, id
, direction
, unread_only
) {
971 if (direction
== "next") {
972 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
973 var child
= list
.childNodes
[i
];
974 if (child
.id
&& child
.id
== "feedCatHolder") {
975 if (child
.lastChild
) {
976 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
979 } else if (child
.id
&& child
.id
.match("FEEDR-")) {
980 return child
.id
.replace('FEEDR-', '');
985 // FIXME select last feed doesn't work when only unread feeds are visible
987 if (direction
== "prev") {
988 for (i
= list
.childNodes
.length
-1; i
>= 0; i
--) {
989 var child
= list
.childNodes
[i
];
990 if (child
.id
== "feedCatHolder") {
991 if (child
.firstChild
) {
992 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
995 } else if (child
.id
.match("FEEDR-")) {
997 if (getInitParam("hide_read_feeds") == 1) {
998 if (child
.className
!= "feed") {
999 alert(child
.className
);
1000 return child
.id
.replace('FEEDR-', '');
1003 return child
.id
.replace('FEEDR-', '');
1010 var feed
= list
.ownerDocument
.getElementById("FEEDR-" + getActiveFeedId());
1012 if (getInitParam("hide_read_feeds") == 1) {
1016 if (direction
== "next") {
1022 if (e
.nextSibling
) {
1026 } else if (e
.parentNode
.parentNode
.nextSibling
) {
1028 var this_cat
= e
.parentNode
.parentNode
;
1032 if (this_cat
&& this_cat
.nextSibling
) {
1033 while (!e
&& this_cat
.nextSibling
) {
1034 this_cat
= this_cat
.nextSibling
;
1035 if (this_cat
.id
== "feedCatHolder") {
1036 e
= this_cat
.firstChild
.firstChild
;
1046 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1047 e
.className
!= "error")) {
1048 return e
.id
.replace("FEEDR-", "");
1053 } else if (direction
== "prev") {
1059 if (e
.previousSibling
) {
1061 e
= e
.previousSibling
;
1063 } else if (e
.parentNode
.parentNode
.previousSibling
) {
1065 var this_cat
= e
.parentNode
.parentNode
;
1069 if (this_cat
&& this_cat
.previousSibling
) {
1070 while (!e
&& this_cat
.previousSibling
) {
1071 this_cat
= this_cat
.previousSibling
;
1072 if (this_cat
.id
== "feedCatHolder") {
1073 e
= this_cat
.firstChild
.lastChild
;
1083 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1084 e
.className
!= "error")) {
1085 return e
.id
.replace("FEEDR-", "");
1093 function showBlockElement(id
) {
1094 var elem
= document
.getElementById(id
);
1097 elem
.style
.display
= "block";
1099 alert("[showBlockElement] can't find element with id " + id
);
1103 function hideParentElement(e
) {
1104 e
.parentNode
.style
.display
= "none";
1107 function dropboxSelect(e
, v
) {
1108 for (i
= 0; i
< e
.length
; i
++) {
1109 if (e
[i
].value
== v
) {
1110 e
.selectedIndex
= i
;
1116 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1117 // bugfixed just a little bit :-)
1118 function getURLParam(strParamName
){
1120 var strHref
= window
.location
.href
;
1122 if (strHref
.indexOf("#") == strHref
.length
-1) {
1123 strHref
= strHref
.substring(0, strHref
.length
-1);
1126 if ( strHref
.indexOf("?") > -1 ){
1127 var strQueryString
= strHref
.substr(strHref
.indexOf("?"));
1128 var aQueryString
= strQueryString
.split("&");
1129 for ( var iParam
= 0; iParam
< aQueryString
.length
; iParam
++ ){
1130 if (aQueryString
[iParam
].indexOf(strParamName
+ "=") > -1 ){
1131 var aParam
= aQueryString
[iParam
].split("=");
1132 strReturn
= aParam
[1];
1140 function leading_zero(p
) {
1142 if (s
.length
== 1) s
= "0" + s
;
1146 function closeInfoBox(cleanup
) {
1147 var box
= document
.getElementById('infoBox');
1148 var shadow
= document
.getElementById('infoBoxShadow');
1151 shadow
.style
.display
= "none";
1153 box
.style
.display
= "none";
1156 if (cleanup
) box
.innerHTML
= " ";
1164 function displayDlg(id
, param
) {
1166 if (!xmlhttp_ready(xmlhttp
)) {
1167 printLockingError();
1173 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
1174 param_escape(id
) + "¶m=" + param_escape(param
), true);
1175 xmlhttp
.onreadystatechange
=infobox_callback
;
1183 function infobox_submit_callback() {
1184 if (xmlhttp
.readyState
== 4) {
1187 // called from prefs, reload tab
1189 selectTab(active_tab
, false);
1192 notify(xmlhttp
.responseText
);
1197 function infobox_callback() {
1198 if (xmlhttp
.readyState
== 4) {
1199 var box
= document
.getElementById('infoBox');
1200 var shadow
= document
.getElementById('infoBoxShadow');
1202 box
.innerHTML
=xmlhttp
.responseText
;
1204 shadow
.style
.display
= "block";
1206 box
.style
.display
= "block";
1212 function qaddFilter() {
1214 if (!xmlhttp_ready(xmlhttp
)) {
1215 printLockingError();
1219 var query
= Form
.serialize("filter_add_form");
1221 xmlhttp
.open("GET", "backend.php?" + query
, true);
1222 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
1228 function toggleSubmitNotEmpty(e
, submit_id
) {
1230 document
.getElementById(submit_id
).disabled
= (e
.value
== "")
1232 exception_error("toggleSubmitNotEmpty", e
);
1236 function isValidURL(s
) {
1237 return s
.match("http://") != null || s
.match("https://") != null;
1242 if (!xmlhttp_ready(xmlhttp
)) {
1243 printLockingError();
1247 notify("Adding feed...");
1251 var feeds_doc
= getFeedsContext().document
;
1253 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
1255 var query
= Form
.serialize("feed_add_form");
1257 xmlhttp
.open("GET", "backend.php?" + query
, true);
1258 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
1262 function filterCR(e
)
1267 key
= window
.event
.keyCode
; //IE
1269 key
= e
.which
; //firefox
1277 function getMainContext() {
1278 if (parent
.window
!= window
) {
1279 return parent
.window
;
1285 function getFeedsContext() {
1287 return getMainContext().frames
["feeds-frame"];
1289 exception_error("getFeedsContext", e
);
1294 function getHeadlinesContext() {
1296 return getMainContext().frames
["headlines-frame"];
1298 exception_error("getHeadlinesContext", e
);
1302 var debug_last_class
= "even";
1304 function debug(msg
) {
1305 var ctx
= getMainContext();
1307 if (ctx
.debug_last_class
== "even") {
1308 ctx
.debug_last_class
= "odd";
1310 ctx
.debug_last_class
= "even";
1313 var c
= ctx
.document
.getElementById('debug_output');
1314 if (c
&& c
.style
.display
== "block") {
1315 while (c
.lastChild
!= 'undefined' && c
.childNodes
.length
> 100) {
1316 c
.removeChild(c
.lastChild
);
1320 var ts
= leading_zero(d
.getHours()) + ":" + leading_zero(d
.getMinutes()) +
1321 ":" + leading_zero(d
.getSeconds());
1322 c
.innerHTML
= "<li class=\"" + ctx
.debug_last_class
+ "\"><span class=\"debugTS\">[" + ts
+ "]</span> " +
1323 msg
+ "</li>" + c
.innerHTML
;
1327 function getInitParam(key
) {
1328 return getMainContext().init_params
[key
];
1331 function storeInitParam(key
, value
, is_client
) {
1334 if (getMainContext().init_params
[key
] != value
) {
1335 debug("storeInitParam: " + key
+ " => " + value
);
1336 //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" +
1337 // param_escape(key) + "&value=" + param_escape(value));
1338 var f
= getMainContext().document
.getElementById("backReqBox");
1339 f
.src
= "backend.php?op=rpc&subop=storeParam&key=" +
1340 param_escape(key
) + "&value=" + param_escape(value
);
1343 getMainContext().init_params
[key
] = value
;
1345 exception_error("storeInitParam", e
);
1350 function storeInitParams(params, is_client) {
1355 if (getMainContext().init_params[k] != params[k]) {
1356 s += k + "=" + params[k] + ";";
1357 getMainContext().init_params[k] = params[k];
1361 debug("storeInitParams: " + s);
1364 new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
1367 exception_error("storeInitParams", e);
1371 function fatalError(code
, message
) {
1373 var fe
= document
.getElementById("fatal_error");
1374 var fc
= document
.getElementById("fatal_error_msg");
1376 fc
.innerHTML
= "Code " + code
+ ": " + message
;
1378 fe
.style
.display
= "block";
1381 exception_error("fatalError", e
);
1385 function getFeedName(id
, is_cat
) {
1386 var d
= getFeedsContext().document
;
1391 e
= d
.getElementById("FCATN-" + id
);
1393 e
= d
.getElementById("FEEDN-" + id
);
1396 return e
.innerHTML
.stripTags();