| changeset 1026 | 420608a77566 |
| parent 1013 | 392ddcd212d7 |
| child 1027 | 9ae9453bad73 |
| 1025:5fb8d735fde0 | 1026:420608a77566 |
|---|---|
19 custom_stopwords: [], |
19 custom_stopwords: [], |
20 exclude_pattern: false, |
20 exclude_pattern: false, |
21 annotation_type: false, |
21 annotation_type: false, |
22 segment_annotation_type: false, |
22 segment_annotation_type: false, |
23 min_font_size: 10, |
23 min_font_size: 10, |
24 max_font_size: 26 |
24 max_font_size: 26, |
25 min_count: 2 |
|
25 }; |
26 }; |
26 |
27 |
27 IriSP.Widgets.Tagcloud.prototype.stopword_lists = { |
28 IriSP.Widgets.Tagcloud.prototype.stopword_lists = { |
28 "fr" : [ |
29 "fr" : [ |
29 'aussi', 'avec', 'aux', 'bien', 'car', 'cette', 'comme', 'dans', 'des', 'donc', 'dont', 'elle', 'encore', 'entre', 'est', |
30 'aussi', 'avec', 'aux', 'bien', 'car', 'cette', 'comme', 'dans', 'des', 'donc', 'dont', 'elle', 'encore', 'entre', 'est', |
52 } |
53 } |
53 }; |
54 }; |
54 |
55 |
55 IriSP.Widgets.Tagcloud.prototype.redraw = function(_from, _to) { |
56 IriSP.Widgets.Tagcloud.prototype.redraw = function(_from, _to) { |
56 var _urlRegExp = /https?:\/\/[0-9a-zA-Z\.%\/-_]+/g, |
57 var _urlRegExp = /https?:\/\/[0-9a-zA-Z\.%\/-_]+/g, |
57 _regexpword = /[^\s\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g, |
58 _regexpword = /[^\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g, |
58 _words = {}, |
59 _words = {}, |
59 _this = this, |
60 _this = this, |
60 _annotations = this.getWidgetAnnotations(); |
61 _annotations = this.getWidgetAnnotations(); |
61 |
62 |
62 if (typeof _from !== "undefined" && typeof _to !== "undefined") { |
63 if (typeof _from !== "undefined" && typeof _to !== "undefined") { |
63 _annotations = _annotations.filter(function(_annotation) { |
64 _annotations = _annotations.filter(function(_annotation) { |
64 return _annotation.begin >= _from && _annotation.end <= _to; |
65 return _annotation.begin >= _from && _annotation.end <= _to; |
65 }); |
66 }); |
66 } |
67 } |
67 |
|
68 _annotations.forEach(function(_annotation) { |
68 _annotations.forEach(function(_annotation) { |
69 var _txt = |
69 var _txt = |
70 (_this.include_titles ? _annotation.title : '') |
70 (_this.include_titles ? _annotation.title : '') |
71 + ' ' |
71 + ' ' |
72 + (_this.include_descriptions ? _annotation.description : '') |
72 + (_this.include_descriptions ? _annotation.description : '') |
73 + ' ' |
73 + ' ' |
74 + (_this.include_tag_texts ? _annotation.getTagTexts() : ''); |
74 + (_this.include_tag_texts ? _annotation.getTagTexts() : ''); |
75 IriSP._(_txt.toLowerCase().replace(_urlRegExp, '').match(_regexpword)).each(function(_word) { |
75 IriSP._(_txt.toLowerCase().replace(_urlRegExp, '').match(_regexpword)).each(function(_word) { |
76 _word = _word.trim(); |
|
76 if (IriSP._(_this.stopwords).indexOf(_word) == -1 && (!_this.exclude_pattern || !_this.exclude_pattern.test(_word))) { |
77 if (IriSP._(_this.stopwords).indexOf(_word) == -1 && (!_this.exclude_pattern || !_this.exclude_pattern.test(_word))) { |
77 _words[_word] = 1 + (_words[_word] || 0); |
78 _words[_word] = 1 + (_words[_word] || 0); |
78 } |
79 } |
79 }); |
80 }); |
80 }); |
81 }); |
85 "word" : _k, |
86 "word" : _k, |
86 "count" : _v |
87 "count" : _v |
87 }; |
88 }; |
88 }) |
89 }) |
89 .filter(function(_v) { |
90 .filter(function(_v) { |
90 return _v.count > 2; |
91 return _v.count > _this.min_count; |
91 }) |
92 }) |
92 .sortBy(function(_v) { |
93 .sortBy(function(_v) { |
93 return - _v.count; |
94 return - _v.count; |
94 }) |
95 }) |
95 .first(this.tag_count) |
96 .first(this.tag_count) |
103 }); |
104 }); |
104 } |
105 } |
105 this.$.html(Mustache.to_html(this.template, {words: _words })); |
106 this.$.html(Mustache.to_html(this.template, {words: _words })); |
106 this.$.find(".Ldt-Tagcloud-item").click(function() { |
107 this.$.find(".Ldt-Tagcloud-item").click(function() { |
107 var _txt = IriSP.jQuery(this).attr("content"); |
108 var _txt = IriSP.jQuery(this).attr("content"); |
108 _this.source.getAnnotations().search(_txt); |
109 _this.source.getAnnotations().searchByTags(_txt); |
109 }); |
110 }); |
110 this.source.getAnnotations().on("search", this.functionWrapper("onSearch")); |
111 this.source.getAnnotations().on("search", this.functionWrapper("onSearch")); |
111 this.source.getAnnotations().on("search-cleared", this.functionWrapper("onSearch")); |
112 this.source.getAnnotations().on("search-cleared", this.functionWrapper("onSearch")); |
112 }; |
113 }; |
113 |
114 |