diff --git a/common/cloudfunc.js b/common/cloudfunc.js index bb806ef6..cfbf42c2 100644 --- a/common/cloudfunc.js +++ b/common/cloudfunc.js @@ -188,8 +188,8 @@ module.exports.buildFromJSON = (params) => { const name = encode(file.name); const link = prefix + FS + path + name; - const type = getType(file.size); - const size = getSize(file.size); + const {type} = file; + const size = getSize(file); const date = file.date || '--.--.----'; const owner = file.owner || 'root'; @@ -199,7 +199,7 @@ module.exports.buildFromJSON = (params) => { link, title: name, name, - attribute: getAttribute(file.size) + attribute: getAttribute(file.type) }); const dataName = getDataName(file.name); @@ -223,22 +223,20 @@ module.exports.buildFromJSON = (params) => { return fileTable; }; -function getType(size) { - if (size === 'dir') - return 'directory'; - - return 'text-file'; -} - -function getAttribute(size) { - if (size === 'dir') +function getAttribute(type) { + if (type === 'directory') return ''; return 'target="_blank" '; } -function getSize(size) { - if (size === 'dir') +function getSize(file) { + const { + size, + type, + } = file; + + if (type === 'directory') return '<dir>'; return size; diff --git a/css/query.css b/css/query.css index bda5f93c..0765b652 100644 --- a/css/query.css +++ b/css/query.css @@ -107,12 +107,12 @@ color: white; } - .text-file::before { + .file::before, .file-link::before { color: rgba(26, 224, 124, 0.56); content: '\e80d'; } - .current-file .text-file::before { + .current-file .file::before, .file-link::before { color: white; } @@ -133,11 +133,11 @@ display: inline-block; } - .directory::before { + .directory::before, .directory-link::before { content: '\e807'; } - .text-file { + .file, .file-link { background-image: none; } diff --git a/css/urls.css b/css/urls.css index e071784c..ddb381f6 100644 --- a/css/urls.css +++ b/css/urls.css @@ -37,7 +37,15 @@ background-image: url(../img/dir.png); } -.text-file { +.directory-link { + background-image: url(../img/dir.png); +} + +.file { + background-image: url(../img/txt.png); +} + +.file-link { background-image: url(../img/txt.png); } diff --git a/test/common/cloudfunc.html b/test/common/cloudfunc.html index 2251e69a..c5f9a5b2 100644 --- a/test/common/cloudfunc.html +++ b/test/common/cloudfunc.html @@ -20,7 +20,7 @@ root rwx r-x r-x
  • - + ай 1.30kb --.--.---- diff --git a/test/common/cloudfunc.js b/test/common/cloudfunc.js index 98625a0a..46c292e2 100644 --- a/test/common/cloudfunc.js +++ b/test/common/cloudfunc.js @@ -41,16 +41,18 @@ const JSON_FILES = { path : '/etc/X11/', files : [{ name: 'applnk', - size: 'dir', + size: '4.0.0kb', date: '21.02.2016', uid : 0, - mode: 'rwx r-x r-x' + mode: 'rwx r-x r-x', + type: 'directory', }, { name: 'ай', size: '1.30kb', date: 0, uid : 0, - mode: 'rwx r-x r-x' + mode: 'rwx r-x r-x', + type: 'file', }] };