diff --git a/dashboard-ui/scripts/directorybrowser.js b/dashboard-ui/scripts/directorybrowser.js index 4397cfc8b4..7c711b87b1 100644 --- a/dashboard-ui/scripts/directorybrowser.js +++ b/dashboard-ui/scripts/directorybrowser.js @@ -1,6 +1,6 @@ (function (window, document, $) { - function refreshDirectoryBrowser(page, path) { + function refreshDirectoryBrowser(page, path, fileOptions) { Dashboard.showLoadingMsg(); @@ -16,7 +16,7 @@ promise = ApiClient.getNetworkDevices(); } else if (path) { - promise = ApiClient.getDirectoryContents(path, { includeDirectories: true }); + promise = ApiClient.getDirectoryContents(path, fileOptions); } else { promise = ApiClient.getDrives(); } @@ -46,18 +46,20 @@ parentPath = "Network"; } - html += '
  • ..
  • '; + html += '
  • ..
  • '; } for (var i = 0, length = folders.length; i < length; i++) { var folder = folders[i]; - html += '
  • ' + folder.Name + '
  • '; + var cssClass = folder.Type == "File" ? "lnkPath lnkFile" : "lnkPath lnkDirectory"; + + html += '
  • ' + folder.Name + '
  • '; } if (!path) { - html += '
  • Network
  • '; + html += '
  • Network
  • '; } $('#ulDirectoryPickerList', page).html(html).listview('refresh'); @@ -81,6 +83,19 @@ options = options || {}; + var fileOptions = { + includeDirectories: true, + includeFiles: true + }; + + if (options.includeDirectories != null) { + fileOptions.includeDirectories = options.includeDirectories; + } + + if (options.includeFiles != null) { + fileOptions.includeFiles = options.includeFiles; + } + options.header = options.header || "Select Media Path"; options.instruction = options.instruction || "Any path will do, but for optimal playback of bluray, dvd folders, and games, network paths (UNC) are recommended."; @@ -95,7 +110,7 @@ html += '

    ' + options.instruction + '

    '; html += '
    '; - html += ''; + html += ''; html += '
    '; html += ''; html += '
    '; @@ -107,7 +122,7 @@ html += ''; - + html += '

    '; html += ''; @@ -129,21 +144,26 @@ $(this).off("click").off("change").off("popupafterclose").remove(); - }).on("click", ".lnkDirectory", function () { + }).on("click", ".lnkPath", function () { var path = this.getAttribute('data-path'); - refreshDirectoryBrowser(page, path); + if ($(this).hasClass('lnkFile')) { + $('#txtDirectoryPickerPath', page).val(path); + } else { + refreshDirectoryBrowser(page, path, fileOptions); + } + }).on("click", ".btnRefreshDirectories", function () { var path = $('#txtDirectoryPickerPath', page).val(); - refreshDirectoryBrowser(page, path); + refreshDirectoryBrowser(page, path, fileOptions); }).on("change", "#txtDirectoryPickerPath", function () { - refreshDirectoryBrowser(page, this.value); + refreshDirectoryBrowser(page, this.value, fileOptions); }); var txtCurrentPath = $('#txtDirectoryPickerPath', popup);