|
|
@ -1,16 +1,23 @@
|
|
|
|
var $ = require('jquery');
|
|
|
|
var $ = require('jquery');
|
|
|
|
require('./AutoComplete');
|
|
|
|
require('./AutoComplete');
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.directoryAutoComplete = function() {
|
|
|
|
$.fn.directoryAutoComplete = function(options) {
|
|
|
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
|
|
var query = 'path';
|
|
|
|
var query = 'path';
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
|
|
|
|
includeFiles: options.includeFiles || false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$(this).autoComplete({
|
|
|
|
$(this).autoComplete({
|
|
|
|
resource : '/filesystem',
|
|
|
|
resource : '/filesystem',
|
|
|
|
query : query,
|
|
|
|
query : query,
|
|
|
|
|
|
|
|
data : data,
|
|
|
|
filter : function(filter, response, callback) {
|
|
|
|
filter : function(filter, response, callback) {
|
|
|
|
var matches = [];
|
|
|
|
var matches = [];
|
|
|
|
|
|
|
|
var results = response.directories.concat(response.files);
|
|
|
|
|
|
|
|
|
|
|
|
$.each(response.directories, function(i, d) {
|
|
|
|
$.each(results, function(i, d) {
|
|
|
|
if (d[query] && d[query].startsWith(filter)) {
|
|
|
|
if (d[query] && d[query].startsWith(filter)) {
|
|
|
|
matches.push({ value : d[query] });
|
|
|
|
matches.push({ value : d[query] });
|
|
|
|
}
|
|
|
|
}
|
|
|
|