diff --git a/Resources/Public/JavaScript/PageView/PageView.js b/Resources/Public/JavaScript/PageView/PageView.js
index 312d577d61..8837342a98 100644
--- a/Resources/Public/JavaScript/PageView/PageView.js
+++ b/Resources/Public/JavaScript/PageView/PageView.js
@@ -734,6 +734,18 @@ dlfViewer.prototype.createControl = function(controlName, layers) {
}
};
+/**
+ * Forwards the search to dlfUtils.searchFeatureCollectionForWords
+ *
+ * @param {Array.
} stringFeatures - Array of features containing text information
+ * @param {string} value - Search term
+ * @returns {Array.|undefined} Array of OpenLayers features containing found words
+ * @see dlfUtils.searchFeatureCollectionForWords
+ */
+dlfViewer.prototype.searchFeatures = function(stringFeatures, value) {
+ return dlfUtils.searchFeatureCollectionForWords(stringFeatures, value);
+};
+
/**
* Displays highlight words
*/
@@ -786,23 +798,23 @@ dlfViewer.prototype.displayHighlightWord = function(highlightWords = null) {
}
if (this.highlightWords !== null) {
- var self = this;
- var values = decodeURIComponent(this.highlightWords).split(';');
+ const self = this;
+ const values = decodeURIComponent(this.highlightWords).split(';');
$.when.apply($, this.fulltextsLoaded_)
- .done(function (fulltextData, fulltextDataImageTwo) {
- var stringFeatures = [];
+ .done((fulltextData, fulltextDataImageTwo) => {
+ const stringFeatures = [];
- [fulltextData, fulltextDataImageTwo].forEach(function (data) {
+ [fulltextData, fulltextDataImageTwo].forEach(data => {
if (data !== undefined) {
Array.prototype.push.apply(stringFeatures, data.getStringFeatures());
}
});
- values.forEach(function(value) {
- var features = dlfUtils.searchFeatureCollectionForCoordinates(stringFeatures, value);
+ values.forEach((value) => {
+ const features = this.searchFeatures(stringFeatures, value);
if (features !== undefined) {
- for (var i = 0; i < features.length; i++) {
+ for (let i = 0; i < features.length; i++) {
self.highlightLayer.getSource().addFeatures([features[i]]);
}
}
diff --git a/Resources/Public/JavaScript/PageView/Utility.js b/Resources/Public/JavaScript/PageView/Utility.js
index c70b9d4d6c..048e81d8bf 100644
--- a/Resources/Public/JavaScript/PageView/Utility.js
+++ b/Resources/Public/JavaScript/PageView/Utility.js
@@ -645,13 +645,31 @@ dlfUtils.scaleToImageSize = function (features, imageObj, width, height, optOffs
return features;
};
+/**
+ * Search a feature collection for a feature with the given coordinates
+ * @param {Array.} featureCollection
+ * @param {string} coordinates for highlighting
+ * @returns {Array.|undefined}
+ */
+dlfUtils.searchFeatureCollectionForCoordinates = function (featureCollection, coordinates) {
+ var features = [];
+ featureCollection.forEach(function (ft) {
+ if (ft.get('fulltext') !== undefined) {
+ if (ft.getId() === coordinates) {
+ features.push(ft);
+ }
+ }
+ });
+ return features.length > 0 ? features : undefined;
+};
+
/**
* Search a feature collection for a feature with the given word in its fulltext
* @param {Array.} featureCollection
* @param {string} word for highlighting
* @returns {Array.|undefined}
*/
-dlfUtils.searchFeatureCollectionForCoordinates = function (featureCollection, word) {
+dlfUtils.searchFeatureCollectionForWords = function (featureCollection, word) {
var features = [];
featureCollection.forEach(function (ft) {
if (ft.values_.fulltext !== undefined) {