]>
git.wh0rd.org - tt-rss.git/blob - functions.js
1 var hotkeys_enabled
= true;
3 function browser_has_opacity() {
4 return navigator
.userAgent
.match("Gecko") != null ||
5 navigator
.userAgent
.match("Opera") != null;
8 function exception_error(location
, e
) {
12 var base_fname
= e
.fileName
.substring(e
.fileName
.lastIndexOf("/") + 1);
14 msg
= "Exception: " + e
.name
+ ", " + e
.message
+
15 "\nFunction: " + location
+ "()" +
16 "\nLocation: " + base_fname
+ ":" + e
.lineNumber
;
19 msg
= "Exception: " + e
+ "\nFunction: " + location
+ "()";
22 debug("<b>EXCEPTION: " + msg
+ "</b>");
27 function disableHotkeys() {
28 hotkeys_enabled
= false;
31 function enableHotkeys() {
32 hotkeys_enabled
= true;
35 function xmlhttp_ready(obj
) {
36 return obj
.readyState
== 4 || obj
.readyState
== 0 || !obj
.readyState
;
39 function notify_callback() {
40 var container
= document
.getElementById('notify');
41 if (xmlhttp
.readyState
== 4) {
42 container
.innerHTML
=xmlhttp
.responseText
;
46 function rpc_notify_callback() {
47 var container
= document
.getElementById('notify');
48 if (xmlhttp_rpc
.readyState
== 4) {
49 container
.innerHTML
=xmlhttp_rpc
.responseText
;
53 function param_escape(arg
) {
54 if (typeof encodeURIComponent
!= 'undefined')
55 return encodeURIComponent(arg
);
60 function param_unescape(arg
) {
61 if (typeof decodeURIComponent
!= 'undefined')
62 return decodeURIComponent(arg
);
69 then
=new Date().getTime();
71 while((now
-then
)<gap
) {
72 now
=new Date().getTime();
76 var notify_hide_timerid
= false;
77 var notify_last_doc
= false;
79 var notify_effect
= false;
81 function hide_notify() {
82 if (notify_last_doc
) {
83 var n
= notify_last_doc
.getElementById("notify");
84 if (browser_has_opacity()) {
85 if (notify_opacity
>= 0) {
86 notify_opacity
= notify_opacity
- 0.1;
87 n
.style
.opacity
= notify_opacity
;
88 notify_hide_timerid
= window
.setTimeout("hide_notify()", 20);
90 n
.style
.display
= "none";
94 n
.style
.display
= "none";
99 function notify_real(msg
, doc
, no_hide
, is_err
) {
101 var n
= doc
.getElementById("notify");
102 var nb
= doc
.getElementById("notify_body");
104 if (!n
|| !nb
) return;
106 if (notify_hide_timerid
) {
107 window
.clearTimeout(notify_hide_timerid
);
110 notify_last_doc
= doc
;
114 if (n
.style
.display
== "block") {
115 notify_hide_timerid
= window
.setTimeout("hide_notify()", 0);
119 n
.style
.display
= "block";
123 n
.style
.backgroundColor
= "#ffcccc";
124 n
.style
.color
= "black";
125 n
.style
.borderColor
= "#ff0000";
127 n
.style
.backgroundColor
= "#fff7d5";
128 n
.style
.borderColor
= "#d7c47a";
129 n
.style
.color
= "black";
135 notify_hide_timerid
= window
.setTimeout("hide_notify()", 3000);
139 function p_notify(msg
, no_hide
, is_err
) {
140 notify_real(msg
, parent
.document
, no_hide
, is_err
);
143 function notify(msg
, no_hide
, is_err
) {
144 notify_real(msg
, document
, no_hide
, is_err
);
147 function printLockingError() {
148 notify("Please wait until operation finishes");}
152 function hotkey_handler(e
) {
158 if (!hotkeys_enabled
) return;
161 keycode
= window
.event
.keyCode
;
166 if (keycode
== 13 || keycode
== 27) {
169 seq
= seq
+ "" + 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
== 85) { // u
181 if (getActiveFeedId()) {
182 return f_ctx
.viewfeed(getActiveFeedId(), 0, "ForceUpdate");
186 if (keycode
== 65) { // a
187 return m_ctx
.toggleDispRead();
190 var f_doc
= m_ctx
.frames
["feeds-frame"].document
;
191 var feedlist
= f_doc
.getElementById('feedList');
193 if (keycode
== 74) { // j
194 var feed
= getActiveFeedId();
195 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
196 if (new_feed
) viewfeed(new_feed
, 0, '');
199 if (keycode
== 75) { // k
200 var feed
= getActiveFeedId();
201 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
202 if (new_feed
) viewfeed(new_feed
, 0, '');
205 if (keycode
== 78 || keycode
== 40) { // n, down
206 return h_ctx
.moveToPost('next');
209 if (keycode
== 80 || keycode
== 38) { // p, up
210 return h_ctx
.moveToPost('prev');
213 if (document
.getElementById("piggie")) {
215 if (seq
.match("807371717369")) {
217 localPiggieFunction(true);
219 localPiggieFunction(false);
223 if (typeof localHotkeyHandler
!= 'undefined') {
225 localHotkeyHandler(keycode
);
227 exception_error("hotkey_handler, local:", e
);
231 exception_error("hotkey_handler", e
);
235 function cleanSelectedList(element
) {
236 var content
= document
.getElementById(element
);
238 if (!document
.getElementById("feedCatHolder")) {
239 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
240 var child
= content
.childNodes
[i
];
242 child
.className
= child
.className
.replace("Selected", "");
248 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
249 var child
= content
.childNodes
[i
];
250 if (child
.id
== "feedCatHolder") {
251 parent
.debug(child
.id
);
252 var fcat
= child
.lastChild
;
253 for (j
= 0; j
< fcat
.childNodes
.length
; j
++) {
254 var feed
= fcat
.childNodes
[j
];
255 feed
.className
= feed
.className
.replace("Selected", "");
263 function cleanSelected(element
) {
264 var content
= document
.getElementById(element
);
266 for (i
= 0; i
< content
.rows
.length
; i
++) {
267 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
271 function getVisibleUnreadHeadlines() {
272 var content
= document
.getElementById("headlinesList");
274 var rows
= new Array();
276 for (i
= 0; i
< content
.rows
.length
; i
++) {
277 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
278 if (row_id
.length
> 0 && content
.rows
[i
].className
.match("Unread")) {
285 function getVisibleHeadlineIds() {
287 var content
= document
.getElementById("headlinesList");
289 var rows
= new Array();
291 for (i
= 0; i
< content
.rows
.length
; i
++) {
292 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
293 if (row_id
.length
> 0) {
300 function getFirstVisibleHeadlineId() {
301 var rows
= getVisibleHeadlineIds();
305 function getLastVisibleHeadlineId() {
306 var rows
= getVisibleHeadlineIds();
307 return rows
[rows
.length
-1];
310 function markHeadline(id
) {
311 var row
= document
.getElementById("RROW-" + id
);
313 var is_active
= false;
315 if (row
.className
.match("Active")) {
318 row
.className
= row
.className
.replace("Selected", "");
319 row
.className
= row
.className
.replace("Active", "");
320 row
.className
= row
.className
.replace("Insensitive", "");
323 row
.className
= row
.className
= "Active";
326 var check
= document
.getElementById("RCHK-" + id
);
329 check
.checked
= true;
332 row
.className
= row
.className
+ "Selected";
337 function getFeedIds() {
338 var content
= document
.getElementById("feedsList");
340 var rows
= new Array();
342 for (i
= 0; i
< content
.rows
.length
; i
++) {
343 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
352 function setCookie(name
, value
, lifetime
, path
, domain
, secure
) {
358 d
.setTime(lifetime
* 1000);
361 int_setCookie(name
, value
, d
, path
, domain
, secure
);
365 function int_setCookie(name
, value
, expires
, path
, domain
, secure
) {
366 document
.cookie
= name
+ "=" + escape(value
) +
367 ((expires
) ? "; expires=" + expires
.toGMTString() : "") +
368 ((path
) ? "; path=" + path
: "") +
369 ((domain
) ? "; domain=" + domain
: "") +
370 ((secure
) ? "; secure" : "");
373 function delCookie(name
, path
, domain
) {
374 if (getCookie(name
)) {
375 document
.cookie
= name
+ "=" +
376 ((path
) ? ";path=" + path
: "") +
377 ((domain
) ? ";domain=" + domain
: "" ) +
378 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
383 function getCookie(name
) {
385 var dc
= document
.cookie
;
386 var prefix
= name
+ "=";
387 var begin
= dc
.indexOf("; " + prefix
);
389 begin
= dc
.indexOf(prefix
);
390 if (begin
!= 0) return null;
395 var end
= document
.cookie
.indexOf(";", begin
);
399 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
402 function disableContainerChildren(id
, disable
, doc
) {
404 if (!doc
) doc
= document
;
406 var container
= doc
.getElementById(id
);
409 //alert("disableContainerChildren: element " + id + " not found");
413 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
414 var child
= container
.childNodes
[i
];
417 child
.disabled
= disable
;
423 if (child
.className
&& child
.className
.match("button")) {
424 child
.className
= "disabledButton";
427 if (child
.className
&& child
.className
.match("disabledButton")) {
428 child
.className
= "button";
435 function gotoPreferences() {
436 document
.location
.href
= "prefs.php";
439 function gotoMain() {
440 document
.location
.href
= "tt-rss.php";
443 function gotoExportOpml() {
444 document
.location
.href
= "opml.php?op=Export";
447 function getActiveFeedId() {
448 // return getCookie("ttrss_vf_actfeed");
450 debug("gAFID: " + getMainContext().active_feed_id
);
451 return getMainContext().active_feed_id
;
453 exception_error("getActiveFeedId", e
);
457 function setActiveFeedId(id
) {
458 // return setCookie("ttrss_vf_actfeed", id);
460 getMainContext().active_feed_id
= id
;
462 exception_error("setActiveFeedId", e
);
466 var xmlhttp_rpc
= Ajax
.getTransport();
468 function parse_counters(reply
, scheduled_call
) {
470 var f_document
= getFeedsContext().document
;
471 var title_obj
= getMainContext();
473 debug("F_DOC: " + f_document
+ ", T_OBJ: " + title_obj
);
475 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
476 if (!reply
.childNodes
[l
] ||
477 typeof(reply
.childNodes
[l
].getAttribute
) == "undefined") {
478 // where did this come from?
482 var id
= reply
.childNodes
[l
].getAttribute("id");
483 var t
= reply
.childNodes
[l
].getAttribute("type");
484 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
485 var error
= reply
.childNodes
[l
].getAttribute("error");
486 var has_img
= reply
.childNodes
[l
].getAttribute("hi");
487 var updated
= reply
.childNodes
[l
].getAttribute("updated");
489 if (id
== "global-unread") {
490 title_obj
.global_unread
= ctr
;
491 title_obj
.updateTitle();
495 if (t
== "category") {
496 var catctr
= f_document
.getElementById("FCATCTR-" + id
);
498 catctr
.innerHTML
= "(" + ctr
+ " unread)";
503 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
504 var feedu
= f_document
.getElementById("FEEDU-" + id
);
505 var feedr
= f_document
.getElementById("FEEDR-" + id
);
506 var feed_img
= f_document
.getElementById("FIMG-" + id
);
507 var feedlink
= f_document
.getElementById("FEEDL-" + id
);
509 if (updated
&& feedlink
) {
511 feedlink
.title
= "Error: " + error
+ " (" + updated
+ ")";
513 feedlink
.title
= "Updated: " + updated
;
517 if (feedctr
&& feedu
&& feedr
) {
519 if (feedu
.innerHTML
!= ctr
&& id
== getActiveFeedId() && scheduled_call
) {
520 var hf
= title_obj
.parent
.frames
["headlines-frame"];
521 hf
.location
.reload(true);
524 feedu
.innerHTML
= ctr
;
527 feedr
.className
= feedr
.className
.replace("feed", "error");
529 feedr
.className
= feedr
.className
.replace("error", "feed");
533 feedctr
.className
= "odd";
534 if (!feedr
.className
.match("Unread")) {
535 var is_selected
= feedr
.className
.match("Selected");
537 feedr
.className
= feedr
.className
.replace("Selected", "");
538 feedr
.className
= feedr
.className
.replace("Unread", "");
540 feedr
.className
= feedr
.className
+ "Unread";
543 feedr
.className
= feedr
.className
+ "Selected";
548 feedctr
.className
= "invisible";
549 feedr
.className
= feedr
.className
.replace("Unread", "");
554 exception_error("parse_counters", e
);
558 function all_counters_callback() {
559 if (xmlhttp_rpc
.readyState
== 4) {
561 if (!xmlhttp_rpc
.responseXML
|| !xmlhttp_rpc
.responseXML
.firstChild
) {
562 notify("[all_counters_callback] backend did not return valid XML");
566 var reply
= xmlhttp_rpc
.responseXML
.firstChild
;
568 parse_counters(reply
);
571 exception_error("all_counters_callback", e
);
576 function update_all_counters(feed
) {
577 if (xmlhttp_ready(xmlhttp_rpc
)) {
578 var query
= "backend.php?op=rpc&subop=getAllCounters";
581 query
= query
+ "&aid=" + feed
;
584 xmlhttp_rpc
.open("GET", query
, true);
585 xmlhttp_rpc
.onreadystatechange
=all_counters_callback
;
586 xmlhttp_rpc
.send(null);
590 function popupHelp(tid
) {
591 var w
= window
.open("backend.php?op=help&tid=" + tid
,
593 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
596 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
597 * * @author Sundar Dorai-Raj
598 * * Email: sdoraira@vt.edu
599 * * This program is free software; you can redistribute it and/or
600 * * modify it under the terms of the GNU General Public License
601 * * as published by the Free Software Foundation; either version 2
602 * * of the License, or (at your option) any later version,
603 * * provided that any use properly credits the author.
604 * * This program is distributed in the hope that it will be useful,
605 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
606 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
607 * * GNU General Public License for more details at http://www.gnu.org * * */
609 var numbers
=".0123456789";
610 function isNumeric(x
) {
611 // is x a String or a character?
613 // remove negative sign
615 for(j
=0;j
<x
.length
;j
++) {
616 // call isNumeric recursively for each character
617 number
=isNumeric(x
.substring(j
,j
+1));
618 if(!number
) return number
;
623 // if x is number return true
624 if(numbers
.indexOf(x
)>=0) return true;
630 function hideOrShowFeeds(doc
, hide
) {
632 if (!doc
.styleSheets
) return;
634 var css_rules
= doc
.styleSheets
[0].cssRules
;
636 if (!css_rules
|| !css_rules
.length
) return;
638 for (i
= 0; i
< css_rules
.length
; i
++) {
639 var rule
= css_rules
[i
];
641 if (rule
.selectorText
== "ul.feedList li.feed") {
643 rule
.style
.display
= "block";
645 rule
.style
.display
= "none";
653 function selectTableRow(r
, do_select
) {
654 r
.className
= r
.className
.replace("Selected", "");
657 r
.className
= r
.className
+ "Selected";
661 function selectTableRowById(elem_id
, check_id
, do_select
) {
665 var row
= document
.getElementById(elem_id
);
668 selectTableRow(row
, do_select
);
671 var check
= document
.getElementById(check_id
);
674 check
.checked
= do_select
;
677 exception_error("selectTableRowById", e
);
681 function selectTableRowsByIdPrefix(content_id
, prefix
, check_prefix
, do_select
,
682 classcheck
, reset_others
) {
684 var content
= document
.getElementById(content_id
);
687 alert("[selectTableRows] Element " + content_id
+ " not found.");
691 for (i
= 0; i
< content
.rows
.length
; i
++) {
692 if (!classcheck
|| content
.rows
[i
].className
.match(classcheck
)) {
694 if (content
.rows
[i
].id
.match(prefix
)) {
695 selectTableRow(content
.rows
[i
], do_select
);
697 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
698 var check
= document
.getElementById(check_prefix
+ row_id
);
701 check
.checked
= do_select
;
703 } else if (reset_others
) {
704 selectTableRow(content
.rows
[i
], false);
706 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
707 var check
= document
.getElementById(check_prefix
+ row_id
);
710 check
.checked
= false;
714 } else if (reset_others
) {
715 selectTableRow(content
.rows
[i
], false);
717 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
718 var check
= document
.getElementById(check_prefix
+ row_id
);
721 check
.checked
= false;
728 function getSelectedTableRowIds(content_id
, prefix
) {
730 var content
= document
.getElementById(content_id
);
733 alert("[getSelectedTableRowIds] Element " + content_id
+ " not found.");
737 var sel_rows
= new Array();
739 for (i
= 0; i
< content
.rows
.length
; i
++) {
740 if (content
.rows
[i
].id
.match(prefix
) &&
741 content
.rows
[i
].className
.match("Selected")) {
743 var row_id
= content
.rows
[i
].id
.replace(prefix
+ "-", "");
744 sel_rows
.push(row_id
);
752 function toggleSelectRowById(sender
, id
) {
753 var row
= document
.getElementById(id
);
755 if (sender
.checked
) {
756 if (!row
.className
.match("Selected")) {
757 row
.className
= row
.className
+ "Selected";
760 if (row
.className
.match("Selected")) {
761 row
.className
= row
.className
.replace("Selected", "");
766 function toggleSelectListRow(sender
) {
767 var parent_row
= sender
.parentNode
;
769 if (sender
.checked
) {
770 if (!parent_row
.className
.match("Selected")) {
771 parent_row
.className
= parent_row
.className
+ "Selected";
774 if (parent_row
.className
.match("Selected")) {
775 parent_row
.className
= parent_row
.className
.replace("Selected", "");
781 function toggleSelectRow(sender
) {
782 var parent_row
= sender
.parentNode
.parentNode
;
784 if (sender
.checked
) {
785 if (!parent_row
.className
.match("Selected")) {
786 parent_row
.className
= parent_row
.className
+ "Selected";
789 if (parent_row
.className
.match("Selected")) {
790 parent_row
.className
= parent_row
.className
.replace("Selected", "");
795 function openExternalUrl(url
) {
796 var w
= window
.open(url
);
799 function getRelativeFeedId(list
, id
, direction
, unread_only
) {
801 if (direction
== "next") {
802 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
803 var child
= list
.childNodes
[i
];
804 if (child
.id
&& child
.id
== "feedCatHolder") {
805 if (child
.lastChild
) {
806 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
809 } else if (child
.id
&& child
.id
.match("FEEDR-")) {
810 return child
.id
.replace('FEEDR-', '');
815 // FIXME select last feed doesn't work when only unread feeds are visible
817 if (direction
== "prev") {
818 for (i
= list
.childNodes
.length
-1; i
>= 0; i
--) {
819 var child
= list
.childNodes
[i
];
820 if (child
.id
== "feedCatHolder") {
821 if (child
.firstChild
) {
822 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
825 } else if (child
.id
.match("FEEDR-")) {
827 if (getInitParam("hide_read_feeds") == 1) {
828 if (child
.className
!= "feed") {
829 alert(child
.className
);
830 return child
.id
.replace('FEEDR-', '');
833 return child
.id
.replace('FEEDR-', '');
840 var feed
= list
.ownerDocument
.getElementById("FEEDR-" + getActiveFeedId());
842 if (getInitParam("hide_read_feeds") == 1) {
846 if (direction
== "next") {
856 } else if (e
.parentNode
.parentNode
.nextSibling
) {
858 var this_cat
= e
.parentNode
.parentNode
;
862 if (this_cat
&& this_cat
.nextSibling
) {
863 while (!e
&& this_cat
.nextSibling
) {
864 this_cat
= this_cat
.nextSibling
;
865 if (this_cat
.id
== "feedCatHolder") {
866 e
= this_cat
.firstChild
.firstChild
;
876 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
877 e
.className
!= "error")) {
878 return e
.id
.replace("FEEDR-", "");
883 } else if (direction
== "prev") {
889 if (e
.previousSibling
) {
891 e
= e
.previousSibling
;
893 } else if (e
.parentNode
.parentNode
.previousSibling
) {
895 var this_cat
= e
.parentNode
.parentNode
;
899 if (this_cat
&& this_cat
.previousSibling
) {
900 while (!e
&& this_cat
.previousSibling
) {
901 this_cat
= this_cat
.previousSibling
;
902 if (this_cat
.id
== "feedCatHolder") {
903 e
= this_cat
.firstChild
.lastChild
;
913 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
914 e
.className
!= "error")) {
915 return e
.id
.replace("FEEDR-", "");
923 function showBlockElement(id
) {
924 var elem
= document
.getElementById(id
);
927 elem
.style
.display
= "block";
929 alert("[showBlockElement] can't find element with id " + id
);
933 function hideParentElement(e
) {
934 e
.parentNode
.style
.display
= "none";
937 function dropboxSelect(e
, v
) {
938 for (i
= 0; i
< e
.length
; i
++) {
939 if (e
[i
].value
== v
) {
946 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
947 // bugfixed just a little bit :-)
948 function getURLParam(strParamName
){
950 var strHref
= window
.location
.href
;
952 if (strHref
.indexOf("#") == strHref
.length
-1) {
953 strHref
= strHref
.substring(0, strHref
.length
-1);
956 if ( strHref
.indexOf("?") > -1 ){
957 var strQueryString
= strHref
.substr(strHref
.indexOf("?"));
958 var aQueryString
= strQueryString
.split("&");
959 for ( var iParam
= 0; iParam
< aQueryString
.length
; iParam
++ ){
960 if (aQueryString
[iParam
].indexOf(strParamName
+ "=") > -1 ){
961 var aParam
= aQueryString
[iParam
].split("=");
962 strReturn
= aParam
[1];
970 function leading_zero(p
) {
972 if (s
.length
== 1) s
= "0" + s
;
976 function closeInfoBox(cleanup
) {
977 var box
= document
.getElementById('infoBox');
978 var shadow
= document
.getElementById('infoBoxShadow');
981 shadow
.style
.display
= "none";
983 box
.style
.display
= "none";
986 if (cleanup
) box
.innerHTML
= " ";
993 function displayDlg(id
, param
) {
995 if (!xmlhttp_ready(xmlhttp
)) {
1002 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
1003 param_escape(id
) + "¶m=" + param_escape(param
), true);
1004 xmlhttp
.onreadystatechange
=infobox_callback
;
1011 function infobox_submit_callback() {
1012 if (xmlhttp
.readyState
== 4) {
1015 // called from prefs, reload tab
1017 selectTab(active_tab
, false);
1020 notify(xmlhttp
.responseText
);
1025 function infobox_callback() {
1026 if (xmlhttp
.readyState
== 4) {
1027 var box
= document
.getElementById('infoBox');
1028 var shadow
= document
.getElementById('infoBoxShadow');
1030 box
.innerHTML
=xmlhttp
.responseText
;
1032 shadow
.style
.display
= "block";
1034 box
.style
.display
= "block";
1040 function qaddFilter() {
1042 if (!xmlhttp_ready(xmlhttp
)) {
1043 printLockingError();
1047 var query
= Form
.serialize("filter_add_form");
1049 xmlhttp
.open("GET", "backend.php?" + query
, true);
1050 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
1056 function toggleSubmitNotEmpty(e
, submit_id
) {
1058 document
.getElementById(submit_id
).disabled
= (e
.value
== "")
1060 exception_error("toggleSubmitNotEmpty", e
);
1064 function isValidURL(s
) {
1065 return s
.match("http://") != null || s
.match("https://") != null;
1070 if (!xmlhttp_ready(xmlhttp
)) {
1071 printLockingError();
1075 notify("Adding feed...");
1079 var feeds_doc
= getFeedsContext().document
;
1081 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
1083 var query
= Form
.serialize("feed_add_form");
1085 xmlhttp
.open("GET", "backend.php?" + query
, true);
1086 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
1090 function filterCR(e
)
1095 key
= window
.event
.keyCode
; //IE
1097 key
= e
.which
; //firefox
1105 function getMainContext() {
1106 if (parent
.window
!= window
) {
1107 return parent
.window
;
1113 function getFeedsContext() {
1115 return getMainContext().frames
["feeds-frame"];
1117 exception_error("getFeedsContext", e
);
1122 function getHeadlinesContext() {
1124 return getMainContext().frames
["headlines-frame"];
1126 exception_error("getHeadlinesContext", e
);
1130 function debug(msg
) {
1131 var ctx
= getMainContext();
1133 var c
= ctx
.document
.getElementById('debug_output');
1134 if (c
&& c
.style
.display
== "block") {
1135 while (c
.lastChild
!= 'undefined' && c
.childNodes
.length
> 20) {
1136 c
.removeChild(c
.lastChild
);
1140 var ts
= leading_zero(d
.getHours()) + ":" + leading_zero(d
.getMinutes()) +
1141 ":" + leading_zero(d
.getSeconds());
1142 c
.innerHTML
= "<li>[" + ts
+ "] " + msg
+ "</li>" + c
.innerHTML
;
1146 function getInitParam(key
) {
1147 return getMainContext().init_params
[key
];
1151 function storeInitParam(key
, value
, is_client
) {
1153 getMainContext().init_params
[key
] = value
;
1155 new Ajax
.Request("backend.php?op=rpc&subop=storeParam&key=" +
1156 param_escape(key
) + "&value=" + param_escape(value
));
1159 exception_error("storeInitParam", e
);