1 
  2 ////////////////////////////////////////////////////////////////////////////////
  3 /**
  4  * @fileOverview Copyright (C) 2009 www.webis.de<br/>
  5  * A central space where all extension to native JavaScript objects and functions.
  6  * @author Christof Braeutigam christof.braeutigam@uni-weimar.de
  7  * @author Alexander Kuemmel alexander.kuemmel@uni-weimar.de
  8  * @author Christian Fricke christian.fricke@uni-weimar.de
  9  * @version 0.1
 10  */
 11 // info: provides additional methods for JavaScript built-in objects,
 12 //       to be used with great caution
 13 
 14 // extensions to Object
 15 /*
 16  * Inherits all methods of superClass into current class
 17  * http://www.ailis.de/~k/archives/20-OOP-with-JavaScript.html
 18  */
 19 /*
 20  Object.prototype.inherit = function (superClass) {
 21  var tmpClass = function () {};
 22  tmpClass.prototype = superClass.prototype;
 23  this.prototype = new tmpClass();
 24  };
 25  */
 26 /*
 27  Object.prototype.length = function () {
 28  var len = 0;
 29  for (var i in this) {
 30  if (this.hasOwnProperty(i)) len++;
 31  }
 32  return len;
 33  };
 34  */
 35 // deepCopy clones every key of an Object,
 36 // iterating through all keys, regardless of how the object / array is used.
 37 // For debugging purposes: private members will not be printed, ever.
 38 // Will not work for any other type, NOT even Function.
 39 
 40 /*
 41  Object.prototype.deepCopy = function () {
 42  if (this instanceof Array) { var newObj = []; }
 43  else { var newObj = {}; }
 44  
 45  for (var i in this) {
 46  if (typeof(this[i]) === "object") {
 47  if (this[i] instanceof Array) {
 48  newObj[i] = [];
 49  
 50  for (var j = 0; j < this[i].length; j++) {
 51  if (typeof(this[i]) === "object") {
 52  newObj[i].push(this[i][j].deepCopy);
 53  } else { newObj[i].push(this[i][j]); }
 54  }
 55  } else { newObj[i] = this[i].deepCopy; }
 56  } else { newObj[i] = this[i]; }
 57  }
 58  return newObj;
 59  };
 60  */
 61 // extensions to Array
 62 Array.toAssocArray = function(arr){
 63     var o = {};
 64     for (var x = 0; x < arr.length; ++x) {
 65         o[arr[x]] = arr[x];
 66     }
 67     return o;
 68 };
 69 
 70 // JSExtensions.js
 71 ////////////////////////////////////////////////////////////////////////////////
 72