3 // Copyright (c) 2009 Kyle Banker
4 // Licensed under the MIT licence.
5 // http://www.opensource.org/licenses/mit-license.php
7 // extending array like this is breaking datatables
9 /*Array.prototype.include = function(value) {
10 for(var i=0; i < this.length; i++) {
11 if(this[i] == value) {
18 Array.prototype.empty = function() {
19 return (this.length == 0);
22 function ArrayInclude(arr,value) {
23 for(var i=0; i < arr.length; i++) {
31 Function.prototype.bind = function() {
32 var __method = this, object = arguments[0], args = [];
34 for(i = 1; i < arguments.length; i++) {
35 args.push(arguments[i]);
39 return __method.apply(object, args);
43 String.prototype.trim = function() {
44 return this.replace(/^\s+|\s+$/g,"");
47 // Prints javascript types as readable strings.
48 Inspect = function(obj) {
49 if(typeof(obj) != 'object') {
53 else if (obj instanceof Array) {
55 for(var prop in obj) {
56 if(obj.hasOwnProperty(prop)) {
57 objRep.push(obj[prop]);
60 return '[' + objRep.join(', ') + ']';
65 for(var prop in obj) {
66 if(obj.hasOwnProperty(prop)) {
67 objRep.push(prop + ': ' + ((typeof(obj[prop]) == 'object') ? Inspect(obj[prop]) : obj[prop]));
70 return '{' + objRep.join(', ') + '}';
74 // Prints an array of javascript objects.
75 CollectionInspect = function(coll) {
77 for(var i=0; i<coll.length; i++) {
78 str += Inspect(coll[i]) + '<br />';