fix(search): html entity does not display correctly in insight search items
This commit is contained in:
parent
486b1fc077
commit
f4d2092f4a
|
@ -10,6 +10,13 @@
|
||||||
$main.parent().remove('.ins-search');
|
$main.parent().remove('.ins-search');
|
||||||
$('body').append($main);
|
$('body').append($main);
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/1147359/how-to-decode-html-entities-using-jquery#answer-1395954
|
||||||
|
function decodeEntities(encodedString) {
|
||||||
|
var textArea = document.createElement('textarea');
|
||||||
|
textArea.innerHTML = encodedString;
|
||||||
|
return textArea.value;
|
||||||
|
}
|
||||||
|
|
||||||
function section (title) {
|
function section (title) {
|
||||||
return $('<section>').addClass('ins-section')
|
return $('<section>').addClass('ins-section')
|
||||||
.append($('<header>').addClass('ins-section-header').text(title));
|
.append($('<header>').addClass('ins-section-header').text(title));
|
||||||
|
@ -19,7 +26,7 @@
|
||||||
return $('<div>').addClass('ins-selectable').addClass('ins-search-item')
|
return $('<div>').addClass('ins-selectable').addClass('ins-search-item')
|
||||||
.append($('<header>').append($('<i>').addClass('fa').addClass('fa-' + icon)).append(title != null && title != '' ? title : CONFIG.TRANSLATION['UNTITLED'])
|
.append($('<header>').append($('<i>').addClass('fa').addClass('fa-' + icon)).append(title != null && title != '' ? title : CONFIG.TRANSLATION['UNTITLED'])
|
||||||
.append(slug ? $('<span>').addClass('ins-slug').text(slug) : null))
|
.append(slug ? $('<span>').addClass('ins-slug').text(slug) : null))
|
||||||
.append(preview ? $('<p>').addClass('ins-search-preview').text(preview) : null)
|
.append(preview ? $('<p>').addClass('ins-search-preview').text(decodeEntities(preview)) : null)
|
||||||
.attr('data-url', url);
|
.attr('data-url', url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue