diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/explorer.js b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/explorer.js index d2f372920a..6917b70d54 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/explorer.js +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/explorer.js @@ -300,6 +300,11 @@ } function browse_directory(dir) { + if (dir.match('^/+$')) { + $('#parentDir').prop('disabled', true); + } else { + $('#parentDir').prop('disabled', false); + } var HELPERS = { 'helper_date_tostring' : function (chunk, ctx, bodies, params) { var value = dust.helpers.tap(params.value, chunk, ctx); @@ -378,11 +383,10 @@ $('#parentDir').click(function () { - var current = current_directory; - var lastIndex = current.lastIndexOf('/'); - var parent = current.substr(0, lastIndex); - browse_directory(parent); - }) + var current = current_directory; + var parent = current.replace(/\/+[^/]+\/*$/,"") || '/'; + browse_directory(parent); + }); function init() { dust.loadSource(dust.compile($('#tmpl-explorer').html(), 'explorer')); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js index f1a5f4a48c..cc555670b2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js @@ -300,6 +300,11 @@ } function browse_directory(dir) { + if (dir.match('^/+$')) { + $('#parentDir').prop('disabled', true); + } else { + $('#parentDir').prop('disabled', false); + } var HELPERS = { 'helper_date_tostring' : function (chunk, ctx, bodies, params) { var value = dust.helpers.tap(params.value, chunk, ctx); @@ -378,10 +383,9 @@ $('#parentDir').click(function () { var current = current_directory; - var lastIndex = current.lastIndexOf('/'); - var parent = current.substr(0, lastIndex); + var parent = current.replace(/\/+[^/]+\/*$/,"") || '/'; browse_directory(parent); - }) + }); function init() {