diff --git a/client.js b/client.js index 26e216d1..6ac02be9 100644 --- a/client.js +++ b/client.js @@ -838,7 +838,8 @@ CloudClient.Util = new CloudClient.Util(); CloudClient.KeyBinding = (function(){ /* loading keyBinding module and start it */ Util.jsload(CloudClient.LIBDIRCLIENT+'keyBinding.js', function(){ - CloudCommander.KeyBinding.init(); + cloudcmd.KeyBinding.init(); + KeyBinding = cloudcmd.KeyBinding; }); }); @@ -849,7 +850,7 @@ CloudClient.Editor = (function(pCurrentFile, pIsReadOnly) { Util.jsload(CloudClient.LIBDIRCLIENT + 'editor.js',{ onload:(function(){ - CloudCommander.Editor.Keys(pCurrentFile, pIsReadOnly); + cloudcmd.Editor.Keys(pCurrentFile, pIsReadOnly); }) }); }); @@ -860,7 +861,7 @@ CloudClient.Config = (function() { Util.jsload(CloudClient.LIBDIRCLIENT + 'config.js',{ onload: function(){ - CloudCommander.Config.Keys(); + cloudcmd.Config.Keys(); } }); }); @@ -885,7 +886,7 @@ CloudClient.Viewer = (function(pCurrentFile){ Util.jsload(CloudClient.LIBDIRCLIENT + 'viewer.js',{ onload: (function(){ - CloudCommander.Viewer.Keys(pCurrentFile); + cloudcmd.Viewer.Keys(pCurrentFile); }) }); }); @@ -895,7 +896,7 @@ CloudClient.Terminal = (function(){ Util.jsload(CloudClient.LIBDIRCLIENT + 'terminal.js',{ onload: (function(){ - CloudCommander.Terminal.Keys(); + cloudcmd.Terminal.Keys(); }) }); }); @@ -907,7 +908,7 @@ CloudClient.Menu = (function(pPosition){ Util.jsload(CloudClient.LIBDIRCLIENT + 'menu.js',{ onload: (function(){ - CloudCommander.Menu.Keys(pPosition); + cloudcmd.Menu.Keys(pPosition); }) }); }); diff --git a/lib/client/editor.js b/lib/client/editor.js index 06475a75..96d1f8bc 100644 --- a/lib/client/editor.js +++ b/lib/client/editor.js @@ -4,22 +4,22 @@ var CloudCommander, CloudFunc, CodeMirror; */ (function(){ "use strict"; - var cloudcmd = CloudCommander; - var Util = CloudCommander.Util; - var KeyBinding = CloudCommander.KeyBinding; + var cloudcmd = CloudCommander; + var Util = CloudCommander.Util; + var KeyBinding = CloudCommander.KeyBinding; - CloudCommander.Editor = { + CloudCommander.Editor = { get : (function(){ return this.CodeMirror; }) }; - var Cloud_CodeMirror = {}; + var CloudMirror = {}; /* indicator says CodeMirror still loads */ - Cloud_CodeMirror.loading = false; + CloudMirror.loading = false; /* function loads CodeMirror js and css files */ - Cloud_CodeMirror.load = (function(pCurrentFile, pIsReadOnly){ + CloudMirror.load = (function(pCurrentFile, pIsReadOnly){ /* function shows editor */ var lThis = this; var createEditorDiv = function(){ @@ -69,7 +69,7 @@ var CloudCommander, CloudFunc, CodeMirror; }); /* function shows CodeMirror editor */ - Cloud_CodeMirror.show = (function(pCurrentFile, pIsReadOnly){ + CloudMirror.show = (function(pCurrentFile, pIsReadOnly){ /* if CloudEditor is not loaded - loading him */ var lCloudEditor = Util.getById('CloudEditor'); if(!lCloudEditor) @@ -168,7 +168,7 @@ var CloudCommander, CloudFunc, CodeMirror; }); /* function hides CodeMirror editor */ - Cloud_CodeMirror.hide = (function() { + CloudMirror.hide = (function() { return function(){ KeyBinding.set(); Util.showPanel(); @@ -185,7 +185,7 @@ var CloudCommander, CloudFunc, CodeMirror; }; }); - CloudCommander.Editor.Keys = (function(pCurrentFile, pIsReadOnly){ + cloudcmd.Editor.Keys = (function(pCurrentFile, pIsReadOnly){ "use strict"; var lThis = this.CodeMirror; @@ -197,8 +197,8 @@ var CloudCommander, CloudFunc, CodeMirror; /* если клавиши можно обрабатывать */ if( KeyBinding.get() ){ /* if f4 or f3 pressed */ - var lF3 = CloudCommander.KEY.F3; - var lF4 = CloudCommander.KEY.F4; + var lF3 = cloudcmd.KEY.F3; + var lF4 = cloudcmd.KEY.F4; var lShow = lThis.show.bind(lThis); var lCurrentFile = Util.getCurrentFile(); @@ -231,5 +231,5 @@ var CloudCommander, CloudFunc, CodeMirror; } }); - CloudCommander.Editor.CodeMirror = Cloud_CodeMirror; + cloudcmd.Editor.CodeMirror = CloudMirror; })(); \ No newline at end of file diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index bd606462..a5a8c8de 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -36,6 +36,8 @@ var CloudCommander; F10 : 121 }; + var KEY = cloudcmd.KEY; + cloudcmd.KeyBinding = {}; var KeyBinding = cloudcmd.KeyBinding; @@ -47,7 +49,7 @@ var CloudCommander; KeyBinding.unSet = function(){keyBinded = false;}; KeyBinding.init = (function(){ - var Util = CloudCommander.Util; + var Util = cloudcmd.Util; /* saving state of tabs varibles */ var lTabPanel = { @@ -55,22 +57,20 @@ var CloudCommander; right : 0 }; - - var lKEY = CloudCommander.KEY; - var key_event = function(event){ + var key_event = function(event){ /* получаем выдленный файл*/ var lCurrentFile = Util.getCurrentFile(), lName, i; /* если клавиши можно обрабатывать*/ if(keyBinded && event){ /* open configuration window */ - if(event.keyCode === lKEY.O && event.altKey){ + if(event.keyCode === KEY.O && event.altKey){ console.log('openning config window...'); Util.Images.showLoad(); - if (typeof CloudCommander.Config === 'function') - CloudCommander.Config(); + if (typeof cloudcmd.Config === 'function') + cloudcmd.Config(); } @@ -80,7 +80,7 @@ var CloudCommander; * мы были на левой и * наоборот */ - else if(event.keyCode === lKEY.TAB){ + else if(event.keyCode === KEY.TAB){ console.log('Tab pressed'); try{ @@ -107,26 +107,22 @@ var CloudCommander; event.preventDefault();//запрет на дальнейшее действие } /* if f2 pressed */ - else if(event.keyCode === lKEY.F2){ + else if(event.keyCode === KEY.F2){ } - else if(event.keyCode === lKEY.Delete){ + else if(event.keyCode === KEY.Delete){ Util.removeCurrent(lCurrentFile); } /* if f3 or shift+f3 or alt+f3 pressed */ - else if(event.keyCode === lKEY.F3){ + else if(event.keyCode === KEY.F3){ Util.Images.showLoad(); - var lViewer = CloudCommander.Viewer; - var lEditor = CloudCommander.Editor; - var lTerminal = CloudCommander.Terminal; + var lViewer = cloudcmd.Viewer; + var lEditor = cloudcmd.Editor; if(event.shiftKey && typeof lViewer === 'function') - lViewer(lCurrentFile); - - else if(event.altKey && typeof lTerminal === 'function') - lTerminal(); + lViewer(lCurrentFile); else if (typeof lEditor === 'function') lEditor(lCurrentFile, true); @@ -135,24 +131,29 @@ var CloudCommander; } /* if f4 pressed */ - else if(event.keyCode === lKEY.F4) { + else if(event.keyCode === KEY.F4) { Util.Images.showLoad(); - if (typeof CloudCommander.Editor === 'function') - CloudCommander.Editor(lCurrentFile); + if (typeof cloudcmd.Editor === 'function') + cloudcmd.Editor(lCurrentFile); event.preventDefault();//запрет на дальнейшее действие } - else if(event.keyCode === lKEY.F10 && + else if(event.keyCode === KEY.F10 && event.shiftKey){ - if (typeof CloudCommander.Menu === 'function') - CloudCommander.Menu(); + if (typeof cloudcmd.Menu === 'function') + cloudcmd.Menu(); event.preventDefault();//запрет на дальнейшее действие } + + else if (event.keyCode === KEY.T && event.altKey){ + if(typeof cloudcmd.Terminal === 'function') + cloudcmd.Terminal(); + } /* навигация по таблице файлов*/ /* если нажали клавишу вверх*/ - else if(event.keyCode === lKEY.UP){ + else if(event.keyCode === KEY.UP){ /* если ненайдены выделенные файлы - выходим*/ if(!lCurrentFile) return; @@ -170,7 +171,7 @@ var CloudCommander; } /* если нажали клавишу в низ*/ - else if(event.keyCode === lKEY.DOWN){ + else if(event.keyCode === KEY.DOWN){ /* если ненайдены выделенные файлы - выходим*/ if(!lCurrentFile)return; @@ -188,7 +189,7 @@ var CloudCommander; * переходим к самому верхнему * элементу */ - else if(event.keyCode === lKEY.HOME){ + else if(event.keyCode === KEY.HOME){ /* получаем первый элемент * пропускаем путь и заголовки столбиков * выделяем верхий файл @@ -207,7 +208,7 @@ var CloudCommander; /* если нажали клавишу End * выделяем последний элемент */ - else if( event.keyCode === lKEY.END){ + else if( event.keyCode === KEY.END){ /* выделяем самый нижний файл */ lCurrentFile = lCurrentFile. parentElement.lastElementChild; @@ -222,7 +223,7 @@ var CloudCommander; /* если нажали клавишу page down * проматываем экран */ - else if(event.keyCode === lKEY.PAGE_DOWN){ + else if(event.keyCode === KEY.PAGE_DOWN){ Util.getPanel().scrollByPages(1); for(i=0; i<30; i++){ @@ -238,7 +239,7 @@ var CloudCommander; /* если нажали клавишу page up * проматываем экран */ - else if(event.keyCode === lKEY.PAGE_UP){ + else if(event.keyCode === KEY.PAGE_UP){ Util.getPanel().scrollByPages(-1); for(i=0; i<30; i++){ @@ -261,7 +262,7 @@ var CloudCommander; } /* если нажали Enter - открываем папку*/ - else if(event.keyCode === lKEY.ENTER){ + else if(event.keyCode === KEY.ENTER){ /* если ненайдены выделенные файлы - выходим*/ if(!lCurrentFile)return; @@ -297,7 +298,7 @@ var CloudCommander; * сервера, а не из кэша * (обновляем кэш) */ - else if(event.keyCode === lKEY.R && + else if(event.keyCode === KEY.R && event.ctrlKey){ console.log('+r pressed'); console.log('reloading page...'); @@ -318,14 +319,14 @@ var CloudCommander; */ lRefreshIcon.onclick(); - CloudCommander._currentToParent(lSelectedName); + cloudcmd._currentToParent(lSelectedName); event.preventDefault();//запрет на дальнейшее действие } } /* если нажали +d чистим кэш */ - else if(event.keyCode === lKEY.D && + else if(event.keyCode === KEY.D && event.ctrlKey){ console.log('+d pressed'); console.log('clearing cache...'); @@ -342,7 +343,7 @@ var CloudCommander; * убираем все обработчики * нажатий клавиш */ - else if(event.keyCode === lKEY.Q && + else if(event.keyCode === KEY.Q && event.altKey){ //document.removeEventListener('keydown', key_event,false); console.log('+q pressed'); @@ -361,7 +362,7 @@ var CloudCommander; * устанавливаем все обработчики * нажатий клавиш */ - else if(event.keyCode === lKEY.S && + else if(event.keyCode === KEY.S && event.altKey){ /* обрабатываем нажатия на клавиши*/ keyBinded = true; diff --git a/lib/client/terminal.js b/lib/client/terminal.js index f2cf4dbf..90460a63 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -2,33 +2,40 @@ var CloudCommander, jqconsole; /* object contains terminal jqconsole */ (function(){ - var cloudcmd = CloudCommander; - var Util = CloudCommander.Util; + var cloudcmd = CloudCommander; + var Util = CloudCommander.Util; + + cloudcmd.Terminal = {}; + + jqconsole = {}; - jqconsole.load = (function(pParent){ + jqconsole.load = (function(pParent){ Util.cssLoad({ src : 'lib/client/terminal/ansi.css' }); - Util.jsload({ - src : 'lib/client/terminal/jqconsole-2.7.min.js', - func : function(){ - pParent.init(); - } + Util.jsload('lib/client/terminal/jqconsole-2.7.min.js', function(){ + pParent.init(); }); }); - jqconsole.init = (function(){ - var pConsole = document.getById('terminal'); - if(!pConsole){ - Util.anyload({ - name : 'div', - id :'terminal' - }); + jqconsole.init = (function(){ + var lFM = Util.getById('fm'); + if(lFM){ + var lTerminal = Util.getById('terminal'); + if(!lTerminal){ + Util.anyload({ + name : 'div', + id : 'terminal', + parent : lFM + }); + } } + else + console.log('Error. Something went wrong FM not found'); }); - jqconsole.show = function(){ + jqconsole.show = function(){ $(function () { var jqconsole = $('#terminal').jqconsole('Hi\n', '>>>'); var startPrompt = function () { @@ -41,15 +48,15 @@ var CloudCommander, jqconsole; }); }; startPrompt(); - }); + })(); }; - cloudcmd.Terminal.Keys = (function(){ + cloudcmd.Terminal.Keys = (function(){ "use strict"; /* loading js and css of CodeMirror */ - cloudcmd.Terminal.load(this.jqconsole); + jqconsole.load(jqconsole); var key_event=function(event){ @@ -70,7 +77,6 @@ var CloudCommander, jqconsole; else document.onkeypress=key_event; }); - - CloudCommander.Terminal = {}; - CloudCommander.Terminal.jqconsole = jqconsole; -}); \ No newline at end of file + + cloudcmd.Terminal.jqconsole = jqconsole; +})(); \ No newline at end of file