client/splunk.ui.charting.js
function(){
            var self = this,
                startTime = null,
                stopTime = null,
                times = [];
            var isSet = function(prop){
                return (prop==null)?false:true;
            };
            var isStarted = function(){
                return isSet(startTime);
            };
            var isStopped = function(){
                return isSet(stopTime);
            };
            var softReset = function(){
                startTime = null;
                stopTime = null;
            };
            self.start = function(){
                if(isStarted()){
                   throw new Error("cannot call start, start already invoked.");
                }
                startTime = new Date();
            };
            self.stop = function(){
               if(!isStarted()){
                   throw new Error("cannot call stop, start not invoked.");
               }
               if(isStopped()){
                   throw new Error("cannot call stop, stop already invoked.");
               }
               stopTime = new Date();
               time = stopTime - startTime;
               times.push(time);
            };
            self.pause = function(){
                if(!isStarted()){
                   throw new Error("cannot call pause, start not invoked.");
                }
                if(isStopped()){
                   throw new Error("cannot call pause, stop already invoked.");
                }
                self.stop();
                softReset();
            };
            self.reset = function(){
                softReset();
                times = [];
            };
            self.time = function(){
                var total = 0;
                for(i=0; i<times.length; i++){
                    total += times[i];
                }
                if(isStarted() && !isStopped()){
                    total += (new Date() - startTime);
                }
                return total/1000;
            };
        }
function(){
            var self = this,
                startTime = null,
                stopTime = null,
                times = [];
            var isSet = function(prop){
                return (prop==null)?false:true;
            };
            var isStarted = function(){
                return isSet(startTime);
            };
            var isStopped = function(){
                return isSet(stopTime);
            };
            var softReset = function(){
                startTime = null;
                stopTime = null;
            };
            self.start = function(){
                if(isStarted()){
                   throw new Error("cannot call start, start already invoked.");
                }
                startTime = new Date();
            };
            self.stop = function(){
               if(!isStarted()){
                   throw new Error("cannot call stop, start not invoked.");
               }
               if(isStopped()){
                   throw new Error("cannot call stop, stop already invoked.");
               }
               stopTime = new Date();
               time = stopTime - startTime;
               times.push(time);
            };
            self.pause = function(){
                if(!isStarted()){
                   throw new Error("cannot call pause, start not invoked.");
                }
                if(isStopped()){
                   throw new Error("cannot call pause, stop already invoked.");
                }
                self.stop();
                softReset();
            };
            self.reset = function(){
                softReset();
                times = [];
            };
            self.time = function(){
                var total = 0;
                for(i=0; i<times.length; i++){
                    total += times[i];
                }
                if(isStarted() && !isStopped()){
                    total += (new Date() - startTime);
                }
                return total/1000;
            };
        }
function ( ) { var self = this , startTime = null , stopTime = null , times = [ ] ; var isSet = function ( prop ) { return ( prop == null ) ? false : true ; } ; var isStarted = function ( ) { return isSet ( startTime ) ; } ; var isStopped = function ( ) { return isSet ( stopTime ) ; } ; var softReset = function ( ) { startTime = null ; stopTime = null ; } ; self . start = function ( ) { if ( isStarted ( ) ) { throw new Error ( "cannot call start, start already invoked." ) ; } startTime = new Date ( ) ; } ; self . stop = function ( ) { if ( ! isStarted ( ) ) { throw new Error ( "cannot call stop, start not invoked." ) ; } if ( isStopped ( ) ) { throw new Error ( "cannot call stop, stop already invoked." ) ; } stopTime = new Date ( ) ; time = stopTime - startTime ; times . push ( time ) ; } ; self . pause = function ( ) { if ( ! isStarted ( ) ) { throw new Error ( "cannot call pause, start not invoked." ) ; } if ( isStopped ( ) ) { throw new Error ( "cannot call pause, stop already invoked." ) ; } self . stop ( ) ; softReset ( ) ; } ; self . reset = function ( ) { softReset ( ) ; times = [ ] ; } ; self . time = function ( ) { var total = 0 ; for ( i = 0 ; i < times . length ; i ++ ) { total += times [ i ] ; } if ( isStarted ( ) && ! isStopped ( ) ) { total += ( new Date ( ) - startTime ) ; } return total / 1000 ; } ; }
Stop watch class.
Stop watch class .