]>
git.wh0rd.org - tt-rss.git/blob - functions.js
72638dcca3e4fcb64df3aa86ae7238c309522fdd
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 var m_ctx
= getMainContext();
173 var f_ctx
= getFeedsContext();
174 var h_ctx
= getHeadlinesContext();
176 if (keycode
== 82) { // r
177 return m_ctx
.scheduleFeedUpdate(true);
180 if (keycode
== 83) { // r
181 return m_ctx
.displayDlg("search", getActiveFeedId());
184 if (keycode
== 85) { // u
185 if (getActiveFeedId()) {
186 return f_ctx
.viewfeed(getActiveFeedId(), "ForceUpdate");
190 if (keycode
== 65) { // a
191 return m_ctx
.toggleDispRead();
194 var f_doc
= document
;
195 var feedlist
= f_doc
.getElementById('feedList');
197 if (keycode
== 74) { // j
198 var feed
= getActiveFeedId();
199 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
200 if (new_feed
) viewfeed(new_feed
, '');
203 if (keycode
== 75) { // k
204 var feed
= getActiveFeedId();
205 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
206 if (new_feed
) viewfeed(new_feed
, '');
209 if (keycode
== 78 || keycode
== 40) { // n, down
210 if (typeof h_ctx
.moveToPost
!= 'undefined') {
211 return h_ctx
.moveToPost('next');
215 if (keycode
== 80 || keycode
== 38) { // p, up
216 if (typeof h_ctx
.moveToPost
!= 'undefined') {
217 return h_ctx
.moveToPost('prev');
221 if (typeof localHotkeyHandler
!= 'undefined') {
223 localHotkeyHandler(keycode
);
225 exception_error("hotkey_handler, local:", e
);
229 exception_error("hotkey_handler", e
);
233 function cleanSelectedList(element
) {
234 var content
= document
.getElementById(element
);
236 if (!document
.getElementById("feedCatHolder")) {
237 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
238 var child
= content
.childNodes
[i
];
240 child
.className
= child
.className
.replace("Selected", "");
246 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
247 var child
= content
.childNodes
[i
];
248 if (child
.id
== "feedCatHolder") {
250 var fcat
= child
.lastChild
;
251 for (j
= 0; j
< fcat
.childNodes
.length
; j
++) {
252 var feed
= fcat
.childNodes
[j
];
253 feed
.className
= feed
.className
.replace("Selected", "");
261 function cleanSelected(element
) {
262 var content
= document
.getElementById(element
);
264 for (i
= 0; i
< content
.rows
.length
; i
++) {
265 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
269 function getVisibleUnreadHeadlines() {
270 var content
= document
.getElementById("headlinesList");
272 var rows
= new Array();
274 for (i
= 0; i
< content
.rows
.length
; i
++) {
275 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
276 if (row_id
.length
> 0 && content
.rows
[i
].className
.match("Unread")) {
283 function getVisibleHeadlineIds() {
285 var content
= document
.getElementById("headlinesList");
287 var rows
= new Array();
289 for (i
= 0; i
< content
.rows
.length
; i
++) {
290 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
291 if (row_id
.length
> 0) {
298 function getFirstVisibleHeadlineId() {
299 var rows
= getVisibleHeadlineIds();
303 function getLastVisibleHeadlineId() {
304 var rows
= getVisibleHeadlineIds();
305 return rows
[rows
.length
-1];
308 function markHeadline(id
) {
309 var row
= document
.getElementById("RROW-" + id
);
311 var is_active
= false;
313 if (row
.className
.match("Active")) {
316 row
.className
= row
.className
.replace("Selected", "");
317 row
.className
= row
.className
.replace("Active", "");
318 row
.className
= row
.className
.replace("Insensitive", "");
321 row
.className
= row
.className
= "Active";
324 var check
= document
.getElementById("RCHK-" + id
);
327 check
.checked
= true;
330 row
.className
= row
.className
+ "Selected";
335 function getFeedIds() {
336 var content
= document
.getElementById("feedsList");
338 var rows
= new Array();
340 for (i
= 0; i
< content
.rows
.length
; i
++) {
341 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
350 function setCookie(name
, value
, lifetime
, path
, domain
, secure
) {
356 d
.setTime(lifetime
* 1000);
359 int_setCookie(name
, value
, d
, path
, domain
, secure
);
363 function int_setCookie(name
, value
, expires
, path
, domain
, secure
) {
364 document
.cookie
= name
+ "=" + escape(value
) +
365 ((expires
) ? "; expires=" + expires
.toGMTString() : "") +
366 ((path
) ? "; path=" + path
: "") +
367 ((domain
) ? "; domain=" + domain
: "") +
368 ((secure
) ? "; secure" : "");
371 function delCookie(name
, path
, domain
) {
372 if (getCookie(name
)) {
373 document
.cookie
= name
+ "=" +
374 ((path
) ? ";path=" + path
: "") +
375 ((domain
) ? ";domain=" + domain
: "" ) +
376 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
381 function getCookie(name
) {
383 var dc
= document
.cookie
;
384 var prefix
= name
+ "=";
385 var begin
= dc
.indexOf("; " + prefix
);
387 begin
= dc
.indexOf(prefix
);
388 if (begin
!= 0) return null;
393 var end
= document
.cookie
.indexOf(";", begin
);
397 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
400 function disableContainerChildren(id
, disable
, doc
) {
402 if (!doc
) doc
= document
;
404 var container
= doc
.getElementById(id
);
407 //alert("disableContainerChildren: element " + id + " not found");
411 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
412 var child
= container
.childNodes
[i
];
415 child
.disabled
= disable
;
421 if (child
.className
&& child
.className
.match("button")) {
422 child
.className
= "disabledButton";
425 if (child
.className
&& child
.className
.match("disabledButton")) {
426 child
.className
= "button";
433 function gotoPreferences() {
434 document
.location
.href
= "prefs.php";
437 function gotoMain() {
438 document
.location
.href
= "tt-rss.php";
441 function gotoExportOpml() {
442 document
.location
.href
= "opml.php?op=Export";
445 function getActiveFeedId() {
446 // return getCookie("ttrss_vf_actfeed");
448 debug("gAFID: " + getMainContext().active_feed_id
);
449 return getMainContext().active_feed_id
;
451 exception_error("getActiveFeedId", e
);
455 function activeFeedIsCat() {
456 return getMainContext().active_feed_is_cat
;
459 function setActiveFeedId(id
) {
460 // return setCookie("ttrss_vf_actfeed", id);
462 debug("sAFID(" + id
+ ")");
463 getMainContext().active_feed_id
= id
;
465 exception_error("setActiveFeedId", e
);
469 function parse_counters(reply
, scheduled_call
) {
471 var f_document
= document
;
472 var title_obj
= this.window
;
476 if (reply
.firstChild
&& reply
.firstChild
.firstChild
) {
477 debug("<b>wrong element passed to parse_counters, adjusting.</b>");
478 reply
= reply
.firstChild
;
481 debug("F_DOC: " + f_document
+ ", T_OBJ: " + title_obj
);
483 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
484 if (!reply
.childNodes
[l
] ||
485 typeof(reply
.childNodes
[l
].getAttribute
) == "undefined") {
486 // where did this come from?
490 var id
= reply
.childNodes
[l
].getAttribute("id");
491 var t
= reply
.childNodes
[l
].getAttribute("type");
492 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
493 var error
= reply
.childNodes
[l
].getAttribute("error");
494 var has_img
= reply
.childNodes
[l
].getAttribute("hi");
495 var updated
= reply
.childNodes
[l
].getAttribute("updated");
497 if (id
== "global-unread") {
498 title_obj
.global_unread
= ctr
;
499 title_obj
.updateTitle();
503 if (id
== "subscribed-feeds") {
508 if (t
== "category") {
509 var catctr
= f_document
.getElementById("FCATCTR-" + id
);
511 catctr
.innerHTML
= "(" + ctr
+ " unread)";
516 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
517 var feedu
= f_document
.getElementById("FEEDU-" + id
);
518 var feedr
= f_document
.getElementById("FEEDR-" + id
);
519 var feed_img
= f_document
.getElementById("FIMG-" + id
);
520 var feedlink
= f_document
.getElementById("FEEDL-" + id
);
521 var feedupd
= f_document
.getElementById("FLUPD-" + id
);
523 if (updated
&& feedlink
) {
525 feedlink
.title
= "Error: " + error
+ " (" + updated
+ ")";
527 feedlink
.title
= "Updated: " + updated
;
531 if (updated
&& feedupd
) {
533 feedupd
.innerHTML
= updated
+ " (Error)";
535 feedupd
.innerHTML
= updated
;
539 if (feedctr
&& feedu
&& feedr
) {
541 if (feedu
.innerHTML
!= ctr
&& id
== getActiveFeedId() && scheduled_call
) {
545 feedu
.innerHTML
= ctr
;
548 feedr
.className
= feedr
.className
.replace("feed", "error");
550 feedr
.className
= feedr
.className
.replace("error", "feed");
554 feedctr
.className
= "odd";
555 if (!feedr
.className
.match("Unread")) {
556 var is_selected
= feedr
.className
.match("Selected");
558 feedr
.className
= feedr
.className
.replace("Selected", "");
559 feedr
.className
= feedr
.className
.replace("Unread", "");
561 feedr
.className
= feedr
.className
+ "Unread";
564 feedr
.className
= feedr
.className
+ "Selected";
569 feedctr
.className
= "invisible";
570 feedr
.className
= feedr
.className
.replace("Unread", "");
575 hideOrShowFeeds(getFeedsContext().document
,
576 getInitParam("hide_read_feeds") == 1);
578 var feeds_stored
= getMainContext().number_of_feeds
;
580 debug("Feed counters, C: " + feeds_found
+ ", S:" + feeds_stored
);
582 if (feeds_stored
!= feeds_found
) {
583 getMainContext().number_of_feeds
= feeds_found
;
585 if (feeds_stored
!= 0) {
586 debug("Subscribed feed number changed, refreshing feedlist");
592 exception_error("parse_counters", e
);
596 function all_counters_callback() {
597 if (xmlhttp_rpc
.readyState
== 4) {
599 if (!xmlhttp_rpc
.responseXML
|| !xmlhttp_rpc
.responseXML
.firstChild
) {
600 debug("[all_counters_callback] backend did not return valid XML");
604 debug("in all_counters_callback : " + xmlhttp_rpc
.responseXML
);
606 var reply
= xmlhttp_rpc
.responseXML
.firstChild
;
608 var counters
= reply
.firstChild
;
610 parse_counters(counters
);
612 var runtime
= counters
.nextSibling
;
615 getMainContext().parse_runtime_info(runtime
);
618 if (getInitParam("feeds_sort_by_unread") == 1) {
622 hideOrShowFeeds(document
, getInitParam("hide_read_feeds") == 1);
625 exception_error("all_counters_callback", e
);
630 function get_feed_entry_unread(doc
, elem
) {
632 var id
= elem
.id
.replace("FEEDR-", "");
639 return parseInt(doc
.getElementById("FEEDU-" + id
).innerHTML
);
645 function resort_category(doc
, node
) {
646 debug("resort_category: " + node
);
648 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
649 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
650 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
652 if (get_feed_entry_unread(doc
, node
.childNodes
[i
]) < 0) {
656 for (j
= i
+1; j
< node
.childNodes
.length
; j
++) {
657 if (node
.childNodes
[j
].nodeName
!= "LI") { continue; }
659 var tmp_val
= get_feed_entry_unread(doc
, node
.childNodes
[i
]);
660 var cur_val
= get_feed_entry_unread(doc
, node
.childNodes
[j
]);
662 if (cur_val
> tmp_val
) {
663 tempnode_i
= node
.childNodes
[i
].cloneNode(true);
664 tempnode_j
= node
.childNodes
[j
].cloneNode(true);
665 node
.replaceChild(tempnode_i
, node
.childNodes
[j
]);
666 node
.replaceChild(tempnode_j
, node
.childNodes
[i
]);
675 function resort_feedlist() {
676 debug("resort_feedlist");
678 var fd
= getFeedsContext().document
;
680 if (fd
.getElementById("feedCatHolder")) {
682 var feeds
= fd
.getElementById("feedList");
683 var child
= feeds
.firstChild
;
687 if (child
.id
== "feedCatHolder") {
688 resort_category(fd
, child
.firstChild
);
691 child
= child
.nextSibling
;
695 resort_category(fd
, fd
.getElementById("feedList"));
699 function update_all_counters(feed
) {
700 if (xmlhttp_ready(xmlhttp_rpc
)) {
701 var query
= "backend.php?op=rpc&subop=getAllCounters";
704 query
= query
+ "&aid=" + feed
;
707 xmlhttp_rpc
.open("GET", query
, true);
708 xmlhttp_rpc
.onreadystatechange
=all_counters_callback
;
709 xmlhttp_rpc
.send(null);
713 function popupHelp(tid
) {
714 var w
= window
.open("backend.php?op=help&tid=" + tid
,
716 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
719 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
720 * * @author Sundar Dorai-Raj
721 * * Email: sdoraira@vt.edu
722 * * This program is free software; you can redistribute it and/or
723 * * modify it under the terms of the GNU General Public License
724 * * as published by the Free Software Foundation; either version 2
725 * * of the License, or (at your option) any later version,
726 * * provided that any use properly credits the author.
727 * * This program is distributed in the hope that it will be useful,
728 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
729 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
730 * * GNU General Public License for more details at http://www.gnu.org * * */
732 var numbers
=".0123456789";
733 function isNumeric(x
) {
734 // is x a String or a character?
736 // remove negative sign
738 for(j
=0;j
<x
.length
;j
++) {
739 // call isNumeric recursively for each character
740 number
=isNumeric(x
.substring(j
,j
+1));
741 if(!number
) return number
;
746 // if x is number return true
747 if(numbers
.indexOf(x
)>=0) return true;
753 function hideOrShowFeeds(doc
, hide
) {
755 debug("hideOrShowFeeds: " + doc
+ ", " + hide
);
757 var fd
= getFeedsContext().document
;
759 var list
= fd
.getElementById("feedList");
761 if (fd
.getElementById("feedCatHolder")) {
763 var feeds
= fd
.getElementById("feedList");
764 var child
= feeds
.firstChild
;
768 if (child
.id
== "feedCatHolder") {
769 hideOrShowFeedsCategory(fd
, child
.firstChild
, hide
, child
.previousSibling
);
772 child
= child
.nextSibling
;
776 hideOrShowFeedsCategory(fd
, fd
.getElementById("feedList"), hide
);
780 function hideOrShowFeedsCategory(doc
, node
, hide
, cat_node
) {
782 // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
786 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
787 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
788 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
790 if (node
.childNodes
[i
].style
!= undefined) {
792 var has_unread
= (node
.childNodes
[i
].className
!= "feed");
794 // debug(node.childNodes[i].id + " --> " + has_unread);
796 if (hide
&& !has_unread
) {
797 node
.childNodes
[i
].style
.display
= "none";
801 node
.childNodes
[i
].style
.display
= "list-item";
805 node
.childNodes
[i
].style
.display
= "list-item";
812 if (cat_unread
== 0) {
813 if (cat_node
.style
== undefined) {
814 debug("ERROR: supplied cat_node " + cat_node
+
815 " has no styles. WTF?");
819 cat_node
.style
.display
= "none";
821 cat_node
.style
.display
= "list-item";
825 cat_node
.style
.display
= "list-item";
831 // debug("unread for category: " + cat_unread);
834 function selectTableRow(r
, do_select
) {
835 r
.className
= r
.className
.replace("Selected", "");
838 r
.className
= r
.className
+ "Selected";
842 function selectTableRowById(elem_id
, check_id
, do_select
) {
846 var row
= document
.getElementById(elem_id
);
849 selectTableRow(row
, do_select
);
852 var check
= document
.getElementById(check_id
);
855 check
.checked
= do_select
;
858 exception_error("selectTableRowById", e
);
862 function selectTableRowsByIdPrefix(content_id
, prefix
, check_prefix
, do_select
,
863 classcheck
, reset_others
) {
865 var content
= document
.getElementById(content_id
);
868 alert("[selectTableRows] Element " + content_id
+ " not found.");
872 for (i
= 0; i
< content
.rows
.length
; i
++) {
873 if (!classcheck
|| content
.rows
[i
].className
.match(classcheck
)) {
875 if (content
.rows
[i
].id
.match(prefix
)) {
876 selectTableRow(content
.rows
[i
], do_select
);
878 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
879 var check
= document
.getElementById(check_prefix
+ row_id
);
882 check
.checked
= do_select
;
884 } else if (reset_others
) {
885 selectTableRow(content
.rows
[i
], false);
887 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
888 var check
= document
.getElementById(check_prefix
+ row_id
);
891 check
.checked
= false;
895 } else if (reset_others
) {
896 selectTableRow(content
.rows
[i
], false);
898 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
899 var check
= document
.getElementById(check_prefix
+ row_id
);
902 check
.checked
= false;
909 function getSelectedTableRowIds(content_id
, prefix
) {
911 var content
= document
.getElementById(content_id
);
914 alert("[getSelectedTableRowIds] Element " + content_id
+ " not found.");
918 var sel_rows
= new Array();
920 for (i
= 0; i
< content
.rows
.length
; i
++) {
921 if (content
.rows
[i
].id
.match(prefix
) &&
922 content
.rows
[i
].className
.match("Selected")) {
924 var row_id
= content
.rows
[i
].id
.replace(prefix
+ "-", "");
925 sel_rows
.push(row_id
);
933 function toggleSelectRowById(sender
, id
) {
934 var row
= document
.getElementById(id
);
936 if (sender
.checked
) {
937 if (!row
.className
.match("Selected")) {
938 row
.className
= row
.className
+ "Selected";
941 if (row
.className
.match("Selected")) {
942 row
.className
= row
.className
.replace("Selected", "");
947 function toggleSelectListRow(sender
) {
948 var parent_row
= sender
.parentNode
;
950 if (sender
.checked
) {
951 if (!parent_row
.className
.match("Selected")) {
952 parent_row
.className
= parent_row
.className
+ "Selected";
955 if (parent_row
.className
.match("Selected")) {
956 parent_row
.className
= parent_row
.className
.replace("Selected", "");
962 function toggleSelectRow(sender
) {
963 var parent_row
= sender
.parentNode
.parentNode
;
965 if (sender
.checked
) {
966 if (!parent_row
.className
.match("Selected")) {
967 parent_row
.className
= parent_row
.className
+ "Selected";
970 if (parent_row
.className
.match("Selected")) {
971 parent_row
.className
= parent_row
.className
.replace("Selected", "");
976 function openExternalUrl(url
) {
977 var w
= window
.open(url
);
980 function getRelativeFeedId(list
, id
, direction
, unread_only
) {
982 if (direction
== "next") {
983 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
984 var child
= list
.childNodes
[i
];
985 if (child
.id
&& child
.id
== "feedCatHolder") {
986 if (child
.lastChild
) {
987 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
990 } else if (child
.id
&& child
.id
.match("FEEDR-")) {
991 return child
.id
.replace('FEEDR-', '');
996 // FIXME select last feed doesn't work when only unread feeds are visible
998 if (direction
== "prev") {
999 for (i
= list
.childNodes
.length
-1; i
>= 0; i
--) {
1000 var child
= list
.childNodes
[i
];
1001 if (child
.id
== "feedCatHolder") {
1002 if (child
.firstChild
) {
1003 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
1006 } else if (child
.id
.match("FEEDR-")) {
1008 if (getInitParam("hide_read_feeds") == 1) {
1009 if (child
.className
!= "feed") {
1010 alert(child
.className
);
1011 return child
.id
.replace('FEEDR-', '');
1014 return child
.id
.replace('FEEDR-', '');
1021 var feed
= list
.ownerDocument
.getElementById("FEEDR-" + getActiveFeedId());
1023 if (getInitParam("hide_read_feeds") == 1) {
1027 if (direction
== "next") {
1033 if (e
.nextSibling
) {
1037 } else if (e
.parentNode
.parentNode
.nextSibling
) {
1039 var this_cat
= e
.parentNode
.parentNode
;
1043 if (this_cat
&& this_cat
.nextSibling
) {
1044 while (!e
&& this_cat
.nextSibling
) {
1045 this_cat
= this_cat
.nextSibling
;
1046 if (this_cat
.id
== "feedCatHolder") {
1047 e
= this_cat
.firstChild
.firstChild
;
1057 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1058 e
.className
!= "error")) {
1059 return e
.id
.replace("FEEDR-", "");
1064 } else if (direction
== "prev") {
1070 if (e
.previousSibling
) {
1072 e
= e
.previousSibling
;
1074 } else if (e
.parentNode
.parentNode
.previousSibling
) {
1076 var this_cat
= e
.parentNode
.parentNode
;
1080 if (this_cat
&& this_cat
.previousSibling
) {
1081 while (!e
&& this_cat
.previousSibling
) {
1082 this_cat
= this_cat
.previousSibling
;
1083 if (this_cat
.id
== "feedCatHolder") {
1084 e
= this_cat
.firstChild
.lastChild
;
1094 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1095 e
.className
!= "error")) {
1096 return e
.id
.replace("FEEDR-", "");
1104 function showBlockElement(id
) {
1105 var elem
= document
.getElementById(id
);
1108 elem
.style
.display
= "block";
1110 alert("[showBlockElement] can't find element with id " + id
);
1114 function hideParentElement(e
) {
1115 e
.parentNode
.style
.display
= "none";
1118 function dropboxSelect(e
, v
) {
1119 for (i
= 0; i
< e
.length
; i
++) {
1120 if (e
[i
].value
== v
) {
1121 e
.selectedIndex
= i
;
1127 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1128 // bugfixed just a little bit :-)
1129 function getURLParam(strParamName
){
1131 var strHref
= window
.location
.href
;
1133 if (strHref
.indexOf("#") == strHref
.length
-1) {
1134 strHref
= strHref
.substring(0, strHref
.length
-1);
1137 if ( strHref
.indexOf("?") > -1 ){
1138 var strQueryString
= strHref
.substr(strHref
.indexOf("?"));
1139 var aQueryString
= strQueryString
.split("&");
1140 for ( var iParam
= 0; iParam
< aQueryString
.length
; iParam
++ ){
1141 if (aQueryString
[iParam
].indexOf(strParamName
+ "=") > -1 ){
1142 var aParam
= aQueryString
[iParam
].split("=");
1143 strReturn
= aParam
[1];
1151 function leading_zero(p
) {
1153 if (s
.length
== 1) s
= "0" + s
;
1157 function closeInfoBox(cleanup
) {
1158 var box
= document
.getElementById('infoBox');
1159 var shadow
= document
.getElementById('infoBoxShadow');
1162 shadow
.style
.display
= "none";
1164 box
.style
.display
= "none";
1167 if (cleanup
) box
.innerHTML
= " ";
1175 function displayDlg(id
, param
) {
1177 if (!xmlhttp_ready(xmlhttp
)) {
1178 printLockingError();
1184 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
1185 param_escape(id
) + "¶m=" + param_escape(param
), true);
1186 xmlhttp
.onreadystatechange
=infobox_callback
;
1194 function infobox_submit_callback() {
1195 if (xmlhttp
.readyState
== 4) {
1198 // called from prefs, reload tab
1200 selectTab(active_tab
, false);
1203 notify(xmlhttp
.responseText
);
1208 function infobox_callback() {
1209 if (xmlhttp
.readyState
== 4) {
1210 var box
= document
.getElementById('infoBox');
1211 var shadow
= document
.getElementById('infoBoxShadow');
1213 box
.innerHTML
=xmlhttp
.responseText
;
1215 shadow
.style
.display
= "block";
1217 box
.style
.display
= "block";
1223 function qaddFilter() {
1225 if (!xmlhttp_ready(xmlhttp
)) {
1226 printLockingError();
1230 var query
= Form
.serialize("filter_add_form");
1232 xmlhttp
.open("GET", "backend.php?" + query
, true);
1233 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
1239 function toggleSubmitNotEmpty(e
, submit_id
) {
1241 document
.getElementById(submit_id
).disabled
= (e
.value
== "")
1243 exception_error("toggleSubmitNotEmpty", e
);
1247 function isValidURL(s
) {
1248 return s
.match("http://") != null || s
.match("https://") != null;
1253 if (!xmlhttp_ready(xmlhttp
)) {
1254 printLockingError();
1258 notify("Adding feed...");
1262 var feeds_doc
= getFeedsContext().document
;
1264 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
1266 var query
= Form
.serialize("feed_add_form");
1268 xmlhttp
.open("GET", "backend.php?" + query
, true);
1269 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
1273 function filterCR(e
)
1278 key
= window
.event
.keyCode
; //IE
1280 key
= e
.which
; //firefox
1288 function getMainContext() {
1292 function getFeedsContext() {
1296 function getContentContext() {
1301 function getHeadlinesContext() {
1305 var debug_last_class
= "even";
1307 function debug(msg
) {
1308 var ctx
= getMainContext();
1310 if (ctx
.debug_last_class
== "even") {
1311 ctx
.debug_last_class
= "odd";
1313 ctx
.debug_last_class
= "even";
1316 var c
= ctx
.document
.getElementById('debug_output');
1317 if (c
&& c
.style
.display
== "block") {
1318 while (c
.lastChild
!= 'undefined' && c
.childNodes
.length
> 100) {
1319 c
.removeChild(c
.lastChild
);
1323 var ts
= leading_zero(d
.getHours()) + ":" + leading_zero(d
.getMinutes()) +
1324 ":" + leading_zero(d
.getSeconds());
1325 c
.innerHTML
= "<li class=\"" + ctx
.debug_last_class
+ "\"><span class=\"debugTS\">[" + ts
+ "]</span> " +
1326 msg
+ "</li>" + c
.innerHTML
;
1330 function getInitParam(key
) {
1331 return getMainContext().init_params
[key
];
1334 function storeInitParam(key
, value
, is_client
) {
1337 if (getMainContext().init_params
[key
] != value
) {
1338 debug("storeInitParam: " + key
+ " => " + value
);
1339 //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" +
1340 // param_escape(key) + "&value=" + param_escape(value));
1341 var f
= getMainContext().document
.getElementById("backReqBox");
1342 f
.src
= "backend.php?op=rpc&subop=storeParam&key=" +
1343 param_escape(key
) + "&value=" + param_escape(value
);
1346 getMainContext().init_params
[key
] = value
;
1348 exception_error("storeInitParam", e
);
1353 function storeInitParams(params, is_client) {
1358 if (getMainContext().init_params[k] != params[k]) {
1359 s += k + "=" + params[k] + ";";
1360 getMainContext().init_params[k] = params[k];
1364 debug("storeInitParams: " + s);
1367 new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
1370 exception_error("storeInitParams", e);
1374 function fatalError(code
, message
) {
1376 var fe
= document
.getElementById("fatal_error");
1377 var fc
= document
.getElementById("fatal_error_msg");
1379 fc
.innerHTML
= "Code " + code
+ ": " + message
;
1381 fe
.style
.display
= "block";
1384 exception_error("fatalError", e
);
1388 function getFeedName(id
, is_cat
) {
1389 var d
= getFeedsContext().document
;
1394 e
= d
.getElementById("FCATN-" + id
);
1396 e
= d
.getElementById("FEEDN-" + id
);
1399 return e
.innerHTML
.stripTags();
1405 function viewContentUrl(url
) {
1406 getContentContext().location
= url
;