var CloudCommander, CloudFunc, CodeMirror; /* object contains editors CodeMirror * and later will be Ace */ (function(){ "use strict"; var cloudcmd = CloudCommander, Util = CloudCommander.Util, KeyBinding = CloudCommander.KeyBinding, CodeMirrorEditor = {}, FM, CodeMirrorElement, CodeMirrorLoaded = false, /* indicator says CodeMirror still loads */ Loading = false, ReadOnly = false; cloudcmd.Editor = { get : (function(){ return this.CodeMirror; }) }; /* private functions */ function initCodeMirror(pValue){ if(!FM) FM = Util.getById('fm'); CodeMirrorElement = Util.anyload({ name : 'div', id : 'CodeMirrorEditor', className : 'panel', parent : FM }); CodeMirrorEditor.CodeMirror = new CodeMirror(CodeMirrorElement,{ mode : 'javascript', value : pValue, theme : 'night', lineNumbers : true, //переносим длинные строки lineWrapping: false, autofocus : true, extraKeys: { //Сохранение "Esc": CodeMirrorEditor.hide }, readOnly : ReadOnly }); } cloudcmd.Editor.dir = 'lib/client/editor/'; CodeMirrorEditor.dir = cloudcmd.Editor.dir + 'codemirror/'; /* function loads CodeMirror js and css files */ CodeMirrorEditor.load = (function(){ /* function loads css files of CodeMirror */ var loadAll = function() { Util.cssLoad([ { src : CodeMirrorEditor.dir + 'codemirror.css'}, { src : CodeMirrorEditor.dir + 'theme/night.css'} ]); Util.cssSet({id:'editor', inner : '.CodeMirror{' + 'font-family :\'Droid Sans Mono\';' + 'font-size :15px;' + /* codemirror v3 */ //'height : ' + cloudcmd.HEIGHT + 'px' + '}' + '.CodeMirror-scroll{' + 'height : ' + (cloudcmd.HEIGHT) + 'px' + '}' //+ /* codemirror v3 */ //'#CodeMirrorEditor{' + // 'padding :20px 20px 20px 20px;' + // '}' }); Util.jsload(CodeMirrorEditor.dir + 'mode/javascript.js', function(){ CodeMirrorLoaded = true; CodeMirrorEditor.show(); }); }; /* load CodeMirror main module */ Util.jsload(CodeMirrorEditor.dir + 'codemirror.js', loadAll); }); /* function shows CodeMirror editor */ CodeMirrorEditor.show = (function(){ /* if CodeMirrorEditor is not loaded - loading him */ if(!CodeMirrorLoaded) return this.load(); /* if CodeMirror function show already * called do not call it again * if f4 key pressed couple times */ if(Loading) return; /* 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 === '