diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index a03e78ca..60877338 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -3,18 +3,22 @@ var Util; (function(scope, Util) { 'use strict'; + var check, rendy; + if (typeof module === 'object' && module.exports) { - Util = require('./util'); + check = require('checkup'); + rendy = require('rendy'); + module.exports = new CloudFuncProto(Util); } else { + check = Util.check; + rendy = Util.render; scope.CloudFunc = new CloudFuncProto(Util); } - function CloudFuncProto(Util) { + function CloudFuncProto() { var CloudFunc = this, Entity = new entityProto(), - check = Util.check, - render = Util.render, FS; /* КОНСТАНТЫ (общие для клиента и сервера)*/ @@ -142,7 +146,7 @@ var Util; if (index) slash = '/'; - pathHTML += render(template, { + pathHTML += rendy(template, { path: path, name: name, slash: slash @@ -181,13 +185,13 @@ var Util; */ refreshPath = CloudFunc.rmLastSlash(path), - fileTable = render(template.path, { + fileTable = rendy(template.path, { link : FS + refreshPath, fullPath : path, path : htmlPath }), - header = render(templateFile, { + header = rendy(templateFile, { tag : 'div', attribute : '', className : 'fm-header', @@ -215,7 +219,7 @@ var Util; link = FS + dotDot; - linkResult = render(template.link, { + linkResult = rendy(template.link, { link : link, title : '..', name : '..' @@ -224,7 +228,7 @@ var Util; dataName = 'data-name="js-file-.." ', attribute = 'draggable="true" ' + dataName, /* Сохраняем путь к каталогу верхнего уровня*/ - fileTable += render(template.file, { + fileTable += rendy(template.file, { tag : 'li', attribute : attribute, className : '', @@ -254,7 +258,7 @@ var Util; owner = file.owner || 'root'; mode = file.mode; - linkResult = render(templateLink, { + linkResult = rendy(templateLink, { link : link, title : file.name, name : Entity.encode(file.name), @@ -264,7 +268,7 @@ var Util; dataName = 'data-name="js-file-' + file.name + '" '; attribute = 'draggable="true" ' + dataName; - fileTable += render(templateFile, { + fileTable += rendy(templateFile, { tag : 'li', attribute : attribute, className : '',