All Downloads are FREE. Search and download functionalities are using the official Maven repository.

includes.js.statusbar-4.0.js Maven / Gradle / Ivy

There is a newer version: 4.2.4
Show newest version


	BAR_VIEW = 0; 
	GIF_VIEW = 1; 
	NUM_VIEW = 2;

	function StatusChart(displayId, imgDir, fontSize, initView)
	{
		this.imgDir = imgDir;
		this.displayId = displayId;
		this.fontSize = fontSize ? fontSize : 16;
		this.view = initView ? initView : GIF_VIEW;
		this.totalTics = 0;	this.success = 0; this.failures = 0;
		this.successCount = 0; this.failuresCount = 0; this.errorsCount = 0;
	
		this.switchView = function(){ this.view = (this.view == NUM_VIEW ? BAR_VIEW : this.view + 1); this.draw(); };
		this.wasIgnored = function(){ return this.successCount == 0 && this.failuresCount == 0 && this.errorsCount == 0; };
		this.wasSuccessfull = function(){ return this.successCount != 0  && this.failuresCount == 0 && this.errorsCount == 0; };
		this.hasFailed = function(){ return this.failuresCount != 0 || this.errorsCount != 0; };
		
		this.register = function(exc, suc, fai, err, initialTics)
		{
			if($(this.displayId))
			{
				this.totalTics = initialTics;
				this.successCount += suc;
				this.failuresCount += fai;
				this.errorsCount += err + (exc ? 1 : 0);
				if(suc != 0 && !exc && fai == 0 && err == 0){this.addSuccess(); return;}
				if(exc || fai != 0 || err != 0){this.addFailure(); return;}
				this.draw();
			}
		};
		
		this.unregister = function(exc, suc, fai, err)
		{
			if($(this.displayId))
			{
				this.successCount -= suc;
				this.failuresCount -= fai;
				this.errorsCount -= err + (exc ? 1 : 0);
				if(suc != 0 && !exc && fai == 0 && err == 0){this.removeSuccess(); return;}
				if(exc || fai != 0 || err != 0){this.removeFailure(); return;}
				this.draw();
			}
		};
	
		this.reset = function(draw){ if($(this.displayId)){ this.totalTics = 0; this.success = 0; this.failures = 0; this.successCount = 0; this.failuresCount = 0; this.errorsCount = 0; if(draw)this.draw(); } };
		this.addSuccess = function(){ if(this.success <= this.totalTics){this.success++;} this.draw(); };
		this.addFailure = function(){ if(this.failures <= this.totalTics){this.failures++;} this.draw(); };
		this.removeSuccess = function(){ if(this.success > 0){this.success--;} this.draw(); };
		this.removeFailure = function(){ if(this.failures){this.failures--;} this.draw(); };
	
		this.draw = function()
		{
			switch(this.view)
			{
				case GIF_VIEW : this.drawGifBar(); break;
				case NUM_VIEW : this.drawDetailedBar(); break;
				default : this.drawBar();
			}
		};
	
		this.drawGifBar = function()
		{
			this.view = GIF_VIEW;
			var inHTML = "";
			var limit = this.totalTics - this.success - this.failures;
			if(limit < 0){this.totalTics = this.success + this.failures;}
			for(var i = 0; i < this.success; i++){inHTML =  inHTML + "";}
			for(var j = 0; j < this.failures; j++){inHTML =  inHTML + "";}
			for(var z = 0; z < limit; z++){inHTML =  inHTML + "";}
		 	GP.View.write(this.displayId, inHTML + '
'); }; this.drawBar = function() { this.view = BAR_VIEW; var inHTML = ""; var limit = this.totalTics - this.success - this.failures; if(limit < 0){this.totalTics = this.success + this.failures;} for(var i = 0; i < this.success; i++){inHTML = inHTML + "";} for(var j = 0; j < this.failures; j++){inHTML = inHTML + "";} for(var z = 0; z < limit; z++){inHTML = inHTML + "";} GP.View.write(this.displayId, inHTML + '
   
'); }; this.drawDetailedBar = function() { this.view = NUM_VIEW; var inHTML = ""; inHTML += ""; inHTML += ""; inHTML += ""; GP.View.write(this.displayId, inHTML + '
"; inHTML += "Rights:  "; inHTML += "" + this.successCount + "  "; inHTML += ""; inHTML += "Wrongs:  "; inHTML += "" + this.failuresCount + "  "; inHTML += ""; inHTML += "Errors:  "; inHTML += "" + this.errorsCount + ""; inHTML += "
'); }; this.getBgColor = function() { if(this.wasIgnored()) return "#F8F8F8"; if(this.wasSuccessfull()) return "#aaffaa"; if(this.hasFailed()) return "#ffcccc"; } this.getBorderColor = function() { if(this.wasIgnored()) return "#bbb"; if(this.wasSuccessfull()) return "#339999"; if(this.hasFailed()) return "#cc0000"; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy