diff --git a/lib/client/viewer.js b/lib/client/viewer.js
index 3b12ec1f..03e360ea 100644
--- a/lib/client/viewer.js
+++ b/lib/client/viewer.js
@@ -3,9 +3,12 @@ var CloudCommander, CloudFunc, $;
* https://github.com/fancyapps/fancyBox
*/
(function(){
- var cloudcmd = CloudCommander;
- var Util = CloudCommander.Util;
- var KeyBinding = CloudCommander.KeyBinding;
+ "use strict";
+
+ var cloudcmd = CloudCommander,
+ Util = CloudCommander.Util,
+ KeyBinding = CloudCommander.KeyBinding,
+ FancyBox;
cloudcmd.Viewer = {
get: (function(){
@@ -13,15 +16,12 @@ var CloudCommander, CloudFunc, $;
})
};
- var FancyBox = {};
-
cloudcmd.Viewer.dir = './lib/client/viewer/';
FancyBox.dir = cloudcmd.Viewer.dir + 'fancybox/';
- /* function return configureation
- * for FancyBox open and
- * onclick (it shoud be
- * different objects)
+ /**
+ * function return configureation for FancyBox open and
+ * onclick (it shoud be different objects)
*/
FancyBox.getConfig = (function(){
return{
@@ -57,7 +57,8 @@ var CloudCommander, CloudFunc, $;
};
});
- /* function loads css and js of FancyBox
+ /**
+ * function loads css and js of FancyBox
* @pParent - this
* @pCallBack - executes, when everything loaded
*/
@@ -93,13 +94,14 @@ var CloudCommander, CloudFunc, $;
});
});
- /* function loads data an put it to pSuccess_f
- * @pA - link to data
- * @pSucces_f - function, thet process data (@data)
+ /**
+ * function loads data an put it to pSuccess_f
+ * @param pA - link to data
+ * @param pSucces_f - function, thet process data (@data)
*
* Example: loadData('index.html', function(pData){console.log(pData)});
*/
- FancyBox.loadData = (function(pA, pSuccess_f){
+ FancyBox.loadData = function(pA, pSuccess_f){
Util.Images.showLoad();
var lThis = this;
@@ -125,9 +127,9 @@ var CloudCommander, CloudFunc, $;
Util.Images.hideLoad();
}
});
- });
+ };
- FancyBox.onDataLoaded = (function(pData){
+ FancyBox.onDataLoaded = function(pData){
var lConfig = FancyBox.getConfig();
/* if we got json - show it */
@@ -135,10 +137,10 @@ var CloudCommander, CloudFunc, $;
pData = JSON.stringify(pData, null, 4);
$.fancybox('
' + pData + '
', lConfig);
- });
+ };
- FancyBox.set = (function(){
+ FancyBox.set = function(){
if(Util.getByClass('fancybox').length)
return;
try{
@@ -147,17 +149,15 @@ var CloudCommander, CloudFunc, $;
/* get all file links */
var lA = Util.getByTag('a', lPanel);
-
- var lThis = this;
-
+
var lDblClick_f = function(pA){
return function(){
- var lConfig = lThis.getConfig();
+ var lConfig = FancyBox.getConfig();
lConfig.href = pA.href;
if(pA.rel)
$.fancybox(lConfig);
else
- lThis.loadData(pA, lThis.onDataLoaded);
+ FancyBox.loadData(pA, FancyBox.onDataLoaded);
};
};
@@ -176,10 +176,13 @@ var CloudCommander, CloudFunc, $;
}catch(pError){
console.log(pError);
}
- });
+ };
- FancyBox.show = (function(pCurrentFile){
+ /**
+ * function shows FancyBox
+ */
+ FancyBox.show = function(pCurrentFile){
FancyBox.set();
var lConfig = this.getConfig();
@@ -199,28 +202,27 @@ var CloudCommander, CloudFunc, $;
}
Util.Images.hideLoad();
- });
+ };
- cloudcmd.Viewer.Keys = (function(pCurrentFile){
- "use strict";
-
+ cloudcmd.Viewer.Keys = function(pCurrentFile){
var lCallBack_f = (function(){
- var key_event = (function(pEvent){
+
+ var lF3 = cloudcmd.KEY.F3;
+ var key_event = function(pEvent){
/* если клавиши можно обрабатывать */
if( KeyBinding.get() )
- if(pEvent.keyCode === cloudcmd.KEY.F3 &&
- pEvent.shiftKey){
+ if(pEvent.keyCode === lF3 && pEvent.shiftKey){
var lCurrentFile = Util.getCurrentFile();
FancyBox.show(lCurrentFile);
-
+
pEvent.preventDefault();
}
- });
+ };
/* добавляем обработчик клавишь */
if (document.addEventListener)
document.addEventListener('keydown', key_event, false);
-
+
else{
var lFunc;
if(typeof document.onkeydown === 'function')
@@ -242,7 +244,7 @@ var CloudCommander, CloudFunc, $;
Util.jqueryLoad(function(){
FancyBox.load(FancyBox, lCallBack_f);
});
- });
+ };
cloudcmd.Viewer.FancyBox = FancyBox;
})();
\ No newline at end of file
diff --git a/lib/server/is-file-changed.js b/lib/server/is-file-changed.js
deleted file mode 100644
index e79fa515..00000000
--- a/lib/server/is-file-changed.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Модуль проверяет поменялось ли содержимое файла по хэшу. */
-
-var fs = require('fs'),
- crypto = require('crypto');
-
-/* object contains hashes of files*/
-var Hashes;
-
-/*
- * Function reads hash table of files
- * checks is file changed or not
- * and return result.
- * @pFileName - name of file
- * @pFileData - data of file
- * result: boolean
- */
-exports.check = function(pFileName, pFileData, pOverWrite_b){
- var lReadedHash;
-
- /* boolean hashes.json changed or not */
- var lHashesChanged_b = false;
-
- if(!Hashes)
- try {
- console.log('trying to read hashes.json');
- Hashes = require(process.cwd() + '/hashes');
-
- }catch(pError) {
- console.log('hashes.json not found... \n');
- Hashes = {};
- }
-
- for(var lFileName in Hashes)
- /* if founded row with
- * file name - save hash
- */
- if (lFileName === pFileName) {
- lReadedHash = Hashes[pFileName];
- break;
- }
-
- /* create hash of file data */
- var lFileHash = crypto.createHash('sha1');
- lFileHash = crypto.createHash('sha1');
- lFileHash.update(pFileData);
- lFileHash = lFileHash.digest('hex');
-
- if(lReadedHash !== lFileHash){
- Hashes[pFileName] = lFileHash;
- lHashesChanged_b = true;
- }
-
- if(pOverWrite_b){
- /* if hashes file was changes - write it */
- if(lHashesChanged_b)
- fs.writeFile('./hashes.json',
- JSON.stringify(Hashes),
- fileWrited('./hashes.json'));
- else console.log('no one file has been changed');
- }
- /* has file changed? */
- return lHashesChanged_b;
-};
-
-/*
- * Функция вызываеться после записи файла
- * и выводит ошибку или сообщает,
- * что файл успешно записан
- */
-function fileWrited(pFileName){
- "use strict";
- return function(error){
- console.log(error?error:('file '+pFileName+' writed...'));
- };
-}
\ No newline at end of file