From 2b7a9403aa7fcebcdb30b1d614d41abf485c3f4a Mon Sep 17 00:00:00 2001 From: Gunther Brunner Date: Thu, 1 Oct 2015 17:11:14 +0900 Subject: [PATCH] Style File Explorer along with coding standard. --- .../explorer/explorer-controller.js | 47 ++++++++--------- .../control-panes/explorer/explorer-spec.js | 16 +++--- res/app/control-panes/explorer/index.js | 52 +++++++++---------- 3 files changed, 57 insertions(+), 58 deletions(-) diff --git a/res/app/control-panes/explorer/explorer-controller.js b/res/app/control-panes/explorer/explorer-controller.js index afcc15fd..0c527101 100644 --- a/res/app/control-panes/explorer/explorer-controller.js +++ b/res/app/control-panes/explorer/explorer-controller.js @@ -1,47 +1,46 @@ module.exports = function ExplorerCtrl($scope) { $scope.search = '' - $scope.files = []; - $scope.paths = []; + $scope.files = [] + $scope.paths = [] - var listdir = function(){ - var path = '/'+$scope.paths.join('/'); + var listDir = function () { + var path = '/' + $scope.paths.join('/') $scope.control.fslist(path) - .then(function(result){ + .then(function (result) { $scope.files = result.body; $scope.$digest(); }) - .catch(function(err){ + .catch(function (err) { alert(err.message); }) } - $scope.dirEnter = function(name){ - if (name){ - $scope.paths.push(name); + $scope.dirEnter = function (name) { + if (name) { + $scope.paths.push(name) } - listdir(); - $scope.search = ''; + listDir() + $scope.search = '' } - $scope.dirJump = function(){ - if ($scope.paths.length !== 0){ - $scope.paths.pop(); + $scope.dirJump = function () { + if ($scope.paths.length !== 0) { + $scope.paths.pop() } - listdir(); + listDir() } - $scope.getFile = function(file){ - var path = '/'+$scope.paths.join('/')+'/'+file; + $scope.getFile = function (file) { + var path = '/' + $scope.paths.join('/') + '/' + file $scope.control.fsretrieve(path) - .then(function(result){ - location.href = result.body.href+"?download" + .then(function (result) { + location.href = result.body.href + "?download" }) - .catch(function(err){ - alert(err.message); + .catch(function (err) { + alert(err.message) }) } - - // init - listdir($scope.dir); + // Initialize + listDir($scope.dir) } diff --git a/res/app/control-panes/explorer/explorer-spec.js b/res/app/control-panes/explorer/explorer-spec.js index d93d6f4a..52ebf1af 100644 --- a/res/app/control-panes/explorer/explorer-spec.js +++ b/res/app/control-panes/explorer/explorer-spec.js @@ -1,17 +1,17 @@ describe('FsCtrl', function () { - beforeEach(angular.mock.module(require('./').name)); + beforeEach(angular.mock.module(require('./').name)) - var scope, ctrl; + var scope, ctrl beforeEach(inject(function ($rootScope, $controller) { - scope = $rootScope.$new(); - ctrl = $controller('ExplorerCtrl', {$scope: scope}); - })); + scope = $rootScope.$new() + ctrl = $controller('ExplorerCtrl', {$scope: scope}) + })) it('should ...', inject(function () { - expect(1).toEqual(1); + expect(1).toEqual(1) - })); + })) -}); +}) diff --git a/res/app/control-panes/explorer/index.js b/res/app/control-panes/explorer/index.js index cb6dffed..9de3f0f3 100644 --- a/res/app/control-panes/explorer/index.js +++ b/res/app/control-panes/explorer/index.js @@ -6,32 +6,32 @@ module.exports = angular.module('stf.explorer', []) require('./explorer.jade') ) }]) - .filter('mode2unix', function(){ - return function(mode){ - if(mode !== null){ - var res = []; - var s = ['x', 'w', 'r']; - for (var i = 0; i < 3; i++) { - for (var j = 0; j < 3; j++) { - if ((mode >> (i*3+j)) & 1 !== 0){ - res.unshift(s[j]) - } else { - res.unshift('-') - } - } - } - res.unshift(mode & 040000 ? 'd' : '-'); - return res.join(''); - } - } + .filter('mode2unix', function () { + return function (mode) { + if (mode !== null) { + var res = []; + var s = ['x', 'w', 'r']; + for (var i = 0; i < 3; i++) { + for (var j = 0; j < 3; j++) { + if ((mode >> (i * 3 + j)) & 1 !== 0) { + res.unshift(s[j]) + } else { + res.unshift('-') + } + } + } + res.unshift(mode & 040000 ? 'd' : '-'); + return res.join(''); + } + } }) - .filter('isdir', function(){ - return function(mode){ - if(mode !== null){ - mode = parseInt(mode, 10) - mode = mode - (mode & 0777); - return (mode == 040000) || (mode == 0120000); - } - } + .filter('isdir', function () { + return function (mode) { + if (mode !== null) { + mode = parseInt(mode, 10) + mode = mode - (mode & 0777) + return (mode == 040000) || (mode == 0120000) + } + } }) .controller('ExplorerCtrl', require('./explorer-controller'))