# HG changeset patch # User hamidouk # Date 1322577773 -3600 # Node ID cc2cdecc5ce57a2f1a09065e8b7c496cc3d44cdd # Parent e5190c3a682c238e90d703dde74e73a4e13cecf4 ignore tweets in search. diff -r e5190c3a682c -r cc2cdecc5ce5 src/js/serializers/JSONSerializer.js --- a/src/js/serializers/JSONSerializer.js Tue Nov 29 15:09:34 2011 +0100 +++ b/src/js/serializers/JSONSerializer.js Tue Nov 29 15:42:53 2011 +0100 @@ -41,6 +41,22 @@ "" matches any field. */ IriSP.JSONSerializer.prototype.searchAnnotations = function(title, description, keyword) { + + /* we can have many types of annotations. We want search to only look for regular segments */ + /* the next two lines are a bit verbose because for some test data, _serializer.data.view is either + null or undefined. + */ + var view; + + if (typeof(this._data.views) !== "undefined" && this._data.views !== null) + view = this._data.views[0]; + + var searchViewType = ""; + + if(typeof(view) !== "undefined" && typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) { + searchViewType = view.annotation_types[0]; + } + var rTitle; var rDescription; var rKeyword; @@ -63,6 +79,12 @@ for (i in this._data.annotations) { var annotation = this._data.annotations[i]; + /* filter the annotations whose type is not the one we want */ + if (searchViewType != "" && typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" + && annotation.meta["id-ref"] !== searchViewType) { + continue; + } + if (rTitle.test(annotation.content.title) && rDescription.test(annotation.content.description)) { /* FIXME : implement keyword support */