# HG changeset patch # User cavaliet # Date 1391694210 -3600 # Node ID 420608a775665d28cf33dc9114133d79ca6c4031 # Parent 5fb8d735fde043a71bb791133f3975ea134ca9f1 few enhancements diff -r 5fb8d735fde0 -r 420608a77566 src/js/model.js --- a/src/js/model.js Thu Feb 06 12:29:31 2014 +0100 +++ b/src/js/model.js Thu Feb 06 14:43:30 2014 +0100 @@ -276,6 +276,26 @@ return res; }; +List.prototype.searchByTags = function(_text) { + if (!_text) { + this.trigger("clear-search"); + return this; + } + this.searching = true; + this.trigger("search", _text); + var rxsource = fullTextRegexps(_text), + rgxp = new RegExp(rxsource,"im"); + this.regexp = new RegExp(rxsource,"gim"); + var res = this.filter(function(_element, _k) { + var _isfound = rgxp.test(_element.getTagTexts()); + _element.found = _isfound; + _element.trigger(_isfound ? "found" : "not-found"); + return _isfound; + }); + this.trigger(res.length ? "found" : "not-found",res); + return res; +}; + List.prototype.getTitles = function() { return this.map(function(_el) { return _el.title; diff -r 5fb8d735fde0 -r 420608a77566 src/widgets/Segments.js --- a/src/widgets/Segments.js Thu Feb 06 12:29:31 2014 +0100 +++ b/src/widgets/Segments.js Thu Feb 06 14:43:30 2014 +0100 @@ -77,7 +77,7 @@ color : color, medcolor: medcolor, lowcolor: lowcolor, - text: _fulltext.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1…'), + text: (_annotation.creator ? (_annotation.creator + " : ") : "" ) + _fulltext.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1…'), left : _left, width : _width, top: _top, diff -r 5fb8d735fde0 -r 420608a77566 src/widgets/Tagcloud.js --- a/src/widgets/Tagcloud.js Thu Feb 06 12:29:31 2014 +0100 +++ b/src/widgets/Tagcloud.js Thu Feb 06 14:43:30 2014 +0100 @@ -21,7 +21,8 @@ annotation_type: false, segment_annotation_type: false, min_font_size: 10, - max_font_size: 26 + max_font_size: 26, + min_count: 2 }; IriSP.Widgets.Tagcloud.prototype.stopword_lists = { @@ -54,7 +55,7 @@ IriSP.Widgets.Tagcloud.prototype.redraw = function(_from, _to) { var _urlRegExp = /https?:\/\/[0-9a-zA-Z\.%\/-_]+/g, - _regexpword = /[^\s\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g, + _regexpword = /[^\.&;,'"!\?\d\(\)\+\[\]\\\…\-«»:\/]{3,}/g, _words = {}, _this = this, _annotations = this.getWidgetAnnotations(); @@ -64,7 +65,6 @@ return _annotation.begin >= _from && _annotation.end <= _to; }); } - _annotations.forEach(function(_annotation) { var _txt = (_this.include_titles ? _annotation.title : '') @@ -73,6 +73,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 +88,7 @@ }; }) .filter(function(_v) { - return _v.count > 2; + return _v.count > _this.min_count; }) .sortBy(function(_v) { return - _v.count; @@ -105,7 +106,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"));