diff --git a/lib/client/dom.js b/lib/client/dom.js index 93d1e810..f2632656 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1,4 +1,4 @@ -var CloudCommander, $, Util, DOM, CloudFunc; +var CloudCommander, Util, DOM, CloudFunc; (function(){ "use strict"; @@ -15,6 +15,8 @@ var CloudCommander, $, Util, DOM, CloudFunc; * private function thet unset currentfile */ function UnSetCurrentFile(pCurrentFile){ + var lRet_b = DOM.isCurrentFile(pCurrentFile); + if(!pCurrentFile) DOM.addCloudStatus({ code : -1, @@ -23,8 +25,6 @@ var CloudCommander, $, Util, DOM, CloudFunc; 'could not be none' }); - var lRet_b = DOM.isCurrentFile(pCurrentFile); - if(lRet_b) DOM.removeClass(pCurrentFile, getCurrentFile()); @@ -129,9 +129,10 @@ var CloudCommander, $, Util, DOM, CloudFunc; XMLHTTP.open(lType, pParams.url, true); XMLHTTP.send(lData); - if( !Util.isFunction(lSuccess_f) ) - console.log('error in DOM.ajax onSuccess:', pParams) && + if( !Util.isFunction(lSuccess_f) ){ + console.log('error in DOM.ajax onSuccess:', pParams); console.log(pParams); + } XMLHTTP.onreadystatechange = function(pEvent){ if (XMLHTTP.readyState === 4 /* Complete */){ diff --git a/lib/client/ie.js b/lib/client/ie.js index e64f715a..010db487 100644 --- a/lib/client/ie.js +++ b/lib/client/ie.js @@ -112,8 +112,8 @@ var Util, DOM, $; parentBorderLeftWidth + pElement.clientWidth / 2; - if ( (overTop || overBottom || overLeft || overRight) - && !centerIfNeeded) + if ( (overTop || overBottom || overLeft || overRight) && + !centerIfNeeded) pElement.scrollIntoView(alignWithTop); }; diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index df9c3a92..084a7f01 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -236,11 +236,11 @@ var CloudCommander, Util, DOM; var lC = lCurrentFile, tryCatch = function(pCurrentFile){ Util.tryCatch(function(){ - pCurrentFile - .previousSibling + return pCurrentFile .previousSibling .previousSibling - .previousSibling; + .previousSibling + .previousSibling; }); }; diff --git a/lib/client/socket.js b/lib/client/socket.js index 168f97f5..89a730ac 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -82,14 +82,14 @@ var CloudCommander, DOM, Util, io; } Messages = []; } - + lStdout = pMsg.stdout; lStderr = pMsg.stderr; if(lStdout) lResult = lTerm.echo(lStdout); - if(lStderr && lStderr.code != 1) + if(lStderr && lStderr.code !== 1) lResult = lTerm.error(lStderr.toString()); } else{ diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index f1219223..c56be6b1 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -18,7 +18,7 @@ var CloudCommander, Util, DOM, $, Github, cb; cloudcmd.Storage = {}; - cb = function (err, data){ console.log(err || data);} + cb = function (err, data){ console.log(err || data);}; /* PRIVATE FUNCTIONS */ diff --git a/lib/client/viewer.js b/lib/client/viewer.js index 73fe9e5e..3e973f51 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -87,7 +87,7 @@ var CloudCommander, Util, DOM, CloudFunc, $; }, padding : 0 }; - }; + } /** * function loads css and js of FancyBox diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 0605850b..35be329b 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -248,7 +248,7 @@ var CloudFunc, exports; lFS_s + lNoJS_s + lTitle + - '"/"' + + '/' + _l + '/' + lHrefEnd; @@ -430,7 +430,7 @@ var CloudFunc, exports; '' : ' target="_blank"') + ' title="' + files[i].name +'"' + - 'draggable=true>' + files[i].name + + ' draggable=true>' + files[i].name + "" + ''; /* если папка - не выводим размер */ diff --git a/lib/util.js b/lib/util.js index 14a1a412..5c6c968a 100644 --- a/lib/util.js +++ b/lib/util.js @@ -31,7 +31,7 @@ var Util, exports; */ Util.strCmp = function (pStr1, pStr2){ return this.isContainStr(pStr1, pStr2) && - pStr1.length == pStr2.length; + pStr1.length === pStr2.length; }; /** diff --git a/test/test.js b/test/test.js index 7d7d5584..242d48d8 100644 --- a/test/test.js +++ b/test/test.js @@ -1,8 +1,12 @@ -var CloudFunc = require('../lib/cloudfunc'); -var assert = require('assert'); - -try{ - var lJSON = [{ +(function(){ + "use strict"; + + var DIR = process.cwd() + '/', + main = require(DIR + 'lib/server/main'), + + CloudFunc = main.cloudfunc, + + lJSON = [{ "path": "/etc/X11/", "size": "dir" }, { @@ -17,8 +21,10 @@ try{ "mode": "100755" }]; - console.time('CloudFunc.buildFromJSON'); + start(); var lResult = CloudFunc.buildFromJSON(lJSON); + end(); + var lExpect = '
  • ' + ''+ '' + '' + - '/' + + '/' + '' + 'etc' + '/X11/' + @@ -40,38 +46,53 @@ try{ 'owner' + 'mode' + '
  • ' + - '
  • ' + - '' + - '..' + - '<dir>' + - '.' + - '
  • ' + - '
  • ' + + '
  • ' + '' + '' + - 'applnk' + + '..' + '' + '<dir>' + - 'root' + - 'rwx r-x r-x' + + '.' + + '' + '
  • ' + - '
  • ' + - '' + - '' + - '' + - 'prefdm' + + '
  • ' + + '' + + '' + + 'applnk' + + '' + + '<dir>' + + 'root' + + 'rwx r-x r-x' + + '
  • ' + + '
  • ' + + '' + + '' + + '' + + 'prefdm' + '' + '' + - '1.30kb' + - 'root' + - 'rwx r-x r-x' + - '
  • 1'; + '1.30kb' + + 'root' + + 'rwx r-x r-x' + + ''; + + for(var i = 0, n = lExpect.length; i < n; i++) + if(lResult[i] !== lExpect[i]){ + console.log('Error in char number: ' + i + '\n' + + 'Expect: ' + lExpect.substr(i) + '\n' + + 'Result: ' + lResult.substr(i) ); + break; + } + if(i===n) + console.log('CloudFunc.buildFromJSON: OK'); - console.timeEnd('CloudFunc.buildFromJSON'); - assert.equal( - lResult, - lExpect, 'Something wrong in buildFromJSON'); -} -catch(pError){ - console.log(pError); -} \ No newline at end of file + + function start(){ + return console.time('CloudFunc.buildFromJSON'); + } + function end(){ + return console.timeEnd('CloudFunc.buildFromJSON'); + } +})(); diff --git a/test/test.sh b/test/test.sh index 209ecf5f..1605986a 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,15 +1,16 @@ -set jshint = "../node_modules/jshint/bin/hint --config ./test/.jshintrc" -echo "jshint server.js client.js cloudcmd.js" -jshint server.js client.js cloudcmd.js -echo "jshint lib/cloudfunc.js lib/client/keyBinding.js" -jshint ./lib/util.js ./lib/cloudfunc.js ./node_modules/minify/minify.js ./lib/client/keyBinding.js -jshint ./lib/client/dom.js ./lib/client/ie.js ./lib/client/menu.js ./lib/client/socket.js ./lib/client/terminal.js ./lib/client/viewer.js ./lib/client/storage/_github.js ./lib/client/menu.js ./lib/client/editor/_codemirror.js -echo "jshint ./package.json ./config.json" -jshint ./package.json ./config.json -#linting css files -npm i recess -echo "recess css/*.css" -./node_modules/recess/bin/recess ../css/*.css -node ./test/test.js -node cloudcmd.js test +#!/bin/sh +echo "jshint server.js client.js cloudcmd.js" +node_modules/jshint/bin/hint --config test/.jshintrc server.js client.js cloudcmd.js +echo "jshint lib/cloudfunc.js lib/client/keyBinding.js" +node_modules/jshint/bin/hint --config test/.jshintrc lib/util.js lib/cloudfunc.js node_modules/minify/minify.js lib/client/keyBinding.js +echo "lib/client/dom.js lib/client/ie.js lib/client/menu.js lib/client/socket.js ./lib/client/terminal.js lib/client/viewer.js lib/client/storage/_github.js lib/client/menu.js lib/client/editor/_codemirror.js" +node_modules/jshint/bin/hint --config test/.jshintrc lib/client/dom.js lib/client/ie.js lib/client/menu.js lib/client/socket.js ./lib/client/terminal.js lib/client/viewer.js lib/client/storage/_github.js lib/client/menu.js lib/client/editor/_codemirror.js +echo "jshint ./package.json ./config.json" +jshint ./package.json ./config.json +#linting css files +npm i recess +echo "recess css/*.css" +./node_modules/recess/bin/recess css/*.css +node test/test.js +node cloudcmd.js test ls ./min \ No newline at end of file