]>
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
, 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 if (keycode
== 82) { // r
173 return scheduleFeedUpdate(true);
176 if (keycode
== 83) { // r
177 return displayDlg("search", getActiveFeedId());
180 if (keycode
== 85) { // u
181 if (getActiveFeedId()) {
182 return viewfeed(getActiveFeedId(), "ForceUpdate");
186 if (keycode
== 65) { // a
187 return toggleDispRead();
190 var feedlist
= document
.getElementById('feedList');
192 if (keycode
== 74) { // j
193 var feed
= getActiveFeedId();
194 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
195 if (new_feed
) viewfeed(new_feed
, '');
198 if (keycode
== 75) { // k
199 var feed
= getActiveFeedId();
200 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
201 if (new_feed
) viewfeed(new_feed
, '');
204 if (keycode
== 78 || keycode
== 40) { // n, down
205 if (typeof moveToPost
!= 'undefined') {
206 return moveToPost('next');
210 if (keycode
== 80 || keycode
== 38) { // p, up
211 if (typeof moveToPost
!= 'undefined') {
212 return moveToPost('prev');
216 if (typeof localHotkeyHandler
!= 'undefined') {
218 localHotkeyHandler(keycode
);
220 exception_error("hotkey_handler, local:", e
);
224 exception_error("hotkey_handler", e
);
228 function cleanSelectedList(element
) {
229 var content
= document
.getElementById(element
);
231 if (!document
.getElementById("feedCatHolder")) {
232 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
233 var child
= content
.childNodes
[i
];
235 child
.className
= child
.className
.replace("Selected", "");
241 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
242 var child
= content
.childNodes
[i
];
243 if (child
.id
== "feedCatHolder") {
245 var fcat
= child
.lastChild
;
246 for (j
= 0; j
< fcat
.childNodes
.length
; j
++) {
247 var feed
= fcat
.childNodes
[j
];
248 feed
.className
= feed
.className
.replace("Selected", "");
256 function cleanSelected(element
) {
257 var content
= document
.getElementById(element
);
259 for (i
= 0; i
< content
.rows
.length
; i
++) {
260 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
264 function getVisibleUnreadHeadlines() {
265 var content
= document
.getElementById("headlinesList");
267 var rows
= new Array();
269 for (i
= 0; i
< content
.rows
.length
; i
++) {
270 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
271 if (row_id
.length
> 0 && content
.rows
[i
].className
.match("Unread")) {
278 function getVisibleHeadlineIds() {
280 var content
= document
.getElementById("headlinesList");
282 var rows
= new Array();
284 for (i
= 0; i
< content
.rows
.length
; i
++) {
285 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
286 if (row_id
.length
> 0) {
293 function getFirstVisibleHeadlineId() {
294 var rows
= getVisibleHeadlineIds();
298 function getLastVisibleHeadlineId() {
299 var rows
= getVisibleHeadlineIds();
300 return rows
[rows
.length
-1];
303 function markHeadline(id
) {
304 var row
= document
.getElementById("RROW-" + id
);
306 var is_active
= false;
308 if (row
.className
.match("Active")) {
311 row
.className
= row
.className
.replace("Selected", "");
312 row
.className
= row
.className
.replace("Active", "");
313 row
.className
= row
.className
.replace("Insensitive", "");
316 row
.className
= row
.className
= "Active";
319 var check
= document
.getElementById("RCHK-" + id
);
322 check
.checked
= true;
325 row
.className
= row
.className
+ "Selected";
330 function getFeedIds() {
331 var content
= document
.getElementById("feedsList");
333 var rows
= new Array();
335 for (i
= 0; i
< content
.rows
.length
; i
++) {
336 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
345 function setCookie(name
, value
, lifetime
, path
, domain
, secure
) {
351 d
.setTime(lifetime
* 1000);
354 int_setCookie(name
, value
, d
, path
, domain
, secure
);
358 function int_setCookie(name
, value
, expires
, path
, domain
, secure
) {
359 document
.cookie
= name
+ "=" + escape(value
) +
360 ((expires
) ? "; expires=" + expires
.toGMTString() : "") +
361 ((path
) ? "; path=" + path
: "") +
362 ((domain
) ? "; domain=" + domain
: "") +
363 ((secure
) ? "; secure" : "");
366 function delCookie(name
, path
, domain
) {
367 if (getCookie(name
)) {
368 document
.cookie
= name
+ "=" +
369 ((path
) ? ";path=" + path
: "") +
370 ((domain
) ? ";domain=" + domain
: "" ) +
371 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
376 function getCookie(name
) {
378 var dc
= document
.cookie
;
379 var prefix
= name
+ "=";
380 var begin
= dc
.indexOf("; " + prefix
);
382 begin
= dc
.indexOf(prefix
);
383 if (begin
!= 0) return null;
388 var end
= document
.cookie
.indexOf(";", begin
);
392 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
395 function disableContainerChildren(id
, disable
, doc
) {
397 if (!doc
) doc
= document
;
399 var container
= doc
.getElementById(id
);
402 //alert("disableContainerChildren: element " + id + " not found");
406 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
407 var child
= container
.childNodes
[i
];
410 child
.disabled
= disable
;
416 if (child
.className
&& child
.className
.match("button")) {
417 child
.className
= "disabledButton";
420 if (child
.className
&& child
.className
.match("disabledButton")) {
421 child
.className
= "button";
428 function gotoPreferences() {
429 document
.location
.href
= "prefs.php";
432 function gotoMain() {
433 document
.location
.href
= "tt-rss.php";
436 function gotoExportOpml() {
437 document
.location
.href
= "opml.php?op=Export";
440 function getActiveFeedId() {
441 // return getCookie("ttrss_vf_actfeed");
443 debug("gAFID: " + active_feed_id
);
444 return active_feed_id
;
446 exception_error("getActiveFeedId", e
);
450 function activeFeedIsCat() {
451 return active_feed_is_cat
;
454 function setActiveFeedId(id
) {
455 // return setCookie("ttrss_vf_actfeed", id);
457 debug("sAFID(" + id
+ ")");
460 exception_error("setActiveFeedId", e
);
464 function parse_counters(reply
, scheduled_call
) {
469 if (reply
.firstChild
&& reply
.firstChild
.firstChild
) {
470 debug("<b>wrong element passed to parse_counters, adjusting.</b>");
471 reply
= reply
.firstChild
;
474 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
475 if (!reply
.childNodes
[l
] ||
476 typeof(reply
.childNodes
[l
].getAttribute
) == "undefined") {
477 // where did this come from?
481 var id
= reply
.childNodes
[l
].getAttribute("id");
482 var t
= reply
.childNodes
[l
].getAttribute("type");
483 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
484 var error
= reply
.childNodes
[l
].getAttribute("error");
485 var has_img
= reply
.childNodes
[l
].getAttribute("hi");
486 var updated
= reply
.childNodes
[l
].getAttribute("updated");
488 if (id
== "global-unread") {
494 if (id
== "subscribed-feeds") {
499 if (t
== "category") {
500 var catctr
= document
.getElementById("FCATCTR-" + id
);
502 catctr
.innerHTML
= "(" + ctr
+ " unread)";
507 var feedctr
= document
.getElementById("FEEDCTR-" + id
);
508 var feedu
= document
.getElementById("FEEDU-" + id
);
509 var feedr
= document
.getElementById("FEEDR-" + id
);
510 var feed_img
= document
.getElementById("FIMG-" + id
);
511 var feedlink
= document
.getElementById("FEEDL-" + id
);
512 var feedupd
= document
.getElementById("FLUPD-" + id
);
514 if (updated
&& feedlink
) {
516 feedlink
.title
= "Error: " + error
+ " (" + updated
+ ")";
518 feedlink
.title
= "Updated: " + updated
;
522 if (updated
&& feedupd
) {
524 feedupd
.innerHTML
= updated
+ " (Error)";
526 feedupd
.innerHTML
= updated
;
530 if (feedctr
&& feedu
&& feedr
) {
532 if (feedu
.innerHTML
!= ctr
&& id
== getActiveFeedId() && scheduled_call
) {
536 feedu
.innerHTML
= ctr
;
539 feedr
.className
= feedr
.className
.replace("feed", "error");
541 feedr
.className
= feedr
.className
.replace("error", "feed");
545 feedctr
.className
= "odd";
546 if (!feedr
.className
.match("Unread")) {
547 var is_selected
= feedr
.className
.match("Selected");
549 feedr
.className
= feedr
.className
.replace("Selected", "");
550 feedr
.className
= feedr
.className
.replace("Unread", "");
552 feedr
.className
= feedr
.className
+ "Unread";
555 feedr
.className
= feedr
.className
+ "Selected";
560 feedctr
.className
= "invisible";
561 feedr
.className
= feedr
.className
.replace("Unread", "");
566 hideOrShowFeeds(document
, getInitParam("hide_read_feeds") == 1);
568 var feeds_stored
= number_of_feeds
;
570 debug("Feed counters, C: " + feeds_found
+ ", S:" + feeds_stored
);
572 if (feeds_stored
!= feeds_found
) {
573 number_of_feeds
= feeds_found
;
575 if (feeds_stored
!= 0) {
576 debug("Subscribed feed number changed, refreshing feedlist");
577 setTimeout('updateFeedList(false, false)', 50);
582 exception_error("parse_counters", e
);
586 function all_counters_callback() {
587 if (xmlhttp_rpc
.readyState
== 4) {
589 if (!xmlhttp_rpc
.responseXML
|| !xmlhttp_rpc
.responseXML
.firstChild
) {
590 debug("[all_counters_callback] backend did not return valid XML");
594 debug("in all_counters_callback : " + xmlhttp_rpc
.responseXML
);
596 var reply
= xmlhttp_rpc
.responseXML
.firstChild
;
598 var counters
= reply
.firstChild
;
600 parse_counters(counters
);
602 var runtime
= counters
.nextSibling
;
605 parse_runtime_info(runtime
);
608 if (getInitParam("feeds_sort_by_unread") == 1) {
612 hideOrShowFeeds(document
, getInitParam("hide_read_feeds") == 1);
615 exception_error("all_counters_callback", e
);
620 function get_feed_entry_unread(doc
, elem
) {
622 var id
= elem
.id
.replace("FEEDR-", "");
629 return parseInt(doc
.getElementById("FEEDU-" + id
).innerHTML
);
635 function resort_category(doc
, node
) {
636 debug("resort_category: " + node
);
638 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
639 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
640 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
642 if (get_feed_entry_unread(doc
, node
.childNodes
[i
]) < 0) {
646 for (j
= i
+1; j
< node
.childNodes
.length
; j
++) {
647 if (node
.childNodes
[j
].nodeName
!= "LI") { continue; }
649 var tmp_val
= get_feed_entry_unread(doc
, node
.childNodes
[i
]);
650 var cur_val
= get_feed_entry_unread(doc
, node
.childNodes
[j
]);
652 if (cur_val
> tmp_val
) {
653 tempnode_i
= node
.childNodes
[i
].cloneNode(true);
654 tempnode_j
= node
.childNodes
[j
].cloneNode(true);
655 node
.replaceChild(tempnode_i
, node
.childNodes
[j
]);
656 node
.replaceChild(tempnode_j
, node
.childNodes
[i
]);
665 function resort_feedlist() {
666 debug("resort_feedlist");
670 if (fd
.getElementById("feedCatHolder")) {
672 var feeds
= fd
.getElementById("feedList");
673 var child
= feeds
.firstChild
;
677 if (child
.id
== "feedCatHolder") {
678 resort_category(fd
, child
.firstChild
);
681 child
= child
.nextSibling
;
685 resort_category(fd
, fd
.getElementById("feedList"));
689 function update_all_counters(feed
) {
690 if (xmlhttp_ready(xmlhttp_rpc
)) {
691 var query
= "backend.php?op=rpc&subop=getAllCounters";
694 query
= query
+ "&aid=" + feed
;
697 xmlhttp_rpc
.open("GET", query
, true);
698 xmlhttp_rpc
.onreadystatechange
=all_counters_callback
;
699 xmlhttp_rpc
.send(null);
703 function popupHelp(tid
) {
704 var w
= window
.open("backend.php?op=help&tid=" + tid
,
706 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
709 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
710 * * @author Sundar Dorai-Raj
711 * * Email: sdoraira@vt.edu
712 * * This program is free software; you can redistribute it and/or
713 * * modify it under the terms of the GNU General Public License
714 * * as published by the Free Software Foundation; either version 2
715 * * of the License, or (at your option) any later version,
716 * * provided that any use properly credits the author.
717 * * This program is distributed in the hope that it will be useful,
718 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
719 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
720 * * GNU General Public License for more details at http://www.gnu.org * * */
722 var numbers
=".0123456789";
723 function isNumeric(x
) {
724 // is x a String or a character?
726 // remove negative sign
728 for(j
=0;j
<x
.length
;j
++) {
729 // call isNumeric recursively for each character
730 number
=isNumeric(x
.substring(j
,j
+1));
731 if(!number
) return number
;
736 // if x is number return true
737 if(numbers
.indexOf(x
)>=0) return true;
743 function hideOrShowFeeds(doc
, hide
) {
745 debug("hideOrShowFeeds: " + doc
+ ", " + hide
);
749 var list
= fd
.getElementById("feedList");
751 if (fd
.getElementById("feedCatHolder")) {
753 var feeds
= fd
.getElementById("feedList");
754 var child
= feeds
.firstChild
;
758 if (child
.id
== "feedCatHolder") {
759 hideOrShowFeedsCategory(fd
, child
.firstChild
, hide
, child
.previousSibling
);
762 child
= child
.nextSibling
;
766 hideOrShowFeedsCategory(fd
, fd
.getElementById("feedList"), hide
);
770 function hideOrShowFeedsCategory(doc
, node
, hide
, cat_node
) {
772 // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
776 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
777 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
778 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
780 if (node
.childNodes
[i
].style
!= undefined) {
782 var has_unread
= (node
.childNodes
[i
].className
!= "feed");
784 // debug(node.childNodes[i].id + " --> " + has_unread);
786 if (hide
&& !has_unread
) {
787 node
.childNodes
[i
].style
.display
= "none";
791 node
.childNodes
[i
].style
.display
= "list-item";
795 node
.childNodes
[i
].style
.display
= "list-item";
802 if (cat_unread
== 0) {
803 if (cat_node
.style
== undefined) {
804 debug("ERROR: supplied cat_node " + cat_node
+
805 " has no styles. WTF?");
809 cat_node
.style
.display
= "none";
811 cat_node
.style
.display
= "list-item";
815 cat_node
.style
.display
= "list-item";
821 // debug("unread for category: " + cat_unread);
824 function selectTableRow(r
, do_select
) {
825 r
.className
= r
.className
.replace("Selected", "");
828 r
.className
= r
.className
+ "Selected";
832 function selectTableRowById(elem_id
, check_id
, do_select
) {
836 var row
= document
.getElementById(elem_id
);
839 selectTableRow(row
, do_select
);
842 var check
= document
.getElementById(check_id
);
845 check
.checked
= do_select
;
848 exception_error("selectTableRowById", e
);
852 function selectTableRowsByIdPrefix(content_id
, prefix
, check_prefix
, do_select
,
853 classcheck
, reset_others
) {
855 var content
= document
.getElementById(content_id
);
858 alert("[selectTableRows] Element " + content_id
+ " not found.");
862 for (i
= 0; i
< content
.rows
.length
; i
++) {
863 if (!classcheck
|| content
.rows
[i
].className
.match(classcheck
)) {
865 if (content
.rows
[i
].id
.match(prefix
)) {
866 selectTableRow(content
.rows
[i
], do_select
);
868 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
869 var check
= document
.getElementById(check_prefix
+ row_id
);
872 check
.checked
= do_select
;
874 } else if (reset_others
) {
875 selectTableRow(content
.rows
[i
], false);
877 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
878 var check
= document
.getElementById(check_prefix
+ row_id
);
881 check
.checked
= false;
885 } else if (reset_others
) {
886 selectTableRow(content
.rows
[i
], false);
888 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
889 var check
= document
.getElementById(check_prefix
+ row_id
);
892 check
.checked
= false;
899 function getSelectedTableRowIds(content_id
, prefix
) {
901 var content
= document
.getElementById(content_id
);
904 alert("[getSelectedTableRowIds] Element " + content_id
+ " not found.");
908 var sel_rows
= new Array();
910 for (i
= 0; i
< content
.rows
.length
; i
++) {
911 if (content
.rows
[i
].id
.match(prefix
) &&
912 content
.rows
[i
].className
.match("Selected")) {
914 var row_id
= content
.rows
[i
].id
.replace(prefix
+ "-", "");
915 sel_rows
.push(row_id
);
923 function toggleSelectRowById(sender
, id
) {
924 var row
= document
.getElementById(id
);
926 if (sender
.checked
) {
927 if (!row
.className
.match("Selected")) {
928 row
.className
= row
.className
+ "Selected";
931 if (row
.className
.match("Selected")) {
932 row
.className
= row
.className
.replace("Selected", "");
937 function toggleSelectListRow(sender
) {
938 var parent_row
= sender
.parentNode
;
940 if (sender
.checked
) {
941 if (!parent_row
.className
.match("Selected")) {
942 parent_row
.className
= parent_row
.className
+ "Selected";
945 if (parent_row
.className
.match("Selected")) {
946 parent_row
.className
= parent_row
.className
.replace("Selected", "");
952 function toggleSelectRow(sender
) {
953 var parent_row
= sender
.parentNode
.parentNode
;
955 if (sender
.checked
) {
956 if (!parent_row
.className
.match("Selected")) {
957 parent_row
.className
= parent_row
.className
+ "Selected";
960 if (parent_row
.className
.match("Selected")) {
961 parent_row
.className
= parent_row
.className
.replace("Selected", "");
966 function openExternalUrl(url
) {
967 var w
= window
.open(url
);
970 function getRelativeFeedId(list
, id
, direction
, unread_only
) {
972 if (direction
== "next") {
973 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
974 var child
= list
.childNodes
[i
];
975 if (child
.id
&& child
.id
== "feedCatHolder") {
976 if (child
.lastChild
) {
977 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
980 } else if (child
.id
&& child
.id
.match("FEEDR-")) {
981 return child
.id
.replace('FEEDR-', '');
986 // FIXME select last feed doesn't work when only unread feeds are visible
988 if (direction
== "prev") {
989 for (i
= list
.childNodes
.length
-1; i
>= 0; i
--) {
990 var child
= list
.childNodes
[i
];
991 if (child
.id
== "feedCatHolder") {
992 if (child
.firstChild
) {
993 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
996 } else if (child
.id
.match("FEEDR-")) {
998 if (getInitParam("hide_read_feeds") == 1) {
999 if (child
.className
!= "feed") {
1000 alert(child
.className
);
1001 return child
.id
.replace('FEEDR-', '');
1004 return child
.id
.replace('FEEDR-', '');
1011 var feed
= list
.ownerDocument
.getElementById("FEEDR-" + getActiveFeedId());
1013 if (getInitParam("hide_read_feeds") == 1) {
1017 if (direction
== "next") {
1023 if (e
.nextSibling
) {
1027 } else if (e
.parentNode
.parentNode
.nextSibling
) {
1029 var this_cat
= e
.parentNode
.parentNode
;
1033 if (this_cat
&& this_cat
.nextSibling
) {
1034 while (!e
&& this_cat
.nextSibling
) {
1035 this_cat
= this_cat
.nextSibling
;
1036 if (this_cat
.id
== "feedCatHolder") {
1037 e
= this_cat
.firstChild
.firstChild
;
1047 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1048 e
.className
!= "error")) {
1049 return e
.id
.replace("FEEDR-", "");
1054 } else if (direction
== "prev") {
1060 if (e
.previousSibling
) {
1062 e
= e
.previousSibling
;
1064 } else if (e
.parentNode
.parentNode
.previousSibling
) {
1066 var this_cat
= e
.parentNode
.parentNode
;
1070 if (this_cat
&& this_cat
.previousSibling
) {
1071 while (!e
&& this_cat
.previousSibling
) {
1072 this_cat
= this_cat
.previousSibling
;
1073 if (this_cat
.id
== "feedCatHolder") {
1074 e
= this_cat
.firstChild
.lastChild
;
1084 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1085 e
.className
!= "error")) {
1086 return e
.id
.replace("FEEDR-", "");
1094 function showBlockElement(id
) {
1095 var elem
= document
.getElementById(id
);
1098 elem
.style
.display
= "block";
1100 alert("[showBlockElement] can't find element with id " + id
);
1104 function hideParentElement(e
) {
1105 e
.parentNode
.style
.display
= "none";
1108 function dropboxSelect(e
, v
) {
1109 for (i
= 0; i
< e
.length
; i
++) {
1110 if (e
[i
].value
== v
) {
1111 e
.selectedIndex
= i
;
1117 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1118 // bugfixed just a little bit :-)
1119 function getURLParam(strParamName
){
1121 var strHref
= window
.location
.href
;
1123 if (strHref
.indexOf("#") == strHref
.length
-1) {
1124 strHref
= strHref
.substring(0, strHref
.length
-1);
1127 if ( strHref
.indexOf("?") > -1 ){
1128 var strQueryString
= strHref
.substr(strHref
.indexOf("?"));
1129 var aQueryString
= strQueryString
.split("&");
1130 for ( var iParam
= 0; iParam
< aQueryString
.length
; iParam
++ ){
1131 if (aQueryString
[iParam
].indexOf(strParamName
+ "=") > -1 ){
1132 var aParam
= aQueryString
[iParam
].split("=");
1133 strReturn
= aParam
[1];
1141 function leading_zero(p
) {
1143 if (s
.length
== 1) s
= "0" + s
;
1147 function closeInfoBox(cleanup
) {
1148 var box
= document
.getElementById('infoBox');
1149 var shadow
= document
.getElementById('infoBoxShadow');
1152 shadow
.style
.display
= "none";
1154 box
.style
.display
= "none";
1157 if (cleanup
) box
.innerHTML
= " ";
1165 function displayDlg(id
, param
) {
1167 if (!xmlhttp_ready(xmlhttp
)) {
1168 printLockingError();
1174 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
1175 param_escape(id
) + "¶m=" + param_escape(param
), true);
1176 xmlhttp
.onreadystatechange
=infobox_callback
;
1184 function infobox_submit_callback() {
1185 if (xmlhttp
.readyState
== 4) {
1188 // called from prefs, reload tab
1190 selectTab(active_tab
, false);
1193 notify(xmlhttp
.responseText
);
1198 function infobox_callback() {
1199 if (xmlhttp
.readyState
== 4) {
1200 var box
= document
.getElementById('infoBox');
1201 var shadow
= document
.getElementById('infoBoxShadow');
1203 box
.innerHTML
=xmlhttp
.responseText
;
1205 shadow
.style
.display
= "block";
1207 box
.style
.display
= "block";
1213 function qaddFilter() {
1215 if (!xmlhttp_ready(xmlhttp
)) {
1216 printLockingError();
1220 var query
= Form
.serialize("filter_add_form");
1222 xmlhttp
.open("GET", "backend.php?" + query
, true);
1223 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
1229 function toggleSubmitNotEmpty(e
, submit_id
) {
1231 document
.getElementById(submit_id
).disabled
= (e
.value
== "")
1233 exception_error("toggleSubmitNotEmpty", e
);
1237 function isValidURL(s
) {
1238 return s
.match("http://") != null || s
.match("https://") != null;
1243 if (!xmlhttp_ready(xmlhttp
)) {
1244 printLockingError();
1248 notify("Adding feed...");
1252 var feeds_doc
= document
;
1254 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
1256 var query
= Form
.serialize("feed_add_form");
1258 xmlhttp
.open("GET", "backend.php?" + query
, true);
1259 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
1265 function filterCR(e
)
1270 key
= window
.event
.keyCode
; //IE
1272 key
= e
.which
; //firefox
1280 function getMainContext() {
1284 function getFeedsContext() {
1288 function getContentContext() {
1292 function getHeadlinesContext() {
1296 var debug_last_class
= "even";
1298 function debug(msg
) {
1300 if (debug_last_class
== "even") {
1301 debug_last_class
= "odd";
1303 debug_last_class
= "even";
1306 var c
= document
.getElementById('debug_output');
1307 if (c
&& c
.style
.display
== "block") {
1308 while (c
.lastChild
!= 'undefined' && c
.childNodes
.length
> 100) {
1309 c
.removeChild(c
.lastChild
);
1313 var ts
= leading_zero(d
.getHours()) + ":" + leading_zero(d
.getMinutes()) +
1314 ":" + leading_zero(d
.getSeconds());
1315 c
.innerHTML
= "<li class=\"" + debug_last_class
+ "\"><span class=\"debugTS\">[" + ts
+ "]</span> " +
1316 msg
+ "</li>" + c
.innerHTML
;
1320 function getInitParam(key
) {
1321 return getMainContext().init_params
[key
];
1324 function storeInitParam(key
, value
, is_client
) {
1327 if (getMainContext().init_params
[key
] != value
) {
1328 debug("storeInitParam: " + key
+ " => " + value
);
1329 //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" +
1330 // param_escape(key) + "&value=" + param_escape(value));
1331 var f
= getMainContext().document
.getElementById("backReqBox");
1332 f
.src
= "backend.php?op=rpc&subop=storeParam&key=" +
1333 param_escape(key
) + "&value=" + param_escape(value
);
1336 getMainContext().init_params
[key
] = value
;
1338 exception_error("storeInitParam", e
);
1343 function storeInitParams(params, is_client) {
1348 if (getMainContext().init_params[k] != params[k]) {
1349 s += k + "=" + params[k] + ";";
1350 getMainContext().init_params[k] = params[k];
1354 debug("storeInitParams: " + s);
1357 new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
1360 exception_error("storeInitParams", e);
1364 function fatalError(code
, message
) {
1366 var fe
= document
.getElementById("fatal_error");
1367 var fc
= document
.getElementById("fatal_error_msg");
1369 fc
.innerHTML
= "Code " + code
+ ": " + message
;
1371 fe
.style
.display
= "block";
1374 exception_error("fatalError", e
);
1378 function getFeedName(id
, is_cat
) {
1379 var d
= getFeedsContext().document
;
1384 e
= d
.getElementById("FCATN-" + id
);
1386 e
= d
.getElementById("FEEDN-" + id
);
1389 return e
.innerHTML
.stripTags();
1395 function viewContentUrl(url
) {
1396 getContentContext().location
= url
;