PageRenderTime 55ms CodeModel.GetById 48ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/jsonrpc/public/services/phpolait/jsolait/missingmixin.js

http://pyjamas.googlecode.com/
JavaScript | 115 lines | 115 code | 0 blank | 0 comment | 34 complexity | 84fcf647508562d5d78dab9e92309d76 MD5 | raw file
  1if(Function.prototype.apply == null){
  2Function.prototype.apply = function(thisObj, args){
  3var a =[];
  4for(var i=0;i<args.length;i++){
  5a[i] = "args[" + i + "]";
  6}
  7thisObj.__apply__ = this;
  8a="thisObj.__apply__(" + a.join(",") +")";
  9var r = eval(a);
 10delete thisObj.__apply__;
 11return r;
 12}
 13}
 14if(Function.prototype.call==null){
 15Function.prototype.call=function(thisObj){
 16var args=[]; 
 17for(var i=1;i<arguments.length;i++){
 18args[i-1] = arguments[i];
 19}
 20return this.apply(thisObj, args);
 21}
 22}
 23if(Array.prototype.splice == null){
 24Array.prototype.splice = function(index, howMany){
 25var a = this.slice(0, index);
 26var e = this.slice(index + howMany, this.length);
 27var r = this.slice(index, index+howMany);
 28this.length=0;
 29for(var i=0;i<a.length;i++){
 30this[this.length] = a[i];
 31}
 32for(var i=2;i<arguments.length;i++){
 33this[this.length] = arguments[i];
 34}
 35for(var i=0;i<e.length;i++){
 36this[this.length] = e[i];
 37}
 38return r;
 39}
 40}
 41if(Array.prototype.pop == null){
 42Array.prototype.pop = function(){
 43var e=this[this.length-1];
 44this.length -= 1;
 45return e;
 46}
 47}
 48if(Array.prototype.push == null){
 49Array.prototype.push = function(){
 50for(var i=0;i<arguments.length;i++){
 51this[this.length] = arguments[i];
 52}
 53return this.length;
 54}
 55}
 56if(Array.prototype.shift == null){
 57Array.prototype.shift = function(){
 58var e = this[0];
 59for(var i=1;i<this.length;i++){
 60this[i-1] = this[i];
 61}
 62this.length -= 1;
 63return e;
 64}
 65}
 66if(Array.prototype.unshift == null){
 67Array.prototype.unshift = function(){
 68var a=[]
 69for(var i=0;i<arguments.length;i++){
 70a[i] = arguments[i];
 71}
 72for(var i=0;i<this.length;i++){
 73a[a.length] = this[i];
 74}
 75this.length=a.length;
 76for(var i=0;i<a.length;i++){
 77this[i] = a[i];
 78}
 79return this.length;
 80}
 81}
 82if(Number.prototype.toFixed == null){
 83Number.prototype.toFixed = function(d){
 84var n = this;
 85d = d || 0;
 86var f = Math.pow(10, d);
 87n = Math.round (f * n) / f;
 88n = (n >= 0) ? n+Math.pow(10, -(d+1)) : n-Math.pow(10, -(d+1));
 89n += '';
 90return d == 0 ? n.substring(0, n.indexOf('.')) : n.substring(0, n.indexOf('.') + d + 1);
 91}
 92}
 93if(Number.prototype.toExponential == null){
 94Number.prototype.toExponential = function(d){
 95var n = this;
 96var e = 0;
 97if (n != 0){
 98e = Math.floor(Math.log(Math.abs(n)) / Math.LN10);
 99}
100n /= Math.pow(10, e);
101if (isFinite(d)){
102if (Math.abs(n) + 5*Math.pow(10, -(d+1)) >= 10.0){
103n /= 10;
104e += 1;
105}
106n = n.toFixed(d);
107}
108n += "e";
109if (e >= 0){
110n += "+";
111}
112n += e;
113return n;
114}
115}