Commit 01197d81 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

891: Highlighting von Treffen in der Suchausgabe

Task-Url: https://pm.winseda.de/issues/891
parent 3ff50988
......@@ -87,11 +87,20 @@ var Util = function() {
};
var __util = new Util();
Util.prototype.escapeHtml = function(string) {
var _this = this;
return String(string).replace(/[&<>"'\/]/g, function(s) {
return _this.entityMap[s];
});
Util.prototype.escapeHtml = function (a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
};
Util.prototype.contains = function(string) {
var _this = this;
return String(string).replace(/[&<>"'\/]/g, function(s) {
return _this.entityMap[s];
});
};
Util.prototype.showLoginNote = function() {
......
......@@ -606,6 +606,25 @@ QueryHandler.prototype.processResponseResources = function(isShowMore, resultEle
}
if (resultElements[i].fieldHighlights!==undefined) {
var highlights = [];
for (var j=0; j<resultElements[i].fieldHighlights.length; j++) {
for (var k=0; k<resultElements[i].fieldHighlights[j].highlightTexts.length; k++) {
//if (!__util.contains(highlights, resultElements[i].fieldHighlights[j].highlightTexts[k])) {
highlights.push(resultElements[i].fieldHighlights[j].highlightTexts[k]);
//}
}
}
var strHighlight = "";
for (var j=0; j<highlights.length; j++) {
strHighlight += "<li>" + highlights[j] + "</li>";
}
content.push(["highlights", strHighlight]);
}
/*if (resultElements[i].presentation.Presentation.Images!==undefined && resultElements[i].presentation.Presentation.Images.Resource!==undefined) {
......@@ -628,6 +647,10 @@ QueryHandler.prototype.processResponseResources = function(isShowMore, resultEle
if (resultElements[i].presentation.Presentation.Objects!==undefined) {
this.handleObjects(resultElements[i].presentation.Presentation.Objects, i);
}
//highlights
} else {
content.push(["title", "<em>" + __translator.translate("~eu.dariah.de.minfba.search.view.result.no_title") + "</em>"]);
content.push(["link", ""]);
......@@ -876,6 +899,7 @@ QueryHandler.prototype.renderResultItem = function(item, content, hideElements)
} else {
result = this.renderValue(content[i][1], content[i][2]);
}
item = item.split("~{" + content[i][0] + "}").join(result);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment