diff --git a/ChangeLog b/ChangeLog
index ad470a90..142e433c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,10 @@
dispatch
(dispatchKeyEvent, dispatchClickEvent, dispatchDblClickEvent)
+* Changed object name CloudCommander -> CloudCmd
+
+* Moved loading functions to Loader object in DOM module.
+
2012.04.22, v0.2.0
diff --git a/lib/client.js b/lib/client.js
index 02d244c3..80658705 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -1,8 +1,8 @@
-/* Функция которая возвратит обьект CloudCommander
+/* Функция которая возвратит обьект CloudCmd
* @CloudFunc - обьект содержащий общий функционал
* клиентский и серверный
*/
-var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
+var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd;
(function(Util, DOM){
'use strict';
@@ -10,7 +10,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
var Config, Modules, FileTemplate, PathTemplate;
/* Клиентский обьект, содержащий функциональную часть*/
- var CloudCmd = {
+ CloudCmd = {
/* Конструктор CloudClient, который выполняет
* весь функционал по инициализации
*/
@@ -706,8 +706,6 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander;
return Util.stringifyJSON(lFileTable);
};
- CloudCommander = CloudCmd;
-
DOM.addOneTimeListener('load', function(){
/* базовая инициализация*/
CloudCmd.init();
diff --git a/lib/client/config.js b/lib/client/config.js
index e86b5596..1806e1a2 100644
--- a/lib/client/config.js
+++ b/lib/client/config.js
@@ -1,28 +1,26 @@
/* gui module for config.json editing */
-var CloudCommander;
+var CloudCmd;
(function(){
- "use strict";
-
- var cloudcmd = CloudCommander;
+ 'use strict';
var Config = {};
Config.Show = (function(){
console.log('config showed');
- var lFancyBox = cloudcmd.Viewer.FancyBox;
+ var lFancyBox = CloudCmd.Viewer.FancyBox;
lFancyBox.loadData({hreef: 'htlm/config.html'},
lFancyBox.onDataLoaded);
});
Config.Keys = function(){
console.log('config.js loaded');
- cloudcmd.Viewer(function(){
+ CloudCmd.Viewer(function(){
Config.Show();
});
};
- cloudcmd.Config = Config;
+ CloudCmd.Config = Config;
})();
\ No newline at end of file
diff --git a/lib/client/dom.js b/lib/client/dom.js
index 6e449d9f..f0555cb0 100644
--- a/lib/client/dom.js
+++ b/lib/client/dom.js
@@ -1,4 +1,4 @@
-var CloudCommander, Util, DOM, CloudFunc;
+var CloudCmd, Util, DOM, CloudFunc;
(function(Util){
'use strict';
@@ -68,7 +68,6 @@ var CloudCommander, Util, DOM, CloudFunc;
* hide load image
*/
this.hideLoad = function(){
-
DOM.hide( lImages.loading() );
};
@@ -159,7 +158,7 @@ var CloudCommander, Util, DOM, CloudFunc;
var p = pParams;
Images.showLoad( p.imgPosition );
- CloudCommander.getConfig(function(pConfig){
+ CloudCmd.getConfig(function(pConfig){
var lData;
if( Util.isString(p.url) )
@@ -171,7 +170,7 @@ var CloudCommander, Util, DOM, CloudFunc;
lData = p.data;
p.url = pConfig && pConfig.api_url + p.url,
- DOM.ajax({
+ Loader.ajax({
method : p.method,
url : p.url,
data : lData,
@@ -530,27 +529,34 @@ var CloudCommander, Util, DOM, CloudFunc;
return lRet;
};
},
- CmdProto = function(){
- var CURRENT_FILE = 'current-file',
- SELECTED_FILE = 'selected-file',
- XMLHTTP, Title;
+ LoaderProto = function(){
+ var XMLHTTP;
/**
- * private function thet unset currentfile
+ * Function gets id by src
+ * @param pSrc
*
- * @pCurrentFile
+ * Example: http://domain.com/1.js -> 1_js
*/
- function unsetCurrentFile(pCurrentFile){
- var lRet = DOM.isCurrentFile(pCurrentFile);
+ this.getIdBySrc = function(pSrc){
+ var lRet = Util.isString(pSrc);
- if(lRet)
- DOM.removeClass(pCurrentFile, CURRENT_FILE);
+ if(lRet){
+ var lNum = pSrc.lastIndexOf('/') + 1,
+ lSub = pSrc.substr(pSrc, lNum),
+ lID = Util.removeStrOneTime(pSrc, lSub );
+
+ /* убираем точки */
+ while(lID.indexOf('.') > 0)
+ lID = lID.replace('.', '_');
+
+ lRet = lID;
+ }
return lRet;
- }
+ };
-
- /**
+ /**
* load file countent thrue ajax
*
* @param pParams
@@ -598,143 +604,6 @@ var CloudCommander, Util, DOM, CloudFunc;
return lRet;
};
- /**
- * create new folder
- *
- * @pCurrentFile
- */
- this.promptNewDir = function(){
- this.promptNewFile('directory', '?dir');
- };
-
- /**
- * create new file
- *
- * @pCurrentFile
- */
- this.promptNewFile = function(pTypeName, pType){
- var lName = this.getCurrentName(),
- lDir = this.getCurrentDirPath(),
- lMsg = 'New ' + pTypeName || 'File',
- lType = Util.isString(pType) ? pType : '';
-
- if(lName === '..')
- lName = '';
-
- lName = prompt(lMsg, lName);
-
- if(lName)
- RESTfull.save(lDir + lName + lType, null, CloudCommander.refresh);
- };
-
-
-
- /**
- * delete currentfile, prompt before it
- *
- * @pCurrentFile
- */
- this.promptDeleteSelected = function(pCurrentFile){
- var lRet,
- lCurrent, lQuery, lMsg,
- lName = '',
- lMsgAsk = 'Do you really want to delete the ',
- lMsgSel = 'selected ',
- lFiles = this.getSelectedFiles(),
- lSelected = this.getSelectedNames(lFiles),
- i, n = lSelected && lSelected.length;
-
- if(n > 1){
- for(i = 0; i < 5 && i < n; i++)
- lName += '\n' + lSelected[i];
-
- if(n >= 5)
- lName += '\n...';
-
- lMsg = lMsgAsk + lMsgSel + n + ' files/directoris?\n' + lName ;
- lQuery = '?files';
- }else{
- var lType, lIsDir;
-
- /* dom element passed and it is not event */
- if( pCurrentFile && !pCurrentFile.pType)
- lCurrent = pCurrentFile;
- else
- lCurrent = this.getCurrentFile();
-
- lIsDir = this.isCurrentIsDir(lCurrent);
-
- if(lIsDir){
- lQuery = '?dir';
- lType ='directory';
- }
- else
- lType = 'file';
-
- lType += ' ';
-
- lName = this.getCurrentName(lCurrent);
- lMsg = lMsgAsk + lMsgSel + lType + lName + '?';
- }
-
- if(lName !== '..')
- lRet = confirm(lMsg);
- else
- alert('No files selected!');
- if(lRet){
- var lUrl;
-
- if(lCurrent)
- lUrl = this.getCurrentPath(lCurrent);
- else{
- lUrl = this.getCurrentDirPath();
- lCurrent = lFiles[0];
- }
-
- if(lCurrent || lSelected)
- RESTfull.delete(lUrl, lSelected, function(){
- if(n > 1)
- DOM.deleteSelected(lFiles);
- else
- DOM.deleteCurrent(lCurrent);
-
- var lDir = CloudFunc.removeLastSlash(
- DOM.getCurrentDirPath()
- );
-
- Cache.remove(lDir);
- }, lQuery);
-
- return lCurrent;
- }
-
- return lRet;
- };
-
- /**
- * Function gets id by src
- * @param pSrc
- *
- * Example: http://domain.com/1.js -> 1_js
- */
- this.getIdBySrc = function(pSrc){
- var lRet = Util.isString(pSrc);
-
- if(lRet){
- var lNum = pSrc.lastIndexOf('/') + 1,
- lSub = pSrc.substr(pSrc, lNum),
- lID = Util.removeStrOneTime(pSrc, lSub );
-
- /* убираем точки */
- while(lID.indexOf('.') > 0)
- lID = lID.replace('.', '_');
-
- lRet = lID;
- }
-
- return lRet;
- },
-
/**
* create elements and load them to DOM-tree
* one-by-one
@@ -1060,6 +929,138 @@ var CloudCommander, Util, DOM, CloudFunc;
this.socketLoad = function(pCallBack){
this.jsload('/lib/client/socket.js', Util.retExec(pCallBack) );
};
+ },
+ CmdProto = function(){
+ var CURRENT_FILE = 'current-file',
+ SELECTED_FILE = 'selected-file',
+ Title;
+
+ /**
+ * private function thet unset currentfile
+ *
+ * @pCurrentFile
+ */
+ function unsetCurrentFile(pCurrentFile){
+ var lRet = DOM.isCurrentFile(pCurrentFile);
+
+ if(lRet)
+ DOM.removeClass(pCurrentFile, CURRENT_FILE);
+
+ return lRet;
+ }
+
+
+ /**
+ * create new folder
+ *
+ * @pCurrentFile
+ */
+ this.promptNewDir = function(){
+ this.promptNewFile('directory', '?dir');
+ };
+
+ /**
+ * create new file
+ *
+ * @pCurrentFile
+ */
+ this.promptNewFile = function(pTypeName, pType){
+ var lName = this.getCurrentName(),
+ lDir = this.getCurrentDirPath(),
+ lMsg = 'New ' + pTypeName || 'File',
+ lType = Util.isString(pType) ? pType : '';
+
+ if(lName === '..')
+ lName = '';
+
+ lName = prompt(lMsg, lName);
+
+ if(lName)
+ RESTfull.save(lDir + lName + lType, null, CloudCmd.refresh);
+ };
+
+
+ /**
+ * delete currentfile, prompt before it
+ *
+ * @pCurrentFile
+ */
+ this.promptDeleteSelected = function(pCurrentFile){
+ var lRet,
+ lCurrent, lQuery, lMsg,
+ lName = '',
+ lMsgAsk = 'Do you really want to delete the ',
+ lMsgSel = 'selected ',
+ lFiles = this.getSelectedFiles(),
+ lSelected = this.getSelectedNames(lFiles),
+ i, n = lSelected && lSelected.length;
+
+ if(n > 1){
+ for(i = 0; i < 5 && i < n; i++)
+ lName += '\n' + lSelected[i];
+
+ if(n >= 5)
+ lName += '\n...';
+
+ lMsg = lMsgAsk + lMsgSel + n + ' files/directoris?\n' + lName ;
+ lQuery = '?files';
+ }else{
+ var lType, lIsDir;
+
+ /* dom element passed and it is not event */
+ if( pCurrentFile && !pCurrentFile.pType)
+ lCurrent = pCurrentFile;
+ else
+ lCurrent = this.getCurrentFile();
+
+ lIsDir = this.isCurrentIsDir(lCurrent);
+
+ if(lIsDir){
+ lQuery = '?dir';
+ lType ='directory';
+ }
+ else
+ lType = 'file';
+
+ lType += ' ';
+
+ lName = this.getCurrentName(lCurrent);
+ lMsg = lMsgAsk + lMsgSel + lType + lName + '?';
+ }
+
+ if(lName !== '..')
+ lRet = confirm(lMsg);
+ else
+ alert('No files selected!');
+ if(lRet){
+ var lUrl;
+
+ if(lCurrent)
+ lUrl = this.getCurrentPath(lCurrent);
+ else{
+ lUrl = this.getCurrentDirPath();
+ lCurrent = lFiles[0];
+ }
+
+ if(lCurrent || lSelected)
+ RESTfull.delete(lUrl, lSelected, function(){
+ if(n > 1)
+ DOM.deleteSelected(lFiles);
+ else
+ DOM.deleteCurrent(lCurrent);
+
+ var lDir = CloudFunc.removeLastSlash(
+ DOM.getCurrentDirPath()
+ );
+
+ Cache.remove(lDir);
+ }, lQuery);
+
+ return lCurrent;
+ }
+
+ return lRet;
+ };
/**
@@ -1346,7 +1347,7 @@ var CloudCommander, Util, DOM, CloudFunc;
*/
this.setButtonKey = function(pKey, pFunc){
Util.tryCatchLog(function(){
- CloudCommander.KeysPanel[pKey].onclick = pFunc;
+ CloudCmd.KeysPanel[pKey].onclick = pFunc;
});
};
@@ -1359,8 +1360,8 @@ var CloudCommander, Util, DOM, CloudFunc;
this.setTitle = function(pName){
if(!Title)
- Title = this.getByTag('title')[0] ||
- this.anyload({
+ Title = DOMTree.getByTag('title')[0] ||
+ Loader.anyload({
name:'title',
parentElement: document.head,
innerHTML: pName
@@ -1437,7 +1438,7 @@ var CloudCommander, Util, DOM, CloudFunc;
lPath = decodeURI(lPath);
/* убираем адрес хоста*/
- lPath = Util.removeStrOneTime( lPath, [CloudCommander.HOST, CloudFunc.FS] );
+ lPath = Util.removeStrOneTime( lPath, [CloudCmd.HOST, CloudFunc.FS] );
return lPath;
};
@@ -1512,7 +1513,7 @@ var CloudCommander, Util, DOM, CloudFunc;
* then always work with passive
* panel
*/
- if(window.innerWidth < CloudCommander.MIN_ONE_PANEL_WIDTH)
+ if(window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH)
lPanel = this.getById('left');
@@ -1713,7 +1714,7 @@ var CloudCommander, Util, DOM, CloudFunc;
lDotDot = DOM.getById( '..(' + lPanel.id + ')');
DOM.setCurrentFile ( lDotDot );
- CloudCommander.refresh();
+ CloudCmd.refresh();
});
}
};
@@ -1744,7 +1745,7 @@ var CloudCommander, Util, DOM, CloudFunc;
lDotDot = DOM.getById( '..(' + lPanel.id + ')');
DOM.setCurrentFile ( lDotDot );
- CloudCommander.refresh();
+ CloudCmd.refresh();
});
}
};
@@ -1792,17 +1793,19 @@ var CloudCommander, Util, DOM, CloudFunc;
};
},
- Images = Util.extendProto(ImagesProto),
- RESTfull = Util.extendProto(RESTfullProto),
DOMTree = Util.extendProto(DOMTreeProto),
Events = Util.extendProto(EventsProto),
+ Loader = Util.extendProto(LoaderProto),
+ Images = Util.extendProto(ImagesProto),
+ RESTfull = Util.extendProto(RESTfullProto),
Cache = Util.extendProto(CacheProto);
DOMProto = DOMFunc.prototype = new CmdProto();
Util.extend(DOMProto, [
DOMTree,
- Events, {
+ Events,
+ Loader, {
RESTfull: RESTfull,
Images : Images,
Cache : Cache
diff --git a/lib/client/editor/_ace.js b/lib/client/editor/_ace.js
index 75097f2f..d93dc1c4 100644
--- a/lib/client/editor/_ace.js
+++ b/lib/client/editor/_ace.js
@@ -1,207 +1,207 @@
-var CloudCommander, CloudFunc, ace;
-/* object contains editors Ace
- * and later will be Ace
- */
- (function(){
- "use strict";
- var cloudcmd = CloudCommander,
- Util = CloudCommander.Util,
- KeyBinding = CloudCommander.KeyBinding,
- AceEditor = {},
- AceLoaded = false,
- ReadOnly = false,
- AceElement,
- FM;
-
- CloudCommander.Editor = {
- get : (function(){
- return this.Ace;
- })
- };
-
- cloudcmd.Editor.dir = 'lib/client/editor/';
- AceEditor.dir = cloudcmd.Editor.dir + 'ace/';
-
-
- /* private functions */
- function initCodeMirror(pValue){
- if(!FM)
- FM = Util.getById('fm');
-
- AceElement = Util.anyload({
- name : 'div',
- id : 'CodeMirrorEditor',
- className : 'panel',
- parent : FM
- });
-
- var editor = ace.edit("AceEditor");
-
- editor.setTheme("ace/theme/tomorrow_night_blue");
- editor.getSession().setMode("ace/mode/javascript");
-
- /*
- editor.commands.addCommand({
- name : 'new_command',
- //bindKey : {win: 'Esc', mac: 'Esc'},
- bindKey: {win: 'Ctrl-M', mac: 'Command-M'},
- exec : function(pEditor){
- lThis.hide();
- }
- });
- */
-
- editor.setReadOnly(ReadOnly);
-
- editor.setValue(pValue);
- }
-
- /* indicator says Ace still loads */
- AceEditor.loading = false;
-
- /* function loads Ace js and css files */
- AceEditor.load = (function(){
- Util.cssSet({id:'editor',
- inner : '#AceEditor{' +
- 'font-size : 15px;' +
- 'padding : 0 0 0 0;' +
- '}'
- });
-
- /* load Ace main module */
- Util.jsload(AceEditor.dir + 'ace.js', function() {
- Util.jsload(AceEditor.dir + 'mode-javascript.js',
- function(){
- AceLoaded = true;
- AceEditor.show();
- });
- });
- });
-
- /* function shows Ace editor */
- AceEditor.show = (function(){
- /* if Ace function show already
- * called do not call it again
- * if f4 key pressed couple times
- */
- if(this.loading)
- return;
-
- if(!AceLoaded){
- return AceEditor.load();
- }
-
- /* getting link */
- var lCurrentFile = Util.getCurrentFile(),
- lA = Util.getCurrentLink(lCurrentFile);
- lA = lA.href;
-
- /* убираем адрес хоста*/
- lA = '/' + lA.replace(document.location.href,'');
-
- /* checking is this link is to directory */
- var lSize = Util.getByClass('size', lCurrentFile);
- if(lSize){
- lSize = lSize[0].textContent;
-
- /* if directory - load json
- * not html data
- */
- if (lSize === '
')
- /* when folder view
- * is no need to edit
- * data
- */
- ReadOnly = true;
- }
-
- this.loading = true;
- setTimeout(function(){
- lThis.loading = false;},
- 400);
-
- /* reading data from current file */
- Util.ajax({
- url:lA,
- error: (function(jqXHR, textStatus, errorThrown){
- lThis.loading = false;
-
- return Util.Images.showError(jqXHR);
- }),
-
- success:function(data, textStatus, jqXHR){
- /* if we got json - show it */
- if(typeof data === 'object')
- data = JSON.stringify(data, null, 4);
-
- initAce_f(data);
-
- /* removing keyBinding if set */
- KeyBinding.unSet();
-
- Util.hidePanel();
- Util.Images.hideLoad();
-
- lThis.loading = false;
- }
- });
- });
-
- /* function hides Ace editor */
- AceEditor.hide = (function() {
- var lElem = AceElement;
- KeyBinding.set();
-
- if(lElem && FM)
- FM.removeChild(lElem);
-
- Util.showPanel();
- });
-
- cloudcmd.Editor.Keys = (function(pCurrentFile, pIsReadOnly){
- "use strict";
-
- var lThis = this.Ace;
- /* loading js and css of Ace */
- this.Ace.show(pCurrentFile, pIsReadOnly);
-
- var key_event = function(pEvent){
-
- /* если клавиши можно обрабатывать */
- if( KeyBinding.get() ){
- /* if f4 or f3 pressed */
- var lF3 = cloudcmd.KEY.F3;
- var lF4 = cloudcmd.KEY.F4;
- var lShow = Util.bind(lThis.show, lThis);
-
- if(!pEvent.shiftKey){
- if(pEvent.keyCode === lF4)
- lShow();
- else if(pEvent.keyCode === lF3){
- lShow(true);
- }
- }
- }else if (pEvent.keyCode === cloudcmd.KEY.ESC)
- AceEditor.hide();
- };
-
- /* добавляем обработчик клавишь */
- if (document.addEventListener)
- document.addEventListener('keydown', key_event,false);
-
- else{
- var lFunc;
- if(typeof document.onkeydown === 'function')
- lFunc = document.onkeydown;
-
- document.onkeydown = function(){
- if(lFunc)
- lFunc();
-
- key_event();
- };
- }
- });
-
- cloudcmd.Editor.Ace = AceEditor;
+var CloudCmd, CloudFunc, ace;
+/* object contains editors Ace
+ * and later will be Ace
+ */
+ (function(){
+ "use strict";
+ var cloudcmd = CloudCmd,
+ Util = CloudCmd.Util,
+ KeyBinding = CloudCmd.KeyBinding,
+ AceEditor = {},
+ AceLoaded = false,
+ ReadOnly = false,
+ AceElement,
+ FM;
+
+ CloudCmd.Editor = {
+ get : (function(){
+ return this.Ace;
+ })
+ };
+
+ cloudcmd.Editor.dir = 'lib/client/editor/';
+ AceEditor.dir = cloudcmd.Editor.dir + 'ace/';
+
+
+ /* private functions */
+ function initCodeMirror(pValue){
+ if(!FM)
+ FM = Util.getById('fm');
+
+ AceElement = Util.anyload({
+ name : 'div',
+ id : 'CodeMirrorEditor',
+ className : 'panel',
+ parent : FM
+ });
+
+ var editor = ace.edit("AceEditor");
+
+ editor.setTheme("ace/theme/tomorrow_night_blue");
+ editor.getSession().setMode("ace/mode/javascript");
+
+ /*
+ editor.commands.addCommand({
+ name : 'new_command',
+ //bindKey : {win: 'Esc', mac: 'Esc'},
+ bindKey: {win: 'Ctrl-M', mac: 'Command-M'},
+ exec : function(pEditor){
+ lThis.hide();
+ }
+ });
+ */
+
+ editor.setReadOnly(ReadOnly);
+
+ editor.setValue(pValue);
+ }
+
+ /* indicator says Ace still loads */
+ AceEditor.loading = false;
+
+ /* function loads Ace js and css files */
+ AceEditor.load = (function(){
+ Util.cssSet({id:'editor',
+ inner : '#AceEditor{' +
+ 'font-size : 15px;' +
+ 'padding : 0 0 0 0;' +
+ '}'
+ });
+
+ /* load Ace main module */
+ Util.jsload(AceEditor.dir + 'ace.js', function() {
+ Util.jsload(AceEditor.dir + 'mode-javascript.js',
+ function(){
+ AceLoaded = true;
+ AceEditor.show();
+ });
+ });
+ });
+
+ /* function shows Ace editor */
+ AceEditor.show = (function(){
+ /* if Ace function show already
+ * called do not call it again
+ * if f4 key pressed couple times
+ */
+ if(this.loading)
+ return;
+
+ if(!AceLoaded){
+ return AceEditor.load();
+ }
+
+ /* getting link */
+ var lCurrentFile = Util.getCurrentFile(),
+ lA = Util.getCurrentLink(lCurrentFile);
+ lA = lA.href;
+
+ /* убираем адрес хоста*/
+ lA = '/' + lA.replace(document.location.href,'');
+
+ /* checking is this link is to directory */
+ var lSize = Util.getByClass('size', lCurrentFile);
+ if(lSize){
+ lSize = lSize[0].textContent;
+
+ /* if directory - load json
+ * not html data
+ */
+ if (lSize === '')
+ /* when folder view
+ * is no need to edit
+ * data
+ */
+ ReadOnly = true;
+ }
+
+ this.loading = true;
+ setTimeout(function(){
+ lThis.loading = false;},
+ 400);
+
+ /* reading data from current file */
+ Util.ajax({
+ url:lA,
+ error: (function(jqXHR, textStatus, errorThrown){
+ lThis.loading = false;
+
+ return Util.Images.showError(jqXHR);
+ }),
+
+ success:function(data, textStatus, jqXHR){
+ /* if we got json - show it */
+ if(typeof data === 'object')
+ data = JSON.stringify(data, null, 4);
+
+ initAce_f(data);
+
+ /* removing keyBinding if set */
+ KeyBinding.unSet();
+
+ Util.hidePanel();
+ Util.Images.hideLoad();
+
+ lThis.loading = false;
+ }
+ });
+ });
+
+ /* function hides Ace editor */
+ AceEditor.hide = (function() {
+ var lElem = AceElement;
+ KeyBinding.set();
+
+ if(lElem && FM)
+ FM.removeChild(lElem);
+
+ Util.showPanel();
+ });
+
+ cloudcmd.Editor.Keys = (function(pCurrentFile, pIsReadOnly){
+ "use strict";
+
+ var lThis = this.Ace;
+ /* loading js and css of Ace */
+ this.Ace.show(pCurrentFile, pIsReadOnly);
+
+ var key_event = function(pEvent){
+
+ /* если клавиши можно обрабатывать */
+ if( KeyBinding.get() ){
+ /* if f4 or f3 pressed */
+ var lF3 = cloudcmd.KEY.F3;
+ var lF4 = cloudcmd.KEY.F4;
+ var lShow = Util.bind(lThis.show, lThis);
+
+ if(!pEvent.shiftKey){
+ if(pEvent.keyCode === lF4)
+ lShow();
+ else if(pEvent.keyCode === lF3){
+ lShow(true);
+ }
+ }
+ }else if (pEvent.keyCode === cloudcmd.KEY.ESC)
+ AceEditor.hide();
+ };
+
+ /* добавляем обработчик клавишь */
+ if (document.addEventListener)
+ document.addEventListener('keydown', key_event,false);
+
+ else{
+ var lFunc;
+ if(typeof document.onkeydown === 'function')
+ lFunc = document.onkeydown;
+
+ document.onkeydown = function(){
+ if(lFunc)
+ lFunc();
+
+ key_event();
+ };
+ }
+ });
+
+ cloudcmd.Editor.Ace = AceEditor;
})();
\ No newline at end of file
diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js
index cd721292..253471e8 100644
--- a/lib/client/editor/_codemirror.js
+++ b/lib/client/editor/_codemirror.js
@@ -1,9 +1,9 @@
-var CloudCommander, Util, DOM, CodeMirror;
+var CloudCmd, Util, DOM, CodeMirror;
/* object contains editors CodeMirror */
(function(CloudCmd, Util, DOM){
'use strict';
- var KeyBinding = CloudCommander.KeyBinding,
+ var KeyBinding = CloudCmd.KeyBinding,
CodeMirrorEditor = {},
FM,
CodeMirrorElement,
@@ -215,4 +215,4 @@ var CloudCommander, Util, DOM, CodeMirror;
CloudCmd.Editor.CodeMirror = CodeMirrorEditor;
-})(CloudCommander, Util, DOM);
\ No newline at end of file
+})(CloudCmd, Util, DOM);
\ No newline at end of file
diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js
index 56111a50..91a3953d 100644
--- a/lib/client/keyBinding.js
+++ b/lib/client/keyBinding.js
@@ -1,9 +1,9 @@
-var CloudCommander, Util, DOM;
+var CloudCmd, Util, DOM;
(function(CloudCmd, Util, DOM){
'use strict';
/* private property set or set key binding */
- var keyBinded;
+ var Binded;
/* Key constants*/
CloudCmd.KEY = {
@@ -53,11 +53,11 @@ var CloudCommander, Util, DOM;
var KeyBinding = CloudCmd.KeyBinding;
- KeyBinding.get = function(){return keyBinded;};
+ KeyBinding.get = function(){return Binded;};
- KeyBinding.set = function(){keyBinded = true;};
+ KeyBinding.set = function(){Binded = true;};
- KeyBinding.unSet = function(){keyBinded = false;};
+ KeyBinding.unSet = function(){Binded = false;};
KeyBinding.init = function(){
/* saving state of tabs varibles */
@@ -75,7 +75,7 @@ var CloudCommander, Util, DOM;
lAlt = pEvent.altKey,
lCtrl = pEvent.ctrlKey;
/* если клавиши можно обрабатывать*/
- if(keyBinded){
+ if(Binded){
switch(lKeyCode){
case KEY.TAB:
/* changing parent panel of curent-file */
@@ -323,7 +323,7 @@ var CloudCommander, Util, DOM;
'press +s to to set them');
/* обработчик нажатий клавиш снят*/
- keyBinded = false;
+ Binded = false;
DOM.preventDefault(pEvent);
}
break;
@@ -335,7 +335,7 @@ var CloudCommander, Util, DOM;
*/
else if(lKeyCode === KEY.S && lAlt){
/* обрабатываем нажатия на клавиши*/
- keyBinded = true;
+ Binded = true;
Util.log('+s pressed\n' +
'+r reload key-handerl - set\n' +
'+s clear cache key-handler - set\n' +
@@ -348,7 +348,7 @@ var CloudCommander, Util, DOM;
DOM.addKeyListener(key_event);
/* клавиши назначены*/
- keyBinded = true;
+ Binded = true;
};
-})(CloudCommander, Util, DOM);
\ No newline at end of file
+})(CloudCmd, Util, DOM);
\ No newline at end of file
diff --git a/lib/client/menu.js b/lib/client/menu.js
index 3f5c5e14..b4a34506 100644
--- a/lib/client/menu.js
+++ b/lib/client/menu.js
@@ -1,7 +1,7 @@
/* object contains jQuery-contextMenu
* https://github.com/medialize/jQuery-contextMenu
*/
-var CloudCommander, Util, DOM, CloudFunc, $;
+var CloudCmd, Util, DOM, CloudFunc, $;
(function(CloudCmd, Util, DOM, CloudFunc){
'use strict';
@@ -119,12 +119,11 @@ var CloudCommander, Util, DOM, CloudFunc, $;
DOM.Images.showLoad();
var lPath = DOM.getCurrentPath(),
- lId = DOM.getIdBySrc(lPath);
+ lId = DOM.getIdBySrc(lPath),
+ lDir = DOM.isCurrentIsDir() ? '&&json' : '';
Util.log('downloading file ' + lPath +'...');
- var lDir = DOM.isCurrentIsDir() ? '&&json' : '';
-
lPath = CloudFunc.FS + lPath + '?download' + lDir;
if(!DOM.getById(lId)){
@@ -313,4 +312,4 @@ var CloudCommander, Util, DOM, CloudFunc, $;
};
CloudCmd.Menu = Menu;
-})(CloudCommander, Util, DOM, CloudFunc);
\ No newline at end of file
+})(CloudCmd, Util, DOM, CloudFunc);
\ No newline at end of file
diff --git a/lib/client/socket.js b/lib/client/socket.js
index bb6dcf96..32041b78 100644
--- a/lib/client/socket.js
+++ b/lib/client/socket.js
@@ -1,103 +1,103 @@
-/* module make possible connectoin thrue socket.io on a client */
-var CloudCommander, Util, DOM, io;
-(function(CloudCmd, Util, DOM){
- 'use strict';
-
- var Messages = [],
- socket,
- Terminal,
-
- ERROR_MSG = 'could not connect to socket.io\n'+
- 'npm i socket.io';
-
- function getTerminal(){
- return CloudCmd.Terminal.JqueryTerminal;
- }
-
- DOM.jsload('/socket.io/lib/socket.io.js', {
- onerror : Util.retExec(Util.log, ERROR_MSG),
-
- onload : function(){
- socket = io.connect(CloudCmd.HOST);
-
- CloudCmd.Socket = socket;
-
- socket.on('connect', function () {
- Terminal = getTerminal();
-
- if(Terminal){
- outToTerminal({stdout: 'socket connected'});
-
- Terminal.Term.resume();
- }
- });
-
- socket.on('message', function (msg) {
- var lMsg = Util.parseJSON(msg);
-
- outToTerminal(lMsg);
-
- });
-
- socket.on('disconnect', function () {
- Terminal = getTerminal();
-
- if(Terminal){
- outToTerminal({stderr: 'socket disconected'});
-
- Terminal.Term.pause();
- }
- });
- }
- });
-
- function outToTerminal(pMsg){
- var lResult, lTerm;
-
- Terminal = getTerminal();
- if(Terminal)
- lTerm = Terminal.Term;
-
- if(lTerm){
- var lStdout,
- lStderr;
-
- if(Messages.length){
- /* show oll msg from buffer */
- for(var i = 0, n = Messages.length; i < n; i++){
- lStdout = Messages[i].stdout;
- lStderr = Messages[i].stderr;
-
- if(lStdout)
- lTerm.echo(lStdout);
-
- if(lStderr){
- /* if it's object - convert is to string' */
- if( Util.isObject(lStderr) )
- lStderr = Util.stringifyJSON(lStderr);
-
- lTerm.error(lStderr);
- }
- }
- Messages = [];
- }
-
- lStdout = pMsg.stdout;
- lStderr = pMsg.stderr;
-
- if(lStdout)
- lResult = lTerm.echo(lStdout);
-
- if(lStderr && lStderr.code !== 1)
- lResult = lTerm.error(lStderr.toString());
- }
- else
- /* if term not accesable save msg to buffer */
- Messages.push(pMsg);
-
- Util.log(pMsg);
-
- return lResult;
- }
-
-})(CloudCommander, Util, DOM);
\ No newline at end of file
+/* module make possible connectoin thrue socket.io on a client */
+var CloudCmd, Util, DOM, io;
+(function(CloudCmd, Util, DOM){
+ 'use strict';
+
+ var Messages = [],
+ socket,
+ Terminal,
+
+ ERROR_MSG = 'could not connect to socket.io\n'+
+ 'npm i socket.io';
+
+ function getTerminal(){
+ return CloudCmd.Terminal.JqueryTerminal;
+ }
+
+ DOM.jsload('/socket.io/lib/socket.io.js', {
+ onerror : Util.retExec(Util.log, ERROR_MSG),
+
+ onload : function(){
+ socket = io.connect(CloudCmd.HOST);
+
+ CloudCmd.Socket = socket;
+
+ socket.on('connect', function () {
+ Terminal = getTerminal();
+
+ if(Terminal){
+ outToTerminal({stdout: 'socket connected'});
+
+ Terminal.Term.resume();
+ }
+ });
+
+ socket.on('message', function (msg) {
+ var lMsg = Util.parseJSON(msg);
+
+ outToTerminal(lMsg);
+
+ });
+
+ socket.on('disconnect', function () {
+ Terminal = getTerminal();
+
+ if(Terminal){
+ outToTerminal({stderr: 'socket disconected'});
+
+ Terminal.Term.pause();
+ }
+ });
+ }
+ });
+
+ function outToTerminal(pMsg){
+ var lResult, lTerm;
+
+ Terminal = getTerminal();
+ if(Terminal)
+ lTerm = Terminal.Term;
+
+ if(lTerm){
+ var lStdout,
+ lStderr;
+
+ if(Messages.length){
+ /* show oll msg from buffer */
+ for(var i = 0, n = Messages.length; i < n; i++){
+ lStdout = Messages[i].stdout;
+ lStderr = Messages[i].stderr;
+
+ if(lStdout)
+ lTerm.echo(lStdout);
+
+ if(lStderr){
+ /* if it's object - convert is to string' */
+ if( Util.isObject(lStderr) )
+ lStderr = Util.stringifyJSON(lStderr);
+
+ lTerm.error(lStderr);
+ }
+ }
+ Messages = [];
+ }
+
+ lStdout = pMsg.stdout;
+ lStderr = pMsg.stderr;
+
+ if(lStdout)
+ lResult = lTerm.echo(lStdout);
+
+ if(lStderr && lStderr.code !== 1)
+ lResult = lTerm.error(lStderr.toString());
+ }
+ else
+ /* if term not accesable save msg to buffer */
+ Messages.push(pMsg);
+
+ Util.log(pMsg);
+
+ return lResult;
+ }
+
+})(CloudCmd, Util, DOM);
\ No newline at end of file
diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js
index 2fa9feb4..d64edeef 100644
--- a/lib/client/storage/_dropbox.js
+++ b/lib/client/storage/_dropbox.js
@@ -1,4 +1,4 @@
-var CloudCommander, Util, DOM, Dropbox, cb, Client;
+var CloudCmd, Util, DOM, Dropbox, cb, Client;
/* module for work with github */
(function(CloudCmd, Util, DOM){
@@ -108,4 +108,4 @@ var CloudCommander, Util, DOM, Dropbox, cb, Client;
};
CloudCmd.DropBox = DropBoxStore;
-})(CloudCommander, Util, DOM);
+})(CloudCmd, Util, DOM);
diff --git a/lib/client/storage/_dropbox_chooser.js b/lib/client/storage/_dropbox_chooser.js
index 5532e1a9..e3a59f5e 100644
--- a/lib/client/storage/_dropbox_chooser.js
+++ b/lib/client/storage/_dropbox_chooser.js
@@ -1,55 +1,54 @@
-var CloudCommander, DOM, Dropbox;
-/* module for work with github */
-
-(function(){
- "use strict";
-
- var cloudcmd = CloudCommander,
- CHOOSER_API = 'https://www.dropbox.com/static/api/1/dropbox.js',
- CLIENT_ID,
- DropBoxStore = {},
- options = {
- linkType: "direct",
- success: function(files) {
- console.log("Here's the file link:" + files[0].link);
- },
- cancel: function() {
- console.log('Chose something');
- }
- };
-
- /* PRIVATE FUNCTIONS */
-
- /**
- * function loads dropbox.js
- */
- function load(){
- console.time('dropbox load');
-
- cloudcmd.getConfig(function(pConfig){
- var lElement = DOM.anyload({
- src : CHOOSER_API,
- not_append : true,
- id : 'dropboxjs',
- func : DropBoxStore.choose
-
- });
-
- var lDropBoxId = pConfig.dropbox_chooser_key;
- lElement.setAttribute('data-app-key', lDropBoxId);
- document.body.appendChild(lElement);
-
- console.timeEnd('dropbox load');
- });
- }
-
- DropBoxStore.choose = function(){
- Dropbox.choose(options);
- };
-
- DropBoxStore.init = function(){
- load();
- };
-
- cloudcmd.DropBox = DropBoxStore;
-})();
+var CloudCmd, DOM, Dropbox;
+/* module for work with github */
+
+(function(CloudCmd, DOM){
+ 'use strict';
+
+ var CHOOSER_API = 'https://www.dropbox.com/static/api/1/dropbox.js',
+ CLIENT_ID,
+ DropBoxStore = {},
+ options = {
+ linkType: "direct",
+ success: function(files) {
+ console.log("Here's the file link:" + files[0].link);
+ },
+ cancel: function() {
+ console.log('Chose something');
+ }
+ };
+
+ /* PRIVATE FUNCTIONS */
+
+ /**
+ * function loads dropbox.js
+ */
+ function load(){
+ console.time('dropbox load');
+
+ CloudCmd.getConfig(function(pConfig){
+ var lElement = DOM.anyload({
+ src : CHOOSER_API,
+ not_append : true,
+ id : 'dropboxjs',
+ func : DropBoxStore.choose
+
+ });
+
+ var lDropBoxId = pConfig.dropbox_chooser_key;
+ lElement.setAttribute('data-app-key', lDropBoxId);
+ document.body.appendChild(lElement);
+
+ console.timeEnd('dropbox load');
+ });
+ }
+
+ DropBoxStore.choose = function(){
+ Dropbox.choose(options);
+ };
+
+ DropBoxStore.init = function(){
+ load();
+ };
+
+ CloudCmd.DropBox = DropBoxStore;
+})(CloudCmd, DOM);
diff --git a/lib/client/storage/_filepicker.js b/lib/client/storage/_filepicker.js
index 9dcd50ef..d029fc59 100644
--- a/lib/client/storage/_filepicker.js
+++ b/lib/client/storage/_filepicker.js
@@ -1,4 +1,4 @@
-var CloudCommander, Util, DOM, $, filepicker;
+var CloudCmd, Util, DOM, $, filepicker;
/* module for work with filepicker */
(function(CloudCmd, Util, DOM){
@@ -55,4 +55,4 @@ var CloudCommander, Util, DOM, $, filepicker;
};
CloudCmd.FilePicker = new FilePicker();
-})(CloudCommander, Util, DOM);
+})(CloudCmd, Util, DOM);
diff --git a/lib/client/storage/_gdrive.js b/lib/client/storage/_gdrive.js
index b8a83c39..21aad69f 100644
--- a/lib/client/storage/_gdrive.js
+++ b/lib/client/storage/_gdrive.js
@@ -1,4 +1,4 @@
-var CloudCommander, Util, DOM, gapi;
+var CloudCmd, Util, DOM, gapi;
(function(CloudCmd, Util, DOM){
'use strict';
@@ -106,4 +106,4 @@ var CloudCommander, Util, DOM, gapi;
};
CloudCmd.GDrive = GDrive;
-})(CloudCommander, Util, DOM);
\ No newline at end of file
+})(CloudCmd, Util, DOM);
\ No newline at end of file
diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js
index e1593d2b..773bbffd 100644
--- a/lib/client/storage/_github.js
+++ b/lib/client/storage/_github.js
@@ -1,4 +1,4 @@
-var CloudCommander, Util, DOM, $, Github, cb;
+var CloudCmd, Util, DOM, $, Github, cb;
/* module for work with github */
(function(CloudCmd, Util, DOM){
@@ -156,4 +156,4 @@ var CloudCommander, Util, DOM, $, Github, cb;
};
CloudCmd.GitHub = GitHubStore;
-})(CloudCommander, Util, DOM);
+})(CloudCmd, Util, DOM);
diff --git a/lib/client/storage/_skydrive.js b/lib/client/storage/_skydrive.js
index 5d8f1871..874f16e8 100644
--- a/lib/client/storage/_skydrive.js
+++ b/lib/client/storage/_skydrive.js
@@ -1,5 +1,5 @@
//http://isdk.dev.live.com/ISDK.aspx?category=scenarioGroup_skyDrive&index=0
-var CloudCommander, Util, DOM, WL;
+var CloudCmd, Util, DOM, WL;
(function(CloudCmd, Util, DOM){
'use strict';
@@ -75,4 +75,4 @@ var CloudCommander, Util, DOM, WL;
CloudCmd.SkyDrive = SkyDrive;
-})(CloudCommander, Util, DOM);
+})(CloudCmd, Util, DOM);
diff --git a/lib/client/storage/_vk.js b/lib/client/storage/_vk.js
index 66972fa0..27d9d5cf 100644
--- a/lib/client/storage/_vk.js
+++ b/lib/client/storage/_vk.js
@@ -1,97 +1,97 @@
-var CloudCommander, Util, DOM, VK;
-
-(function(CloudCmd, Util, DOM){
- 'use strict';
-
- var VKStorage = {};
-
-
- /* PRIVATE FUNCTIONS */
-
- /**
- * load google api library
- */
- function load(pCallBack){
- console.time('vk');
-
- var lUrl = 'http://vkontakte.ru/js/api/openapi.js',
- lLocal = CloudCmd.LIBDIRCLIENT + 'storage/vk/open.js',
-
- lOnload = function(){
- console.timeEnd('vk load');
- DOM.Images.hideLoad();
-
- Util.exec(pCallBack);
- };
-
- DOM.jsload(lUrl, {
- onload : lOnload,
- error : DOM.retJSLoad(lLocal, lOnload)
- });
-
- }
-
- function auth(pCallBack){
- CloudCmd.getConfig(function(pConfig){
- var lDOCUMENTS_ACCESS = 131072;
-
- VK.init({ apiId: pConfig.vk_id});
-
- VK.Auth.login(function(){
- var lNAME = 1281;
- VK.Api.call('getVariable', {key: lNAME}, function(r) {
- var lName = r.response;
-
- if(lName)
- Util.log ('Hello, ' + lName + ':)');
- });
-
- Util.exec(pCallBack);
-
- }, lDOCUMENTS_ACCESS); /* Доступ к документам пользователя */
- });
- }
-
-
- /**
- * Insert new file.
- *
- * @param {File} fileData {name, data} File object to read data from.
- * @param {Function} callback Function to call when the request is complete.
- */
- VKStorage.uploadFile = function(pParams, pCallBack) {
- /* http://vk.com/developers.php?oid=-1&p=docs.getUploadServer */
- VK.Api.call('docs.getUploadServer', {}, function(pResult){
- var lURL = pResult.response.upload_url,
- lData = pParams.data,
- lName = pParams.name;
-
- DOM.ajax({
- type : "POST",
- url : lURL,
- data : {
- file: lData,
- name: lName
- },
- dataType: 'application/x-www-form-urlencoded',
- success : function(pData){
- Util.log(pData);
- VK.Api.call('docs.save', {}, Util.log);
- },
-
- error : Util.log
- });
- });
- };
-
-
- VKStorage.init = function(pCallBack){
- Util.loadOnLoad([
- Util.retExec(pCallBack),
- auth,
- load
- ]);
- };
-
- CloudCmd.VK = VKStorage;
-})(CloudCommander, Util, DOM);
\ No newline at end of file
+var CloudCmd, Util, DOM, VK;
+
+(function(CloudCmd, Util, DOM){
+ 'use strict';
+
+ var VKStorage = {};
+
+
+ /* PRIVATE FUNCTIONS */
+
+ /**
+ * load google api library
+ */
+ function load(pCallBack){
+ console.time('vk');
+
+ var lUrl = 'http://vkontakte.ru/js/api/openapi.js',
+ lLocal = CloudCmd.LIBDIRCLIENT + 'storage/vk/open.js',
+
+ lOnload = function(){
+ console.timeEnd('vk load');
+ DOM.Images.hideLoad();
+
+ Util.exec(pCallBack);
+ };
+
+ DOM.jsload(lUrl, {
+ onload : lOnload,
+ error : DOM.retJSLoad(lLocal, lOnload)
+ });
+
+ }
+
+ function auth(pCallBack){
+ CloudCmd.getConfig(function(pConfig){
+ var lDOCUMENTS_ACCESS = 131072;
+
+ VK.init({ apiId: pConfig.vk_id});
+
+ VK.Auth.login(function(){
+ var lNAME = 1281;
+ VK.Api.call('getVariable', {key: lNAME}, function(r) {
+ var lName = r.response;
+
+ if(lName)
+ Util.log ('Hello, ' + lName + ':)');
+ });
+
+ Util.exec(pCallBack);
+
+ }, lDOCUMENTS_ACCESS); /* Доступ к документам пользователя */
+ });
+ }
+
+
+ /**
+ * Insert new file.
+ *
+ * @param {File} fileData {name, data} File object to read data from.
+ * @param {Function} callback Function to call when the request is complete.
+ */
+ VKStorage.uploadFile = function(pParams, pCallBack) {
+ /* http://vk.com/developers.php?oid=-1&p=docs.getUploadServer */
+ VK.Api.call('docs.getUploadServer', {}, function(pResult){
+ var lURL = pResult.response.upload_url,
+ lData = pParams.data,
+ lName = pParams.name;
+
+ DOM.ajax({
+ type : "POST",
+ url : lURL,
+ data : {
+ file: lData,
+ name: lName
+ },
+ dataType: 'application/x-www-form-urlencoded',
+ success : function(pData){
+ Util.log(pData);
+ VK.Api.call('docs.save', {}, Util.log);
+ },
+
+ error : Util.log
+ });
+ });
+ };
+
+
+ VKStorage.init = function(pCallBack){
+ Util.loadOnLoad([
+ Util.retExec(pCallBack),
+ auth,
+ load
+ ]);
+ };
+
+ CloudCmd.VK = VKStorage;
+})(CloudCmd, Util, DOM);
\ No newline at end of file
diff --git a/lib/client/terminal.js b/lib/client/terminal.js
index 341a6448..4dc7f503 100644
--- a/lib/client/terminal.js
+++ b/lib/client/terminal.js
@@ -1,4 +1,4 @@
-var CloudCommander, Util, DOM, $;
+var CloudCmd, Util, DOM, $;
/* object contains terminal jqconsole */
(function(CloudCmd, Util, DOM){
@@ -133,4 +133,4 @@ var CloudCommander, Util, DOM, $;
CloudCmd.Terminal.JqueryTerminal = JqueryTerminal;
-})(CloudCommander, Util, DOM);
+})(CloudCmd, Util, DOM);
diff --git a/lib/client/viewer.js b/lib/client/viewer.js
index 071859f2..cdc0e30d 100644
--- a/lib/client/viewer.js
+++ b/lib/client/viewer.js
@@ -1,4 +1,4 @@
-var CloudCommander, Util, DOM, CloudFunc, $;
+var CloudCmd, Util, DOM, CloudFunc, $;
/* object contains viewer FancyBox
* https://github.com/fancyapps/fancyBox
*/
@@ -159,4 +159,4 @@ var CloudCommander, Util, DOM, CloudFunc, $;
CloudCmd.Viewer.FancyBox = FancyBox;
-})(CloudCommander, Util, DOM, CloudFunc);
\ No newline at end of file
+})(CloudCmd, Util, DOM, CloudFunc);
\ No newline at end of file