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 */
23 // TODO: replace things with Prototype where applicable
27 function ml_stripActionInURL(url) {
28 if (url[url.length - 1] != '/') {
31 i = url.lastIndexOf("/");
32 if (i != -1) url = url.substring(0, i);
34 if (url[url.length - 1] != '/') // ensure trailing slash
42 "([a-zA-Z0-9][a-zA-Z0-9_.-]*|\"([^\\\\\x80-\xff\015\012\"]|\\\\[^\x80-\xff])+\")";
44 "([a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*[a-zA-Z0-9][a-zA-Z0-9._-]*\\.[a-zA-Z]{2,5}";
45 var uixEmailRegex = new RegExp("^"+uixEmailUsr+"\@"+uixEmailDomain+"$");
49 function escapeHTML(s) {
50 s = s.replace(/&/g, "&");
51 s = s.replace(/</g, "<");
52 s = s.replace(/>/g, ">");
53 s = s.replace(/"/g, """);
56 function unescapeHTML(s) {
57 s = s.replace(/</g, "<");
58 s = s.replace(/>/g, ">");
59 s = s.replace(/"/g, '"');
60 s = s.replace(/&/g, "&");
64 function createHTTPClient() {
65 // http://developer.apple.com/internet/webcontent/xmlhttpreq.html
66 if (typeof XMLHttpRequest != "undefined")
67 return new XMLHttpRequest();
69 try { return new ActiveXObject("Msxml2.XMLHTTP"); }
71 try { return new ActiveXObject("Microsoft.XMLHTTP"); }
76 function resetSelection(win) {
78 if (win && win.getSelection) {
79 t = win.getSelection().toString();
80 win.getSelection().removeAllRanges();
85 function refreshOpener() {
86 if (window.opener && !window.opener.closed) {
87 window.opener.location.reload();
93 function parseQueryString() {
94 var queryArray, queryDict
95 var key, value, s, idx;
98 queryDict = new Array();
99 queryArray = location.search.substr(1).split('&');
100 for (var i in queryArray) {
101 if (!queryArray[i]) continue ;
103 idx = s.indexOf("=");
109 key = s.substr(0, idx);
110 value = unescape(s.substr(idx + 1));
113 if (typeof queryDict[key] == 'undefined')
116 queryDict[key] = value;
121 function generateQueryString(queryDict) {
123 for (var key in queryDict) {
128 s = s + key + "=" + escape(queryDict[key]);
133 function getQueryParaArray(s) {
134 if (s.charAt(0) == "?") s = s.substr(1, s.length - 1);
137 function getQueryParaValue(s, name) {
140 t = getQueryParaArray(s);
141 for (var i = 0; i < t.length; i++) {
144 if (s.indexOf(name) != 0)
147 s = s.substr(name.length, s.length - name.length);
148 return decodeURIComponent(s);
153 /* opener callback */
155 function triggerOpenerCallback() {
156 /* this code has some issue if the folder has no proper trailing slash! */
157 if (window.opener && !window.opener.closed) {
160 t = getQueryParaValue(window.location.search, "openerurl=");
161 cburl = window.opener.location.href;
162 if (cburl[cburl.length - 1] != "/") {
163 cburl = cburl.substr(0, cburl.lastIndexOf("/") + 1);
166 window.opener.location.href = cburl;