From 25c480ae22ae3a086a98fc3d2dad14bdf7be3842 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 3 Apr 2017 14:00:32 +0300 Subject: [PATCH] chore(cloudfunc) buildFromJSON: es2015-ify --- server/cloudfunc.js | 83 +++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/server/cloudfunc.js b/server/cloudfunc.js index a8b79df5..b066d9b4 100644 --- a/server/cloudfunc.js +++ b/server/cloudfunc.js @@ -9,7 +9,9 @@ const Entity = require('./entity'); const NAME = 'Cloud Commander'; const FS = '/fs'; -let Path; +const Path = store(); + +Path('/'); module.exports.FS = FS; module.exports.apiURL = '/api/v1'; @@ -30,10 +32,7 @@ module.exports.formatMsg = (msg, name, status = 'ok') => { * @path */ module.exports.getTitle = (path) => { - if (!Path) - Path = '/'; - - return NAME + ' - ' + (path || Path); + return NAME + ' - ' + (path || Path()); }; /** Функция получает адреса каждого каталога в пути @@ -84,25 +83,22 @@ function getPathLink(url, prefix, template) { * */ module.exports.buildFromJSON = (params) => { - var attribute, - dotDot, link, dataName, - linkResult, - prefix = params.prefix, - template = params.template, - templateFile = template.file, - templateLink = template.link, - json = params.data, - files = json.files, - path = json.path, - - sort = params.sort || 'name', - order = params.order || 'asc', - - /* - * Строим путь каталога в котором мы находимся - * со всеми подкаталогами - */ - htmlPath = getPathLink(path, prefix, template.pathLink); + const prefix = params.prefix; + const template = params.template; + const templateFile = template.file; + const templateLink = template.link; + const json = params.data; + + const {path, files} = json; + + const sort = params.sort || 'name'; + const order = params.order || 'asc'; + + /* + * Строим путь каталога в котором мы находимся + * со всеми подкаталогами + */ + const htmlPath = getPathLink(path, prefix, template.pathLink); let fileTable = rendy(template.path, { link : prefix + FS + path, @@ -137,33 +133,30 @@ module.exports.buildFromJSON = (params) => { }); /* сохраняем путь */ - Path = path; + Path(path); fileTable += header + '