mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-02 22:00:34 +01:00
closes #4475
This commit is contained in:
@@ -118,25 +118,25 @@ define('forum/search', ['search', 'autocomplete'], function(searchModule, autoco
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var regexStr = searchQuery.replace(/^"/, '').replace(/"$/, '').trim().split(' ').join('|');
|
||||
var regex = new RegExp('(' + regexStr + ')', 'gi');
|
||||
var regexStr = searchQuery.replace(/^"/, '').replace(/"$/, '').trim().split(' ').join('|');
|
||||
var regex = new RegExp('(' + regexStr + ')', 'gi');
|
||||
|
||||
$('.search-result-text').each(function() {
|
||||
var result = $(this);
|
||||
$('.search-result-text p, .search-result-text h4').each(function() {
|
||||
var result = $(this), nested = [];
|
||||
|
||||
var text = result.html().replace(regex, '<strong>$1</strong>');
|
||||
result.html(text).find('img:not(.not-responsive)').addClass('img-responsive').each(function() {
|
||||
$(this).attr('src', $(this).attr('src').replace(/<strong>([\s\S]*?)<\/strong>/gi, '$1'));
|
||||
});
|
||||
|
||||
result.find('a').each(function() {
|
||||
$(this).attr('href', $(this).attr('href').replace(/<strong>([\s\S]*?)<\/strong>/gi, '$1'));
|
||||
});
|
||||
result.find('*').each(function() {
|
||||
$(this).after('<!-- ' + nested.length + ' -->');
|
||||
nested.push($('<div />').append($(this)));
|
||||
});
|
||||
} catch(e) {
|
||||
return;
|
||||
}
|
||||
|
||||
result.html(result.html().replace(regex, '<strong>$1</strong>'));
|
||||
|
||||
for (var i = 0, ii = nested.length; i < ii; i++) {
|
||||
result.html(result.html().replace('<!-- ' + i + ' -->', nested[i].html()));
|
||||
}
|
||||
});
|
||||
|
||||
$('.search-result-text').find('img:not(.not-responsive)').addClass('img-responsive');
|
||||
}
|
||||
|
||||
function handleSavePreferences() {
|
||||
|
||||
Reference in New Issue
Block a user