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.style.backgroundColor = "#ffcccc";
134 n.style.color = "black";
135 n.style.borderColor = "#ff0000";
137 n.style.backgroundColor = "#fff7d5";
138 n.style.borderColor = "#d7c47a";
139 n.style.color = "black";
142 // msg = "<img src='images/live_com_loading.gif'> " + msg;
147 notify_hide_timerid = window.setTimeout("hide_notify()", 3000);
151 function p_notify(msg, no_hide, is_err) {
152 notify_real(msg, document, no_hide, is_err);
155 function notify(msg, no_hide, is_err) {
156 notify_real(msg, document, no_hide, is_err);
159 function printLockingError() {
160 notify("Please wait until operation finishes");}
162 function hotkey_handler(e) {
168 if (!hotkeys_enabled) return;
171 keycode = window.event.keyCode;
176 if (keycode == 82) { // r
177 return scheduleFeedUpdate(true);
180 if (keycode == 83) { // r
181 return displayDlg("search", getActiveFeedId());
184 if (keycode == 85) { // u
185 if (getActiveFeedId()) {
186 return viewfeed(getActiveFeedId(), "ForceUpdate");
190 if (keycode == 65) { // a
191 return toggleDispRead();
194 var feedlist = document.getElementById('feedList');
196 if (keycode == 74) { // j
197 var feed = getActiveFeedId();
198 var new_feed = getRelativeFeedId(feedlist, feed, 'prev');
199 if (new_feed) viewfeed(new_feed, '');
202 if (keycode == 75) { // k
203 var feed = getActiveFeedId();
204 var new_feed = getRelativeFeedId(feedlist, feed, 'next');
205 if (new_feed) viewfeed(new_feed, '');
208 if (keycode == 78 || keycode == 40) { // n, down
209 if (typeof moveToPost != 'undefined') {
210 return moveToPost('next');
214 if (keycode == 80 || keycode == 38) { // p, up
215 if (typeof moveToPost != 'undefined') {
216 return moveToPost('prev');
220 if (typeof localHotkeyHandler != 'undefined') {
222 localHotkeyHandler(keycode);
224 exception_error("hotkey_handler, local:", e);
228 exception_error("hotkey_handler", e);
232 function cleanSelectedList(element) {
233 var content = document.getElementById(element);
235 if (!document.getElementById("feedCatHolder")) {
236 for (i = 0; i < content.childNodes.length; i++) {
237 var child = content.childNodes[i];
239 child.className = child.className.replace("Selected", "");
245 for (i = 0; i < content.childNodes.length; i++) {
246 var child = content.childNodes[i];
247 if (child.id == "feedCatHolder") {
249 var fcat = child.lastChild;
250 for (j = 0; j < fcat.childNodes.length; j++) {
251 var feed = fcat.childNodes[j];
252 feed.className = feed.className.replace("Selected", "");
260 function cleanSelected(element) {
261 var content = document.getElementById(element);
263 for (i = 0; i < content.rows.length; i++) {
264 content.rows[i].className = content.rows[i].className.replace("Selected", "");
268 function getVisibleUnreadHeadlines() {
269 var content = document.getElementById("headlinesList");
271 var rows = new Array();
273 for (i = 0; i < content.rows.length; i++) {
274 var row_id = content.rows[i].id.replace("RROW-", "");
275 if (row_id.length > 0 && content.rows[i].className.match("Unread")) {
282 function getVisibleHeadlineIds() {
284 var content = document.getElementById("headlinesList");
286 var rows = new Array();
288 for (i = 0; i < content.rows.length; i++) {
289 var row_id = content.rows[i].id.replace("RROW-", "");
290 if (row_id.length > 0) {
297 function getFirstVisibleHeadlineId() {
298 var rows = getVisibleHeadlineIds();
302 function getLastVisibleHeadlineId() {
303 var rows = getVisibleHeadlineIds();
304 return rows[rows.length-1];
307 function markHeadline(id) {
308 var row = document.getElementById("RROW-" + id);
310 var is_active = false;
312 if (row.className.match("Active")) {
315 row.className = row.className.replace("Selected", "");
316 row.className = row.className.replace("Active", "");
317 row.className = row.className.replace("Insensitive", "");
320 row.className = row.className = "Active";
323 var check = document.getElementById("RCHK-" + id);
326 check.checked = true;
329 row.className = row.className + "Selected";
334 function getFeedIds() {
335 var content = document.getElementById("feedsList");
337 var rows = new Array();
339 for (i = 0; i < content.rows.length; i++) {
340 var id = content.rows[i].id.replace("FEEDR-", "");
349 function setCookie(name, value, lifetime, path, domain, secure) {
355 d.setTime(lifetime * 1000);
358 int_setCookie(name, value, d, path, domain, secure);
362 function int_setCookie(name, value, expires, path, domain, secure) {
363 document.cookie= name + "=" + escape(value) +
364 ((expires) ? "; expires=" + expires.toGMTString() : "") +
365 ((path) ? "; path=" + path : "") +
366 ((domain) ? "; domain=" + domain : "") +
367 ((secure) ? "; secure" : "");
370 function delCookie(name, path, domain) {
371 if (getCookie(name)) {
372 document.cookie = name + "=" +
373 ((path) ? ";path=" + path : "") +
374 ((domain) ? ";domain=" + domain : "" ) +
375 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
380 function getCookie(name) {
382 var dc = document.cookie;
383 var prefix = name + "=";
384 var begin = dc.indexOf("; " + prefix);
386 begin = dc.indexOf(prefix);
387 if (begin != 0) return null;
392 var end = document.cookie.indexOf(";", begin);
396 return unescape(dc.substring(begin + prefix.length, end));
399 function disableContainerChildren(id, disable, doc) {
401 if (!doc) doc = document;
403 var container = doc.getElementById(id);
406 //alert("disableContainerChildren: element " + id + " not found");
410 for (var i = 0; i < container.childNodes.length; i++) {
411 var child = container.childNodes[i];
414 child.disabled = disable;
420 if (child.className && child.className.match("button")) {
421 child.className = "disabledButton";
424 if (child.className && child.className.match("disabledButton")) {
425 child.className = "button";
432 function gotoPreferences() {
433 document.location.href = "prefs.php";
436 function gotoMain() {
437 document.location.href = "tt-rss.php";
440 function gotoExportOpml() {
441 document.location.href = "opml.php?op=Export";
444 function getActiveFeedId() {
445 // return getCookie("ttrss_vf_actfeed");
447 debug("gAFID: " + active_feed_id);
448 return active_feed_id;
450 exception_error("getActiveFeedId", e);
454 function activeFeedIsCat() {
455 return active_feed_is_cat;
458 function setActiveFeedId(id) {
459 // return setCookie("ttrss_vf_actfeed", id);
461 debug("sAFID(" + id + ")");
464 exception_error("setActiveFeedId", e);
468 function parse_counters(reply, scheduled_call) {
473 if (reply.firstChild && reply.firstChild.firstChild) {
474 debug("<b>wrong element passed to parse_counters, adjusting.</b>");
475 reply = reply.firstChild;
478 for (var l = 0; l < reply.childNodes.length; l++) {
479 if (!reply.childNodes[l] ||
480 typeof(reply.childNodes[l].getAttribute) == "undefined") {
481 // where did this come from?
485 var id = reply.childNodes[l].getAttribute("id");
486 var t = reply.childNodes[l].getAttribute("type");
487 var ctr = reply.childNodes[l].getAttribute("counter");
488 var error = reply.childNodes[l].getAttribute("error");
489 var has_img = reply.childNodes[l].getAttribute("hi");
490 var updated = reply.childNodes[l].getAttribute("updated");
492 if (id == "global-unread") {
498 if (id == "subscribed-feeds") {
503 if (t == "category") {
504 var catctr = document.getElementById("FCATCTR-" + id);
506 catctr.innerHTML = "(" + ctr + " unread)";
511 var feedctr = document.getElementById("FEEDCTR-" + id);
512 var feedu = document.getElementById("FEEDU-" + id);
513 var feedr = document.getElementById("FEEDR-" + id);
514 var feed_img = document.getElementById("FIMG-" + id);
515 var feedlink = document.getElementById("FEEDL-" + id);
516 var feedupd = document.getElementById("FLUPD-" + id);
518 if (updated && feedlink) {
520 feedlink.title = "Error: " + error + " (" + updated + ")";
522 feedlink.title = "Updated: " + updated;
526 if (updated && feedupd) {
528 feedupd.innerHTML = updated + " (Error)";
530 feedupd.innerHTML = updated;
534 if (feedctr && feedu && feedr) {
536 if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) {
540 feedu.innerHTML = ctr;
543 feedr.className = feedr.className.replace("feed", "error");
545 feedr.className = feedr.className.replace("error", "feed");
549 feedctr.className = "odd";
550 if (!feedr.className.match("Unread")) {
551 var is_selected = feedr.className.match("Selected");
553 feedr.className = feedr.className.replace("Selected", "");
554 feedr.className = feedr.className.replace("Unread", "");
556 feedr.className = feedr.className + "Unread";
559 feedr.className = feedr.className + "Selected";
564 feedctr.className = "invisible";
565 feedr.className = feedr.className.replace("Unread", "");
570 hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1);
572 var feeds_stored = number_of_feeds;
574 debug("Feed counters, C: " + feeds_found + ", S:" + feeds_stored);
576 if (feeds_stored != feeds_found) {
577 number_of_feeds = feeds_found;
579 if (feeds_stored != 0) {
580 debug("Subscribed feed number changed, refreshing feedlist");
581 setTimeout('updateFeedList(false, false)', 50);
586 exception_error("parse_counters", e);
590 function all_counters_callback() {
591 if (xmlhttp_rpc.readyState == 4) {
593 if (!xmlhttp_rpc.responseXML || !xmlhttp_rpc.responseXML.firstChild) {
594 debug("[all_counters_callback] backend did not return valid XML");
598 debug("in all_counters_callback : " + xmlhttp_rpc.responseXML);
600 var reply = xmlhttp_rpc.responseXML.firstChild;
602 var counters = reply.firstChild;
604 parse_counters(counters);
606 var runtime = counters.nextSibling;
609 parse_runtime_info(runtime);
612 if (getInitParam("feeds_sort_by_unread") == 1) {
616 hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1);
619 exception_error("all_counters_callback", e);
624 function get_feed_entry_unread(doc, elem) {
626 var id = elem.id.replace("FEEDR-", "");
633 return parseInt(doc.getElementById("FEEDU-" + id).innerHTML);
639 function resort_category(doc, node) {
640 debug("resort_category: " + node);
642 if (node.hasChildNodes() && node.firstChild.nextSibling != false) {
643 for (i = 0; i < node.childNodes.length; i++) {
644 if (node.childNodes[i].nodeName != "LI") { continue; }
646 if (get_feed_entry_unread(doc, node.childNodes[i]) < 0) {
650 for (j = i+1; j < node.childNodes.length; j++) {
651 if (node.childNodes[j].nodeName != "LI") { continue; }
653 var tmp_val = get_feed_entry_unread(doc, node.childNodes[i]);
654 var cur_val = get_feed_entry_unread(doc, node.childNodes[j]);
656 if (cur_val > tmp_val) {
657 tempnode_i = node.childNodes[i].cloneNode(true);
658 tempnode_j = node.childNodes[j].cloneNode(true);
659 node.replaceChild(tempnode_i, node.childNodes[j]);
660 node.replaceChild(tempnode_j, node.childNodes[i]);
669 function resort_feedlist() {
670 debug("resort_feedlist");
674 if (fd.getElementById("feedCatHolder")) {
676 var feeds = fd.getElementById("feedList");
677 var child = feeds.firstChild;
681 if (child.id == "feedCatHolder") {
682 resort_category(fd, child.firstChild);
685 child = child.nextSibling;
689 resort_category(fd, fd.getElementById("feedList"));
693 function update_all_counters(feed) {
694 if (xmlhttp_ready(xmlhttp_rpc)) {
695 var query = "backend.php?op=rpc&subop=getAllCounters";
698 query = query + "&aid=" + feed;
701 xmlhttp_rpc.open("GET", query, true);
702 xmlhttp_rpc.onreadystatechange=all_counters_callback;
703 xmlhttp_rpc.send(null);
707 function popupHelp(tid) {
708 var w = window.open("backend.php?op=help&tid=" + tid,
710 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
713 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
714 * * @author Sundar Dorai-Raj
715 * * Email: sdoraira@vt.edu
716 * * This program is free software; you can redistribute it and/or
717 * * modify it under the terms of the GNU General Public License
718 * * as published by the Free Software Foundation; either version 2
719 * * of the License, or (at your option) any later version,
720 * * provided that any use properly credits the author.
721 * * This program is distributed in the hope that it will be useful,
722 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
723 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
724 * * GNU General Public License for more details at http://www.gnu.org * * */
726 var numbers=".0123456789";
727 function isNumeric(x) {
728 // is x a String or a character?
730 // remove negative sign
732 for(j=0;j<x.length;j++) {
733 // call isNumeric recursively for each character
734 number=isNumeric(x.substring(j,j+1));
735 if(!number) return number;
740 // if x is number return true
741 if(numbers.indexOf(x)>=0) return true;
747 function hideOrShowFeeds(doc, hide) {
749 debug("hideOrShowFeeds: " + doc + ", " + hide);
753 var list = fd.getElementById("feedList");
755 if (fd.getElementById("feedCatHolder")) {
757 var feeds = fd.getElementById("feedList");
758 var child = feeds.firstChild;
762 if (child.id == "feedCatHolder") {
763 hideOrShowFeedsCategory(fd, child.firstChild, hide, child.previousSibling);
766 child = child.nextSibling;
770 hideOrShowFeedsCategory(fd, fd.getElementById("feedList"), hide);
774 function hideOrShowFeedsCategory(doc, node, hide, cat_node) {
776 // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
780 if (node.hasChildNodes() && node.firstChild.nextSibling != false) {
781 for (i = 0; i < node.childNodes.length; i++) {
782 if (node.childNodes[i].nodeName != "LI") { continue; }
784 if (node.childNodes[i].style != undefined) {
786 var has_unread = (node.childNodes[i].className != "feed");
788 // debug(node.childNodes[i].id + " --> " + has_unread);
790 if (hide && !has_unread) {
791 node.childNodes[i].style.display = "none";
795 node.childNodes[i].style.display = "list-item";
799 node.childNodes[i].style.display = "list-item";
806 if (cat_unread == 0) {
807 if (cat_node.style == undefined) {
808 debug("ERROR: supplied cat_node " + cat_node +
809 " has no styles. WTF?");
813 cat_node.style.display = "none";
815 cat_node.style.display = "list-item";
819 cat_node.style.display = "list-item";
825 // debug("unread for category: " + cat_unread);
828 function selectTableRow(r, do_select) {
829 r.className = r.className.replace("Selected", "");
832 r.className = r.className + "Selected";
836 function selectTableRowById(elem_id, check_id, do_select) {
840 var row = document.getElementById(elem_id);
843 selectTableRow(row, do_select);
846 var check = document.getElementById(check_id);
849 check.checked = do_select;
852 exception_error("selectTableRowById", e);
856 function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select,
857 classcheck, reset_others) {
859 var content = document.getElementById(content_id);
862 alert("[selectTableRows] Element " + content_id + " not found.");
866 for (i = 0; i < content.rows.length; i++) {
867 if (!classcheck || content.rows[i].className.match(classcheck)) {
869 if (content.rows[i].id.match(prefix)) {
870 selectTableRow(content.rows[i], do_select);
872 var row_id = content.rows[i].id.replace(prefix, "");
873 var check = document.getElementById(check_prefix + row_id);
876 check.checked = do_select;
878 } else if (reset_others) {
879 selectTableRow(content.rows[i], false);
881 var row_id = content.rows[i].id.replace(prefix, "");
882 var check = document.getElementById(check_prefix + row_id);
885 check.checked = false;
889 } else if (reset_others) {
890 selectTableRow(content.rows[i], false);
892 var row_id = content.rows[i].id.replace(prefix, "");
893 var check = document.getElementById(check_prefix + row_id);
896 check.checked = false;
903 function getSelectedTableRowIds(content_id, prefix) {
905 var content = document.getElementById(content_id);
908 alert("[getSelectedTableRowIds] Element " + content_id + " not found.");
912 var sel_rows = new Array();
914 for (i = 0; i < content.rows.length; i++) {
915 if (content.rows[i].id.match(prefix) &&
916 content.rows[i].className.match("Selected")) {
918 var row_id = content.rows[i].id.replace(prefix + "-", "");
919 sel_rows.push(row_id);
927 function toggleSelectRowById(sender, id) {
928 var row = document.getElementById(id);
930 if (sender.checked) {
931 if (!row.className.match("Selected")) {
932 row.className = row.className + "Selected";
935 if (row.className.match("Selected")) {
936 row.className = row.className.replace("Selected", "");
941 function toggleSelectListRow(sender) {
942 var parent_row = sender.parentNode;
944 if (sender.checked) {
945 if (!parent_row.className.match("Selected")) {
946 parent_row.className = parent_row.className + "Selected";
949 if (parent_row.className.match("Selected")) {
950 parent_row.className = parent_row.className.replace("Selected", "");
956 function toggleSelectRow(sender) {
957 var parent_row = sender.parentNode.parentNode;
959 if (sender.checked) {
960 if (!parent_row.className.match("Selected")) {
961 parent_row.className = parent_row.className + "Selected";
964 if (parent_row.className.match("Selected")) {
965 parent_row.className = parent_row.className.replace("Selected", "");
970 function openExternalUrl(url) {
971 var w = window.open(url);
974 function getRelativeFeedId(list, id, direction, unread_only) {
976 if (direction == "next") {
977 for (i = 0; i < list.childNodes.length; i++) {
978 var child = list.childNodes[i];
979 if (child.id && child.id == "feedCatHolder") {
980 if (child.lastChild) {
981 var cr = getRelativeFeedId(child.firstChild, id, direction, unread_only);
984 } else if (child.id && child.id.match("FEEDR-")) {
985 return child.id.replace('FEEDR-', '');
990 // FIXME select last feed doesn't work when only unread feeds are visible
992 if (direction == "prev") {
993 for (i = list.childNodes.length-1; i >= 0; i--) {
994 var child = list.childNodes[i];
995 if (child.id == "feedCatHolder") {
996 if (child.firstChild) {
997 var cr = getRelativeFeedId(child.firstChild, id, direction);
1000 } else if (child.id.match("FEEDR-")) {
1002 if (getInitParam("hide_read_feeds") == 1) {
1003 if (child.className != "feed") {
1004 alert(child.className);
1005 return child.id.replace('FEEDR-', '');
1008 return child.id.replace('FEEDR-', '');
1015 var feed = list.ownerDocument.getElementById("FEEDR-" + id);
1017 if (getInitParam("hide_read_feeds") == 1) {
1021 if (direction == "next") {
1027 if (e.nextSibling) {
1031 } else if (e.parentNode.parentNode.nextSibling) {
1033 var this_cat = e.parentNode.parentNode;
1037 if (this_cat && this_cat.nextSibling) {
1038 while (!e && this_cat.nextSibling) {
1039 this_cat = this_cat.nextSibling;
1040 if (this_cat.id == "feedCatHolder") {
1041 e = this_cat.firstChild.firstChild;
1051 if (!unread_only || (unread_only && e.className != "feed" &&
1052 e.className != "label" && e.className != "virt" &&
1053 e.className != "error")) {
1054 return e.id.replace("FEEDR-", "");
1059 } else if (direction == "prev") {
1065 if (e.previousSibling) {
1067 e = e.previousSibling;
1069 } else if (e.parentNode.parentNode.previousSibling) {
1071 var this_cat = e.parentNode.parentNode;
1075 if (this_cat && this_cat.previousSibling) {
1076 while (!e && this_cat.previousSibling) {
1077 this_cat = this_cat.previousSibling;
1078 if (this_cat.id == "feedCatHolder") {
1079 e = this_cat.firstChild.lastChild;
1089 if (!unread_only || (unread_only && e.className != "feed" &&
1090 e.className != "error")) {
1091 return e.id.replace("FEEDR-", "");
1099 function showBlockElement(id) {
1100 var elem = document.getElementById(id);
1103 elem.style.display = "block";
1105 alert("[showBlockElement] can't find element with id " + id);
1109 function hideParentElement(e) {
1110 e.parentNode.style.display = "none";
1113 function dropboxSelect(e, v) {
1114 for (i = 0; i < e.length; i++) {
1115 if (e[i].value == v) {
1116 e.selectedIndex = i;
1122 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1123 // bugfixed just a little bit :-)
1124 function getURLParam(strParamName){
1126 var strHref = window.location.href;
1128 if (strHref.indexOf("#") == strHref.length-1) {
1129 strHref = strHref.substring(0, strHref.length-1);
1132 if ( strHref.indexOf("?") > -1 ){
1133 var strQueryString = strHref.substr(strHref.indexOf("?"));
1134 var aQueryString = strQueryString.split("&");
1135 for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
1136 if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
1137 var aParam = aQueryString[iParam].split("=");
1138 strReturn = aParam[1];
1146 function leading_zero(p) {
1148 if (s.length == 1) s = "0" + s;
1152 function closeInfoBox(cleanup) {
1153 var box = document.getElementById('infoBox');
1154 var shadow = document.getElementById('infoBoxShadow');
1157 shadow.style.display = "none";
1159 box.style.display = "none";
1162 if (cleanup) box.innerHTML = " ";
1170 function displayDlg(id, param) {
1172 if (!xmlhttp_ready(xmlhttp)) {
1173 printLockingError();
1179 xmlhttp.open("GET", "backend.php?op=dlg&id=" +
1180 param_escape(id) + "¶m=" + param_escape(param), true);
1181 xmlhttp.onreadystatechange=infobox_callback;
1189 function infobox_submit_callback() {
1190 if (xmlhttp.readyState == 4) {
1193 // called from prefs, reload tab
1195 selectTab(active_tab, false);
1198 notify(xmlhttp.responseText);
1203 function infobox_callback() {
1204 if (xmlhttp.readyState == 4) {
1205 var box = document.getElementById('infoBox');
1206 var shadow = document.getElementById('infoBoxShadow');
1208 box.innerHTML=xmlhttp.responseText;
1210 shadow.style.display = "block";
1212 box.style.display = "block";
1218 function qaddFilter() {
1220 if (!xmlhttp_ready(xmlhttp)) {
1221 printLockingError();
1225 var query = Form.serialize("filter_add_form");
1227 xmlhttp.open("GET", "backend.php?" + query, true);
1228 xmlhttp.onreadystatechange=infobox_submit_callback;
1234 function toggleSubmitNotEmpty(e, submit_id) {
1236 document.getElementById(submit_id).disabled = (e.value == "")
1238 exception_error("toggleSubmitNotEmpty", e);
1242 function isValidURL(s) {
1243 return s.match("http://") != null || s.match("https://") != null;
1248 if (!xmlhttp_ready(xmlhttp)) {
1249 printLockingError();
1253 notify("Adding feed...");
1257 var feeds_doc = document;
1259 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
1261 var query = Form.serialize("feed_add_form");
1263 xmlhttp.open("GET", "backend.php?" + query, true);
1264 xmlhttp.onreadystatechange=dlg_frefresh_callback;
1270 function filterCR(e)
1275 key = window.event.keyCode; //IE
1277 key = e.which; //firefox
1285 function getMainContext() {
1289 function getFeedsContext() {
1293 function getContentContext() {
1297 function getHeadlinesContext() {
1301 var debug_last_class = "even";
1303 function debug(msg) {
1305 if (debug_last_class == "even") {
1306 debug_last_class = "odd";
1308 debug_last_class = "even";
1311 var c = document.getElementById('debug_output');
1312 if (c && c.style.display == "block") {
1313 while (c.lastChild != 'undefined' && c.childNodes.length > 100) {
1314 c.removeChild(c.lastChild);
1318 var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) +
1319 ":" + leading_zero(d.getSeconds());
1320 c.innerHTML = "<li class=\"" + debug_last_class + "\"><span class=\"debugTS\">[" + ts + "]</span> " +
1321 msg + "</li>" + c.innerHTML;
1325 function getInitParam(key) {
1326 return getMainContext().init_params[key];
1329 function storeInitParam(key, value, is_client) {
1332 if (getMainContext().init_params[key] != value) {
1333 debug("storeInitParam: " + key + " => " + value);
1334 //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" +
1335 // param_escape(key) + "&value=" + param_escape(value));
1336 var f = getMainContext().document.getElementById("backReqBox");
1337 f.src = "backend.php?op=rpc&subop=storeParam&key=" +
1338 param_escape(key) + "&value=" + param_escape(value);
1341 getMainContext().init_params[key] = value;
1343 exception_error("storeInitParam", e);
1348 function storeInitParams(params, is_client) {
1353 if (getMainContext().init_params[k] != params[k]) {
1354 s += k + "=" + params[k] + ";";
1355 getMainContext().init_params[k] = params[k];
1359 debug("storeInitParams: " + s);
1362 new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
1365 exception_error("storeInitParams", e);
1369 function fatalError(code, message) {
1371 var fe = document.getElementById("fatal_error");
1372 var fc = document.getElementById("fatal_error_msg");
1374 fc.innerHTML = "Code " + code + ": " + message;
1376 fe.style.display = "block";
1379 exception_error("fatalError", e);
1383 function getFeedName(id, is_cat) {
1384 var d = getFeedsContext().document;
1389 e = d.getElementById("FCATN-" + id);
1391 e = d.getElementById("FEEDN-" + id);
1394 return e.innerHTML.stripTags();
1400 function viewContentUrl(url) {
1401 getContentContext().location = url;