/* * Limb PHP Framework * * @link http://limb-project.com * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) * @license LGPL http://www.gnu.org/copyleft/lesser.html */ if(Limb == undefined) var Limb = {}; Limb.get = function(id) { return document.getElementById(id); } Limb.trim = function(str) { var r = /^\s+|\s+$/; return str.replace(r,''); } if(!String.prototype.trim) { String.prototype.trim = Limb.trim; } if(!Function.prototype.bind) { Function.prototype.bind = function( object, args ) { var __method = this; var __args = args; return function() { __method.apply( object, __args || arguments ); }; }; } if(!Function.prototype.bindAsEventListener) { Function.prototype.bindAsEventListener = function(object) { var __method = this; return function(event) {__method.call(object, event || window.event);}; }; } Limb.Exception = function() { if(arguments.length == 1 && Limb.isObject(arguments[0])) { this.type = arguments[0].type || 'LimbException'; this.message = arguments[0].message; this.stack = arguments[0].stack || 'Stack is not available'; this.file_name = arguments[0].fileName || 'File name is not available'; this.line_number = arguments[0].lineNumber || 'Line number is not available'; } else { this.type = arguments[0] || 'LimbException'; this.message = arguments[1] || 'Unknown error'; if(typeof(arguments[2]) == 'object') { this.stack = arguments[2].stack || e.stack; this.file_name = arguments[2].fileName || e.fileName; this.line_number = arguments[2].lineNumber || e.lineNumber; } else { this.stack = 'Stack is not available'; this.file_name = 'File name is not available'; this.line_number = 'Line number is not available'; } } } Limb.Exception.prototype = { getMessage: function() { return this.message; }, getType: function() { return this.type; }, getStack: function() { return this.stack; }, getFileName: function() { return this.file_name; }, getLineNumber: function() { return this.line_number; }, toString: function() { return '[ exception ' + this.type + ' ]'; } } Limb.define = function(name, value) { var parts = name.split('.'); var var_name = parts.pop(); var namespace = Limb.namespace(parts.join('.')); namespace[var_name] = value; } Limb.namespace = function(name) { var parts = name.split('.'); var parent = window; for(var i=0; i