]>
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;
10 function exception_error(location
, e
) {
14 var base_fname
= e
.fileName
.substring(e
.fileName
.lastIndexOf("/") + 1);
16 msg
= "Exception: " + e
.name
+ ", " + e
.message
+
17 "\nFunction: " + location
+ "()" +
18 "\nLocation: " + base_fname
+ ":" + e
.lineNumber
;
21 msg
= "Exception: " + e
+ "\nFunction: " + location
+ "()";
24 debug("<b>EXCEPTION: " + msg
+ "</b>");
29 function disableHotkeys() {
30 hotkeys_enabled
= false;
33 function enableHotkeys() {
34 hotkeys_enabled
= true;
37 function xmlhttp_ready(obj
) {
38 return obj
.readyState
== 4 || obj
.readyState
== 0 || !obj
.readyState
;
41 function notify_callback() {
42 var container
= document
.getElementById('notify');
43 if (xmlhttp
.readyState
== 4) {
44 container
.innerHTML
=xmlhttp
.responseText
;
48 function rpc_notify_callback() {
49 var container
= document
.getElementById('notify');
50 if (xmlhttp_rpc
.readyState
== 4) {
51 container
.innerHTML
=xmlhttp_rpc
.responseText
;
55 function param_escape(arg
) {
56 if (typeof encodeURIComponent
!= 'undefined')
57 return encodeURIComponent(arg
);
62 function param_unescape(arg
) {
63 if (typeof decodeURIComponent
!= 'undefined')
64 return decodeURIComponent(arg
);
71 then
=new Date().getTime();
73 while((now
-then
)<gap
) {
74 now
=new Date().getTime();
78 var notify_hide_timerid
= false;
79 var notify_last_doc
= false;
81 var notify_effect
= false;
83 function hide_notify() {
84 if (notify_last_doc
) {
85 var n
= notify_last_doc
.getElementById("notify");
86 if (browser_has_opacity()) {
87 if (notify_opacity
>= 0) {
88 notify_opacity
= notify_opacity
- 0.1;
89 n
.style
.opacity
= notify_opacity
;
90 notify_hide_timerid
= window
.setTimeout("hide_notify()", 20);
92 n
.style
.display
= "none";
96 n
.style
.display
= "none";
101 function notify_real(msg
, doc
, no_hide
, is_err
) {
103 var n
= doc
.getElementById("notify");
104 var nb
= doc
.getElementById("notify_body");
106 if (!n
|| !nb
) return;
108 if (notify_hide_timerid
) {
109 window
.clearTimeout(notify_hide_timerid
);
112 notify_last_doc
= doc
;
116 if (n
.style
.display
== "block") {
117 notify_hide_timerid
= window
.setTimeout("hide_notify()", 0);
121 n
.style
.display
= "block";
125 n
.style
.backgroundColor
= "#ffcccc";
126 n
.style
.color
= "black";
127 n
.style
.borderColor
= "#ff0000";
129 n
.style
.backgroundColor
= "#fff7d5";
130 n
.style
.borderColor
= "#d7c47a";
131 n
.style
.color
= "black";
137 notify_hide_timerid
= window
.setTimeout("hide_notify()", 3000);
141 function p_notify(msg
, no_hide
, is_err
) {
142 notify_real(msg
, parent
.document
, no_hide
, is_err
);
145 function notify(msg
, no_hide
, is_err
) {
146 notify_real(msg
, document
, no_hide
, is_err
);
149 function printLockingError() {
150 notify("Please wait until operation finishes");}
154 function hotkey_handler(e
) {
160 if (!hotkeys_enabled
) return;
163 keycode
= window
.event
.keyCode
;
168 if (keycode
== 13 || keycode
== 27) {
171 seq
= seq
+ "" + keycode
;
174 var m_ctx
= getMainContext();
175 var f_ctx
= getFeedsContext();
176 var h_ctx
= getHeadlinesContext();
178 if (keycode
== 82) { // r
179 return m_ctx
.scheduleFeedUpdate(true);
182 if (keycode
== 85) { // u
183 if (getActiveFeedId()) {
184 return f_ctx
.viewfeed(getActiveFeedId(), 0, "ForceUpdate");
188 if (keycode
== 65) { // a
189 return m_ctx
.toggleDispRead();
192 var f_doc
= m_ctx
.frames
["feeds-frame"].document
;
193 var feedlist
= f_doc
.getElementById('feedList');
195 if (keycode
== 74) { // j
196 var feed
= getActiveFeedId();
197 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
198 if (new_feed
) viewfeed(new_feed
, 0, '');
201 if (keycode
== 75) { // k
202 var feed
= getActiveFeedId();
203 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
204 if (new_feed
) viewfeed(new_feed
, 0, '');
207 if (keycode
== 78 || keycode
== 40) { // n, down
208 return h_ctx
.moveToPost('next');
211 if (keycode
== 80 || keycode
== 38) { // p, up
212 return h_ctx
.moveToPost('prev');
215 if (document
.getElementById("piggie")) {
217 if (seq
.match("807371717369")) {
219 localPiggieFunction(true);
221 localPiggieFunction(false);
225 if (typeof localHotkeyHandler
!= 'undefined') {
227 localHotkeyHandler(keycode
);
229 exception_error("hotkey_handler, local:", e
);
233 exception_error("hotkey_handler", e
);
237 function cleanSelectedList(element
) {
238 var content
= document
.getElementById(element
);
240 if (!document
.getElementById("feedCatHolder")) {
241 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
242 var child
= content
.childNodes
[i
];
244 child
.className
= child
.className
.replace("Selected", "");
250 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
251 var child
= content
.childNodes
[i
];
252 if (child
.id
== "feedCatHolder") {
253 parent
.debug(child
.id
);
254 var fcat
= child
.lastChild
;
255 for (j
= 0; j
< fcat
.childNodes
.length
; j
++) {
256 var feed
= fcat
.childNodes
[j
];
257 feed
.className
= feed
.className
.replace("Selected", "");
265 function cleanSelected(element
) {
266 var content
= document
.getElementById(element
);
268 for (i
= 0; i
< content
.rows
.length
; i
++) {
269 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
273 function getVisibleUnreadHeadlines() {
274 var content
= document
.getElementById("headlinesList");
276 var rows
= new Array();
278 for (i
= 0; i
< content
.rows
.length
; i
++) {
279 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
280 if (row_id
.length
> 0 && content
.rows
[i
].className
.match("Unread")) {
287 function getVisibleHeadlineIds() {
289 var content
= document
.getElementById("headlinesList");
291 var rows
= new Array();
293 for (i
= 0; i
< content
.rows
.length
; i
++) {
294 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
295 if (row_id
.length
> 0) {
302 function getFirstVisibleHeadlineId() {
303 var rows
= getVisibleHeadlineIds();
307 function getLastVisibleHeadlineId() {
308 var rows
= getVisibleHeadlineIds();
309 return rows
[rows
.length
-1];
312 function markHeadline(id
) {
313 var row
= document
.getElementById("RROW-" + id
);
315 var is_active
= false;
317 if (row
.className
.match("Active")) {
320 row
.className
= row
.className
.replace("Selected", "");
321 row
.className
= row
.className
.replace("Active", "");
322 row
.className
= row
.className
.replace("Insensitive", "");
325 row
.className
= row
.className
= "Active";
328 var check
= document
.getElementById("RCHK-" + id
);
331 check
.checked
= true;
334 row
.className
= row
.className
+ "Selected";
339 function getFeedIds() {
340 var content
= document
.getElementById("feedsList");
342 var rows
= new Array();
344 for (i
= 0; i
< content
.rows
.length
; i
++) {
345 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
354 function setCookie(name
, value
, lifetime
, path
, domain
, secure
) {
360 d
.setTime(lifetime
* 1000);
363 int_setCookie(name
, value
, d
, path
, domain
, secure
);
367 function int_setCookie(name
, value
, expires
, path
, domain
, secure
) {
368 document
.cookie
= name
+ "=" + escape(value
) +
369 ((expires
) ? "; expires=" + expires
.toGMTString() : "") +
370 ((path
) ? "; path=" + path
: "") +
371 ((domain
) ? "; domain=" + domain
: "") +
372 ((secure
) ? "; secure" : "");
375 function delCookie(name
, path
, domain
) {
376 if (getCookie(name
)) {
377 document
.cookie
= name
+ "=" +
378 ((path
) ? ";path=" + path
: "") +
379 ((domain
) ? ";domain=" + domain
: "" ) +
380 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
385 function getCookie(name
) {
387 var dc
= document
.cookie
;
388 var prefix
= name
+ "=";
389 var begin
= dc
.indexOf("; " + prefix
);
391 begin
= dc
.indexOf(prefix
);
392 if (begin
!= 0) return null;
397 var end
= document
.cookie
.indexOf(";", begin
);
401 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
404 function disableContainerChildren(id
, disable
, doc
) {
406 if (!doc
) doc
= document
;
408 var container
= doc
.getElementById(id
);
411 //alert("disableContainerChildren: element " + id + " not found");
415 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
416 var child
= container
.childNodes
[i
];
419 child
.disabled
= disable
;
425 if (child
.className
&& child
.className
.match("button")) {
426 child
.className
= "disabledButton";
429 if (child
.className
&& child
.className
.match("disabledButton")) {
430 child
.className
= "button";
437 function gotoPreferences() {
438 document
.location
.href
= "prefs.php";
441 function gotoMain() {
442 document
.location
.href
= "tt-rss.php";
445 function gotoExportOpml() {
446 document
.location
.href
= "opml.php?op=Export";
449 function getActiveFeedId() {
450 // return getCookie("ttrss_vf_actfeed");
452 debug("gAFID: " + getMainContext().active_feed_id
);
453 return getMainContext().active_feed_id
;
455 exception_error("getActiveFeedId", e
);
459 function setActiveFeedId(id
) {
460 // return setCookie("ttrss_vf_actfeed", id);
462 getMainContext().active_feed_id
= id
;
464 exception_error("setActiveFeedId", e
);
468 function parse_counters(reply
, scheduled_call
) {
470 var f_document
= getFeedsContext().document
;
471 var title_obj
= getMainContext();
473 if (reply
.firstChild
&& reply
.firstChild
.firstChild
) {
474 debug("<b>wrong element passed to parse_counters, adjusting.</b>");
475 reply
= reply
.firstChild
;
478 debug("F_DOC: " + f_document
+ ", T_OBJ: " + title_obj
);
480 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
481 if (!reply
.childNodes
[l
] ||
482 typeof(reply
.childNodes
[l
].getAttribute
) == "undefined") {
483 // where did this come from?
487 var id
= reply
.childNodes
[l
].getAttribute("id");
488 var t
= reply
.childNodes
[l
].getAttribute("type");
489 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
490 var error
= reply
.childNodes
[l
].getAttribute("error");
491 var has_img
= reply
.childNodes
[l
].getAttribute("hi");
492 var updated
= reply
.childNodes
[l
].getAttribute("updated");
494 if (id
== "global-unread") {
495 title_obj
.global_unread
= ctr
;
496 title_obj
.updateTitle();
500 if (t
== "category") {
501 var catctr
= f_document
.getElementById("FCATCTR-" + id
);
503 catctr
.innerHTML
= "(" + ctr
+ " unread)";
508 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
509 var feedu
= f_document
.getElementById("FEEDU-" + id
);
510 var feedr
= f_document
.getElementById("FEEDR-" + id
);
511 var feed_img
= f_document
.getElementById("FIMG-" + id
);
512 var feedlink
= f_document
.getElementById("FEEDL-" + id
);
514 if (updated
&& feedlink
) {
516 feedlink
.title
= "Error: " + error
+ " (" + updated
+ ")";
518 feedlink
.title
= "Updated: " + updated
;
522 if (feedctr
&& feedu
&& feedr
) {
524 if (feedu
.innerHTML
!= ctr
&& id
== getActiveFeedId() && scheduled_call
) {
525 var hf
= title_obj
.parent
.frames
["headlines-frame"];
526 hf
.location
.reload(true);
529 feedu
.innerHTML
= ctr
;
532 feedr
.className
= feedr
.className
.replace("feed", "error");
534 feedr
.className
= feedr
.className
.replace("error", "feed");
538 feedctr
.className
= "odd";
539 if (!feedr
.className
.match("Unread")) {
540 var is_selected
= feedr
.className
.match("Selected");
542 feedr
.className
= feedr
.className
.replace("Selected", "");
543 feedr
.className
= feedr
.className
.replace("Unread", "");
545 feedr
.className
= feedr
.className
+ "Unread";
548 feedr
.className
= feedr
.className
+ "Selected";
553 feedctr
.className
= "invisible";
554 feedr
.className
= feedr
.className
.replace("Unread", "");
559 exception_error("parse_counters", e
);
563 function all_counters_callback() {
564 if (xmlhttp_rpc
.readyState
== 4) {
566 if (!xmlhttp_rpc
.responseXML
|| !xmlhttp_rpc
.responseXML
.firstChild
) {
567 notify("[all_counters_callback] backend did not return valid XML");
571 var reply
= xmlhttp_rpc
.responseXML
.firstChild
;
573 var counters
= reply
.firstChild
;
575 parse_counters(counters
);
578 exception_error("all_counters_callback", e
);
583 function update_all_counters(feed
) {
584 if (xmlhttp_ready(xmlhttp_rpc
)) {
585 var query
= "backend.php?op=rpc&subop=getAllCounters";
588 query
= query
+ "&aid=" + feed
;
591 xmlhttp_rpc
.open("GET", query
, true);
592 xmlhttp_rpc
.onreadystatechange
=all_counters_callback
;
593 xmlhttp_rpc
.send(null);
597 function popupHelp(tid
) {
598 var w
= window
.open("backend.php?op=help&tid=" + tid
,
600 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
603 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
604 * * @author Sundar Dorai-Raj
605 * * Email: sdoraira@vt.edu
606 * * This program is free software; you can redistribute it and/or
607 * * modify it under the terms of the GNU General Public License
608 * * as published by the Free Software Foundation; either version 2
609 * * of the License, or (at your option) any later version,
610 * * provided that any use properly credits the author.
611 * * This program is distributed in the hope that it will be useful,
612 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
613 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
614 * * GNU General Public License for more details at http://www.gnu.org * * */
616 var numbers
=".0123456789";
617 function isNumeric(x
) {
618 // is x a String or a character?
620 // remove negative sign
622 for(j
=0;j
<x
.length
;j
++) {
623 // call isNumeric recursively for each character
624 number
=isNumeric(x
.substring(j
,j
+1));
625 if(!number
) return number
;
630 // if x is number return true
631 if(numbers
.indexOf(x
)>=0) return true;
637 function hideOrShowFeeds(doc
, hide
) {
639 if (!doc
.styleSheets
) return;
641 var css_rules
= doc
.styleSheets
[0].cssRules
;
643 if (!css_rules
|| !css_rules
.length
) return;
645 for (i
= 0; i
< css_rules
.length
; i
++) {
646 var rule
= css_rules
[i
];
648 if (rule
.selectorText
== "ul.feedList li.feed") {
650 rule
.style
.display
= "block";
652 rule
.style
.display
= "none";
660 function selectTableRow(r
, do_select
) {
661 r
.className
= r
.className
.replace("Selected", "");
664 r
.className
= r
.className
+ "Selected";
668 function selectTableRowById(elem_id
, check_id
, do_select
) {
672 var row
= document
.getElementById(elem_id
);
675 selectTableRow(row
, do_select
);
678 var check
= document
.getElementById(check_id
);
681 check
.checked
= do_select
;
684 exception_error("selectTableRowById", e
);
688 function selectTableRowsByIdPrefix(content_id
, prefix
, check_prefix
, do_select
,
689 classcheck
, reset_others
) {
691 var content
= document
.getElementById(content_id
);
694 alert("[selectTableRows] Element " + content_id
+ " not found.");
698 for (i
= 0; i
< content
.rows
.length
; i
++) {
699 if (!classcheck
|| content
.rows
[i
].className
.match(classcheck
)) {
701 if (content
.rows
[i
].id
.match(prefix
)) {
702 selectTableRow(content
.rows
[i
], do_select
);
704 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
705 var check
= document
.getElementById(check_prefix
+ row_id
);
708 check
.checked
= do_select
;
710 } else if (reset_others
) {
711 selectTableRow(content
.rows
[i
], false);
713 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
714 var check
= document
.getElementById(check_prefix
+ row_id
);
717 check
.checked
= false;
721 } else if (reset_others
) {
722 selectTableRow(content
.rows
[i
], false);
724 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
725 var check
= document
.getElementById(check_prefix
+ row_id
);
728 check
.checked
= false;
735 function getSelectedTableRowIds(content_id
, prefix
) {
737 var content
= document
.getElementById(content_id
);
740 alert("[getSelectedTableRowIds] Element " + content_id
+ " not found.");
744 var sel_rows
= new Array();
746 for (i
= 0; i
< content
.rows
.length
; i
++) {
747 if (content
.rows
[i
].id
.match(prefix
) &&
748 content
.rows
[i
].className
.match("Selected")) {
750 var row_id
= content
.rows
[i
].id
.replace(prefix
+ "-", "");
751 sel_rows
.push(row_id
);
759 function toggleSelectRowById(sender
, id
) {
760 var row
= document
.getElementById(id
);
762 if (sender
.checked
) {
763 if (!row
.className
.match("Selected")) {
764 row
.className
= row
.className
+ "Selected";
767 if (row
.className
.match("Selected")) {
768 row
.className
= row
.className
.replace("Selected", "");
773 function toggleSelectListRow(sender
) {
774 var parent_row
= sender
.parentNode
;
776 if (sender
.checked
) {
777 if (!parent_row
.className
.match("Selected")) {
778 parent_row
.className
= parent_row
.className
+ "Selected";
781 if (parent_row
.className
.match("Selected")) {
782 parent_row
.className
= parent_row
.className
.replace("Selected", "");
788 function toggleSelectRow(sender
) {
789 var parent_row
= sender
.parentNode
.parentNode
;
791 if (sender
.checked
) {
792 if (!parent_row
.className
.match("Selected")) {
793 parent_row
.className
= parent_row
.className
+ "Selected";
796 if (parent_row
.className
.match("Selected")) {
797 parent_row
.className
= parent_row
.className
.replace("Selected", "");
802 function openExternalUrl(url
) {
803 var w
= window
.open(url
);
806 function getRelativeFeedId(list
, id
, direction
, unread_only
) {
808 if (direction
== "next") {
809 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
810 var child
= list
.childNodes
[i
];
811 if (child
.id
&& child
.id
== "feedCatHolder") {
812 if (child
.lastChild
) {
813 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
816 } else if (child
.id
&& child
.id
.match("FEEDR-")) {
817 return child
.id
.replace('FEEDR-', '');
822 // FIXME select last feed doesn't work when only unread feeds are visible
824 if (direction
== "prev") {
825 for (i
= list
.childNodes
.length
-1; i
>= 0; i
--) {
826 var child
= list
.childNodes
[i
];
827 if (child
.id
== "feedCatHolder") {
828 if (child
.firstChild
) {
829 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
832 } else if (child
.id
.match("FEEDR-")) {
834 if (getInitParam("hide_read_feeds") == 1) {
835 if (child
.className
!= "feed") {
836 alert(child
.className
);
837 return child
.id
.replace('FEEDR-', '');
840 return child
.id
.replace('FEEDR-', '');
847 var feed
= list
.ownerDocument
.getElementById("FEEDR-" + getActiveFeedId());
849 if (getInitParam("hide_read_feeds") == 1) {
853 if (direction
== "next") {
863 } else if (e
.parentNode
.parentNode
.nextSibling
) {
865 var this_cat
= e
.parentNode
.parentNode
;
869 if (this_cat
&& this_cat
.nextSibling
) {
870 while (!e
&& this_cat
.nextSibling
) {
871 this_cat
= this_cat
.nextSibling
;
872 if (this_cat
.id
== "feedCatHolder") {
873 e
= this_cat
.firstChild
.firstChild
;
883 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
884 e
.className
!= "error")) {
885 return e
.id
.replace("FEEDR-", "");
890 } else if (direction
== "prev") {
896 if (e
.previousSibling
) {
898 e
= e
.previousSibling
;
900 } else if (e
.parentNode
.parentNode
.previousSibling
) {
902 var this_cat
= e
.parentNode
.parentNode
;
906 if (this_cat
&& this_cat
.previousSibling
) {
907 while (!e
&& this_cat
.previousSibling
) {
908 this_cat
= this_cat
.previousSibling
;
909 if (this_cat
.id
== "feedCatHolder") {
910 e
= this_cat
.firstChild
.lastChild
;
920 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
921 e
.className
!= "error")) {
922 return e
.id
.replace("FEEDR-", "");
930 function showBlockElement(id
) {
931 var elem
= document
.getElementById(id
);
934 elem
.style
.display
= "block";
936 alert("[showBlockElement] can't find element with id " + id
);
940 function hideParentElement(e
) {
941 e
.parentNode
.style
.display
= "none";
944 function dropboxSelect(e
, v
) {
945 for (i
= 0; i
< e
.length
; i
++) {
946 if (e
[i
].value
== v
) {
953 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
954 // bugfixed just a little bit :-)
955 function getURLParam(strParamName
){
957 var strHref
= window
.location
.href
;
959 if (strHref
.indexOf("#") == strHref
.length
-1) {
960 strHref
= strHref
.substring(0, strHref
.length
-1);
963 if ( strHref
.indexOf("?") > -1 ){
964 var strQueryString
= strHref
.substr(strHref
.indexOf("?"));
965 var aQueryString
= strQueryString
.split("&");
966 for ( var iParam
= 0; iParam
< aQueryString
.length
; iParam
++ ){
967 if (aQueryString
[iParam
].indexOf(strParamName
+ "=") > -1 ){
968 var aParam
= aQueryString
[iParam
].split("=");
969 strReturn
= aParam
[1];
977 function leading_zero(p
) {
979 if (s
.length
== 1) s
= "0" + s
;
983 function closeInfoBox(cleanup
) {
984 var box
= document
.getElementById('infoBox');
985 var shadow
= document
.getElementById('infoBoxShadow');
988 shadow
.style
.display
= "none";
990 box
.style
.display
= "none";
993 if (cleanup
) box
.innerHTML
= " ";
1000 function displayDlg(id
, param
) {
1002 if (!xmlhttp_ready(xmlhttp
)) {
1003 printLockingError();
1009 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
1010 param_escape(id
) + "¶m=" + param_escape(param
), true);
1011 xmlhttp
.onreadystatechange
=infobox_callback
;
1018 function infobox_submit_callback() {
1019 if (xmlhttp
.readyState
== 4) {
1022 // called from prefs, reload tab
1024 selectTab(active_tab
, false);
1027 notify(xmlhttp
.responseText
);
1032 function infobox_callback() {
1033 if (xmlhttp
.readyState
== 4) {
1034 var box
= document
.getElementById('infoBox');
1035 var shadow
= document
.getElementById('infoBoxShadow');
1037 box
.innerHTML
=xmlhttp
.responseText
;
1039 shadow
.style
.display
= "block";
1041 box
.style
.display
= "block";
1047 function qaddFilter() {
1049 if (!xmlhttp_ready(xmlhttp
)) {
1050 printLockingError();
1054 var query
= Form
.serialize("filter_add_form");
1056 xmlhttp
.open("GET", "backend.php?" + query
, true);
1057 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
1063 function toggleSubmitNotEmpty(e
, submit_id
) {
1065 document
.getElementById(submit_id
).disabled
= (e
.value
== "")
1067 exception_error("toggleSubmitNotEmpty", e
);
1071 function isValidURL(s
) {
1072 return s
.match("http://") != null || s
.match("https://") != null;
1077 if (!xmlhttp_ready(xmlhttp
)) {
1078 printLockingError();
1082 notify("Adding feed...");
1086 var feeds_doc
= getFeedsContext().document
;
1088 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
1090 var query
= Form
.serialize("feed_add_form");
1092 xmlhttp
.open("GET", "backend.php?" + query
, true);
1093 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
1097 function filterCR(e
)
1102 key
= window
.event
.keyCode
; //IE
1104 key
= e
.which
; //firefox
1112 function getMainContext() {
1113 if (parent
.window
!= window
) {
1114 return parent
.window
;
1120 function getFeedsContext() {
1122 return getMainContext().frames
["feeds-frame"];
1124 exception_error("getFeedsContext", e
);
1129 function getHeadlinesContext() {
1131 return getMainContext().frames
["headlines-frame"];
1133 exception_error("getHeadlinesContext", e
);
1137 function debug(msg
) {
1138 var ctx
= getMainContext();
1140 var c
= ctx
.document
.getElementById('debug_output');
1141 if (c
&& c
.style
.display
== "block") {
1142 while (c
.lastChild
!= 'undefined' && c
.childNodes
.length
> 20) {
1143 c
.removeChild(c
.lastChild
);
1147 var ts
= leading_zero(d
.getHours()) + ":" + leading_zero(d
.getMinutes()) +
1148 ":" + leading_zero(d
.getSeconds());
1149 c
.innerHTML
= "<li>[" + ts
+ "] " + msg
+ "</li>" + c
.innerHTML
;
1153 function getInitParam(key
) {
1154 return getMainContext().init_params
[key
];
1158 function storeInitParam(key
, value
, is_client
) {
1160 getMainContext().init_params
[key
] = value
;
1162 new Ajax
.Request("backend.php?op=rpc&subop=storeParam&key=" +
1163 param_escape(key
) + "&value=" + param_escape(value
));
1166 exception_error("storeInitParam", e
);
1170 function fatalError(code
, message
) {
1172 var fe
= document
.getElementById("fatal_error");
1173 var fc
= document
.getElementById("fatal_error_msg");
1175 fc
.innerHTML
= "Code " + code
+ ": " + message
;
1177 fe
.style
.display
= "block";
1180 exception_error("fatalError", e
);
1184 function getFeedName(id
) {
1185 var d
= getFeedsContext().document
;
1186 var e
= d
.getElementById("FEEDN-" + id
);
1188 return e
.innerHTML
.stripTags();