/* Copyright 2008-2011 Clipperz Srl This file is part of Clipperz's Javascript Crypto Library. Javascript Crypto Library provides web developers with an extensive and efficient set of cryptographic functions. The library aims to obtain maximum execution speed while preserving modularity and reusability. For further information about its features and functionalities please refer to http://www.clipperz.com * Javascript Crypto Library is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * Javascript Crypto Library 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 Affero General Public License for more details. * You should have received a copy of the GNU Affero General Public License along with Javascript Crypto Library. If not, see . */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.Base) == 'undefined') { Clipperz.Base = {}; } Clipperz.Base.VERSION = "0.1"; Clipperz.Base.NAME = "Clipperz.Base"; MochiKit.Base.update(Clipperz.Base, { //------------------------------------------------------------------------- '__repr__': function () { return "[" + this.NAME + " " + this.VERSION + "]"; }, //------------------------------------------------------------------------- 'toString': function () { return this.__repr__(); }, //------------------------------------------------------------------------- 'trim': function (aValue) { return aValue.replace(/^\s+|\s+$/g, ""); }, //------------------------------------------------------------------------- 'stringToByteArray': function (aValue) { var result; var i, c; result = []; c = aValue.length; for (i=0; i -1) { Clipperz.Base.removeObjectAtIndexFromArray(objectIndex, anArray); } else { // jslog.error("Trying to remove an object not present in the array"); // TODO: raise an exception } }, 'removeFromArray': function(anArray, anObject) { return Clipperz.Base.removeObjectFromArray(anObject, anArray); }, //------------------------------------------------------------------------- 'splitStringAtFixedTokenSize': function(aString, aTokenSize) { var result; var stringToProcess; stringToProcess = aString; result = []; if (stringToProcess != null) { while (stringToProcess.length > aTokenSize) { result.push(stringToProcess.substring(0, aTokenSize)); stringToProcess = stringToProcess.substring(aTokenSize); } result.push(stringToProcess); } return result; }, //------------------------------------------------------------------------- 'objectType': function(anObject) { var result; if (anObject == null) { result = null; } else { result = typeof(anObject); if (result == "object") { if (anObject instanceof Array) { result = 'array' } else if (anObject.constructor == Boolean) { result = 'boolean' } else if (anObject instanceof Date) { result = 'date' } else if (anObject instanceof Error) { result = 'error' } else if (anObject instanceof Function) { result = 'function' } else if (anObject.constructor == Number) { result = 'number' } else if (anObject.constructor == String) { result = 'string' } else if (anObject instanceof Object) { result = 'object' } else { throw Clipperz.Base.exception.UnknownType; } } } return result; }, //------------------------------------------------------------------------- 'escapeHTML': function(aValue) { var result; result = aValue; result = result.replace(//g, ">"); return result; }, //------------------------------------------------------------------------- 'deepClone': function(anObject) { var result; result = Clipperz.Base.evalJSON(Clipperz.Base.serializeJSON(anObject)); return result; }, //------------------------------------------------------------------------- 'evalJSON': function(aString) { /* var result; // check for XSS injection if (/