mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-27 13:34:30 -04:00
Filter accepts RegExp and primitive search sequences.
This commit is contained in:
parent
749a87eaf7
commit
84f543aca5
5 changed files with 42 additions and 22 deletions
|
@ -38,6 +38,18 @@
|
|||
$filter.removeClass('current');
|
||||
}
|
||||
},
|
||||
parseFilterSequence = function (sequence) {
|
||||
|
||||
if (sequence.substr(0,3) === 're:') {
|
||||
return new RegExp(sequence.substr(3));
|
||||
}
|
||||
|
||||
sequence = $.map($.trim(sequence).split(/\s+/), function (part) {
|
||||
|
||||
return H5AI.util.reEscape(part);
|
||||
}).join('|');
|
||||
return new RegExp(sequence);
|
||||
},
|
||||
init = function () {
|
||||
|
||||
if (H5AI.core.settings.showFilter) {
|
||||
|
@ -63,7 +75,7 @@
|
|||
val = $input.val();
|
||||
|
||||
if (val) {
|
||||
filter(new RegExp(val));
|
||||
filter(parseFilterSequence(val));
|
||||
} else {
|
||||
filter();
|
||||
}
|
||||
|
|
|
@ -100,6 +100,10 @@
|
|||
return decodeURI(uri);
|
||||
} catch (err) {}
|
||||
return uri;
|
||||
},
|
||||
reEscape = function (sequence) {
|
||||
|
||||
return sequence.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -108,7 +112,8 @@
|
|||
getAbsHref: getAbsHref,
|
||||
parseSize: parseSize,
|
||||
formatSize: formatSize,
|
||||
checkedDecodeUri: checkedDecodeUri
|
||||
checkedDecodeUri: checkedDecodeUri,
|
||||
reEscape: reEscape
|
||||
};
|
||||
}());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue