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 var m_ctx = getMainContext();
169 var f_ctx = getFeedsContext();
170 var h_ctx = getHeadlinesContext();
172 if (keycode == 82) { // r
173 return m_ctx.scheduleFeedUpdate(true);
176 if (keycode == 83) { // r
177 return m_ctx.displayDlg("search", getActiveFeedId());
180 if (keycode == 85) { // u
181 if (getActiveFeedId()) {
182 return f_ctx.viewfeed(getActiveFeedId(), "ForceUpdate");
186 if (keycode == 65) { // a
187 return m_ctx.toggleDispRead();
190 var f_doc = m_ctx.frames["feeds-frame"].document;
191 var feedlist = f_doc.getElementById('feedList');
193 if (keycode == 74) { // j
194 var feed = getActiveFeedId();
195 var new_feed = getRelativeFeedId(feedlist, feed, 'prev');
196 if (new_feed) viewfeed(new_feed, '');
199 if (keycode == 75) { // k
200 var feed = getActiveFeedId();
201 var new_feed = getRelativeFeedId(feedlist, feed, 'next');
202 if (new_feed) viewfeed(new_feed, '');
205 if (keycode == 78 || keycode == 40) { // n, down
206 if (typeof h_ctx.moveToPost != 'undefined') {
207 return h_ctx.moveToPost('next');
211 if (keycode == 80 || keycode == 38) { // p, up
212 if (typeof h_ctx.moveToPost != 'undefined') {
213 return h_ctx.moveToPost('prev');
217 if (typeof localHotkeyHandler != 'undefined') {
219 localHotkeyHandler(keycode);
221 exception_error("hotkey_handler, local:", e);
225 exception_error("hotkey_handler", e);
229 function cleanSelectedList(element) {
230 var content = document.getElementById(element);
232 if (!document.getElementById("feedCatHolder")) {
233 for (i = 0; i < content.childNodes.length; i++) {
234 var child = content.childNodes[i];
236 child.className = child.className.replace("Selected", "");
242 for (i = 0; i < content.childNodes.length; i++) {
243 var child = content.childNodes[i];
244 if (child.id == "feedCatHolder") {
245 parent.debug(child.id);
246 var fcat = child.lastChild;
247 for (j = 0; j < fcat.childNodes.length; j++) {
248 var feed = fcat.childNodes[j];
249 feed.className = feed.className.replace("Selected", "");
257 function cleanSelected(element) {
258 var content = document.getElementById(element);
260 for (i = 0; i < content.rows.length; i++) {
261 content.rows[i].className = content.rows[i].className.replace("Selected", "");
265 function getVisibleUnreadHeadlines() {
266 var content = document.getElementById("headlinesList");
268 var rows = new Array();
270 for (i = 0; i < content.rows.length; i++) {
271 var row_id = content.rows[i].id.replace("RROW-", "");
272 if (row_id.length > 0 && content.rows[i].className.match("Unread")) {
279 function getVisibleHeadlineIds() {
281 var content = document.getElementById("headlinesList");
283 var rows = new Array();
285 for (i = 0; i < content.rows.length; i++) {
286 var row_id = content.rows[i].id.replace("RROW-", "");
287 if (row_id.length > 0) {
294 function getFirstVisibleHeadlineId() {
295 var rows = getVisibleHeadlineIds();
299 function getLastVisibleHeadlineId() {
300 var rows = getVisibleHeadlineIds();
301 return rows[rows.length-1];
304 function markHeadline(id) {
305 var row = document.getElementById("RROW-" + id);
307 var is_active = false;
309 if (row.className.match("Active")) {
312 row.className = row.className.replace("Selected", "");
313 row.className = row.className.replace("Active", "");
314 row.className = row.className.replace("Insensitive", "");
317 row.className = row.className = "Active";
320 var check = document.getElementById("RCHK-" + id);
323 check.checked = true;
326 row.className = row.className + "Selected";
331 function getFeedIds() {
332 var content = document.getElementById("feedsList");
334 var rows = new Array();
336 for (i = 0; i < content.rows.length; i++) {
337 var id = content.rows[i].id.replace("FEEDR-", "");
346 function setCookie(name, value, lifetime, path, domain, secure) {
352 d.setTime(lifetime * 1000);
355 int_setCookie(name, value, d, path, domain, secure);
359 function int_setCookie(name, value, expires, path, domain, secure) {
360 document.cookie= name + "=" + escape(value) +
361 ((expires) ? "; expires=" + expires.toGMTString() : "") +
362 ((path) ? "; path=" + path : "") +
363 ((domain) ? "; domain=" + domain : "") +
364 ((secure) ? "; secure" : "");
367 function delCookie(name, path, domain) {
368 if (getCookie(name)) {
369 document.cookie = name + "=" +
370 ((path) ? ";path=" + path : "") +
371 ((domain) ? ";domain=" + domain : "" ) +
372 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
377 function getCookie(name) {
379 var dc = document.cookie;
380 var prefix = name + "=";
381 var begin = dc.indexOf("; " + prefix);
383 begin = dc.indexOf(prefix);
384 if (begin != 0) return null;
389 var end = document.cookie.indexOf(";", begin);
393 return unescape(dc.substring(begin + prefix.length, end));
396 function disableContainerChildren(id, disable, doc) {
398 if (!doc) doc = document;
400 var container = doc.getElementById(id);
403 //alert("disableContainerChildren: element " + id + " not found");
407 for (var i = 0; i < container.childNodes.length; i++) {
408 var child = container.childNodes[i];
411 child.disabled = disable;
417 if (child.className && child.className.match("button")) {
418 child.className = "disabledButton";
421 if (child.className && child.className.match("disabledButton")) {
422 child.className = "button";
429 function gotoPreferences() {
430 document.location.href = "prefs.php";
433 function gotoMain() {
434 document.location.href = "tt-rss.php";
437 function gotoExportOpml() {
438 document.location.href = "opml.php?op=Export";
441 function getActiveFeedId() {
442 // return getCookie("ttrss_vf_actfeed");
444 debug("gAFID: " + getMainContext().active_feed_id);
445 return getMainContext().active_feed_id;
447 exception_error("getActiveFeedId", e);
451 function activeFeedIsCat() {
452 return getMainContext().active_feed_is_cat;
455 function setActiveFeedId(id) {
456 // return setCookie("ttrss_vf_actfeed", id);
458 debug("sAFID(" + id + ")");
459 getMainContext().active_feed_id = id;
461 exception_error("setActiveFeedId", e);
465 function parse_counters(reply, scheduled_call) {
467 var f_document = getFeedsContext().document;
468 var title_obj = getMainContext();
472 if (reply.firstChild && reply.firstChild.firstChild) {
473 debug("<b>wrong element passed to parse_counters, adjusting.</b>");
474 reply = reply.firstChild;
477 debug("F_DOC: " + f_document + ", T_OBJ: " + title_obj);
479 for (var l = 0; l < reply.childNodes.length; l++) {
480 if (!reply.childNodes[l] ||
481 typeof(reply.childNodes[l].getAttribute) == "undefined") {
482 // where did this come from?
486 var id = reply.childNodes[l].getAttribute("id");
487 var t = reply.childNodes[l].getAttribute("type");
488 var ctr = reply.childNodes[l].getAttribute("counter");
489 var error = reply.childNodes[l].getAttribute("error");
490 var has_img = reply.childNodes[l].getAttribute("hi");
491 var updated = reply.childNodes[l].getAttribute("updated");
493 if (id == "global-unread") {
494 title_obj.global_unread = ctr;
495 title_obj.updateTitle();
499 if (id == "subscribed-feeds") {
504 if (t == "category") {
505 var catctr = f_document.getElementById("FCATCTR-" + id);
507 catctr.innerHTML = "(" + ctr + " unread)";
512 var feedctr = f_document.getElementById("FEEDCTR-" + id);
513 var feedu = f_document.getElementById("FEEDU-" + id);
514 var feedr = f_document.getElementById("FEEDR-" + id);
515 var feed_img = f_document.getElementById("FIMG-" + id);
516 var feedlink = f_document.getElementById("FEEDL-" + id);
517 var feedupd = f_document.getElementById("FLUPD-" + id);
519 if (updated && feedlink) {
521 feedlink.title = "Error: " + error + " (" + updated + ")";
523 feedlink.title = "Updated: " + updated;
527 if (updated && feedupd) {
529 feedupd.innerHTML = updated + " (Error)";
531 feedupd.innerHTML = updated;
535 if (feedctr && feedu && feedr) {
537 if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) {
538 var hf = title_obj.parent.frames["headlines-frame"];
539 hf.location.reload(true);
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 var feeds_stored = getMainContext().number_of_feeds;
574 debug("Feed counters, C: " + feeds_found + ", S:" + feeds_stored);
576 if (feeds_stored != feeds_found) {
577 getMainContext().number_of_feeds = feeds_found;
579 if (feeds_stored != 0) {
580 debug("Subscribed feed number changed, refreshing feedlist");
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");
600 var reply = xmlhttp_rpc.responseXML.firstChild;
602 var counters = reply.firstChild;
604 parse_counters(counters);
606 var runtime = counters.nextSibling;
609 getMainContext().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");
672 var fd = getFeedsContext().document;
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 var fd = getFeedsContext().document;
751 var list = fd.getElementById("feedList");
753 if (fd.getElementById("feedCatHolder")) {
755 var feeds = fd.getElementById("feedList");
756 var child = feeds.firstChild;
760 if (child.id == "feedCatHolder") {
761 hideOrShowFeedsCategory(fd, child.firstChild, hide, child.previousSibling);
764 child = child.nextSibling;
768 hideOrShowFeedsCategory(fd, fd.getElementById("feedList"), hide);
772 function hideOrShowFeedsCategory(doc, node, hide, cat_node) {
774 // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
778 if (node.hasChildNodes() && node.firstChild.nextSibling != false) {
779 for (i = 0; i < node.childNodes.length; i++) {
780 if (node.childNodes[i].nodeName != "LI") { continue; }
782 if (node.childNodes[i].style != undefined) {
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) {
804 if (cat_node.style == undefined) {
805 debug("ERROR: supplied cat_node " + cat_node +
806 " has no styles. WTF?");
810 cat_node.style.display = "none";
812 cat_node.style.display = "list-item";
816 // debug("unread for category: " + cat_unread);
819 function selectTableRow(r, do_select) {
820 r.className = r.className.replace("Selected", "");
823 r.className = r.className + "Selected";
827 function selectTableRowById(elem_id, check_id, do_select) {
831 var row = document.getElementById(elem_id);
834 selectTableRow(row, do_select);
837 var check = document.getElementById(check_id);
840 check.checked = do_select;
843 exception_error("selectTableRowById", e);
847 function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select,
848 classcheck, reset_others) {
850 var content = document.getElementById(content_id);
853 alert("[selectTableRows] Element " + content_id + " not found.");
857 for (i = 0; i < content.rows.length; i++) {
858 if (!classcheck || content.rows[i].className.match(classcheck)) {
860 if (content.rows[i].id.match(prefix)) {
861 selectTableRow(content.rows[i], do_select);
863 var row_id = content.rows[i].id.replace(prefix, "");
864 var check = document.getElementById(check_prefix + row_id);
867 check.checked = do_select;
869 } else if (reset_others) {
870 selectTableRow(content.rows[i], false);
872 var row_id = content.rows[i].id.replace(prefix, "");
873 var check = document.getElementById(check_prefix + row_id);
876 check.checked = false;
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;
894 function getSelectedTableRowIds(content_id, prefix) {
896 var content = document.getElementById(content_id);
899 alert("[getSelectedTableRowIds] Element " + content_id + " not found.");
903 var sel_rows = new Array();
905 for (i = 0; i < content.rows.length; i++) {
906 if (content.rows[i].id.match(prefix) &&
907 content.rows[i].className.match("Selected")) {
909 var row_id = content.rows[i].id.replace(prefix + "-", "");
910 sel_rows.push(row_id);
918 function toggleSelectRowById(sender, id) {
919 var row = document.getElementById(id);
921 if (sender.checked) {
922 if (!row.className.match("Selected")) {
923 row.className = row.className + "Selected";
926 if (row.className.match("Selected")) {
927 row.className = row.className.replace("Selected", "");
932 function toggleSelectListRow(sender) {
933 var parent_row = sender.parentNode;
935 if (sender.checked) {
936 if (!parent_row.className.match("Selected")) {
937 parent_row.className = parent_row.className + "Selected";
940 if (parent_row.className.match("Selected")) {
941 parent_row.className = parent_row.className.replace("Selected", "");
947 function toggleSelectRow(sender) {
948 var parent_row = sender.parentNode.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", "");
961 function openExternalUrl(url) {
962 var w = window.open(url);
965 function getRelativeFeedId(list, id, direction, unread_only) {
967 if (direction == "next") {
968 for (i = 0; i < list.childNodes.length; i++) {
969 var child = list.childNodes[i];
970 if (child.id && child.id == "feedCatHolder") {
971 if (child.lastChild) {
972 var cr = getRelativeFeedId(child.firstChild, id, direction);
975 } else if (child.id && child.id.match("FEEDR-")) {
976 return child.id.replace('FEEDR-', '');
981 // FIXME select last feed doesn't work when only unread feeds are visible
983 if (direction == "prev") {
984 for (i = list.childNodes.length-1; i >= 0; i--) {
985 var child = list.childNodes[i];
986 if (child.id == "feedCatHolder") {
987 if (child.firstChild) {
988 var cr = getRelativeFeedId(child.firstChild, id, direction);
991 } else if (child.id.match("FEEDR-")) {
993 if (getInitParam("hide_read_feeds") == 1) {
994 if (child.className != "feed") {
995 alert(child.className);
996 return child.id.replace('FEEDR-', '');
999 return child.id.replace('FEEDR-', '');
1006 var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId());
1008 if (getInitParam("hide_read_feeds") == 1) {
1012 if (direction == "next") {
1018 if (e.nextSibling) {
1022 } else if (e.parentNode.parentNode.nextSibling) {
1024 var this_cat = e.parentNode.parentNode;
1028 if (this_cat && this_cat.nextSibling) {
1029 while (!e && this_cat.nextSibling) {
1030 this_cat = this_cat.nextSibling;
1031 if (this_cat.id == "feedCatHolder") {
1032 e = this_cat.firstChild.firstChild;
1042 if (!unread_only || (unread_only && e.className != "feed" &&
1043 e.className != "error")) {
1044 return e.id.replace("FEEDR-", "");
1049 } else if (direction == "prev") {
1055 if (e.previousSibling) {
1057 e = e.previousSibling;
1059 } else if (e.parentNode.parentNode.previousSibling) {
1061 var this_cat = e.parentNode.parentNode;
1065 if (this_cat && this_cat.previousSibling) {
1066 while (!e && this_cat.previousSibling) {
1067 this_cat = this_cat.previousSibling;
1068 if (this_cat.id == "feedCatHolder") {
1069 e = this_cat.firstChild.lastChild;
1079 if (!unread_only || (unread_only && e.className != "feed" &&
1080 e.className != "error")) {
1081 return e.id.replace("FEEDR-", "");
1089 function showBlockElement(id) {
1090 var elem = document.getElementById(id);
1093 elem.style.display = "block";
1095 alert("[showBlockElement] can't find element with id " + id);
1099 function hideParentElement(e) {
1100 e.parentNode.style.display = "none";
1103 function dropboxSelect(e, v) {
1104 for (i = 0; i < e.length; i++) {
1105 if (e[i].value == v) {
1106 e.selectedIndex = i;
1112 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1113 // bugfixed just a little bit :-)
1114 function getURLParam(strParamName){
1116 var strHref = window.location.href;
1118 if (strHref.indexOf("#") == strHref.length-1) {
1119 strHref = strHref.substring(0, strHref.length-1);
1122 if ( strHref.indexOf("?") > -1 ){
1123 var strQueryString = strHref.substr(strHref.indexOf("?"));
1124 var aQueryString = strQueryString.split("&");
1125 for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
1126 if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
1127 var aParam = aQueryString[iParam].split("=");
1128 strReturn = aParam[1];
1136 function leading_zero(p) {
1138 if (s.length == 1) s = "0" + s;
1142 function closeInfoBox(cleanup) {
1143 var box = document.getElementById('infoBox');
1144 var shadow = document.getElementById('infoBoxShadow');
1147 shadow.style.display = "none";
1149 box.style.display = "none";
1152 if (cleanup) box.innerHTML = " ";
1160 function displayDlg(id, param) {
1162 if (!xmlhttp_ready(xmlhttp)) {
1163 printLockingError();
1169 xmlhttp.open("GET", "backend.php?op=dlg&id=" +
1170 param_escape(id) + "¶m=" + param_escape(param), true);
1171 xmlhttp.onreadystatechange=infobox_callback;
1179 function infobox_submit_callback() {
1180 if (xmlhttp.readyState == 4) {
1183 // called from prefs, reload tab
1185 selectTab(active_tab, false);
1188 notify(xmlhttp.responseText);
1193 function infobox_callback() {
1194 if (xmlhttp.readyState == 4) {
1195 var box = document.getElementById('infoBox');
1196 var shadow = document.getElementById('infoBoxShadow');
1198 box.innerHTML=xmlhttp.responseText;
1200 shadow.style.display = "block";
1202 box.style.display = "block";
1208 function qaddFilter() {
1210 if (!xmlhttp_ready(xmlhttp)) {
1211 printLockingError();
1215 var query = Form.serialize("filter_add_form");
1217 xmlhttp.open("GET", "backend.php?" + query, true);
1218 xmlhttp.onreadystatechange=infobox_submit_callback;
1224 function toggleSubmitNotEmpty(e, submit_id) {
1226 document.getElementById(submit_id).disabled = (e.value == "")
1228 exception_error("toggleSubmitNotEmpty", e);
1232 function isValidURL(s) {
1233 return s.match("http://") != null || s.match("https://") != null;
1238 if (!xmlhttp_ready(xmlhttp)) {
1239 printLockingError();
1243 notify("Adding feed...");
1247 var feeds_doc = getFeedsContext().document;
1249 feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
1251 var query = Form.serialize("feed_add_form");
1253 xmlhttp.open("GET", "backend.php?" + query, true);
1254 xmlhttp.onreadystatechange=dlg_frefresh_callback;
1258 function filterCR(e)
1263 key = window.event.keyCode; //IE
1265 key = e.which; //firefox
1273 function getMainContext() {
1274 if (parent.window != window) {
1275 return parent.window;
1281 function getFeedsContext() {
1283 return getMainContext().frames["feeds-frame"];
1285 exception_error("getFeedsContext", e);
1290 function getHeadlinesContext() {
1292 return getMainContext().frames["headlines-frame"];
1294 exception_error("getHeadlinesContext", e);
1298 var debug_last_class = "even";
1300 function debug(msg) {
1301 var ctx = getMainContext();
1303 if (ctx.debug_last_class == "even") {
1304 ctx.debug_last_class = "odd";
1306 ctx.debug_last_class = "even";
1309 var c = ctx.document.getElementById('debug_output');
1310 if (c && c.style.display == "block") {
1311 while (c.lastChild != 'undefined' && c.childNodes.length > 100) {
1312 c.removeChild(c.lastChild);
1316 var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) +
1317 ":" + leading_zero(d.getSeconds());
1318 c.innerHTML = "<li class=\"" + ctx.debug_last_class + "\"><span class=\"debugTS\">[" + ts + "]</span> " +
1319 msg + "</li>" + c.innerHTML;
1323 function getInitParam(key) {
1324 return getMainContext().init_params[key];
1327 function storeInitParam(key, value, is_client) {
1330 if (getMainContext().init_params[key] != value) {
1331 debug("storeInitParam: " + key + " => " + value);
1332 //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" +
1333 // param_escape(key) + "&value=" + param_escape(value));
1334 var f = getMainContext().document.getElementById("backReqBox");
1335 f.src = "backend.php?op=rpc&subop=storeParam&key=" +
1336 param_escape(key) + "&value=" + param_escape(value);
1339 getMainContext().init_params[key] = value;
1341 exception_error("storeInitParam", e);
1346 function storeInitParams(params, is_client) {
1351 if (getMainContext().init_params[k] != params[k]) {
1352 s += k + "=" + params[k] + ";";
1353 getMainContext().init_params[k] = params[k];
1357 debug("storeInitParams: " + s);
1360 new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
1363 exception_error("storeInitParams", e);
1367 function fatalError(code, message) {
1369 var fe = document.getElementById("fatal_error");
1370 var fc = document.getElementById("fatal_error_msg");
1372 fc.innerHTML = "Code " + code + ": " + message;
1374 fe.style.display = "block";
1377 exception_error("fatalError", e);
1381 function getFeedName(id, is_cat) {
1382 var d = getFeedsContext().document;
1387 e = d.getElementById("FCATN-" + id);
1389 e = d.getElementById("FEEDN-" + id);
1392 return e.innerHTML.stripTags();