Catch notification / Changed: statistic button will not be removed
Change-Id: I9305a8b387957d7ad6c51149aca7321a8c65ace2
diff --git a/dev/js/spec/statSpec.js b/dev/js/spec/statSpec.js
index 2edc972..aefe187 100644
--- a/dev/js/spec/statSpec.js
+++ b/dev/js/spec/statSpec.js
@@ -76,8 +76,7 @@
return cb(preDefinedStat);
};
-
-
+
describe('KorAP.CorpusStat', function(){
var vc = vcClass.create([
@@ -92,13 +91,7 @@
var stat = statClass.create(preDefinedStat);
var descL = stat.element();
- it('statButton should only be added if doc is specified', function(){
- expect(vcEl.children[1].id).not.toBe(null);
- vc2 = vcClass.create().fromJson();
- expect(vc2.element().children[1]).toBeUndefined();
- });
-
-
+
it('should be initiable', function(){
expect(stat._visibleStat).toEqual(false);
expect( function() { statClass.create() }).toThrow(new Error("Missing parameter"));
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index 6941341..05e48ad 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -65,7 +65,8 @@
// KorAP._validDateMatchRE is defined in datepicker.js!
const loc = KorAP.Locale;
- loc.VC_SHOWSTAT = loc.VC_SHOWSTAT || 'Corpus Statistic';
+ loc.SHOWSTAT = loc.SHOWSTAT || 'Statistics';
+ loc.VERB_SHOWSTAT = loc.VERB_SHOWSTAT || 'Corpus Statistics';
KorAP._vcKeyMenu = undefined;
KorAP._vcDatePicker = dpClass.create();
@@ -264,10 +265,8 @@
this._element.appendChild(this._root.element());
//Add corpus statistic button
- if(!(this._root.element().classList.contains('unspecified'))){
this.addStatBut();
- }
-
+
return this._element;
},
@@ -345,11 +344,11 @@
//add button
var bu = dv.addE('div');
- bu.classList.add('bottom', 'button-single');
+ bu.classList.add('bottom', 'button-stat');
var stat = bu.addE('span');
- stat.addT('Statistics');
+ stat.addT(loc.SHOWSTAT);
//localize the buttons title attribute
- stat.setAttribute('title', loc.VC_SHOWSTAT);
+ //stat.setAttribute('title', loc.SHOWSTAT);
stat.classList.add('statistic');
/*
diff --git a/dev/js/src/vc/statistic.js b/dev/js/src/vc/statistic.js
index a5a2f02..4a40ea5 100644
--- a/dev/js/src/vc/statistic.js
+++ b/dev/js/src/vc/statistic.js
@@ -42,10 +42,10 @@
if (this._element !== undefined) {
return this._element;
};
-
- //create HTML Description List Element
- var statDL = document.createElement('dl');
- var statistic = this._statistic;
+
+ //create HTML Description List Element
+ var statDL = document.createElement('dl');
+ var statistic = this._statistic;
var keys = Object.keys(statistic);
for(i = 0; i < keys.length; i++){
@@ -81,6 +81,14 @@
cb(null);
return;
}
+
+ //catches notifications
+ if(statResponse["notifications"] !== null && statResponse["notifications"] !== undefined ){
+ notif = statResponse["notifications"];
+ KorAP.log(0, notif[0][1]);
+ return;
+ }
+
cb(statResponse);
});
}
@@ -123,12 +131,6 @@
statTable.classList.remove('loading');
statisticobj = that.create(statistic);
-
- //Removes statistic button when statistic is displayed
- if(document.getElementById('dCorpStat') !== null){
- var divStatButton = document.getElementById('dCorpStat');
- divStatButton.parentNode.removeChild(divStatButton);
- }
statTable.appendChild(statisticobj.element());
@@ -142,7 +144,6 @@
b.addEventListener('click', function (e){
statTable.parentNode.removeChild(statTable);
that._visibleStat = false;
- vc.addStatBut();
e.halt();
});
});