2 Copyright (C) 2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 /* some generic JavaScript code for SOGo */
25 function ml_stripActionInURL(url) {
26 if (url[url.length - 1] != '/') {
29 i = url.lastIndexOf("/");
30 if (i != -1) url = url.substring(0, i);
32 if (url[url.length - 1] != '/') // ensure trailing slash
37 function escapeHTML(s) {
38 s = s.replace(/&/g, "&");
39 s = s.replace(/</g, "<");
40 s = s.replace(/>/g, ">");
41 s = s.replace(/"/g, """);
44 function unescapeHTML(s) {
45 s = s.replace(/</g, "<");
46 s = s.replace(/>/g, ">");
47 s = s.replace(/"/g, '"');
48 s = s.replace(/&/g, "&");
52 function createHTTPClient() {
53 // http://developer.apple.com/internet/webcontent/xmlhttpreq.html
54 if (typeof XMLHttpRequest != "undefined")
55 return new XMLHttpRequest();
57 try { return new ActiveXObject("Msxml2.XMLHTTP"); }
59 try { return new ActiveXObject("Microsoft.XMLHTTP"); }
64 function resetSelection(win) {
66 if (win && win.getSelection) {
67 t = win.getSelection().toString();
68 win.getSelection().removeAllRanges();
73 function refreshOpener() {
74 if (window.opener && !window.opener.closed) {
75 window.opener.location.reload();
79 function getQueryParaArray(s) {
80 if (s.charAt(0) == "?") s = s.substr(1, s.length - 1);
83 function getQueryParaValue(s, name) {
86 t = getQueryParaArray(s);
87 for (var i = 0; i < t.length; i++) {
90 if (s.indexOf(name) != 0)
93 s = s.substr(name.length, s.length - name.length);
94 return decodeURIComponent(s);
99 function triggerOpenerCallback() {
100 /* this code has some issue if the folder has no proper trailing slash! */
101 if (window.opener && !window.opener.closed) {
104 t = getQueryParaValue(window.location.search, "openerurl=");
105 cburl = window.opener.location.href;
106 if (cburl[cburl.length - 1] != "/") {
107 cburl = cburl.substr(0, cburl.lastIndexOf("/") + 1);
110 window.opener.location.href = cburl;