davadmin/admin/scripts/helper.js
Jan Dittberner 581b0dc90f addresses #14
* include copyright and license information in all necessary files
 * update version to 0.2
 * add svn:keywords properties
2007-11-26 08:49:33 +00:00

52 lines
1.6 KiB
JavaScript

/**
* Helper code. Ideas from Drupal (http://drupal.org/).
*
* @author Jan Dittberner <jan@dittberner.info>
* @version $Id$
* @license GPL
* @package DAVAdmin
*
* Copyright (c) 2007 Jan Dittberner
*
* This file is part of DAVAdmin.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
var DAV = DAV || {};
/**
* Parse a JSON response.
*
* The result is either the JSON object, or an object with 'status' 0 and
* 'data' an error message.
*/
DAV.parseJson = function (data) {
if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
return { status: 0, data: data.length ? data : 'Unspecified error' };
}
return eval('(' + data + ');');
};
/**
* Wrapper to address the mod_rewrite url encoding bug.
*/
DAV.encodeURIComponent = function (item, uri) {
uri = uri || location.href;
item = encodeURIComponent(item).replace('%2F', '/');
return uri.indexOf('?q=') ? item : item.replace('%26', '%2526').replace('%23', '%2523');
};