js/batteryControl.js
// Common functions used for tweaking Battery elements.
Common functions used for tweaking Battery elements.
Common functions used for tweaking Battery elements .
function BatteryControl(limits){
	  	var that=this;
	  	this.limits=limits;
	   	var maxL=document.getElementById('maximum-level');
		maxL.value=this.limits.max;
		maxL.onchange = function() {
			var newMax=parseInt(this.value, 10);
			var safeMax=that.limits.min + that.limits.minGap	
			if(newMax > safeMax ){
				that.limits.max=newMax;
			} else{
				that.limits.max=safeMax;
				this.value=safeMax;
			}
			that.setLevel("max");
			global.emitter.emit("batteryControl.newmax",that.limits.max);
		};
		var minL=document.getElementById('minimum-level');
		minL.value=this.limits.min;
		minL.onchange = function() {
			var newMin=parseInt(this.value, 10);
			var safeMin=that.limits.max - that.limits.minGap;
			if(newMin < safeMin){
				that.limits.min=newMin;
			} else{			
				that.limits.min=safeMin;
				this.value=safeMin;
			}
			that.setLevel("min");
			global.emitter.emit("batteryControl.newmin",that.limits.min);
		};
		that.setLevel("min");
		that.setLevel("max");
	}
function BatteryControl ( limits ) { var that = this ; this . limits = limits ; var maxL = document . getElementById ( 'maximum-level' ) ; maxL . value = this . limits . max ; maxL . onchange = function ( ) { var newMax = parseInt ( this . value , 10 ) ; var safeMax = that . limits . min + that . limits . minGap if ( newMax > safeMax ) { that . limits . max = newMax ; } else { that . limits . max = safeMax ; this . value = safeMax ; } that . setLevel ( "max" ) ; global . emitter . emit ( "batteryControl.newmax" , that . limits . max ) ; } ; var minL = document . getElementById ( 'minimum-level' ) ; minL . value = this . limits . min ; minL . onchange = function ( ) { var newMin = parseInt ( this . value , 10 ) ; var safeMin = that . limits . max - that . limits . minGap ; if ( newMin < safeMin ) { that . limits . min = newMin ; } else { that . limits . min = safeMin ; this . value = safeMin ; } that . setLevel ( "min" ) ; global . emitter . emit ( "batteryControl.newmin" , that . limits . min ) ; } ; that . setLevel ( "min" ) ; that . setLevel ( "max" ) ; }
Common functions used for tweaking Battery elements.
Common functions used for tweaking Battery elements .
//Globar vals EVIL //Initialize //Initialize // console.log("newMin="+ newMin + "CHARGING_LIMITS=" +  JSON.stringify(CHARGING_LIMITS));