]>
git.wh0rd.org - tt-rss.git/blob - functions.js
1 var hotkeys_enabled
= true;
3 var xmlhttp_rpc
= Ajax
.getTransport();
5 function browser_has_opacity() {
6 return navigator
.userAgent
.match("Gecko") != null ||
7 navigator
.userAgent
.match("Opera") != null;
11 return navigator
.userAgent
.match("Opera");
14 function exception_error(location
, e
, silent
) {
18 var base_fname
= e
.fileName
.substring(e
.fileName
.lastIndexOf("/") + 1);
20 msg
= "Exception: " + e
.name
+ ", " + e
.message
+
21 "\nFunction: " + location
+ "()" +
22 "\nLocation: " + base_fname
+ ":" + e
.lineNumber
;
25 msg
= "Exception: " + e
+ "\nFunction: " + location
+ "()";
28 debug("<b>EXCEPTION: " + msg
+ "</b>");
35 function disableHotkeys() {
36 hotkeys_enabled
= false;
39 function enableHotkeys() {
40 hotkeys_enabled
= true;
43 function xmlhttp_ready(obj
) {
44 return obj
.readyState
== 4 || obj
.readyState
== 0 || !obj
.readyState
;
47 function notify_callback() {
48 var container
= document
.getElementById('notify');
49 if (xmlhttp
.readyState
== 4) {
50 container
.innerHTML
=xmlhttp
.responseText
;
54 function rpc_notify_callback() {
55 var container
= document
.getElementById('notify');
56 if (xmlhttp_rpc
.readyState
== 4) {
57 container
.innerHTML
=xmlhttp_rpc
.responseText
;
61 function param_escape(arg
) {
62 if (typeof encodeURIComponent
!= 'undefined')
63 return encodeURIComponent(arg
);
68 function param_unescape(arg
) {
69 if (typeof decodeURIComponent
!= 'undefined')
70 return decodeURIComponent(arg
);
77 then
=new Date().getTime();
79 while((now
-then
)<gap
) {
80 now
=new Date().getTime();
84 var notify_hide_timerid
= false;
85 var notify_last_doc
= false;
87 var notify_effect
= false;
89 function hide_notify() {
90 if (notify_last_doc
) {
91 var n
= notify_last_doc
.getElementById("notify");
92 n
.style
.display
= "none";
94 /* if (browser_has_opacity()) {
95 if (notify_opacity >= 0) {
96 notify_opacity = notify_opacity - 0.1;
97 n.style.opacity = notify_opacity;
98 notify_hide_timerid = window.setTimeout("hide_notify()", 20);
100 n.style.display = "none";
104 n.style.display = "none";
109 function notify_real(msg
, doc
, no_hide
, is_err
) {
111 var n
= doc
.getElementById("notify");
112 var nb
= doc
.getElementById("notify_body");
114 if (!n
|| !nb
) return;
116 if (notify_hide_timerid
) {
117 window
.clearTimeout(notify_hide_timerid
);
120 notify_last_doc
= doc
;
124 if (n
.style
.display
== "block") {
125 notify_hide_timerid
= window
.setTimeout("hide_notify()", 0);
129 n
.style
.display
= "block";
133 n
.className
= "notifyError";
134 // n.style.backgroundColor = "#ffcccc";
135 // n.style.color = "black";
136 // n.style.borderColor = "#ff0000";
138 n
.className
= "notify";
139 // n.style.backgroundColor = "#fff7d5";
140 // n.style.borderColor = "#d7c47a";
141 // n.style.color = "black";
144 // msg = "<img src='images/live_com_loading.gif'> " + msg;
149 notify_hide_timerid
= window
.setTimeout("hide_notify()", 3000);
153 function p_notify(msg
, no_hide
, is_err
) {
154 notify_real(msg
, document
, no_hide
, is_err
);
157 function notify(msg
, no_hide
, is_err
) {
158 notify_real(msg
, document
, no_hide
, is_err
);
161 function printLockingError() {
162 notify("Please wait until operation finishes");}
164 function hotkey_handler(e
) {
170 if (!hotkeys_enabled
) return;
173 keycode
= window
.event
.keyCode
;
178 if (keycode
== 82) { // r
179 return scheduleFeedUpdate(true);
182 if (keycode
== 83) { // r
183 return displayDlg("search", getActiveFeedId());
186 if (keycode
== 85) { // u
187 if (getActiveFeedId()) {
188 return viewfeed(getActiveFeedId(), "ForceUpdate");
192 if (keycode
== 65) { // a
193 return toggleDispRead();
196 var feedlist
= document
.getElementById('feedList');
198 if (keycode
== 74) { // j
199 var feed
= getActiveFeedId();
200 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'prev');
201 if (new_feed
) viewfeed(new_feed
, '');
204 if (keycode
== 75) { // k
205 var feed
= getActiveFeedId();
206 var new_feed
= getRelativeFeedId(feedlist
, feed
, 'next');
207 if (new_feed
) viewfeed(new_feed
, '');
210 if (keycode
== 78 || keycode
== 40) { // n, down
211 if (typeof moveToPost
!= 'undefined') {
212 return moveToPost('next');
216 if (keycode
== 80 || keycode
== 38) { // p, up
217 if (typeof moveToPost
!= 'undefined') {
218 return moveToPost('prev');
222 if (typeof localHotkeyHandler
!= 'undefined') {
224 localHotkeyHandler(keycode
);
226 exception_error("hotkey_handler, local:", e
);
230 exception_error("hotkey_handler", e
);
234 function cleanSelectedList(element
) {
235 var content
= document
.getElementById(element
);
237 if (!document
.getElementById("feedCatHolder")) {
238 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
239 var child
= content
.childNodes
[i
];
241 child
.className
= child
.className
.replace("Selected", "");
247 for (i
= 0; i
< content
.childNodes
.length
; i
++) {
248 var child
= content
.childNodes
[i
];
249 if (child
.id
== "feedCatHolder") {
251 var fcat
= child
.lastChild
;
252 for (j
= 0; j
< fcat
.childNodes
.length
; j
++) {
253 var feed
= fcat
.childNodes
[j
];
254 feed
.className
= feed
.className
.replace("Selected", "");
262 function cleanSelected(element
) {
263 var content
= document
.getElementById(element
);
265 for (i
= 0; i
< content
.rows
.length
; i
++) {
266 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
270 function getVisibleUnreadHeadlines() {
271 var content
= document
.getElementById("headlinesList");
273 var rows
= new Array();
275 for (i
= 0; i
< content
.rows
.length
; i
++) {
276 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
277 if (row_id
.length
> 0 && content
.rows
[i
].className
.match("Unread")) {
284 function getVisibleHeadlineIds() {
286 var content
= document
.getElementById("headlinesList");
288 var rows
= new Array();
290 for (i
= 0; i
< content
.rows
.length
; i
++) {
291 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
292 if (row_id
.length
> 0) {
299 function getFirstVisibleHeadlineId() {
300 var rows
= getVisibleHeadlineIds();
304 function getLastVisibleHeadlineId() {
305 var rows
= getVisibleHeadlineIds();
306 return rows
[rows
.length
-1];
309 function markHeadline(id
) {
310 var row
= document
.getElementById("RROW-" + id
);
312 var is_active
= false;
314 if (row
.className
.match("Active")) {
317 row
.className
= row
.className
.replace("Selected", "");
318 row
.className
= row
.className
.replace("Active", "");
319 row
.className
= row
.className
.replace("Insensitive", "");
322 row
.className
= row
.className
= "Active";
325 var check
= document
.getElementById("RCHK-" + id
);
328 check
.checked
= true;
331 row
.className
= row
.className
+ "Selected";
336 function getFeedIds() {
337 var content
= document
.getElementById("feedsList");
339 var rows
= new Array();
341 for (i
= 0; i
< content
.rows
.length
; i
++) {
342 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
351 function setCookie(name
, value
, lifetime
, path
, domain
, secure
) {
357 d
.setTime(lifetime
* 1000);
360 int_setCookie(name
, value
, d
, path
, domain
, secure
);
364 function int_setCookie(name
, value
, expires
, path
, domain
, secure
) {
365 document
.cookie
= name
+ "=" + escape(value
) +
366 ((expires
) ? "; expires=" + expires
.toGMTString() : "") +
367 ((path
) ? "; path=" + path
: "") +
368 ((domain
) ? "; domain=" + domain
: "") +
369 ((secure
) ? "; secure" : "");
372 function delCookie(name
, path
, domain
) {
373 if (getCookie(name
)) {
374 document
.cookie
= name
+ "=" +
375 ((path
) ? ";path=" + path
: "") +
376 ((domain
) ? ";domain=" + domain
: "" ) +
377 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
382 function getCookie(name
) {
384 var dc
= document
.cookie
;
385 var prefix
= name
+ "=";
386 var begin
= dc
.indexOf("; " + prefix
);
388 begin
= dc
.indexOf(prefix
);
389 if (begin
!= 0) return null;
394 var end
= document
.cookie
.indexOf(";", begin
);
398 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
401 function disableContainerChildren(id
, disable
, doc
) {
403 if (!doc
) doc
= document
;
405 var container
= doc
.getElementById(id
);
408 //alert("disableContainerChildren: element " + id + " not found");
412 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
413 var child
= container
.childNodes
[i
];
416 child
.disabled
= disable
;
422 if (child
.className
&& child
.className
.match("button")) {
423 child
.className
= "disabledButton";
426 if (child
.className
&& child
.className
.match("disabledButton")) {
427 child
.className
= "button";
434 function gotoPreferences() {
435 document
.location
.href
= "prefs.php";
438 function gotoMain() {
439 document
.location
.href
= "tt-rss.php";
442 function gotoExportOpml() {
443 document
.location
.href
= "opml.php?op=Export";
446 function getActiveFeedId() {
447 // return getCookie("ttrss_vf_actfeed");
449 debug("gAFID: " + active_feed_id
);
450 return active_feed_id
;
452 exception_error("getActiveFeedId", e
);
456 function activeFeedIsCat() {
457 return active_feed_is_cat
;
460 function setActiveFeedId(id
) {
461 // return setCookie("ttrss_vf_actfeed", id);
463 debug("sAFID(" + id
+ ")");
466 exception_error("setActiveFeedId", e
);
470 function parse_counters(reply
, scheduled_call
) {
475 if (reply
.firstChild
&& reply
.firstChild
.firstChild
) {
476 debug("<b>wrong element passed to parse_counters, adjusting.</b>");
477 reply
= reply
.firstChild
;
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") {
500 if (id
== "subscribed-feeds") {
505 if (t
== "category") {
506 var catctr
= document
.getElementById("FCATCTR-" + id
);
508 catctr
.innerHTML
= "(" + ctr
+ " unread)";
513 var feedctr
= document
.getElementById("FEEDCTR-" + id
);
514 var feedu
= document
.getElementById("FEEDU-" + id
);
515 var feedr
= document
.getElementById("FEEDR-" + id
);
516 var feed_img
= document
.getElementById("FIMG-" + id
);
517 var feedlink
= document
.getElementById("FEEDL-" + id
);
518 var feedupd
= document
.getElementById("FLUPD-" + id
);
520 if (updated
&& feedlink
) {
522 feedlink
.title
= "Error: " + error
+ " (" + updated
+ ")";
524 feedlink
.title
= "Updated: " + updated
;
528 if (updated
&& feedupd
) {
530 feedupd
.innerHTML
= updated
+ " (Error)";
532 feedupd
.innerHTML
= updated
;
536 if (feedctr
&& feedu
&& feedr
) {
538 if (feedu
.innerHTML
!= ctr
&& id
== getActiveFeedId() && scheduled_call
) {
542 feedu
.innerHTML
= ctr
;
545 feedr
.className
= feedr
.className
.replace("feed", "error");
547 feedr
.className
= feedr
.className
.replace("error", "feed");
551 feedctr
.className
= "odd";
552 if (!feedr
.className
.match("Unread")) {
553 var is_selected
= feedr
.className
.match("Selected");
555 feedr
.className
= feedr
.className
.replace("Selected", "");
556 feedr
.className
= feedr
.className
.replace("Unread", "");
558 feedr
.className
= feedr
.className
+ "Unread";
561 feedr
.className
= feedr
.className
+ "Selected";
566 feedctr
.className
= "invisible";
567 feedr
.className
= feedr
.className
.replace("Unread", "");
572 hideOrShowFeeds(document
, getInitParam("hide_read_feeds") == 1);
574 var feeds_stored
= number_of_feeds
;
576 debug("Feed counters, C: " + feeds_found
+ ", S:" + feeds_stored
);
578 if (feeds_stored
!= feeds_found
) {
579 number_of_feeds
= feeds_found
;
581 if (feeds_stored
!= 0) {
582 debug("Subscribed feed number changed, refreshing feedlist");
583 setTimeout('updateFeedList(false, false)', 50);
588 exception_error("parse_counters", e
);
592 function all_counters_callback() {
593 if (xmlhttp_rpc
.readyState
== 4) {
595 if (!xmlhttp_rpc
.responseXML
|| !xmlhttp_rpc
.responseXML
.firstChild
) {
596 debug("[all_counters_callback] backend did not return valid XML");
600 debug("in all_counters_callback : " + xmlhttp_rpc
.responseXML
);
602 var reply
= xmlhttp_rpc
.responseXML
.firstChild
;
604 var counters
= reply
.firstChild
;
606 parse_counters(counters
);
608 var runtime
= counters
.nextSibling
;
611 parse_runtime_info(runtime
);
614 if (getInitParam("feeds_sort_by_unread") == 1) {
618 hideOrShowFeeds(document
, getInitParam("hide_read_feeds") == 1);
621 exception_error("all_counters_callback", e
);
626 function get_feed_entry_unread(doc
, elem
) {
628 var id
= elem
.id
.replace("FEEDR-", "");
635 return parseInt(doc
.getElementById("FEEDU-" + id
).innerHTML
);
641 function resort_category(doc
, node
) {
642 debug("resort_category: " + node
);
644 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
645 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
646 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
648 if (get_feed_entry_unread(doc
, node
.childNodes
[i
]) < 0) {
652 for (j
= i
+1; j
< node
.childNodes
.length
; j
++) {
653 if (node
.childNodes
[j
].nodeName
!= "LI") { continue; }
655 var tmp_val
= get_feed_entry_unread(doc
, node
.childNodes
[i
]);
656 var cur_val
= get_feed_entry_unread(doc
, node
.childNodes
[j
]);
658 if (cur_val
> tmp_val
) {
659 tempnode_i
= node
.childNodes
[i
].cloneNode(true);
660 tempnode_j
= node
.childNodes
[j
].cloneNode(true);
661 node
.replaceChild(tempnode_i
, node
.childNodes
[j
]);
662 node
.replaceChild(tempnode_j
, node
.childNodes
[i
]);
671 function resort_feedlist() {
672 debug("resort_feedlist");
676 if (fd
.getElementById("feedCatHolder")) {
678 var feeds
= fd
.getElementById("feedList");
679 var child
= feeds
.firstChild
;
683 if (child
.id
== "feedCatHolder") {
684 resort_category(fd
, child
.firstChild
);
687 child
= child
.nextSibling
;
691 resort_category(fd
, fd
.getElementById("feedList"));
695 function update_all_counters(feed
) {
696 if (xmlhttp_ready(xmlhttp_rpc
)) {
697 var query
= "backend.php?op=rpc&subop=getAllCounters";
700 query
= query
+ "&aid=" + feed
;
703 xmlhttp_rpc
.open("GET", query
, true);
704 xmlhttp_rpc
.onreadystatechange
=all_counters_callback
;
705 xmlhttp_rpc
.send(null);
709 function popupHelp(tid
) {
710 var w
= window
.open("backend.php?op=help&tid=" + tid
,
712 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
715 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
716 * * @author Sundar Dorai-Raj
717 * * Email: sdoraira@vt.edu
718 * * This program is free software; you can redistribute it and/or
719 * * modify it under the terms of the GNU General Public License
720 * * as published by the Free Software Foundation; either version 2
721 * * of the License, or (at your option) any later version,
722 * * provided that any use properly credits the author.
723 * * This program is distributed in the hope that it will be useful,
724 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
725 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
726 * * GNU General Public License for more details at http://www.gnu.org * * */
728 var numbers
=".0123456789";
729 function isNumeric(x
) {
730 // is x a String or a character?
732 // remove negative sign
734 for(j
=0;j
<x
.length
;j
++) {
735 // call isNumeric recursively for each character
736 number
=isNumeric(x
.substring(j
,j
+1));
737 if(!number
) return number
;
742 // if x is number return true
743 if(numbers
.indexOf(x
)>=0) return true;
749 function hideOrShowFeeds(doc
, hide
) {
751 debug("hideOrShowFeeds: " + doc
+ ", " + hide
);
755 var list
= fd
.getElementById("feedList");
757 if (fd
.getElementById("feedCatHolder")) {
759 var feeds
= fd
.getElementById("feedList");
760 var child
= feeds
.firstChild
;
764 if (child
.id
== "feedCatHolder") {
765 hideOrShowFeedsCategory(fd
, child
.firstChild
, hide
, child
.previousSibling
);
768 child
= child
.nextSibling
;
772 hideOrShowFeedsCategory(fd
, fd
.getElementById("feedList"), hide
);
776 function hideOrShowFeedsCategory(doc
, node
, hide
, cat_node
) {
778 // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
782 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
783 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
784 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
786 if (node
.childNodes
[i
].style
!= undefined) {
788 var has_unread
= (node
.childNodes
[i
].className
!= "feed");
790 // debug(node.childNodes[i].id + " --> " + has_unread);
792 if (hide
&& !has_unread
) {
793 node
.childNodes
[i
].style
.display
= "none";
797 node
.childNodes
[i
].style
.display
= "list-item";
801 node
.childNodes
[i
].style
.display
= "list-item";
808 if (cat_unread
== 0) {
809 if (cat_node
.style
== undefined) {
810 debug("ERROR: supplied cat_node " + cat_node
+
811 " has no styles. WTF?");
815 cat_node
.style
.display
= "none";
817 cat_node
.style
.display
= "list-item";
821 cat_node
.style
.display
= "list-item";
827 // debug("unread for category: " + cat_unread);
830 function selectTableRow(r
, do_select
) {
831 r
.className
= r
.className
.replace("Selected", "");
834 r
.className
= r
.className
+ "Selected";
838 function selectTableRowById(elem_id
, check_id
, do_select
) {
842 var row
= document
.getElementById(elem_id
);
845 selectTableRow(row
, do_select
);
848 var check
= document
.getElementById(check_id
);
851 check
.checked
= do_select
;
854 exception_error("selectTableRowById", e
);
858 function selectTableRowsByIdPrefix(content_id
, prefix
, check_prefix
, do_select
,
859 classcheck
, reset_others
) {
861 var content
= document
.getElementById(content_id
);
864 alert("[selectTableRows] Element " + content_id
+ " not found.");
868 for (i
= 0; i
< content
.rows
.length
; i
++) {
869 if (!classcheck
|| content
.rows
[i
].className
.match(classcheck
)) {
871 if (content
.rows
[i
].id
.match(prefix
)) {
872 selectTableRow(content
.rows
[i
], do_select
);
874 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
875 var check
= document
.getElementById(check_prefix
+ row_id
);
878 check
.checked
= do_select
;
880 } else if (reset_others
) {
881 selectTableRow(content
.rows
[i
], false);
883 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
884 var check
= document
.getElementById(check_prefix
+ row_id
);
887 check
.checked
= false;
891 } else if (reset_others
) {
892 selectTableRow(content
.rows
[i
], false);
894 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
895 var check
= document
.getElementById(check_prefix
+ row_id
);
898 check
.checked
= false;
905 function getSelectedTableRowIds(content_id
, prefix
) {
907 var content
= document
.getElementById(content_id
);
910 alert("[getSelectedTableRowIds] Element " + content_id
+ " not found.");
914 var sel_rows
= new Array();
916 for (i
= 0; i
< content
.rows
.length
; i
++) {
917 if (content
.rows
[i
].id
.match(prefix
) &&
918 content
.rows
[i
].className
.match("Selected")) {
920 var row_id
= content
.rows
[i
].id
.replace(prefix
+ "-", "");
921 sel_rows
.push(row_id
);
929 function toggleSelectRowById(sender
, id
) {
930 var row
= document
.getElementById(id
);
932 if (sender
.checked
) {
933 if (!row
.className
.match("Selected")) {
934 row
.className
= row
.className
+ "Selected";
937 if (row
.className
.match("Selected")) {
938 row
.className
= row
.className
.replace("Selected", "");
943 function toggleSelectListRow(sender
) {
944 var parent_row
= sender
.parentNode
;
946 if (sender
.checked
) {
947 if (!parent_row
.className
.match("Selected")) {
948 parent_row
.className
= parent_row
.className
+ "Selected";
951 if (parent_row
.className
.match("Selected")) {
952 parent_row
.className
= parent_row
.className
.replace("Selected", "");
958 function toggleSelectRow(sender
) {
959 var parent_row
= sender
.parentNode
.parentNode
;
961 if (sender
.checked
) {
962 if (!parent_row
.className
.match("Selected")) {
963 parent_row
.className
= parent_row
.className
+ "Selected";
966 if (parent_row
.className
.match("Selected")) {
967 parent_row
.className
= parent_row
.className
.replace("Selected", "");
972 function openExternalUrl(url
) {
973 var w
= window
.open(url
);
976 function getRelativeFeedId(list
, id
, direction
, unread_only
) {
978 if (direction
== "next") {
979 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
980 var child
= list
.childNodes
[i
];
981 if (child
.id
&& child
.id
== "feedCatHolder") {
982 if (child
.lastChild
) {
983 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
, unread_only
);
986 } else if (child
.id
&& child
.id
.match("FEEDR-")) {
987 return child
.id
.replace('FEEDR-', '');
992 // FIXME select last feed doesn't work when only unread feeds are visible
994 if (direction
== "prev") {
995 for (i
= list
.childNodes
.length
-1; i
>= 0; i
--) {
996 var child
= list
.childNodes
[i
];
997 if (child
.id
== "feedCatHolder") {
998 if (child
.firstChild
) {
999 var cr
= getRelativeFeedId(child
.firstChild
, id
, direction
);
1002 } else if (child
.id
.match("FEEDR-")) {
1004 if (getInitParam("hide_read_feeds") == 1) {
1005 if (child
.className
!= "feed") {
1006 alert(child
.className
);
1007 return child
.id
.replace('FEEDR-', '');
1010 return child
.id
.replace('FEEDR-', '');
1017 var feed
= list
.ownerDocument
.getElementById("FEEDR-" + id
);
1019 if (getInitParam("hide_read_feeds") == 1) {
1023 if (direction
== "next") {
1029 if (e
.nextSibling
) {
1033 } else if (e
.parentNode
.parentNode
.nextSibling
) {
1035 var this_cat
= e
.parentNode
.parentNode
;
1039 if (this_cat
&& this_cat
.nextSibling
) {
1040 while (!e
&& this_cat
.nextSibling
) {
1041 this_cat
= this_cat
.nextSibling
;
1042 if (this_cat
.id
== "feedCatHolder") {
1043 e
= this_cat
.firstChild
.firstChild
;
1053 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1054 e
.className
.match("feed"))) {
1055 return e
.id
.replace("FEEDR-", "");
1060 } else if (direction
== "prev") {
1066 if (e
.previousSibling
) {
1068 e
= e
.previousSibling
;
1070 } else if (e
.parentNode
.parentNode
.previousSibling
) {
1072 var this_cat
= e
.parentNode
.parentNode
;
1076 if (this_cat
&& this_cat
.previousSibling
) {
1077 while (!e
&& this_cat
.previousSibling
) {
1078 this_cat
= this_cat
.previousSibling
;
1079 if (this_cat
.id
== "feedCatHolder") {
1080 e
= this_cat
.firstChild
.lastChild
;
1090 if (!unread_only
|| (unread_only
&& e
.className
!= "feed" &&
1091 e
.className
.match("feed"))) {
1092 return e
.id
.replace("FEEDR-", "");
1100 function showBlockElement(id
) {
1101 var elem
= document
.getElementById(id
);
1104 elem
.style
.display
= "block";
1106 alert("[showBlockElement] can't find element with id " + id
);
1110 function hideParentElement(e
) {
1111 e
.parentNode
.style
.display
= "none";
1114 function dropboxSelect(e
, v
) {
1115 for (i
= 0; i
< e
.length
; i
++) {
1116 if (e
[i
].value
== v
) {
1117 e
.selectedIndex
= i
;
1123 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1124 // bugfixed just a little bit :-)
1125 function getURLParam(strParamName
){
1127 var strHref
= window
.location
.href
;
1129 if (strHref
.indexOf("#") == strHref
.length
-1) {
1130 strHref
= strHref
.substring(0, strHref
.length
-1);
1133 if ( strHref
.indexOf("?") > -1 ){
1134 var strQueryString
= strHref
.substr(strHref
.indexOf("?"));
1135 var aQueryString
= strQueryString
.split("&");
1136 for ( var iParam
= 0; iParam
< aQueryString
.length
; iParam
++ ){
1137 if (aQueryString
[iParam
].indexOf(strParamName
+ "=") > -1 ){
1138 var aParam
= aQueryString
[iParam
].split("=");
1139 strReturn
= aParam
[1];
1147 function leading_zero(p
) {
1149 if (s
.length
== 1) s
= "0" + s
;
1153 function closeInfoBox(cleanup
) {
1154 var box
= document
.getElementById('infoBox');
1155 var shadow
= document
.getElementById('infoBoxShadow');
1158 shadow
.style
.display
= "none";
1160 box
.style
.display
= "none";
1163 if (cleanup
) box
.innerHTML
= " ";
1171 function displayDlg(id
, param
) {
1173 if (!xmlhttp_ready(xmlhttp
)) {
1174 printLockingError();
1180 xmlhttp
.open("GET", "backend.php?op=dlg&id=" +
1181 param_escape(id
) + "¶m=" + param_escape(param
), true);
1182 xmlhttp
.onreadystatechange
=infobox_callback
;
1190 function infobox_submit_callback() {
1191 if (xmlhttp
.readyState
== 4) {
1195 // called from prefs, reload tab
1197 selectTab(active_tab
, false);
1201 notify(xmlhttp
.responseText
);
1206 function infobox_callback() {
1207 if (xmlhttp
.readyState
== 4) {
1208 var box
= document
.getElementById('infoBox');
1209 var shadow
= document
.getElementById('infoBoxShadow');
1211 box
.innerHTML
=xmlhttp
.responseText
;
1213 shadow
.style
.display
= "block";
1215 box
.style
.display
= "block";
1222 function qaddFilter() {
1224 if (!xmlhttp_ready(xmlhttp
)) {
1225 printLockingError();
1229 var form
= document
.forms
['filter_add_form'];
1230 var reg_exp
= form
.reg_exp
.value
;
1232 if (reg_exp
== "") {
1233 alert("Can't add filter: nothing to match on.");
1237 var query
= Form
.serialize("filter_add_form");
1239 xmlhttp
.open("GET", "backend.php?" + query
, true);
1240 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
1246 function toggleSubmitNotEmpty(e
, submit_id
) {
1248 document
.getElementById(submit_id
).disabled
= (e
.value
== "")
1250 exception_error("toggleSubmitNotEmpty", e
);
1254 function isValidURL(s
) {
1255 return s
.match("http://") != null || s
.match("https://") != null;
1260 if (!xmlhttp_ready(xmlhttp
)) {
1261 printLockingError();
1265 var form
= document
.forms
['feed_add_form'];
1266 var feed_url
= form
.feed_url
.value
;
1268 if (feed_url
== "") {
1269 alert("Can't subscribe: no feed URL given.");
1273 notify("Adding feed...", true);
1277 var feeds_doc
= document
;
1279 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
1281 var query
= Form
.serialize("feed_add_form");
1283 xmlhttp
.open("GET", "backend.php?" + query
, true);
1284 xmlhttp
.onreadystatechange
=dlg_frefresh_callback
;
1290 function filterCR(e
, f
)
1295 key
= window
.event
.keyCode
; //IE
1297 key
= e
.which
; //firefox
1300 if (typeof f
!= 'undefined') {
1311 function getMainContext() {
1315 function getFeedsContext() {
1319 function getContentContext() {
1323 function getHeadlinesContext() {
1327 var debug_last_class
= "even";
1329 function debug(msg
) {
1331 if (debug_last_class
== "even") {
1332 debug_last_class
= "odd";
1334 debug_last_class
= "even";
1337 var c
= document
.getElementById('debug_output');
1338 if (c
&& c
.style
.display
== "block") {
1339 while (c
.lastChild
!= 'undefined' && c
.childNodes
.length
> 100) {
1340 c
.removeChild(c
.lastChild
);
1344 var ts
= leading_zero(d
.getHours()) + ":" + leading_zero(d
.getMinutes()) +
1345 ":" + leading_zero(d
.getSeconds());
1346 c
.innerHTML
= "<li class=\"" + debug_last_class
+ "\"><span class=\"debugTS\">[" + ts
+ "]</span> " +
1347 msg
+ "</li>" + c
.innerHTML
;
1351 function getInitParam(key
) {
1352 return getMainContext().init_params
[key
];
1355 function storeInitParam(key
, value
, is_client
) {
1358 if (getMainContext().init_params
[key
] != value
) {
1359 debug("storeInitParam: " + key
+ " => " + value
);
1360 //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" +
1361 // param_escape(key) + "&value=" + param_escape(value));
1362 var f
= getMainContext().document
.getElementById("backReqBox");
1363 f
.src
= "backend.php?op=rpc&subop=storeParam&key=" +
1364 param_escape(key
) + "&value=" + param_escape(value
);
1367 getMainContext().init_params
[key
] = value
;
1369 exception_error("storeInitParam", e
);
1374 function storeInitParams(params, is_client) {
1379 if (getMainContext().init_params[k] != params[k]) {
1380 s += k + "=" + params[k] + ";";
1381 getMainContext().init_params[k] = params[k];
1385 debug("storeInitParams: " + s);
1388 new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
1391 exception_error("storeInitParams", e);
1395 function fatalError(code
, message
) {
1397 var fe
= document
.getElementById("fatal_error");
1398 var fc
= document
.getElementById("fatal_error_msg");
1400 fc
.innerHTML
= "Code " + code
+ ": " + message
;
1402 fe
.style
.display
= "block";
1405 exception_error("fatalError", e
);
1409 function getFeedName(id
, is_cat
) {
1410 var d
= getFeedsContext().document
;
1415 e
= d
.getElementById("FCATN-" + id
);
1417 e
= d
.getElementById("FEEDN-" + id
);
1420 return e
.innerHTML
.stripTags();
1426 function viewContentUrl(url
) {
1427 getContentContext().location
= url
;