mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +00:00
refactored CodeMirror editor plagin
This commit is contained in:
parent
1cd997583d
commit
4c181a026d
3 changed files with 42 additions and 16 deletions
|
|
@ -21,8 +21,14 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
})
|
||||
};
|
||||
|
||||
cloudcmd.Editor.dir = 'lib/client/editor/';
|
||||
CodeMirrorEditor.dir = cloudcmd.Editor.dir + 'codemirror/';
|
||||
|
||||
/* private functions */
|
||||
|
||||
/**
|
||||
* function initialize CodeMirror
|
||||
*/
|
||||
function initCodeMirror(pValue){
|
||||
if(!FM)
|
||||
FM = Util.getById('fm');
|
||||
|
|
@ -50,11 +56,10 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
});
|
||||
}
|
||||
|
||||
cloudcmd.Editor.dir = 'lib/client/editor/';
|
||||
CodeMirrorEditor.dir = cloudcmd.Editor.dir + 'codemirror/';
|
||||
|
||||
/* function loads CodeMirror js and css files */
|
||||
CodeMirrorEditor.load = (function(){
|
||||
/**
|
||||
* function loads CodeMirror js and css files
|
||||
*/
|
||||
function load(){
|
||||
/* function loads css files of CodeMirror */
|
||||
var loadAll = function() {
|
||||
Util.cssLoad([
|
||||
|
|
@ -88,13 +93,15 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
|
||||
/* load CodeMirror main module */
|
||||
Util.jsload(CodeMirrorEditor.dir + 'codemirror.js', loadAll);
|
||||
});
|
||||
}
|
||||
|
||||
/* function shows CodeMirror editor */
|
||||
/**
|
||||
* function shows CodeMirror editor
|
||||
*/
|
||||
CodeMirrorEditor.show = (function(){
|
||||
/* if CodeMirrorEditor is not loaded - loading him */
|
||||
if(!CodeMirrorLoaded)
|
||||
return this.load();
|
||||
return load();
|
||||
|
||||
/* if CodeMirror function show already
|
||||
* called do not call it again
|
||||
|
|
@ -166,7 +173,9 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
});
|
||||
});
|
||||
|
||||
/* function hides CodeMirror editor */
|
||||
/**
|
||||
* function hides CodeMirror editor
|
||||
*/
|
||||
CodeMirrorEditor.hide = (function() {
|
||||
var lElem = CodeMirrorElement;
|
||||
KeyBinding.set();
|
||||
|
|
@ -177,6 +186,9 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
Util.showPanel();
|
||||
});
|
||||
|
||||
/**
|
||||
* function bind keys
|
||||
*/
|
||||
cloudcmd.Editor.Keys = (function(pIsReadOnly){
|
||||
ReadOnly = pIsReadOnly;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,14 @@ var CloudCommander, $;
|
|||
TerminalId,
|
||||
Term,
|
||||
Hidden = false;
|
||||
|
||||
|
||||
cloudcmd.Terminal = {};
|
||||
|
||||
var JqueryTerminal = {};
|
||||
|
||||
|
||||
/**
|
||||
* function loads jquery-terminal
|
||||
*/
|
||||
JqueryTerminal.load = (function(){
|
||||
Util.cssLoad({
|
||||
src : 'lib/client/terminal/jquery-terminal/jquery.terminal.css'
|
||||
|
|
@ -48,6 +50,9 @@ var CloudCommander, $;
|
|||
});
|
||||
|
||||
|
||||
/**
|
||||
* function do basic initialization
|
||||
*/
|
||||
JqueryTerminal.init = (function(){
|
||||
if(!TerminalId){
|
||||
var lFM = Util.getById('fm');
|
||||
|
|
@ -63,13 +68,16 @@ var CloudCommander, $;
|
|||
console.log('Error. Something went wrong FM not found');
|
||||
});
|
||||
|
||||
/**
|
||||
* functin show jquery-terminal
|
||||
*/
|
||||
JqueryTerminal.show = (function(){
|
||||
Util.Images.hideLoad();
|
||||
|
||||
Hidden = false;
|
||||
/* only if panel was hided */
|
||||
var lHided = Util.hidePanel();
|
||||
if(lHided){
|
||||
Hidden = false;
|
||||
Util.show(TerminalId);
|
||||
|
||||
KeyBinding.unSet();
|
||||
|
|
@ -78,6 +86,9 @@ var CloudCommander, $;
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* function hide jquery-terminal
|
||||
*/
|
||||
JqueryTerminal.hide = (function(){
|
||||
Hidden = true;
|
||||
|
||||
|
|
@ -90,6 +101,9 @@ var CloudCommander, $;
|
|||
});
|
||||
|
||||
|
||||
/**
|
||||
* function bind keys
|
||||
*/
|
||||
cloudcmd.Terminal.Keys = (function(){
|
||||
/* loading js and css*/
|
||||
Util.jqueryLoad( JqueryTerminal.load );
|
||||
|
|
@ -105,15 +119,15 @@ var CloudCommander, $;
|
|||
|
||||
else if(!Hidden && event.keyCode === cloudcmd.KEY.ESC)
|
||||
JqueryTerminal.hide();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* добавляем обработчик клавишь */
|
||||
if (document.addEventListener)
|
||||
document.addEventListener('keydown', key_event, false);
|
||||
|
||||
else
|
||||
else
|
||||
document.onkeypress = key_event;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ exports.listen = function(pServer){
|
|||
|
||||
/* number of connections */
|
||||
var lConnNum = 0;
|
||||
io.sockets.on('connection', function (socket) {
|
||||
io.sockets.on('connection', function (socket){
|
||||
++lConnNum;
|
||||
socket.send('{"stdout":"client connected"}');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue