]> git.wh0rd.org - tt-rss.git/blob - functions.js
fix no old password prompt
[tt-rss.git] / functions.js
1 var hotkeys_enabled = true;
2
3 function browser_has_opacity() {
4 return navigator.userAgent.match("Gecko") != null ||
5 navigator.userAgent.match("Opera") != null;
6 }
7
8 function exception_error(location, e) {
9 var msg;
10
11 if (e.fileName) {
12 var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1);
13
14 msg = "Exception: " + e.name + ", " + e.message +
15 "\nFunction: " + location + "()" +
16 "\nLocation: " + base_fname + ":" + e.lineNumber;
17 } else {
18 msg = "Exception: " + e + "\nFunction: " + location + "()";
19 }
20
21 alert(msg);
22 }
23
24 function disableHotkeys() {
25 hotkeys_enabled = false;
26 }
27
28 function enableHotkeys() {
29 hotkeys_enabled = true;
30 }
31
32 function xmlhttp_ready(obj) {
33 return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState;
34 }
35
36 function notify_callback() {
37 var container = document.getElementById('notify');
38 if (xmlhttp.readyState == 4) {
39 container.innerHTML=xmlhttp.responseText;
40 }
41 }
42
43 function rpc_notify_callback() {
44 var container = document.getElementById('notify');
45 if (xmlhttp_rpc.readyState == 4) {
46 container.innerHTML=xmlhttp_rpc.responseText;
47 }
48 }
49
50 function rpc_pnotify_callback() {
51 var container = parent.document.getElementById('notify');
52 if (xmlhttp_rpc.readyState == 4) {
53 container.innerHTML=xmlhttp_rpc.responseText;
54 }
55 }
56
57 function param_escape(arg) {
58 if (typeof encodeURIComponent != 'undefined')
59 return encodeURIComponent(arg);
60 else
61 return escape(arg);
62 }
63
64 function param_unescape(arg) {
65 if (typeof decodeURIComponent != 'undefined')
66 return decodeURIComponent(arg);
67 else
68 return unescape(arg);
69 }
70
71 function delay(gap) {
72 var then,now;
73 then=new Date().getTime();
74 now=then;
75 while((now-then)<gap) {
76 now=new Date().getTime();
77 }
78 }
79
80 var notify_hide_timerid = false;
81 var notify_last_doc = false;
82
83 function hide_notify() {
84 if (notify_last_doc) {
85 var n = notify_last_doc.getElementById("notify");
86 if (browser_has_opacity()) {
87 if (notify_opacity >= 0) {
88 notify_opacity = notify_opacity - 0.1;
89 n.style.opacity = notify_opacity;
90 notify_hide_timerid = window.setTimeout("hide_notify()", 20);
91 } else {
92 n.style.display = "none";
93 n.style.opacity = 1;
94 }
95 } else {
96 n.style.display = "none";
97 }
98 }
99 }
100
101 function notify_real(msg, doc, no_hide, is_err) {
102
103 var n = doc.getElementById("notify");
104 var nb = doc.getElementById("notify_body");
105
106 if (!n || !nb) return;
107
108 if (notify_hide_timerid) {
109 window.clearTimeout(notify_hide_timerid);
110 }
111
112 notify_last_doc = doc;
113 notify_opacity = 1;
114
115 if (msg == "") {
116 if (n.style.display == "block") {
117 notify_hide_timerid = window.setTimeout("hide_notify()", 0);
118 }
119 return;
120 } else {
121 n.style.display = "block";
122 }
123
124 if (is_err) {
125 n.style.backgroundColor = "#ffcccc";
126 n.style.color = "black";
127 n.style.borderColor = "#ff0000";
128 } else {
129 n.style.backgroundColor = "#fff7d5";
130 n.style.borderColor = "#d7c47a";
131 n.style.color = "black";
132 }
133
134 nb.innerHTML = msg;
135
136 if (!no_hide) {
137 notify_hide_timerid = window.setTimeout("hide_notify()", 3000);
138 }
139 }
140
141 function p_notify(msg, no_hide, is_err) {
142 notify_real(msg, parent.document, no_hide, is_err);
143 }
144
145 function notify(msg, no_hide, is_err) {
146 notify_real(msg, document, no_hide, is_err);
147 }
148
149 function printLockingError() {
150 notify("Please wait until operation finishes");}
151
152 var seq = "";
153
154 function hotkey_handler(e) {
155
156 var keycode;
157
158 if (!hotkeys_enabled) return;
159
160 if (window.event) {
161 keycode = window.event.keyCode;
162 } else if (e) {
163 keycode = e.which;
164 }
165
166 if (keycode == 13 || keycode == 27) {
167 seq = "";
168 } else {
169 seq = seq + "" + keycode;
170 }
171
172 if (document.getElementById("piggie")) {
173
174 if (seq.match("807371717369")) {
175 seq = "";
176 localPiggieFunction(true);
177 } else {
178 localPiggieFunction(false);
179 }
180 }
181
182 if (typeof localHotkeyHandler != 'undefined') {
183 try {
184 localHotkeyHandler(keycode);
185 } catch (e) {
186 exception_error("hotkey_handler", e);
187 }
188 }
189
190 }
191
192 function cleanSelectedList(element) {
193 var content = document.getElementById(element);
194
195 if (!document.getElementById("feedCatHolder")) {
196 for (i = 0; i < content.childNodes.length; i++) {
197 var child = content.childNodes[i];
198 try {
199 child.className = child.className.replace("Selected", "");
200 } catch (e) {
201 //
202 }
203 }
204 } else {
205 for (i = 0; i < content.childNodes.length; i++) {
206 var child = content.childNodes[i];
207 if (child.id == "feedCatHolder") {
208 parent.debug(child.id);
209 var fcat = child.lastChild;
210 for (j = 0; j < fcat.childNodes.length; j++) {
211 var feed = fcat.childNodes[j];
212 feed.className = feed.className.replace("Selected", "");
213 }
214 }
215 }
216 }
217 }
218
219
220 function cleanSelected(element) {
221 var content = document.getElementById(element);
222
223 for (i = 0; i < content.rows.length; i++) {
224 content.rows[i].className = content.rows[i].className.replace("Selected", "");
225 }
226 }
227
228 function getVisibleUnreadHeadlines() {
229 var content = document.getElementById("headlinesList");
230
231 var rows = new Array();
232
233 for (i = 0; i < content.rows.length; i++) {
234 var row_id = content.rows[i].id.replace("RROW-", "");
235 if (row_id.length > 0 && content.rows[i].className.match("Unread")) {
236 rows.push(row_id);
237 }
238 }
239 return rows;
240 }
241
242 function getVisibleHeadlineIds() {
243
244 var content = document.getElementById("headlinesList");
245
246 var rows = new Array();
247
248 for (i = 0; i < content.rows.length; i++) {
249 var row_id = content.rows[i].id.replace("RROW-", "");
250 if (row_id.length > 0) {
251 rows.push(row_id);
252 }
253 }
254 return rows;
255 }
256
257 function getFirstVisibleHeadlineId() {
258 var rows = getVisibleHeadlineIds();
259 return rows[0];
260 }
261
262 function getLastVisibleHeadlineId() {
263 var rows = getVisibleHeadlineIds();
264 return rows[rows.length-1];
265 }
266
267 function markHeadline(id) {
268 var row = document.getElementById("RROW-" + id);
269 if (row) {
270 var is_active = false;
271
272 if (row.className.match("Active")) {
273 is_active = true;
274 }
275 row.className = row.className.replace("Selected", "");
276 row.className = row.className.replace("Active", "");
277 row.className = row.className.replace("Insensitive", "");
278
279 if (is_active) {
280 row.className = row.className = "Active";
281 }
282
283 var check = document.getElementById("RCHK-" + id);
284
285 if (check) {
286 check.checked = true;
287 }
288
289 row.className = row.className + "Selected";
290
291 }
292 }
293
294 function getFeedIds() {
295 var content = document.getElementById("feedsList");
296
297 var rows = new Array();
298
299 for (i = 0; i < content.rows.length; i++) {
300 var id = content.rows[i].id.replace("FEEDR-", "");
301 if (id.length > 0) {
302 rows.push(id);
303 }
304 }
305
306 return rows;
307 }
308
309 function setCookie(name, value, lifetime, path, domain, secure) {
310
311 var d = false;
312
313 if (lifetime) {
314 d = new Date();
315 d.setTime(lifetime * 1000);
316 }
317
318 int_setCookie(name, value, d, path, domain, secure);
319
320 }
321
322 function int_setCookie(name, value, expires, path, domain, secure) {
323 document.cookie= name + "=" + escape(value) +
324 ((expires) ? "; expires=" + expires.toGMTString() : "") +
325 ((path) ? "; path=" + path : "") +
326 ((domain) ? "; domain=" + domain : "") +
327 ((secure) ? "; secure" : "");
328 }
329
330 function delCookie(name, path, domain) {
331 if (getCookie(name)) {
332 document.cookie = name + "=" +
333 ((path) ? ";path=" + path : "") +
334 ((domain) ? ";domain=" + domain : "" ) +
335 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
336 }
337 }
338
339
340 function getCookie(name) {
341
342 var dc = document.cookie;
343 var prefix = name + "=";
344 var begin = dc.indexOf("; " + prefix);
345 if (begin == -1) {
346 begin = dc.indexOf(prefix);
347 if (begin != 0) return null;
348 }
349 else {
350 begin += 2;
351 }
352 var end = document.cookie.indexOf(";", begin);
353 if (end == -1) {
354 end = dc.length;
355 }
356 return unescape(dc.substring(begin + prefix.length, end));
357 }
358
359 function disableContainerChildren(id, disable, doc) {
360
361 if (!doc) doc = document;
362
363 var container = doc.getElementById(id);
364
365 for (var i = 0; i < container.childNodes.length; i++) {
366 var child = container.childNodes[i];
367
368 try {
369 child.disabled = disable;
370 } catch (E) {
371
372 }
373
374 if (disable) {
375 if (child.className && child.className.match("button")) {
376 child.className = "disabledButton";
377 }
378 } else {
379 if (child.className && child.className.match("disabledButton")) {
380 child.className = "button";
381 }
382 }
383 }
384
385 }
386
387 function gotoPreferences() {
388 document.location.href = "prefs.php";
389 }
390
391 function gotoMain() {
392 document.location.href = "tt-rss.php";
393 }
394
395 function gotoExportOpml() {
396 document.location.href = "opml.php?op=Export";
397 }
398
399 function getActiveFeedId() {
400 return getCookie("ttrss_vf_actfeed");
401 }
402
403 function setActiveFeedId(id) {
404 return setCookie("ttrss_vf_actfeed", id);
405 }
406
407 var xmlhttp_rpc = Ajax.getTransport();
408
409 function parse_counters(reply, f_document, title_obj, scheduled_call) {
410 try {
411 for (var l = 0; l < reply.childNodes.length; l++) {
412 if (!reply.childNodes[l] ||
413 typeof(reply.childNodes[l].getAttribute) == "undefined") {
414 // where did this come from?
415 continue;
416 }
417
418 var id = reply.childNodes[l].getAttribute("id");
419 var t = reply.childNodes[l].getAttribute("type");
420 var ctr = reply.childNodes[l].getAttribute("counter");
421 var error = reply.childNodes[l].getAttribute("error");
422 var has_img = reply.childNodes[l].getAttribute("hi");
423 var updated = reply.childNodes[l].getAttribute("updated");
424
425 if (id == "global-unread") {
426 title_obj.global_unread = ctr;
427 title_obj.updateTitle();
428 continue;
429 }
430
431 if (t == "category") {
432 var catctr = f_document.getElementById("FCATCTR-" + id);
433 if (catctr) {
434 catctr.innerHTML = "(" + ctr + " unread)";
435 }
436 continue;
437 }
438
439 var feedctr = f_document.getElementById("FEEDCTR-" + id);
440 var feedu = f_document.getElementById("FEEDU-" + id);
441 var feedr = f_document.getElementById("FEEDR-" + id);
442 var feed_img = f_document.getElementById("FIMG-" + id);
443 var feedlink = f_document.getElementById("FEEDL-" + id);
444
445 if (updated && feedlink) {
446 if (error) {
447 feedlink.title = "Error: " + error + " (" + updated + ")";
448 } else {
449 feedlink.title = "Updated: " + updated;
450 }
451 }
452
453 if (feedctr && feedu && feedr) {
454
455 if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) {
456 var hf = title_obj.parent.frames["headlines-frame"];
457 hf.location.reload(true);
458 }
459
460 feedu.innerHTML = ctr;
461
462 if (error) {
463 feedr.className = feedr.className.replace("feed", "error");
464 } else if (id > 0) {
465 feedr.className = feedr.className.replace("error", "feed");
466 }
467
468 if (ctr > 0) {
469 feedctr.className = "odd";
470 if (!feedr.className.match("Unread")) {
471 var is_selected = feedr.className.match("Selected");
472
473 feedr.className = feedr.className.replace("Selected", "");
474 feedr.className = feedr.className.replace("Unread", "");
475
476 feedr.className = feedr.className + "Unread";
477
478 if (is_selected) {
479 feedr.className = feedr.className + "Selected";
480 }
481
482 }
483 } else {
484 feedctr.className = "invisible";
485 feedr.className = feedr.className.replace("Unread", "");
486 }
487 }
488 }
489 } catch (e) {
490 exception_error("parse_counters", e);
491 }
492 }
493
494 // this one is called from feedlist context
495 // thus title_obj passed to parse_counters is parent (e.g. main ttrss window)
496
497 function all_counters_callback() {
498 if (xmlhttp_rpc.readyState == 4) {
499 try {
500 if (!xmlhttp_rpc.responseXML || !xmlhttp_rpc.responseXML.firstChild) {
501 notify("[all_counters_callback] backend did not return valid XML");
502 return;
503 }
504
505 if (!parent.frames["feeds-frame"]) {
506 notify("[all_counters_callback] no parent feeds-frame");
507 return;
508 }
509
510 var reply = xmlhttp_rpc.responseXML.firstChild;
511 var f_document = parent.frames["feeds-frame"].document;
512
513 parse_counters(reply, f_document, parent);
514
515 } catch (e) {
516 exception_error("all_counters_callback", e);
517 }
518 }
519 }
520
521 function update_all_counters(feed) {
522 if (xmlhttp_ready(xmlhttp_rpc)) {
523 var query = "backend.php?op=rpc&subop=getAllCounters";
524
525 if (feed > 0) {
526 query = query + "&aid=" + feed;
527 }
528
529 xmlhttp_rpc.open("GET", query, true);
530 xmlhttp_rpc.onreadystatechange=all_counters_callback;
531 xmlhttp_rpc.send(null);
532 }
533 }
534
535 function popupHelp(tid) {
536 var w = window.open("backend.php?op=help&tid=" + tid,
537 "Popup Help",
538 "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
539 }
540
541 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
542 * * @author Sundar Dorai-Raj
543 * * Email: sdoraira@vt.edu
544 * * This program is free software; you can redistribute it and/or
545 * * modify it under the terms of the GNU General Public License
546 * * as published by the Free Software Foundation; either version 2
547 * * of the License, or (at your option) any later version,
548 * * provided that any use properly credits the author.
549 * * This program is distributed in the hope that it will be useful,
550 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
551 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
552 * * GNU General Public License for more details at http://www.gnu.org * * */
553
554 var numbers=".0123456789";
555 function isNumeric(x) {
556 // is x a String or a character?
557 if(x.length>1) {
558 // remove negative sign
559 x=Math.abs(x)+"";
560 for(j=0;j<x.length;j++) {
561 // call isNumeric recursively for each character
562 number=isNumeric(x.substring(j,j+1));
563 if(!number) return number;
564 }
565 return number;
566 }
567 else {
568 // if x is number return true
569 if(numbers.indexOf(x)>=0) return true;
570 return false;
571 }
572 }
573
574
575 function hideOrShowFeeds(doc, hide) {
576
577 if (!doc.styleSheets) return;
578
579 var css_rules = doc.styleSheets[0].cssRules;
580
581 if (!css_rules || !css_rules.length) return;
582
583 for (i = 0; i < css_rules.length; i++) {
584 var rule = css_rules[i];
585
586 if (rule.selectorText == "ul.feedList li.feed") {
587 if (!hide) {
588 rule.style.display = "block";
589 } else {
590 rule.style.display = "none";
591 }
592 }
593
594 }
595
596 }
597
598 function selectTableRow(r, do_select) {
599 r.className = r.className.replace("Selected", "");
600
601 if (do_select) {
602 r.className = r.className + "Selected";
603 }
604 }
605
606 function selectTableRowById(elem_id, check_id, do_select) {
607
608 try {
609
610 var row = document.getElementById(elem_id);
611
612 if (row) {
613 selectTableRow(row, do_select);
614 }
615
616 var check = document.getElementById(check_id);
617
618 if (check) {
619 check.checked = do_select;
620 }
621 } catch (e) {
622 exception_error("selectTableRowById", e);
623 }
624 }
625
626 function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select,
627 classcheck, reset_others) {
628
629 var content = document.getElementById(content_id);
630
631 if (!content) {
632 alert("[selectTableRows] Element " + content_id + " not found.");
633 return;
634 }
635
636 for (i = 0; i < content.rows.length; i++) {
637 if (!classcheck || content.rows[i].className.match(classcheck)) {
638
639 if (content.rows[i].id.match(prefix)) {
640 selectTableRow(content.rows[i], do_select);
641
642 var row_id = content.rows[i].id.replace(prefix, "");
643 var check = document.getElementById(check_prefix + row_id);
644
645 if (check) {
646 check.checked = do_select;
647 }
648 } else if (reset_others) {
649 selectTableRow(content.rows[i], false);
650
651 var row_id = content.rows[i].id.replace(prefix, "");
652 var check = document.getElementById(check_prefix + row_id);
653
654 if (check) {
655 check.checked = false;
656 }
657
658 }
659 } else if (reset_others) {
660 selectTableRow(content.rows[i], false);
661
662 var row_id = content.rows[i].id.replace(prefix, "");
663 var check = document.getElementById(check_prefix + row_id);
664
665 if (check) {
666 check.checked = false;
667 }
668
669 }
670 }
671 }
672
673 function getSelectedTableRowIds(content_id, prefix) {
674
675 var content = document.getElementById(content_id);
676
677 if (!content) {
678 alert("[getSelectedTableRowIds] Element " + content_id + " not found.");
679 return;
680 }
681
682 var sel_rows = new Array();
683
684 for (i = 0; i < content.rows.length; i++) {
685 if (content.rows[i].id.match(prefix) &&
686 content.rows[i].className.match("Selected")) {
687
688 var row_id = content.rows[i].id.replace(prefix + "-", "");
689 sel_rows.push(row_id);
690 }
691 }
692
693 return sel_rows;
694
695 }
696
697 function toggleSelectRowById(sender, id) {
698 var row = document.getElementById(id);
699
700 if (sender.checked) {
701 if (!row.className.match("Selected")) {
702 row.className = row.className + "Selected";
703 }
704 } else {
705 if (row.className.match("Selected")) {
706 row.className = row.className.replace("Selected", "");
707 }
708 }
709 }
710
711 function toggleSelectListRow(sender) {
712 var parent_row = sender.parentNode;
713
714 if (sender.checked) {
715 if (!parent_row.className.match("Selected")) {
716 parent_row.className = parent_row.className + "Selected";
717 }
718 } else {
719 if (parent_row.className.match("Selected")) {
720 parent_row.className = parent_row.className.replace("Selected", "");
721 }
722 }
723 }
724
725
726 function toggleSelectRow(sender) {
727 var parent_row = sender.parentNode.parentNode;
728
729 if (sender.checked) {
730 if (!parent_row.className.match("Selected")) {
731 parent_row.className = parent_row.className + "Selected";
732 }
733 } else {
734 if (parent_row.className.match("Selected")) {
735 parent_row.className = parent_row.className.replace("Selected", "");
736 }
737 }
738 }
739
740 function openExternalUrl(url) {
741 var w = window.open(url);
742 }
743
744 function getRelativeFeedId(list, id, direction, unread_only) {
745 if (!id) {
746 if (direction == "next") {
747 for (i = 0; i < list.childNodes.length; i++) {
748 var child = list.childNodes[i];
749 if (child.id && child.id == "feedCatHolder") {
750 if (child.lastChild) {
751 var cr = getRelativeFeedId(child.firstChild, id, direction);
752 if (cr) return cr;
753 }
754 } else if (child.id && child.id.match("FEEDR-")) {
755 return child.id.replace('FEEDR-', '');
756 }
757 }
758 }
759
760 // FIXME select last feed doesn't work when only unread feeds are visible
761
762 if (direction == "prev") {
763 for (i = list.childNodes.length-1; i >= 0; i--) {
764 var child = list.childNodes[i];
765 if (child.id == "feedCatHolder") {
766 if (child.firstChild) {
767 var cr = getRelativeFeedId(child.firstChild, id, direction);
768 if (cr) return cr;
769 }
770 } else if (child.id.match("FEEDR-")) {
771
772 if (getCookie("ttrss_vf_hreadf") == 1) {
773 if (child.className != "feed") {
774 alert(child.className);
775 return child.id.replace('FEEDR-', '');
776 }
777 } else {
778 return child.id.replace('FEEDR-', '');
779 }
780 }
781 }
782 }
783 } else {
784
785 var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId());
786
787 if (getCookie("ttrss_vf_hreadf") == 1) {
788 unread_only = true;
789 }
790
791 if (direction == "next") {
792
793 var e = feed;
794
795 while (e) {
796
797 if (e.nextSibling) {
798
799 e = e.nextSibling;
800
801 } else if (e.parentNode.parentNode.nextSibling) {
802
803 var this_cat = e.parentNode.parentNode;
804
805 e = false;
806
807 if (this_cat && this_cat.nextSibling) {
808 while (!e && this_cat.nextSibling) {
809 this_cat = this_cat.nextSibling;
810 if (this_cat.id == "feedCatHolder") {
811 e = this_cat.firstChild.firstChild;
812 }
813 }
814 }
815
816 } else {
817 e = false;
818 }
819
820 if (e) {
821 if (!unread_only || (unread_only && e.className != "feed" &&
822 e.className != "error")) {
823 return e.id.replace("FEEDR-", "");
824 }
825 }
826 }
827
828 } else if (direction == "prev") {
829
830 var e = feed;
831
832 while (e) {
833
834 if (e.previousSibling) {
835
836 e = e.previousSibling;
837
838 } else if (e.parentNode.parentNode.previousSibling) {
839
840 var this_cat = e.parentNode.parentNode;
841
842 e = false;
843
844 if (this_cat && this_cat.previousSibling) {
845 while (!e && this_cat.previousSibling) {
846 this_cat = this_cat.previousSibling;
847 if (this_cat.id == "feedCatHolder") {
848 e = this_cat.firstChild.lastChild;
849 }
850 }
851 }
852
853 } else {
854 e = false;
855 }
856
857 if (e) {
858 if (!unread_only || (unread_only && e.className != "feed" &&
859 e.className != "error")) {
860 return e.id.replace("FEEDR-", "");
861 }
862 }
863 }
864 }
865 }
866 }
867
868 function showBlockElement(id) {
869 var elem = document.getElementById(id);
870
871 if (elem) {
872 elem.style.display = "block";
873 } else {
874 alert("[showBlockElement] can't find element with id " + id);
875 }
876 }
877
878 function hideParentElement(e) {
879 e.parentNode.style.display = "none";
880 }
881
882 function dropboxSelect(e, v) {
883 for (i = 0; i < e.length; i++) {
884 if (e[i].value == v) {
885 e.selectedIndex = i;
886 break;
887 }
888 }
889 }
890
891 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
892 // bugfixed just a little bit :-)
893 function getURLParam(strParamName){
894 var strReturn = "";
895 var strHref = window.location.href;
896
897 if (strHref.indexOf("#") == strHref.length-1) {
898 strHref = strHref.substring(0, strHref.length-1);
899 }
900
901 if ( strHref.indexOf("?") > -1 ){
902 var strQueryString = strHref.substr(strHref.indexOf("?"));
903 var aQueryString = strQueryString.split("&");
904 for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
905 if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
906 var aParam = aQueryString[iParam].split("=");
907 strReturn = aParam[1];
908 break;
909 }
910 }
911 }
912 return strReturn;
913 }
914
915 function leading_zero(p) {
916 var s = String(p);
917 if (s.length == 1) s = "0" + s;
918 return s;
919 }
920
921 function closeInfoBox() {
922 var box = document.getElementById('infoBox');
923 var shadow = document.getElementById('infoBoxShadow');
924
925 if (shadow) {
926 shadow.style.display = "none";
927 } else if (box) {
928 box.style.display = "none";
929 }
930
931 enableHotkeys();
932
933 }
934
935
936 function displayDlg(id, param) {
937
938 if (!xmlhttp_ready(xmlhttp)) {
939 printLockingError();
940 return
941 }
942
943 notify("");
944
945 xmlhttp.open("GET", "backend.php?op=dlg&id=" +
946 param_escape(id) + "&param=" + param_escape(param), true);
947 xmlhttp.onreadystatechange=infobox_callback;
948 xmlhttp.send(null);
949
950 disableHotkeys();
951
952 }
953
954 function infobox_submit_callback() {
955 if (xmlhttp.readyState == 4) {
956 closeInfoBox();
957
958 // called from prefs, reload tab
959 if (active_tab) {
960 selectTab(active_tab, false);
961 }
962
963 notify(xmlhttp.responseText);
964
965 }
966 }
967
968 function infobox_callback() {
969 if (xmlhttp.readyState == 4) {
970 var box = document.getElementById('infoBox');
971 var shadow = document.getElementById('infoBoxShadow');
972 if (box) {
973 box.innerHTML=xmlhttp.responseText;
974 if (shadow) {
975 shadow.style.display = "block";
976 } else {
977 box.style.display = "block";
978 }
979 }
980 }
981 }
982
983 function qaddFilter() {
984
985 if (!xmlhttp_ready(xmlhttp)) {
986 printLockingError();
987 return
988 }
989
990 var query = Form.serialize("filter_add_form");
991
992 xmlhttp.open("GET", "backend.php?" + query, true);
993 xmlhttp.onreadystatechange=infobox_submit_callback;
994 xmlhttp.send(null);
995
996 return true;
997 }
998
999 function toggleSubmitNotEmpty(e, submit_id) {
1000 try {
1001 document.getElementById(submit_id).disabled = (e.value == "")
1002 } catch (e) {
1003 exception_error("toggleSubmitNotEmpty", e);
1004 }
1005 }
1006
1007 function isValidURL(s) {
1008 return s.match("http://") != null || s.match("https://") != null;
1009 }