refactored

This commit is contained in:
coderaiser 2012-09-19 04:30:19 -04:00
parent 00b52ae3c9
commit 469904241a
2 changed files with 68 additions and 70 deletions

View file

@ -28,6 +28,7 @@ var CloudCommander;
Q : 81,
R : 82,
S : 83,
T : 84,
F2 : 113,
F3 : 114,
@ -113,28 +114,25 @@ var CloudCommander;
Util.removeCurrent(lCurrentFile);
}
/* if f3 or shift+f3 pressed */
/* if f3 or shift+f3 or alt+f3 pressed */
else if(event.keyCode === lKEY.F3){
Util.Images.showLoad();
if(event.shiftKey &&
typeof CloudCommander.Viewer === 'function')
CloudCommander.Viewer(lCurrentFile);
else if (typeof CloudCommander.Editor === 'function')
CloudCommander.Editor(lCurrentFile, true);
var lViewer = CloudCommander.Viewer;
var lEditor = CloudCommander.Editor;
var lTerminal = CloudCommander.Terminal;
if(event.shiftKey && typeof lViewer === 'function')
lViewer(lCurrentFile);
else if(event.altKey && typeof lTerminal === 'function')
lTerminal();
else if (typeof lEditor === 'function')
lEditor(lCurrentFile, true);
event.preventDefault();//запрет на дальнейшее действие
}
/* if alt+f3 pressed */
else if(event.keyCode === lKEY.F3 &&
event.altKey){
Util.Images.showLoad();
if (typeof CloudCommander.Terminal === 'function')
CloudCommander.Terminal();
event.preventDefault();//запрет на дальнейшее действие
}
}
/* if f4 pressed */
else if(event.keyCode === lKEY.F4) {

View file

@ -1,32 +1,34 @@
var CloudCommander, jqconsole;
/* object contains terminal jqconsole
*/
CloudCommander.Terminal = {};
CloudCommander.Terminal.jqconsole = {
load: function(pParent){
CloudCommander.cssLoad({
src : 'lib/client/terminal/ansi.css'
/* object contains terminal jqconsole */
(function(){
var cloudcmd = CloudCommander;
var Util = CloudCommander.Util;
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();
}
});
});
CloudCommander.jsload({
src : 'lib/client/terminal/jqconsole-2.7.min.js',
func : function(){
pParent.init();
}
});
},
init: (function(){
jqconsole.init = (function(){
var pConsole = document.getById('terminal');
if(!pConsole){
CloudCommander.anyload({
Util.anyload({
name : 'div',
id :'terminal'
});
}
}),
show: function(){
});
jqconsole.show = function(){
$(function () {
var jqconsole = $('#terminal').jqconsole('Hi\n', '>>>');
var startPrompt = function () {
@ -40,37 +42,35 @@ CloudCommander.Terminal.jqconsole = {
};
startPrompt();
});
},
getById : function(pId){return document.getElementById(pId);},
getByClass : function(pClass){
return document.getElementsByClassName(pClass);
}
};
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();
}
}
};
/* добавляем обработчик клавишь */
if (document.addEventListener)
document.addEventListener('keydown', key_event,false);
else
document.onkeypress=key_event;
cloudcmd.Terminal.Keys = (function(){
"use strict";
/* loading js and css of CodeMirror */
cloudcmd.Terminal.load(this.jqconsole);
var key_event=function(event){
/* если клавиши можно обрабатывать */
if(cloudcmd.keyBinded){
/* if f4 pressed */
if(event.keyCode===114 &&
event.altKey){
jqconsole.show();
}
}
};
/* добавляем обработчик клавишь */
if (document.addEventListener)
document.addEventListener('keydown', key_event,false);
else
document.onkeypress=key_event;
});
CloudCommander.Terminal = {};
CloudCommander.Terminal.jqconsole = jqconsole;
});