diff -r c9c502117eb6 -r ff4b567d51f2 web/res/metadataplayer/Tagcloud.js --- a/web/res/metadataplayer/Tagcloud.js Fri Feb 13 13:14:15 2015 +0100 +++ b/web/res/metadataplayer/Tagcloud.js Sun Feb 15 00:43:16 2015 +0100 @@ -21,7 +21,9 @@ annotation_type: false, segment_annotation_type: false, min_font_size: 10, - max_font_size: 26 + max_font_size: 26, + min_count: 2, + remove_zero_duration: false }; IriSP.Widgets.Tagcloud.prototype.stopword_lists = { @@ -54,10 +56,16 @@ IriSP.Widgets.Tagcloud.prototype.redraw = function(_from, _to) { var _urlRegExp = /https?:\/\/[0-9a-zA-Z\.%\/-_]+/g, - _regexpword = /[^\s\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g, _words = {}, _this = this, _annotations = this.getWidgetAnnotations(); + + if(!this.include_titles && !this.include_descriptions){ + var _regexpword = /[^\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»\/]{3,}/g; + } + else{ + var _regexpword = /[^\s\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g; + } if (typeof _from !== "undefined" && typeof _to !== "undefined") { _annotations = _annotations.filter(function(_annotation) { @@ -65,6 +73,12 @@ }); } + if(this.remove_zero_duration){ + _annotations = _annotations.filter(function(_annotation) { + return _annotation.getDuration()>0; + }); + } + _annotations.forEach(function(_annotation) { var _txt = (_this.include_titles ? _annotation.title : '') @@ -73,6 +87,7 @@ + ' ' + (_this.include_tag_texts ? _annotation.getTagTexts() : ''); IriSP._(_txt.toLowerCase().replace(_urlRegExp, '').match(_regexpword)).each(function(_word) { + _word = _word.trim(); if (IriSP._(_this.stopwords).indexOf(_word) == -1 && (!_this.exclude_pattern || !_this.exclude_pattern.test(_word))) { _words[_word] = 1 + (_words[_word] || 0); } @@ -87,7 +102,7 @@ }; }) .filter(function(_v) { - return _v.count > 2; + return _v.count > _this.min_count; }) .sortBy(function(_v) { return - _v.count; @@ -105,7 +120,7 @@ this.$.html(Mustache.to_html(this.template, {words: _words })); this.$.find(".Ldt-Tagcloud-item").click(function() { var _txt = IriSP.jQuery(this).attr("content"); - _this.source.getAnnotations().search(_txt); + _this.source.getAnnotations().searchByTags(_txt); }); this.source.getAnnotations().on("search", this.functionWrapper("onSearch")); this.source.getAnnotations().on("search-cleared", this.functionWrapper("onSearch"));