src/widgets/Polemic.js
changeset 1071 02c04d2c8fd8
parent 1070 36517cb225fe
child 1072 ac1eacb3aa33
--- a/src/widgets/Polemic.js	Thu Dec 31 15:51:09 2015 +0100
+++ b/src/widgets/Polemic.js	Sun Nov 12 22:07:33 2017 +0100
@@ -144,7 +144,7 @@
 
             for(var _j = 0; _j < _polemics.length; _j++) {
                 _pol = _polemics[_j];
-                _rgxp = _pol.rgxp || (_pol.rgxp = IriSP.Model.regexpFromTextOrArray(_pol.keywords));
+                _rgxp = IriSP.Model.regexpFromTextOrArray(_pol.keywords);
                 if(_rgxp.test(_annotation.description)) {
                     colAr.push(_pol.color);
                 }
@@ -346,27 +346,30 @@
                 polemicStacks : {}
             };
 
-        _count = _res.annotations.length;
         _res.annotations = _res.annotations.filter(function(_annotation) {
             var _polemicVersion = (_annotation.content && _annotation.content.polemic_version) || _this.default_version,
                 _polemics = _this.getPolemics(_polemicVersion) || [],
                 _pol,
                 _polKey,
                 _polDef,
-                _rgxp;
+                _rgxp,
+                _notMatched = true;
 
             for(var _j = 0; _j < _polemics.length; _j++) {
                 _pol = _polemics[_j];
-                _rgxp = _pol.rgxp || (_pol.rgxp = IriSP.Model.regexpFromTextOrArray(_pol.keywords));
+                _rgxp = IriSP.Model.regexpFromTextOrArray(_pol.keywords);
+
                 if(_rgxp.test(_annotation.description)) {
                     _polKey = _polemicVersion + "_" + _pol.name;
                     _polDef = _res.polemicStacks[_polKey] || (_res.polemicStacks[_polKey] = { 'polemicDef' : _pol, 'annotations': []});
                     _polDef.annotations.push(_annotation);
-                    return false;
+                    _notMatched = false;
+                    _count++;
                 }
             }
-            return true;
+            return _notMatched;
         });
+        _count += _res.annotations.length;
 
         _max = Math.max(_max, _count);
         _slices.push(_res);