29 lines
727 B
JavaScript
29 lines
727 B
JavaScript
// $Id$
|
|
|
|
/**
|
|
* Helper code. Ideas from Drupal.
|
|
*/
|
|
|
|
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');
|
|
};
|