/* Copyright 2008-2013 Clipperz Srl This file is part of Clipperz, the online password manager. For further information about its features and functionalities please refer to http://www.clipperz.com. * Clipperz 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. * Clipperz 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 Clipperz. If not, see http://www.gnu.org/licenses/. */ 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 (/