;(function($) { 'use strict'; $.Browser = { defaults: { title: 'Choose Directory (or enter manually)', url: sbRoot + '/browser/', autocompleteURL: sbRoot + '/browser/complete', includeFiles: 0, showBrowseButton: !0 } }; var fileBrowserDialog, currentBrowserPath, currentRequest = null; function browse(path, endpoint, includeFiles) { if (path === currentBrowserPath) { return; } currentBrowserPath = path; if (currentRequest) { currentRequest.abort(); } fileBrowserDialog.dialog('option', 'classes.ui-dialog', 'browserDialog busy'); currentRequest = $.getJSON(endpoint, {path: path, includeFiles: includeFiles}, function(data){ fileBrowserDialog.empty(); var firstVal = data[0], i = 0, list, link = null; data = $.grep(data, function(){ return i++ != 0; }); $('') .val(firstVal.currentPath) .on('keypress', function(e){ if (13 === e.which) { browse(e.target.value, endpoint, includeFiles); } }) .appendTo(fileBrowserDialog) .fileBrowser({showBrowseButton: !1}) .on('autocompleteselect', function(e, ui){browse(ui.item.value, endpoint, includeFiles); }); list = $('