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");}
154 function hotkey_handler(e) {
160 if (!hotkeys_enabled) return;
163 keycode = window.event.keyCode;
168 if (keycode == 13 || keycode == 27) {
171 seq = seq + "" + keycode;
174 var m_ctx = getMainContext();
175 var f_ctx = getFeedsContext();
176 var h_ctx = getHeadlinesContext();
178 if (keycode == 82) { // r
179 return m_ctx.scheduleFeedUpdate(true);
182 if (keycode == 83) { // r
183 return m_ctx.displayDlg("search", getActiveFeedId());
186 if (keycode == 85) { // u
187 if (getActiveFeedId()) {
188 return f_ctx.viewfeed(getActiveFeedId(), "ForceUpdate");
192 if (keycode == 65) { // a
193 return m_ctx.toggleDispRead();
196 var f_doc = m_ctx.frames["feeds-frame"].document;
197 var feedlist = f_doc.getElementById('feedList');
199 if (keycode == 74) { // j
200 var feed = getActiveFeedId();
201 var new_feed = getRelativeFeedId(feedlist, feed, 'prev');
202 if (new_feed) viewfeed(new_feed, '');
205 if (keycode == 75) { // k
206 var feed = getActiveFeedId();
207 var new_feed = getRelativeFeedId(feedlist, feed, 'next');
208 if (new_feed) viewfeed(new_feed, '');
211 if (keycode == 78 || keycode == 40) { // n, down
212 return h_ctx.moveToPost('next');
215 if (keycode == 80 || keycode == 38) { // p, up
216 return h_ctx.moveToPost('prev');
219 if (typeof localHotkeyHandler != 'undefined') {
221 localHotkeyHandler(keycode);
223 exception_error("hotkey_handler, local:", e);
227 exception_error("hotkey_handler", e);
231 function cleanSelectedList(element) {
232 var content = document.getElementById(element);
234 if (!document.getElementById("feedCatHolder")) {
235 for (i = 0; i < content.childNodes.length; i++) {
236 var child = content.childNodes[i];
238 child.className = child.className.replace("Selected", "");
244 for (i = 0; i < content.childNodes.length; i++) {
245 var child = content.childNodes[i];
246 if (child.id == "feedCatHolder") {
247 parent.debug(child.id);
248 var fcat = child.lastChild;
249 for (j = 0; j < fcat.childNodes.length; j++) {
250 var feed = fcat.childNodes[j];
251 feed.className = feed.className.replace("Selected", "");
259 function cleanSelected(element) {
260 var content = document.getElementById(element);
262 for (i = 0; i < content.rows.length; i++) {
263 content.rows[i].className = content.rows[i].className.replace("Selected", "");
267 function getVisibleUnreadHeadlines() {
268 var content = document.getElementById("headlinesList");
270 var rows = new Array();
272 for (i = 0; i < content.rows.length; i++) {
273 var row_id = content.rows[i].id.replace("RROW-", "");
274 if (row_id.length > 0 && content.rows[i].className.match("Unread")) {
281 function getVisibleHeadlineIds() {
283 var content = document.getElementById("headlinesList");
285 var rows = new Array();
287 for (i = 0; i < content.rows.length; i++) {
288 var row_id = content.rows[i].id.replace("RROW-", "");
289 if (row_id.length > 0) {
296 function getFirstVisibleHeadlineId() {
297 var rows = getVisibleHeadlineIds();
301 function getLastVisibleHeadlineId() {
302 var rows = getVisibleHeadlineIds();
303 return rows[rows.length-1];
306 function markHeadline(id) {
307 var row = document.getElementById("RROW-" + id);
309 var is_active = false;
311 if (row.className.match("Active")) {
314 row.className = row.className.replace("Selected", "");
315 row.className = row.className.replace("Active", "");
316 row.className = row.className.replace("Insensitive", "");
319 row.className = row.className = "Active";
322 var check = document.getElementById("RCHK-" + id);
325 check.checked = true;
328 row.className = row.className + "Selected";
333 function getFeedIds() {
334 var content = document.getElementById("feedsList");
336 var rows = new Array();
338 for (i = 0; i < content.rows.length; i++) {
339 var id = content.rows[i].id.replace("FEEDR-", "");
348 function setCookie(name, value, lifetime, path, domain, secure) {
354 d.setTime(lifetime * 1000);
357 int_setCookie(name, value, d, path, domain, secure);
361 function int_setCookie(name, value, expires, path, domain, secure) {
362 document.cookie= name + "=" + escape(value) +
363 ((expires) ? "; expires=" + expires.toGMTString() : "") +
364 ((path) ? "; path=" + path : "") +
365 ((domain) ? "; domain=" + domain : "") +
366 ((secure) ? "; secure" : "");
369 function delCookie(name, path, domain) {
370 if (getCookie(name)) {
371 document.cookie = name + "=" +
372 ((path) ? ";path=" + path : "") +
373 ((domain) ? ";domain=" + domain : "" ) +
374 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
379 function getCookie(name) {
381 var dc = document.cookie;
382 var prefix = name + "=";
383 var begin = dc.indexOf("; " + prefix);
385 begin = dc.indexOf(prefix);
386 if (begin != 0) return null;
391 var end = document.cookie.indexOf(";", begin);
395 return unescape(dc.substring(begin + prefix.length, end));
398 function disableContainerChildren(id, disable, doc) {
400 if (!doc) doc = document;
402 var container = doc.getElementById(id);
405 //alert("disableContainerChildren: element " + id + " not found");
409 for (var i = 0; i < container.childNodes.length; i++) {
410 var child = container.childNodes[i];
413 child.disabled = disable;
419 if (child.className && child.className.match("button")) {
420 child.className = "disabledButton";
423 if (child.className && child.className.match("disabledButton")) {
424 child.className = "button";
431 function gotoPreferences() {
432 document.location.href = "prefs.php";
435 function gotoMain() {
436 document.location.href = "tt-rss.php";
439 function gotoExportOpml() {
440 document.location.href = "opml.php?op=Export";
443 function getActiveFeedId() {
444 // return getCookie("ttrss_vf_actfeed");
446 debug("gAFID: " + getMainContext().active_feed_id);
447 return getMainContext().active_feed_id;
449 exception_error("getActiveFeedId", e);
453 function activeFeedIsCat() {
454 return getMainContext().active_feed_is_cat;
457 function setActiveFeedId(id) {
458 // return setCookie("ttrss_vf_actfeed", id);
460 debug("sAFID(" + id + ")");
461 getMainContext().active_feed_id = id;
463 exception_error("setActiveFeedId", e);
467 function parse_counters(reply, scheduled_call) {
469 var f_document = getFeedsContext().document;
470 var title_obj = getMainContext();
474 if (reply.firstChild && reply.firstChild.firstChild) {
475 debug("<b>wrong element passed to parse_counters, adjusting.</b>");
476 reply = reply.firstChild;
479 debug("F_DOC: " + f_document + ", T_OBJ: " + title_obj);
481 for (var l = 0; l < reply.childNodes.length; l++) {
482 if (!reply.childNodes[l] ||
483 typeof(reply.childNodes[l].getAttribute) == "undefined") {
484 // where did this come from?
488 var id = reply.childNodes[l].getAttribute("id");
489 var t = reply.childNodes[l].getAttribute("type");
490 var ctr = reply.childNodes[l].getAttribute("counter");
491 var error = reply.childNodes[l].getAttribute("error");
492 var has_img = reply.childNodes[l].getAttribute("hi");
493 var updated = reply.childNodes[l].getAttribute("updated");
499 if (id == "global-unread") {
500 title_obj.global_unread = ctr;
501 title_obj.updateTitle();
505 if (t == "category") {
506 var catctr = f_document.getElementById("FCATCTR-" + id);
508 catctr.innerHTML = "(" + ctr + " unread)";
513 var feedctr = f_document.getElementById("FEEDCTR-" + id);
514 var feedu = f_document.getElementById("FEEDU-" + id);
515 var feedr = f_document.getElementById("FEEDR-" + id);
516 var feed_img = f_document.getElementById("FIMG-" + id);
517 var feedlink = f_document.getElementById("FEEDL-" + id);
518 var feedupd = f_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) {
539 var hf = title_obj.parent.frames["headlines-frame"];
540 hf.location.reload(true);
543 feedu.innerHTML = ctr;
546 feedr.className = feedr.className.replace("feed", "error");
548 feedr.className = feedr.className.replace("error", "feed");
552 feedctr.className = "odd";
553 if (!feedr.className.match("Unread")) {
554 var is_selected = feedr.className.match("Selected");
556 feedr.className = feedr.className.replace("Selected", "");
557 feedr.className = feedr.className.replace("Unread", "");
559 feedr.className = feedr.className + "Unread";
562 feedr.className = feedr.className + "Selected";
567 feedctr.className = "invisible";
568 feedr.className = feedr.className.replace("Unread", "");
573 var feeds_stored = getMainContext().number_of_feeds;
575 debug("Feed counters, C: " + feeds_found + ", S:" + feeds_stored);
577 if (feeds_stored != feeds_found) {
578 if (feeds_found != 0) {
579 getMainContext().number_of_feeds = feeds_found;
581 if (feeds_stored != 0 && feeds_found != 0) {
582 debug("Subscribed feed number changed, refreshing feedlist");
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");
602 var reply = xmlhttp_rpc.responseXML.firstChild;
604 var counters = reply.firstChild;
606 parse_counters(counters);
608 var runtime = counters.nextSibling;
611 getMainContext().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");
674 var fd = getFeedsContext().document;
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 var fd = getFeedsContext().document;
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 var has_unread = (node.childNodes[i].className != "feed");
786 // debug(node.childNodes[i].id + " --> " + has_unread);
788 if (hide && !has_unread) {
789 node.childNodes[i].style.display = "none";
793 node.childNodes[i].style.display = "list-item";
803 if (cat_unread == 0) {
805 cat_node.style.display = "none";
807 cat_node.style.display = "list-item";
811 // debug("unread for category: " + cat_unread);
814 function selectTableRow(r, do_select) {
815 r.className = r.className.replace("Selected", "");
818 r.className = r.className + "Selected";
822 function selectTableRowById(elem_id, check_id, do_select) {
826 var row = document.getElementById(elem_id);
829 selectTableRow(row, do_select);
832 var check = document.getElementById(check_id);
835 check.checked = do_select;
838 exception_error("selectTableRowById", e);
842 function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select,
843 classcheck, reset_others) {
845 var content = document.getElementById(content_id);
848 alert("[selectTableRows] Element " + content_id + " not found.");
852 for (i = 0; i < content.rows.length; i++) {
853 if (!classcheck || content.rows[i].className.match(classcheck)) {
855 if (content.rows[i].id.match(prefix)) {
856 selectTableRow(content.rows[i], do_select);
858 var row_id = content.rows[i].id.replace(prefix, "");
859 var check = document.getElementById(check_prefix + row_id);
862 check.checked = do_select;
864 } else if (reset_others) {
865 selectTableRow(content.rows[i], false);
867 var row_id = content.rows[i].id.replace(prefix, "");
868 var check = document.getElementById(check_prefix + row_id);
871 check.checked = false;
875 } else if (reset_others) {
876 selectTableRow(content.rows[i], false);
878 var row_id = content.rows[i].id.replace(prefix, "");
879 var check = document.getElementById(check_prefix + row_id);
882 check.checked = false;
889 function getSelectedTableRowIds(content_id, prefix) {
891 var content = document.getElementById(content_id);
894 alert("[getSelectedTableRowIds] Element " + content_id + " not found.");
898 var sel_rows = new Array();
900 for (i = 0; i < content.rows.length; i++) {
901 if (content.rows[i].id.match(prefix) &&
902 content.rows[i].className.match("Selected")) {
904 var row_id = content.rows[i].id.replace(prefix + "-", "");
905 sel_rows.push(row_id);
913 function toggleSelectRowById(sender, id) {
914 var row = document.getElementById(id);
916 if (sender.checked) {
917 if (!row.className.match("Selected")) {
918 row.className = row.className + "Selected";
921 if (row.className.match("Selected")) {
922 row.className = row.className.replace("Selected", "");
927 function toggleSelectListRow(sender) {
928 var parent_row = sender.parentNode;
930 if (sender.checked) {
931 if (!parent_row.className.match("Selected")) {
932 parent_row.className = parent_row.className + "Selected";
935 if (parent_row.className.match("Selected")) {
936 parent_row.className = parent_row.className.replace("Selected", "");
942 function toggleSelectRow(sender) {
943 var parent_row = sender.parentNode.parentNode;
945 if (sender.checked) {
946 if (!parent_row.className.match("Selected")) {
947 parent_row.className = parent_row.className + "Selected";
950 if (parent_row.className.match("Selected")) {
951 parent_row.className = parent_row.className.replace("Selected", "");
956 function openExternalUrl(url) {
957 var w = window.open(url);
960 function getRelativeFeedId(list, id, direction, unread_only) {
962 if (direction == "next") {
963 for (i = 0; i < list.childNodes.length; i++) {
964 var child = list.childNodes[i];
965 if (child.id && child.id == "feedCatHolder") {
966 if (child.lastChild) {
967 var cr = getRelativeFeedId(child.firstChild, id, direction);
970 } else if (child.id && child.id.match("FEEDR-")) {
971 return child.id.replace('FEEDR-', '');
976 // FIXME select last feed doesn't work when only unread feeds are visible
978 if (direction == "prev") {
979 for (i = list.childNodes.length-1; i >= 0; i--) {
980 var child = list.childNodes[i];
981 if (child.id == "feedCatHolder") {
982 if (child.firstChild) {
983 var cr = getRelativeFeedId(child.firstChild, id, direction);
986 } else if (child.id.match("FEEDR-")) {
988 if (getInitParam("hide_read_feeds") == 1) {
989 if (child.className != "feed") {
990 alert(child.className);
991 return child.id.replace('FEEDR-', '');
994 return child.id.replace('FEEDR-', '');
1001 var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId());
1003 if (getInitParam("hide_read_feeds") == 1) {
1007 if (direction == "next") {
1013 if (e.nextSibling) {
1017 } else if (e.parentNode.parentNode.nextSibling) {
1019 var this_cat = e.parentNode.parentNode;
1023 if (this_cat && this_cat.nextSibling) {
1024 while (!e && this_cat.nextSibling) {
1025 this_cat = this_cat.nextSibling;
1026 if (this_cat.id == "feedCatHolder") {
1027 e = this_cat.firstChild.firstChild;
1037 if (!unread_only || (unread_only && e.className != "feed" &&
1038 e.className != "error")) {
1039 return e.id.replace("FEEDR-", "");
1044 } else if (direction == "prev") {
1050 if (e.previousSibling) {
1052 e = e.previousSibling;
1054 } else if (e.parentNode.parentNode.previousSibling) {
1056 var this_cat = e.parentNode.parentNode;
1060 if (this_cat && this_cat.previousSibling) {
1061 while (!e && this_cat.previousSibling) {
1062 this_cat = this_cat.previousSibling;
1063 if (this_cat.id == "feedCatHolder") {
1064 e = this_cat.firstChild.lastChild;
1074 if (!unread_only || (unread_only && e.className != "feed" &&
1075 e.className != "error")) {
1076 return e.id.replace("FEEDR-", "");
1084 function showBlockElement(id) {
1085 var elem = document.getElementById(id);
1088 elem.style.display = "block";
1090 alert("[showBlockElement] can't find element with id " + id);
1094 function hideParentElement(e) {
1095 e.parentNode.style.display = "none";
1098 function dropboxSelect(e, v) {
1099 for (i = 0; i < e.length; i++) {
1100 if (e[i].value == v) {
1101 e.selectedIndex = i;
1107 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1108 // bugfixed just a little bit :-)
1109 function getURLParam(strParamName){
1111 var strHref = window.location.href;
1113 if (strHref.indexOf("#") == strHref.length-1) {
1114 strHref = strHref.substring(0, strHref.length-1);
1117 if ( strHref.indexOf("?") > -1 ){
1118 var strQueryString = strHref.substr(strHref.indexOf("?"));
1119 var aQueryString = strQueryString.split("&");
1120 for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
1121 if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
1122 var aParam = aQueryString[iParam].split("=");
1123 strReturn = aParam[1];
1131 function leading_zero(p) {
1133 if (s.length == 1) s = "0" + s;
1137 function closeInfoBox(cleanup) {
1138 var box = document.getElementById('infoBox');
1139 var shadow = document.getElementById('infoBoxShadow');
1142 shadow.style.display = "none";
1144 box.style.display = "none";
1147 if (cleanup) box.innerHTML = " ";
1155 function displayDlg(id, param) {
1157 if (!xmlhttp_ready(xmlhttp)) {
1158 printLockingError();
1164 xmlhttp.open("GET", "backend.php?op=dlg&id=" +
1165 param_escape(id) + "¶m=" + param_escape(param), true);
1166 xmlhttp.onreadystatechange=infobox_callback;
1174 function infobox_submit_callback() {
1175 if (xmlhttp.readyState == 4) {
1178 // called from prefs, reload tab
1180 selectTab(active_tab, false);
1183 notify(xmlhttp.responseText);
1188 function infobox_callback() {
1189 if (xmlhttp.readyState == 4) {
1190 var box = document.getElementById('infoBox');
1191 var shadow = document.getElementById('infoBoxShadow');
1193 box.innerHTML=xmlhttp.responseText;
1195 shadow.style.display = "block";
1197 box.style.display = "block";
1203 function qaddFilter() {
1205 if (!xmlhttp_ready(xmlhttp)) {
1206 printLockingError();
1210 var query = Form.serialize("filter_add_form");
1212 xmlhttp.open("GET", "backend.php?" + query, true);
1213 xmlhttp.onreadystatechange=infobox_submit_callback;
1219 function toggleSubmitNotEmpty(e, submit_id) {
1221 document.getElementById(submit_id).disabled = (e.value == "")
1223 exception_error("toggleSubmitNotEmpty", e);
1227 function isValidURL(s) {
1228 return s.match("http://") != null || s.match("https://") != null;
1233 if (!xmlhttp_ready(xmlhttp)) {
1234 printLockingError();
1238 notify("Adding feed...");
1242 var feeds_doc = getFeedsContext().document;
1244 feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
1246 var query = Form.serialize("feed_add_form");
1248 xmlhttp.open("GET", "backend.php?" + query, true);
1249 xmlhttp.onreadystatechange=dlg_frefresh_callback;
1253 function filterCR(e)
1258 key = window.event.keyCode; //IE
1260 key = e.which; //firefox
1268 function getMainContext() {
1269 if (parent.window != window) {
1270 return parent.window;
1276 function getFeedsContext() {
1278 return getMainContext().frames["feeds-frame"];
1280 exception_error("getFeedsContext", e);
1285 function getHeadlinesContext() {
1287 return getMainContext().frames["headlines-frame"];
1289 exception_error("getHeadlinesContext", e);
1293 var debug_last_class = "even";
1295 function debug(msg) {
1296 var ctx = getMainContext();
1298 if (ctx.debug_last_class == "even") {
1299 ctx.debug_last_class = "odd";
1301 ctx.debug_last_class = "even";
1304 var c = ctx.document.getElementById('debug_output');
1305 if (c && c.style.display == "block") {
1306 while (c.lastChild != 'undefined' && c.childNodes.length > 100) {
1307 c.removeChild(c.lastChild);
1311 var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) +
1312 ":" + leading_zero(d.getSeconds());
1313 c.innerHTML = "<li class=\"" + ctx.debug_last_class + "\"><span class=\"debugTS\">[" + ts + "]</span> " +
1314 msg + "</li>" + c.innerHTML;
1318 function getInitParam(key) {
1319 return getMainContext().init_params[key];
1322 function storeInitParam(key, value, is_client) {
1325 if (getMainContext().init_params[key] != value) {
1326 debug("storeInitParam: " + key + " => " + value);
1327 //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" +
1328 // param_escape(key) + "&value=" + param_escape(value));
1329 var f = getMainContext().document.getElementById("backReqBox");
1330 f.src = "backend.php?op=rpc&subop=storeParam&key=" +
1331 param_escape(key) + "&value=" + param_escape(value);
1334 getMainContext().init_params[key] = value;
1336 exception_error("storeInitParam", e);
1341 function storeInitParams(params, is_client) {
1346 if (getMainContext().init_params[k] != params[k]) {
1347 s += k + "=" + params[k] + ";";
1348 getMainContext().init_params[k] = params[k];
1352 debug("storeInitParams: " + s);
1355 new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
1358 exception_error("storeInitParams", e);
1362 function fatalError(code, message) {
1364 var fe = document.getElementById("fatal_error");
1365 var fc = document.getElementById("fatal_error_msg");
1367 fc.innerHTML = "Code " + code + ": " + message;
1369 fe.style.display = "block";
1372 exception_error("fatalError", e);
1376 function getFeedName(id, is_cat) {
1377 var d = getFeedsContext().document;
1382 e = d.getElementById("FCATN-" + id);
1384 e = d.getElementById("FEEDN-" + id);
1387 return e.innerHTML.stripTags();