pari: branch 2.0 r4213 - /branches/2.0/config/js/astman.js
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Mon Nov 24 16:50:38 CST 2008
Author: pari
Date: Mon Nov 24 16:50:37 2008
New Revision: 4213
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=4213
Log:
somewhat faster '[].firstAvailable()'
Modified:
branches/2.0/config/js/astman.js
Modified: branches/2.0/config/js/astman.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/astman.js?view=diff&rev=4213&r1=4212&r2=4213
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Mon Nov 24 16:50:37 2008
@@ -72,12 +72,23 @@
};
Array.prototype.firstAvailable = function(start) {
- if(!start){ start = 1; }else{ start = Number( start ); }
- if(!this.length){return start;}
- for(var y=0, x=[] ; y< this.length; y++){ x.push( Number(this[y]) ); } // 'this' can also be an array of number strings
- var i=0;
- while( i < 1 ){
- if( x.contains(start) ){ start++; }else{ return start; }
+ start = (!start)? 1 : Number( start );
+ if(!this.length)
+ return start;
+ for( var y=0, x=[], z=this.length ; y < z ; y++ ){
+ var NT = Number(this[y]) ;
+ if( NT < start )
+ continue;
+ x.push(NT);
+ }
+ if( !x.length )
+ return start;
+ while(true){
+ if( x.contains(start) ){
+ start++;
+ }else{
+ return start;
+ }
}
};
More information about the asterisk-gui-commits
mailing list