Added function to show corpus statistic

Change-Id: I75be5a6209ba18871c4acce889cb23e425b0cee8
diff --git a/dev/js/src/vc/statistic.js b/dev/js/src/vc/statistic.js
index 636a1cf..402fb25 100644
--- a/dev/js/src/vc/statistic.js
+++ b/dev/js/src/vc/statistic.js
@@ -62,6 +62,95 @@
 			return this._element;
 		},
 		
+		
+		/**
+		 * 
+		 * Receive Corpus statistic from the server
+		 */			
+		getStatistic : function(vc, cb){
+			//cq = corpusQuery
+			var cq = encodeURI(vc.toQuery());
+			
+			try{	
+				KorAP.API.getCorpStat(cq, function(statResponse){
+					if(statResponse === null){
+						cb(null);
+						return;
+					}
+					if(statResponse === undefined){
+						cb(null);
+						return;
+					}
+					cb(statResponse);
+				});
+			}
+			
+			catch(e){
+				KorAP.log(0, e);
+				cb(null);
+			}
+			
+		},
+		
+		
+		/**
+		* Shows corpus statistic
+		*/
+		showCorpStat : function(appendEl, vc){
+			
+			/*
+			* If corpus statistic is already visible, 
+			* there is no need to show the statistic again.
+			*/
+			if(this._visibleStat)
+				return;
+			
+			var statTable = document.createElement('div');									
+			statTable.classList.add('stattable', 'loading');
+			appendEl.appendChild(statTable);
+			
+			var that = this;
+			
+			
+			/*
+			* Get corpus statistic, remove "loading"-image and 
+			* append result to statTable 
+			*/
+			this.getStatistic(vc, function (statistic) {
+			
+			if (statistic === null)
+				return; 
+				
+			statTable.classList.remove('loading');
+			statisticobj = that.create(statistic);
+			
+			//Removes statistic button when statistic is displayed
+			var divStatButton = document.getElementById('dCorpStat');
+			divStatButton.parentNode.removeChild(divStatButton);
+      
+			statTable.appendChild(statisticobj.element());
+			
+			// Add Close Button
+			var actions = document.createElement('ul');
+			actions.classList.add('action', 'image');
+			var b = actions.addE('li');
+			b.className = 'close'; 
+			b.addE('span').addT('close');
+			statTable.appendChild(actions);
+			b.addEventListener('click', function (e){
+				statTable.parentNode.removeChild(statTable);
+				that._visibleStat = false;
+				vc.addStatBut();
+				e.halt();
+				});
+			});
+			
+			//corpus statistic is displayed
+			this._visibleStat = true;
+			// Do not load any longer
+			statTable.classList.remove('loading');
+		},	
+		
 	}
 	
 });