Improves filter. See readme and config.js.

This commit is contained in:
Lars Jung 2012-08-03 00:03:27 +02:00
parent eaf6ad3fcb
commit 9e6c612513
4 changed files with 16 additions and 5 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
build
local
*.sublime-*
test

View File

@ -35,6 +35,7 @@ It profits from these great projects:
* adds no JavaScript fallback to PHP version
* fixes duplicate tree entries and empty main views
* adds Google Analytics support (async)
* improves filter (now case-insensitive, now only checks if chars in right order)
* adds `hu` translation by [Rodolffo](http://github.com/Rodolffo)
* updates to [jQuery.qrcode](http://larsjung.de/qrcode/) 0.2
* updates to [jQuery.scrollpanel](http://larsjung.de/scrollpanel/) 0.1

View File

@ -84,7 +84,11 @@ var H5AI_CONFIG = {
/*
* Allow filtering the displayed files and folders.
* Note: filters will be treated as JavaScript regular expressions
* Will check entries for right order of characters, i.e.
* "ab" matches "ab", "axb", "xaxbx" but not "ba".
* Space separated sequences get OR-ed.
*
* Filters will be treated as JavaScript regular expressions
* if you prefix them with "re:".
*/
"filter": {
@ -129,7 +133,7 @@ var H5AI_CONFIG = {
* see: http://support.google.com/googleanalytics/bin/topic.py?hl=en&topic=27612
*/
"google-analytics": {
"enabled": false,
"enabled": true,
"gaq": []
},

View File

@ -61,7 +61,6 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
escapeRegExp = function (sequence) {
return sequence.replace(/[\-\[\]{}()*+?.,\\$\^|#\s]/g, '\\$&');
// return sequence.replace(/[|()\[{.+*?^$\\]/g,"\\$0");
},
parseFilterSequence = function (sequence) {
@ -72,10 +71,15 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
sequence = $.map($.trim(sequence).split(/\s+/), function (part) {
return escapeRegExp(part);
return _.map(part.split(''), function (char) {
return escapeRegExp(char);
}).join('.*?');
// return escapeRegExp(part);
}).join('|');
return new RegExp(sequence);
return new RegExp(sequence, 'i');
},
update = function () {