4 |
4 |
5 IriSP.TagCloudWidget.prototype = new IriSP.Widget(); |
5 IriSP.TagCloudWidget.prototype = new IriSP.Widget(); |
6 |
6 |
7 IriSP.TagCloudWidget.prototype.draw = function() { |
7 IriSP.TagCloudWidget.prototype.draw = function() { |
8 |
8 |
9 var _stopwords = [ |
9 var _urlRegExp = /https?:\/\/[0-9a-zA-Z\.%\/-_]+/g, |
10 'aussi', 'and', 'avec', 'aux', 'car', 'cette', 'comme', 'dans', 'donc', 'des', 'elle', 'est', |
10 _stopWords = [ |
11 'être', 'eux', 'fait', 'ici', 'ils', 'les', 'leur', 'leurs', 'mais', 'mes', 'même', 'mon', 'notre', |
11 'aussi', 'and', 'avec', 'aux', 'bien', 'car', 'cette', 'comme', 'dans', 'donc', 'des', 'elle', 'encore', 'est', |
12 'non', 'nos', 'nous', 'ont', 'par', 'pas', 'peu', 'pour', 'que', 'qui', 'ses' ,'son', 'sont', 'sur', |
12 'être', 'eux', 'faire', 'fait', 'http', 'ici', 'ils', 'les', 'leur', 'leurs', 'mais', 'mes', 'même', 'mon', 'notre', |
13 'tes', 'très', 'the', 'ton', 'tous', 'tout', 'une', 'votre', 'vos', 'vous' |
13 'non', 'nos', 'nous', 'ont', 'par', 'pas', 'peu', 'peut', 'plus', 'pour', 'que', 'qui', 'ses' ,'son', 'sont', 'sur', |
14 ], |
14 'tes', 'très', 'the', 'ton', 'tous', 'tout', 'une', 'votre', 'vos', 'vous' ], |
15 _regexpword = /[^\s\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g, |
15 _regexpword = /[^\s\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g, |
16 _words = {}, |
16 _words = {}, |
17 _showTitle = !this._config.excludeTitle, |
17 _showTitle = !this._config.excludeTitle, |
18 _showDescription = !this._config.excludeDescription, |
18 _showDescription = !this._config.excludeDescription, |
|
19 _excludePattern = this._config.excludePattern || null, |
19 _tagCount = this._config.tagCount || 30; |
20 _tagCount = this._config.tagCount || 30; |
|
21 if (typeof this._config.excludeWords !== "undefined" && this._config.excludeWords.length) { |
|
22 IriSP._(this._config.excludeWords).each(function(_w) { |
|
23 _stopWords.push(_w.toLowerCase()); |
|
24 }); |
|
25 } |
20 |
26 |
21 IriSP._(this._serializer._data.annotations).each(function(_annotation) { |
27 IriSP._(this._serializer._data.annotations).each(function(_annotation) { |
22 if (_annotation.content && _annotation.content.description) { |
28 if (_annotation.content && _annotation.content.description) { |
23 var _txt = (_showTitle ? _annotation.content.title : '') + ' ' + (_showDescription ? _annotation.content.description : '') |
29 var _txt = (_showTitle ? _annotation.content.title : '') + ' ' + (_showDescription ? _annotation.content.description : '') |
24 IriSP._(_txt.toLowerCase().match(_regexpword)).each(function(_mot) { |
30 IriSP._(_txt.toLowerCase().replace(_urlRegExp, '').match(_regexpword)).each(function(_mot) { |
25 if (_stopwords.indexOf(_mot) == -1) { |
31 if (_stopWords.indexOf(_mot) == -1 && (_excludePattern == null || !_excludePattern.test(_mot))) { |
26 _words[_mot] = 1 + (_words[_mot] || 0); |
32 _words[_mot] = 1 + (_words[_mot] || 0); |
27 } |
33 } |
28 }) |
34 }) |
29 } |
35 } |
30 }); |
36 }); |