From b69ad90b26d344653b31ce61d440910dd2c8e0d6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 2 Aug 2012 10:31:56 -0400 Subject: [PATCH] added jqconsole lib --- client.js | 12 ++++++ lib/client/keyBinding.js | 20 ++++++---- lib/client/terminal.js | 84 ++++++++++++++-------------------------- 3 files changed, 53 insertions(+), 63 deletions(-) diff --git a/client.js b/client.js index c15d6101..0045c2e6 100644 --- a/client.js +++ b/client.js @@ -19,6 +19,7 @@ var CloudClient={ keyBinding :function(){},/* функция нажатий обработки клавишь */ Editor :function(){},/* function loads and shows editor */ Viewer :function(){},/* function loads and shows viewer */ + Terminal :function(){},/* function loads and shows terminal */ keyBinded :false,/* оброботка нажатий клавишь установлена*/ _loadDir :function(){}, /* @@ -172,6 +173,17 @@ CloudClient.Viewer = (function(){ }) }); }); + +/* function loads and shows terminal */ +CloudClient.Terminal = (function(){ + CloudCommander.jsload(CloudClient.LIBDIRCLIENT + + 'terminal.js',{ + onload: (function(){ + CloudCommander.Terminal.Keys(); + }) + }); +}); + /* * Функция привязываеться ко всем ссылкам и * загружает содержимое каталогов diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 43e39fe7..2d65fa43 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -56,14 +56,20 @@ CloudCommander.keyBinding=(function(){ /* if f2 pressed */ else if(event.keyCode===113){ - } - else if(event.keyCode===114){ - if (typeof CloudCommander.Viewer === 'function') - CloudCommander.Viewer(); - } - + } + /* if f3 pressed */ + else if(event.keyCode===114){ + if (typeof CloudCommander.Viewer === 'function') + CloudCommander.Viewer(); + } + /* if alt+f3 pressed */ + else if(event.keyCode===114 && + event.altKey){ + if (typeof CloudCommander.Terminal === 'function') + CloudCommander.Terminal(); + } /* if f4 pressed */ - else if(event.keyCode === 115) { + else if(event.keyCode === 115) { if (typeof CloudCommander.Editor === 'function') CloudCommander.Editor(); } diff --git a/lib/client/terminal.js b/lib/client/terminal.js index b5744602..df4becc2 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -17,60 +17,32 @@ CloudCommander.Terminal.jqconsole = { }, init: function(){ - $(function() { - // Creating the console. - var header = 'Welcome to JQConsole!\n' + - 'Use jqconsole.Write() to write and ' + - 'jqconsole.Input() to read.\n'; - window.jqconsole = $('#console').jqconsole(header, 'JS> '); - - // Abort prompt on Ctrl+Z. - jqconsole.RegisterShortcut('Z', function() { - jqconsole.AbortPrompt(); - handler(); - }); - - // Move to line start Ctrl+A. - jqconsole.RegisterShortcut('A', function() { - jqconsole.MoveToStart(); - handler(); - }); - - // Move to line end Ctrl+E. - jqconsole.RegisterShortcut('E', function() { - jqconsole.MoveToEnd(); - handler(); - }); - - jqconsole.RegisterMatching('{', '}', 'brace'); - jqconsole.RegisterMatching('(', ')', 'paran'); - jqconsole.RegisterMatching('[', ']', 'bracket'); - // Handle a command. - var handler = function(command) { - if (command) { - try { - jqconsole.Write('==> ' + window.eval(command) + '\n'); - } catch (e) { - jqconsole.Write('ERROR: ' + e.message + '\n'); - } - } - jqconsole.Prompt(true, handler, function(command) { - // Continue line if can't compile the command. - try { - Function(command); - } catch (e) { - if (/[\[\{\(]$/.test(command)) { - return 1; - } else { - return 0; - } - } - return false; - }); - }; - - // Initiate the first prompt. - handler(); - }); + + } +}; + +CloudCommander.Terminal.Keys = (function(){ + "use strict"; + + /* loading js and css of CodeMirror */ + CloudCommander.Editor.Terminal.load(this.jqconsole); + + var key_event=function(event){ + + /* если клавиши можно обрабатывать */ + if(CloudCommander.keyBinded){ + /* if f4 pressed */ + if(event.keyCode===114 && + event.altKey){ + CloudCommander.Terminal.jqconsole.show(); + } } -}; \ No newline at end of file + }; + + /* добавляем обработчик клавишь */ + if (document.addEventListener) + document.addEventListener('keydown', key_event,false); + + else + document.onkeypress=key_event; +}); \ No newline at end of file