]>
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
, silent
) {
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>");
31 function disableHotkeys() {
32 hotkeys_enabled
= false;
35 function enableHotkeys() {
36 hotkeys_enabled
= true;
39 function xmlhttp_ready(obj
) {
40 return obj
.readyState
== 4 || obj
.readyState
== 0 || !obj
.readyState
;
43 function notify_callback() {
44 var container
= document
.getElementById('notify');
45 if (xmlhttp
.readyState
== 4) {
46 container
.innerHTML
=xmlhttp
.responseText
;
50 function rpc_notify_callback() {
51 var container
= document
.getElementById('notify');
52 if (xmlhttp_rpc
.readyState
== 4) {
53 container
.innerHTML
=xmlhttp_rpc
.responseText
;
57 function param_escape(arg
) {
58 if (typeof encodeURIComponent
!= 'undefined')
59 return encodeURIComponent(arg
);
64 function param_unescape(arg
) {
65 if (typeof decodeURIComponent
!= 'undefined')
66 return decodeURIComponent(arg
);
73 then
=new Date().getTime();
75 while((now
-then
)<gap
) {
76 now
=new Date().getTime();
80 var notify_hide_timerid
= false;
81 var notify_last_doc
= false;
83 var notify_effect
= false;
85 function hide_notify() {
86 if (notify_last_doc
) {
87 var n
= notify_last_doc
.getElementById("notify");
88 if (browser_has_opacity()) {
89 if (notify_opacity
>= 0) {
90 notify_opacity
= notify_opacity
- 0.1;
91 n
.style
.opacity
= notify_opacity
;
92 notify_hide_timerid
= window
.setTimeout("hide_notify()", 20);
94 n
.style
.display
= "none";
98 n
.style
.display
= "none";
103 function notify_real(msg
, doc
, no_hide
, is_err
) {
105 var n
= doc
.getElementById("notify");
106 var nb
= doc
.getElementById("notify_body");
108 if (!n
|| !nb
) return;
110 if (notify_hide_timerid
) {
111 window
.clearTimeout(notify_hide_timerid
);
114 notify_last_doc
= doc
;
118 if (n
.style
.display
== "block") {
119 notify_hide_timerid
= window
.setTimeout("hide_notify()", 0);
123 n
.style
.display
= "block";
127 n
.style
.backgroundColor
= "#ffcccc";
128 n
.style
.color
= "black";
129 n
.style
.borderColor
= "#ff0000";
131 n
.style
.backgroundColor
= "#fff7d5";
132 n
.style
.borderColor
= "#d7c47a";
133 n
.style
.color
= "black";
139 notify_hide_timerid
= window
.setTimeout("hide_notify()", 3000);
143 function p_notify(msg
, no_hide
, is_err
) {
144 notify_real(msg
, parent
.document
, no_hide
, is_err
);
147 function notify(msg
, no_hide
, is_err
) {
148 notify_real(msg
, document
, no_hide
, is_err
);
151 function printLockingError() {
152 notify("Please wait until operation finishes");}
156 function hotkey_handler(e
) {
162 if (!hotkeys_enabled
) return;
165 keycode
= window
.event
.keyCode
;
170 if (keycode
== 13 || keycode
== 27) {
173 seq
= seq
+ "" + keycode
;
176 var m_ctx
= getMainContext();
177 var f_ctx
= getFeedsContext();
178 var h_ctx
= getHeadlinesContext();
180 if (keycode
== 82) { // r
181 return m_ctx
.scheduleFeedUpdate(true);
184 if (keycode
== 83) { // r
185 return m_ctx
.displayDlg("search", getActiveFeedId());
188 if (keycode
== 85) { // u
189 if (getActiveFeedId()) {
190 return f_ctx
.viewfeed(getActiveFeedId(), "ForceUpdate");
194 if (keycode
== 65) { // a
195 return m_ctx
.toggleDispRead();
198 var f_doc
= m_ctx
.frames
["feeds-frame"].document
;
199 var feedlist
= f_doc
.getElementById('feedList');
201 if (keycode
== 74) { // j
202 var feed
= getActiveFeedId();
203 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
204 if (new_feed
) viewfeed(new_feed
, '');
207 if (keycode
== 75) { // k
208 var feed
= getActiveFeedId();
209 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
210 if (new_feed
) viewfeed(new_feed
, '');
213 if (keycode
== 78 || keycode
== 40) { // n, down
214 return h_ctx
.moveToPost('next');
217 if (keycode
== 80 || keycode
== 38) { // p, up
218 return h_ctx
.moveToPost('prev');
221 if (document
.getElementById("piggie")) {
223 if (seq
.match("807371717369")) {
225 localPiggieFunction(true);
227 localPiggieFunction(false);
231 if (typeof localHotkeyHandler
!= 'undefined') {
233 localHotkeyHandler(keycode
);
235 exception_error("hotkey_handler, local:", e
);
239 exception_error("hotkey_handler", e
);
243 function cleanSelectedList(element
) {
244 var content
= document
.getElementById(element
);
246 if (!document
.getElementById("feedCatHolder")) {
247 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
248 var child
= content
.childNodes
[i
];
250 child
.className
= child
.className
.replace("Selected", "");
256 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
257 var child
= content
.childNodes
[i
];
258 if (child
.id
== "feedCatHolder") {
259 parent
.debug(child
.id
);
260 var fcat
= child
.lastChild
;
261 for (j
= 0; j
< fcat
.childNodes
.length
; j
++) {
262 var feed
= fcat
.childNodes
[j
];
263 feed
.className
= feed
.className
.replace("Selected", "");
271 function cleanSelected(element
) {
272 var content
= document
.getElementById(element
);
274 for (i
= 0; i
< content
.rows
.length
; i
++) {
275 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
279 function getVisibleUnreadHeadlines() {
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 && content
.rows
[i
].className
.match("Unread")) {
293 function getVisibleHeadlineIds() {
295 var content
= document
.getElementById("headlinesList");
297 var rows
= new Array();
299 for (i
= 0; i
< content
.rows
.length
; i
++) {
300 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
301 if (row_id
.length
> 0) {
308 function getFirstVisibleHeadlineId() {
309 var rows
= getVisibleHeadlineIds();
313 function getLastVisibleHeadlineId() {
314 var rows
= getVisibleHeadlineIds();
315 return rows
[rows
.length
-1];
318 function markHeadline(id
) {
319 var row
= document
.getElementById("RROW-" + id
);
321 var is_active
= false;
323 if (row
.className
.match("Active")) {
326 row
.className
= row
.className
.replace("Selected", "");
327 row
.className
= row
.className
.replace("Active", "");
328 row
.className
= row
.className
.replace("Insensitive", "");
331 row
.className
= row
.className
= "Active";
334 var check
= document
.getElementById("RCHK-" + id
);
337 check
.checked
= true;
340 row
.className
= row
.className
+ "Selected";
345 function getFeedIds() {
346 var content
= document
.getElementById("feedsList");
348 var rows
= new Array();
350 for (i
= 0; i
< content
.rows
.length
; i
++) {
351 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
360 function setCookie(name
, value
, lifetime
, path
, domain
, secure
) {
366 d
.setTime(lifetime
* 1000);
369 int_setCookie(name
, value
, d
, path
, domain
, secure
);
373 function int_setCookie(name
, value
, expires
, path
, domain
, secure
) {
374 document
.cookie
= name
+ "=" + escape(value
) +
375 ((expires
) ? "; expires=" + expires
.toGMTString() : "") +
376 ((path
) ? "; path=" + path
: "") +
377 ((domain
) ? "; domain=" + domain
: "") +
378 ((secure
) ? "; secure" : "");
381 function delCookie(name
, path
, domain
) {
382 if (getCookie(name
)) {
383 document
.cookie
= name
+ "=" +
384 ((path
) ? ";path=" + path
: "") +
385 ((domain
) ? ";domain=" + domain
: "" ) +
386 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
391 function getCookie(name
) {
393 var dc
= document
.cookie
;
394 var prefix
= name
+ "=";
395 var begin
= dc
.indexOf("; " + prefix
);
397 begin
= dc
.indexOf(prefix
);
398 if (begin
!= 0) return null;
403 var end
= document
.cookie
.indexOf(";", begin
);
407 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
410 function disableContainerChildren(id
, disable
, doc
) {
412 if (!doc
) doc
= document
;
414 var container
= doc
.getElementById(id
);
417 //alert("disableContainerChildren: element " + id + " not found");
421 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
422 var child
= container
.childNodes
[i
];
425 child
.disabled
= disable
;
431 if (child
.className
&& child
.className
.match("button")) {
432 child
.className
= "disabledButton";
435 if (child
.className
&& child
.className
.match("disabledButton")) {
436 child
.className
= "button";
443 function gotoPreferences() {
444 document
.location
.href
= "prefs.php";
447 function gotoMain() {
448 document
.location
.href
= "tt-rss.php";
451 function gotoExportOpml() {
452 document
.location
.href
= "opml.php?op=Export";
455 function getActiveFeedId() {
456 // return getCookie("ttrss_vf_actfeed");
458 debug("gAFID: " + getMainContext().active_feed_id
);
459 return getMainContext().active_feed_id
;
461 exception_error("getActiveFeedId", e
);
465 function activeFeedIsCat() {
466 return getMainContext().active_feed_is_cat
;
469 function setActiveFeedId(id
) {
470 // return setCookie("ttrss_vf_actfeed", id);
472 debug("sAFID(" + id
+ ")");
473 getMainContext().active_feed_id
= id
;
475 exception_error("setActiveFeedId", e
);
479 function parse_counters(reply
, scheduled_call
) {
481 var f_document
= getFeedsContext().document
;
482 var title_obj
= getMainContext();
484 if (reply
.firstChild
&& reply
.firstChild
.firstChild
) {
485 debug("<b>wrong element passed to parse_counters, adjusting.</b>");
486 reply
= reply
.firstChild
;
489 debug("F_DOC: " + f_document
+ ", T_OBJ: " + title_obj
);
491 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
492 if (!reply
.childNodes
[l
] ||
493 typeof(reply
.childNodes
[l
].getAttribute
) == "undefined") {
494 // where did this come from?
498 var id
= reply
.childNodes
[l
].getAttribute("id");
499 var t
= reply
.childNodes
[l
].getAttribute("type");
500 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
501 var error
= reply
.childNodes
[l
].getAttribute("error");
502 var has_img
= reply
.childNodes
[l
].getAttribute("hi");
503 var updated
= reply
.childNodes
[l
].getAttribute("updated");
505 if (id
== "global-unread") {
506 title_obj
.global_unread
= ctr
;
507 title_obj
.updateTitle();
511 if (t
== "category") {
512 var catctr
= f_document
.getElementById("FCATCTR-" + id
);
514 catctr
.innerHTML
= "(" + ctr
+ " unread)";
519 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
520 var feedu
= f_document
.getElementById("FEEDU-" + id
);
521 var feedr
= f_document
.getElementById("FEEDR-" + id
);
522 var feed_img
= f_document
.getElementById("FIMG-" + id
);
523 var feedlink
= f_document
.getElementById("FEEDL-" + id
);
524 var feedupd
= f_document
.getElementById("FLUPD-" + id
);
526 if (updated
&& feedlink
) {
528 feedlink
.title
= "Error: " + error
+ " (" + updated
+ ")";
530 feedlink
.title
= "Updated: " + updated
;
534 if (updated
&& feedupd
) {
536 feedupd
.innerHTML
= updated
+ " (Error)";
538 feedupd
.innerHTML
= updated
;
542 if (feedctr
&& feedu
&& feedr
) {
544 if (feedu
.innerHTML
!= ctr
&& id
== getActiveFeedId() && scheduled_call
) {
545 var hf
= title_obj
.parent
.frames
["headlines-frame"];
546 hf
.location
.reload(true);
549 feedu
.innerHTML
= ctr
;
552 feedr
.className
= feedr
.className
.replace("feed", "error");
554 feedr
.className
= feedr
.className
.replace("error", "feed");
558 feedctr
.className
= "odd";
559 if (!feedr
.className
.match("Unread")) {
560 var is_selected
= feedr
.className
.match("Selected");
562 feedr
.className
= feedr
.className
.replace("Selected", "");
563 feedr
.className
= feedr
.className
.replace("Unread", "");
565 feedr
.className
= feedr
.className
+ "Unread";
568 feedr
.className
= feedr
.className
+ "Selected";
573 feedctr
.className
= "invisible";
574 feedr
.className
= feedr
.className
.replace("Unread", "");
579 exception_error("parse_counters", e
);
583 function all_counters_callback() {
584 if (xmlhttp_rpc
.readyState
== 4) {
586 if (!xmlhttp_rpc
.responseXML
|| !xmlhttp_rpc
.responseXML
.firstChild
) {
587 debug("[all_counters_callback] backend did not return valid XML");
591 debug("in all_counters_callback");
593 var reply
= xmlhttp_rpc
.responseXML
.firstChild
;
595 var counters
= reply
.firstChild
;
597 parse_counters(counters
);
599 var runtime
= counters
.nextSibling
;
602 getMainContext().parse_runtime_info(runtime
);
605 if (getInitParam("feeds_sort_by_unread") == 1) {
609 hideOrShowFeeds(document
, getInitParam("hide_read_feeds") == 1);
612 exception_error("all_counters_callback", e
);
617 function get_feed_entry_unread(doc
, elem
) {
619 var id
= elem
.id
.replace("FEEDR-", "");
626 return parseInt(doc
.getElementById("FEEDU-" + id
).innerHTML
);
632 function resort_category(doc
, node
) {
633 debug("resort_category: " + node
);
635 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
636 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
637 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
639 if (get_feed_entry_unread(doc
, node
.childNodes
[i
]) < 0) {
643 for (j
= i
+1; j
< node
.childNodes
.length
; j
++) {
644 if (node
.childNodes
[j
].nodeName
!= "LI") { continue; }
646 var tmp_val
= get_feed_entry_unread(doc
, node
.childNodes
[i
]);
647 var cur_val
= get_feed_entry_unread(doc
, node
.childNodes
[j
]);
649 if (cur_val
> tmp_val
) {
650 tempnode_i
= node
.childNodes
[i
].cloneNode(true);
651 tempnode_j
= node
.childNodes
[j
].cloneNode(true);
652 node
.replaceChild(tempnode_i
, node
.childNodes
[j
]);
653 node
.replaceChild(tempnode_j
, node
.childNodes
[i
]);
662 function resort_feedlist() {
663 debug("resort_feedlist");
665 var fd
= getFeedsContext().document
;
667 if (fd
.getElementById("feedCatHolder")) {
669 var feeds
= fd
.getElementById("feedList");
670 var child
= feeds
.firstChild
;
674 if (child
.id
== "feedCatHolder") {
675 resort_category(fd
, child
.firstChild
);
678 child
= child
.nextSibling
;
682 resort_category(fd
, fd
.getElementById("feedList"));
686 function update_all_counters(feed
) {
687 if (xmlhttp_ready(xmlhttp_rpc
)) {
688 var query
= "backend.php?op=rpc&subop=getAllCounters";
691 query
= query
+ "&aid=" + feed
;
694 xmlhttp_rpc
.open("GET", query
, true);
695 xmlhttp_rpc
.onreadystatechange
=all_counters_callback
;
696 xmlhttp_rpc
.send(null);
700 function popupHelp(tid
) {
701 var w
= window
.open("backend.php?op=help&tid=" + tid
,
703 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
706 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
707 * * @author Sundar Dorai-Raj
708 * * Email: sdoraira@vt.edu
709 * * This program is free software; you can redistribute it and/or
710 * * modify it under the terms of the GNU General Public License
711 * * as published by the Free Software Foundation; either version 2
712 * * of the License, or (at your option) any later version,
713 * * provided that any use properly credits the author.
714 * * This program is distributed in the hope that it will be useful,
715 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
716 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
717 * * GNU General Public License for more details at http://www.gnu.org * * */
719 var numbers
=".0123456789";
720 function isNumeric(x
) {
721 // is x a String or a character?
723 // remove negative sign
725 for(j
=0;j
<x
.length
;j
++) {
726 // call isNumeric recursively for each character
727 number
=isNumeric(x
.substring(j
,j
+1));
728 if(!number
) return number
;
733 // if x is number return true
734 if(numbers
.indexOf(x
)>=0) return true;
740 function hideOrShowFeeds(doc
, hide
) {
742 var fd
= getFeedsContext().document
;
744 var list
= fd
.getElementById("feedList");
746 if (fd
.getElementById("feedCatHolder")) {
748 var feeds
= fd
.getElementById("feedList");
749 var child
= feeds
.firstChild
;
753 if (child
.id
== "feedCatHolder") {
754 hideOrShowFeedsCategory(fd
, child
.firstChild
, hide
, child
.previousSibling
);
757 child
= child
.nextSibling
;
761 hideOrShowFeedsCategory(fd
, fd
.getElementById("feedList"), hide
);
765 function hideOrShowFeedsCategory(doc
, node
, hide
, cat_node
) {
767 // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
771 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
772 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
773 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
775 var has_unread
= (node
.childNodes
[i
].className
!= "feed");
777 // debug(node.childNodes[i].id + " --> " + has_unread);
779 if (hide
&& !has_unread
) {
780 node
.childNodes
[i
].style
.display
= "none";
784 node
.childNodes
[i
].style
.display
= "list-item";
794 if (cat_unread
== 0) {
796 cat_node
.style
.display
= "none";
798 cat_node
.style
.display
= "list-item";
802 // debug("unread for category: " + cat_unread);
805 function selectTableRow(r
, do_select
) {
806 r
.className
= r
.className
.replace("Selected", "");
809 r
.className
= r
.className
+ "Selected";
813 function selectTableRowById(elem_id
, check_id
, do_select
) {
817 var row
= document
.getElementById(elem_id
);
820 selectTableRow(row
, do_select
);
823 var check
= document
.getElementById(check_id
);
826 check
.checked
= do_select
;
829 exception_error("selectTableRowById", e
);
833 function selectTableRowsByIdPrefix(content_id
, prefix
, check_prefix
, do_select
,
834 classcheck
, reset_others
) {
836 var content
= document
.getElementById(content_id
);
839 alert("[selectTableRows] Element " + content_id
+ " not found.");
843 for (i
= 0; i
< content
.rows
.length
; i
++) {
844 if (!classcheck
|| content
.rows
[i
].className
.match(classcheck
)) {
846 if (content
.rows
[i
].id
.match(prefix
)) {
847 selectTableRow(content
.rows
[i
], do_select
);
849 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
850 var check
= document
.getElementById(check_prefix
+ row_id
);
853 check
.checked
= do_select
;
855 } else if (reset_others
) {
856 selectTableRow(content
.rows
[i
], false);
858 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
859 var check
= document
.getElementById(check_prefix
+ row_id
);
862 check
.checked
= false;
866 } else if (reset_others
) {
867 selectTableRow(content
.rows
[i
], false);
869 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
870 var check
= document
.getElementById(check_prefix
+ row_id
);
873 check
.checked
= false;
880 function getSelectedTableRowIds(content_id
, prefix
) {
882 var content
= document
.getElementById(content_id
);
885 alert("[getSelectedTableRowIds] Element " + content_id
+ " not found.");
889 var sel_rows
= new Array();
891 for (i
= 0; i
< content
.rows
.length
; i
++) {
892 if (content
.rows
[i
].id
.match(prefix
) &&
893 content
.rows
[i
].className
.match("Selected")) {
895 var row_id
= content
.rows
[i
].id
.replace(prefix
+ "-", "");
896 sel_rows
.push(row_id
);
904 function toggleSelectRowById(sender
, id
) {
905 var row
= document
.getElementById(id
);
907 if (sender
.checked
) {
908 if (!row
.className
.match("Selected")) {
909 row
.className
= row
.className
+ "Selected";
912 if (row
.className
.match("Selected")) {
913 row
.className
= row
.className
.replace("Selected", "");
918 function toggleSelectListRow(sender
) {
919 var parent_row
= sender
.parentNode
;
921 if (sender
.checked
) {
922 if (!parent_row
.className
.match("Selected")) {
923 parent_row
.className
= parent_row
.className
+ "Selected";
926 if (parent_row
.className
.match("Selected")) {
927 parent_row
.className
= parent_row
.className
.replace("Selected", "");
933 function toggleSelectRow(sender
) {
934 var parent_row
= sender
.parentNode
.parentNode
;
936 if (sender
.checked
) {
937 if (!parent_row
.className
.match("Selected")) {
938 parent_row
.className
= parent_row
.className
+ "Selected";
941 if (parent_row
.className
.match("Selected")) {
942 parent_row
.className
= parent_row
.className
.replace("Selected", "");
947 function openExternalUrl(url
) {
948 var w
= window
.open(url
);
951 function getRelativeFeedId(list
, id
, direction
, unread_only
) {
953 if (direction
== "next") {
954 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
955 var child
= list
.childNodes
[i
];
956 if (child
.id
&& child
.id
== "feedCatHolder") {
957 if (child
.lastChild
) {
958 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
961 } else if (child
.id
&& child
.id
.match("FEEDR-")) {
962 return child
.id
.replace('FEEDR-', '');
967 // FIXME select last feed doesn't work when only unread feeds are visible
969 if (direction
== "prev") {
970 for (i
= list
.childNodes
.length
-1; i
>= 0; i
--) {
971 var child
= list
.childNodes
[i
];
972 if (child
.id
== "feedCatHolder") {
973 if (child
.firstChild
) {
974 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
977 } else if (child
.id
.match("FEEDR-")) {
979 if (getInitParam("hide_read_feeds") == 1) {
980 if (child
.className
!= "feed") {
981 alert(child
.className
);
982 return child
.id
.replace('FEEDR-', '');
985 return child
.id
.replace('FEEDR-', '');
992 var feed
= list
.ownerDocument
.getElementById("FEEDR-" + getActiveFeedId());
994 if (getInitParam("hide_read_feeds") == 1) {
998 if (direction
== "next") {
1004 if (e
.nextSibling
) {
1008 } else if (e
.parentNode
.parentNode
.nextSibling
) {
1010 var this_cat
= e
.parentNode
.parentNode
;
1014 if (this_cat
&& this_cat
.nextSibling
) {
1015 while (!e
&& this_cat
.nextSibling
) {
1016 this_cat
= this_cat
.nextSibling
;
1017 if (this_cat
.id
== "feedCatHolder") {
1018 e
= this_cat
.firstChild
.firstChild
;
1028 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1029 e
.className
!= "error")) {
1030 return e
.id
.replace("FEEDR-", "");
1035 } else if (direction
== "prev") {
1041 if (e
.previousSibling
) {
1043 e
= e
.previousSibling
;
1045 } else if (e
.parentNode
.parentNode
.previousSibling
) {
1047 var this_cat
= e
.parentNode
.parentNode
;
1051 if (this_cat
&& this_cat
.previousSibling
) {
1052 while (!e
&& this_cat
.previousSibling
) {
1053 this_cat
= this_cat
.previousSibling
;
1054 if (this_cat
.id
== "feedCatHolder") {
1055 e
= this_cat
.firstChild
.lastChild
;
1065 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1066 e
.className
!= "error")) {
1067 return e
.id
.replace("FEEDR-", "");
1075 function showBlockElement(id
) {
1076 var elem
= document
.getElementById(id
);
1079 elem
.style
.display
= "block";
1081 alert("[showBlockElement] can't find element with id " + id
);
1085 function hideParentElement(e
) {
1086 e
.parentNode
.style
.display
= "none";
1089 function dropboxSelect(e
, v
) {
1090 for (i
= 0; i
< e
.length
; i
++) {
1091 if (e
[i
].value
== v
) {
1092 e
.selectedIndex
= i
;
1098 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1099 // bugfixed just a little bit :-)
1100 function getURLParam(strParamName
){
1102 var strHref
= window
.location
.href
;
1104 if (strHref
.indexOf("#") == strHref
.length
-1) {
1105 strHref
= strHref
.substring(0, strHref
.length
-1);
1108 if ( strHref
.indexOf("?") > -1 ){
1109 var strQueryString
= strHref
.substr(strHref
.indexOf("?"));
1110 var aQueryString
= strQueryString
.split("&");
1111 for ( var iParam
= 0; iParam
< aQueryString
.length
; iParam
++ ){
1112 if (aQueryString
[iParam
].indexOf(strParamName
+ "=") > -1 ){
1113 var aParam
= aQueryString
[iParam
].split("=");
1114 strReturn
= aParam
[1];
1122 function leading_zero(p
) {
1124 if (s
.length
== 1) s
= "0" + s
;
1128 function closeInfoBox(cleanup
) {
1129 var box
= document
.getElementById('infoBox');
1130 var shadow
= document
.getElementById('infoBoxShadow');
1133 shadow
.style
.display
= "none";
1135 box
.style
.display
= "none";
1138 if (cleanup
) box
.innerHTML
= " ";
1146 function displayDlg(id
, param
) {
1148 if (!xmlhttp_ready(xmlhttp
)) {
1149 printLockingError();
1155 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
1156 param_escape(id
) + "¶m=" + param_escape(param
), true);
1157 xmlhttp
.onreadystatechange
=infobox_callback
;
1165 function infobox_submit_callback() {
1166 if (xmlhttp
.readyState
== 4) {
1169 // called from prefs, reload tab
1171 selectTab(active_tab
, false);
1174 notify(xmlhttp
.responseText
);
1179 function infobox_callback() {
1180 if (xmlhttp
.readyState
== 4) {
1181 var box
= document
.getElementById('infoBox');
1182 var shadow
= document
.getElementById('infoBoxShadow');
1184 box
.innerHTML
=xmlhttp
.responseText
;
1186 shadow
.style
.display
= "block";
1188 box
.style
.display
= "block";
1194 function qaddFilter() {
1196 if (!xmlhttp_ready(xmlhttp
)) {
1197 printLockingError();
1201 var query
= Form
.serialize("filter_add_form");
1203 xmlhttp
.open("GET", "backend.php?" + query
, true);
1204 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
1210 function toggleSubmitNotEmpty(e
, submit_id
) {
1212 document
.getElementById(submit_id
).disabled
= (e
.value
== "")
1214 exception_error("toggleSubmitNotEmpty", e
);
1218 function isValidURL(s
) {
1219 return s
.match("http://") != null || s
.match("https://") != null;
1224 if (!xmlhttp_ready(xmlhttp
)) {
1225 printLockingError();
1229 notify("Adding feed...");
1233 var feeds_doc
= getFeedsContext().document
;
1235 feeds_doc
.location
.href
= "backend.php?op=error&msg=Loading,%20please wait...";
1237 var query
= Form
.serialize("feed_add_form");
1239 xmlhttp
.open("GET", "backend.php?" + query
, true);
1240 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
1244 function filterCR(e
)
1249 key
= window
.event
.keyCode
; //IE
1251 key
= e
.which
; //firefox
1259 function getMainContext() {
1260 if (parent
.window
!= window
) {
1261 return parent
.window
;
1267 function getFeedsContext() {
1269 return getMainContext().frames
["feeds-frame"];
1271 exception_error("getFeedsContext", e
);
1276 function getHeadlinesContext() {
1278 return getMainContext().frames
["headlines-frame"];
1280 exception_error("getHeadlinesContext", e
);
1284 var debug_last_class
= "even";
1286 function debug(msg
) {
1287 var ctx
= getMainContext();
1289 if (ctx
.debug_last_class
== "even") {
1290 ctx
.debug_last_class
= "odd";
1292 ctx
.debug_last_class
= "even";
1295 var c
= ctx
.document
.getElementById('debug_output');
1296 if (c
&& c
.style
.display
== "block") {
1297 while (c
.lastChild
!= 'undefined' && c
.childNodes
.length
> 100) {
1298 c
.removeChild(c
.lastChild
);
1302 var ts
= leading_zero(d
.getHours()) + ":" + leading_zero(d
.getMinutes()) +
1303 ":" + leading_zero(d
.getSeconds());
1304 c
.innerHTML
= "<li class=\"" + ctx
.debug_last_class
+ "\"><span class=\"debugTS\">[" + ts
+ "]</span> " +
1305 msg
+ "</li>" + c
.innerHTML
;
1309 function getInitParam(key
) {
1310 return getMainContext().init_params
[key
];
1313 function storeInitParam(key
, value
, is_client
) {
1316 if (getMainContext().init_params
[key
] != value
) {
1317 debug("storeInitParam: " + key
+ " => " + value
);
1318 //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" +
1319 // param_escape(key) + "&value=" + param_escape(value));
1320 var f
= getMainContext().document
.getElementById("backReqBox");
1321 f
.src
= "backend.php?op=rpc&subop=storeParam&key=" +
1322 param_escape(key
) + "&value=" + param_escape(value
);
1325 getMainContext().init_params
[key
] = value
;
1327 exception_error("storeInitParam", e
);
1332 function storeInitParams(params, is_client) {
1337 if (getMainContext().init_params[k] != params[k]) {
1338 s += k + "=" + params[k] + ";";
1339 getMainContext().init_params[k] = params[k];
1343 debug("storeInitParams: " + s);
1346 new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
1349 exception_error("storeInitParams", e);
1353 function fatalError(code
, message
) {
1355 var fe
= document
.getElementById("fatal_error");
1356 var fc
= document
.getElementById("fatal_error_msg");
1358 fc
.innerHTML
= "Code " + code
+ ": " + message
;
1360 fe
.style
.display
= "block";
1363 exception_error("fatalError", e
);
1367 function getFeedName(id
, is_cat
) {
1368 var d
= getFeedsContext().document
;
1373 e
= d
.getElementById("FCATN-" + id
);
1375 e
= d
.getElementById("FEEDN-" + id
);
1378 return e
.innerHTML
.stripTags();