-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.js
34 lines (28 loc) · 1.1 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
jQuery(function () {
jQuery('.searchform__qsearch_in')
.each(function (i, input) {
var $input = jQuery(input);
var $form = $input.parent().parent();
var $output = $form.find('.searchform__qsearch_out');
var $ns = $form.find('[name="ns"]');
var $notns = $form.find('[name="-ns"]');
$input.dw_qsearch({
output: $output,
getSearchterm: function () {
let query = $input.val(),
reg = new RegExp("(?:^| )(?:\\^|@|-ns:|ns:)[\\w:]+");
if (reg.test(query)) {
return query;
}
let prefix = ' @';
let namespace = $ns.val();
let excludednamespace = $notns.val();
if(excludednamespace) {
namespace = excludednamespace;
prefix = ' ^';
}
return query + (namespace ? prefix + namespace : '');
}
});
});
});