[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 /* 2 DynAPI Distribution 3 dynapi.functions.System extension 4 */ 5 6 var f = dynapi.functions; 7 f.System = System = {}; // used by dynapi.library 8 9 // System Functions --------------------------------- 10 11 f.coalesce=function(){ 12 var a,i; 13 for(i=0;arguments.length;i++){ 14 a=arguments[i]; 15 if(a!=null && a!='' && a!=undefined) return a; 16 } 17 } 18 f.choose = function(index){ 19 if(isNaN(index)) return; 20 if (arguments.length>index) return arguments[index+1]; 21 }; 22 f.cloneObject = function(src) { 23 if(!src) return; 24 var i,tar; 25 if(typeof(src)!='object') return src; 26 else { 27 if((src.constructor+'')==(Array+'')) tar=[]; 28 else if((src.constructor+'')==(Date+'')) return src; 29 else tar={}; 30 }; 31 for(i in src) { 32 if(typeof(src[i])!='object') tar[i]=src[i]; 33 else tar[i]=this.cloneObject(src[i]); 34 } 35 return tar; 36 }; 37 f.copyObject = function(from,to,noclone) { 38 var i; 39 if (to && !noclone) to=this.cloneObject(to); 40 else if(to && noclone) to=to; 41 else { 42 if(typeof(from)=='object') { 43 if((from.constructor+'')==(Array+'')) to=[]; 44 else if((from.constructor+'')==(Date+'')) return from; 45 else to={}; 46 }; 47 } 48 for(i in from) { 49 if(typeof(from[i])!='object') to[i]=from[i]; 50 else to[i]=this.copyObject(from[i],to[i],true); 51 } 52 return to; 53 }; 54 f.getElementById = function(id,parentLyr){ 55 if (document.all) return document.all[id]; 56 else if(document.getElementById) return document.getElementById(id); 57 else if(document.layers){ 58 var i,nLayers,layer; 59 parentLyr = (parentLyr)? parentLyr:document; 60 nLayers = parentLyr.layers; 61 for (i=0;i<nLayers;i++){ 62 layer=nLayers[i]; 63 if (layer.id == id) return layer; 64 else if (layer.layers.length){ 65 layer = this.getElementById(id,layer); 66 if (layer) return layer; 67 } 68 } 69 } 70 }; 71 f.isNull=function(value,_default){ 72 if(value==null||value==''||value=='undefined') return _default; 73 else return value; 74 }; 75 f.lookUp = function(value,array){ 76 var i; if(!array) return; 77 for(i=0;i<array.length;i++){ 78 if(value==array[i]) return i; 79 } 80 }; 81 f.nullIf = function(){ 82 var a,i; 83 for(i=0;arguments.length;i++){ 84 a=arguments[i]; 85 if(a!=null && a!='' && a!=undefined) return null; 86 } 87 };
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |