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();
81 function parseQueryString() {
82 var queryArray, queryDict
83 var key, value, s, idx;
86 queryDict = new Array();
87 queryArray = location.search.substr(1).split('&');
88 for (var i in queryArray) {
89 if (!queryArray[i]) continue ;
97 key = s.substr(0, idx);
98 value = unescape(s.substr(idx + 1));
101 if (typeof queryDict[key] == 'undefined')
104 queryDict[key] = value;
109 function generateQueryString(queryDict) {
111 for (var key in queryDict) {
116 s = s + key + "=" + escape(queryDict[key]);
121 function getQueryParaArray(s) {
122 if (s.charAt(0) == "?") s = s.substr(1, s.length - 1);
125 function getQueryParaValue(s, name) {
128 t = getQueryParaArray(s);
129 for (var i = 0; i < t.length; i++) {
132 if (s.indexOf(name) != 0)
135 s = s.substr(name.length, s.length - name.length);
136 return decodeURIComponent(s);
141 /* opener callback */
143 function triggerOpenerCallback() {
144 /* this code has some issue if the folder has no proper trailing slash! */
145 if (window.opener && !window.opener.closed) {
148 t = getQueryParaValue(window.location.search, "openerurl=");
149 cburl = window.opener.location.href;
150 if (cburl[cburl.length - 1] != "/") {
151 cburl = cburl.substr(0, cburl.lastIndexOf("/") + 1);
154 window.opener.location.href = cburl;