Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions Resources/Public/JavaScript/PageView/PageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,18 @@ dlfViewer.prototype.createControl = function(controlName, layers) {
}
};

/**
* Forwards the search to dlfUtils.searchFeatureCollectionForWords
*
* @param {Array.<ol.Feature>} stringFeatures - Array of features containing text information
* @param {string} value - Search term
* @returns {Array.<ol.Feature>|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
*/
Expand Down Expand Up @@ -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]]);
}
}
Expand Down
20 changes: 19 additions & 1 deletion Resources/Public/JavaScript/PageView/Utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<ol.Feature>} featureCollection
* @param {string} coordinates for highlighting
* @returns {Array.<ol.Feature>|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.<ol.Feature>} featureCollection
* @param {string} word for highlighting
* @returns {Array.<ol.Feature>|undefined}
*/
dlfUtils.searchFeatureCollectionForCoordinates = function (featureCollection, word) {
dlfUtils.searchFeatureCollectionForWords = function (featureCollection, word) {
var features = [];
featureCollection.forEach(function (ft) {
if (ft.values_.fulltext !== undefined) {
Expand Down