diff --git a/json/config.json b/json/config.json index 7189e7ef..689a4ae1 100644 --- a/json/config.json +++ b/json/config.json @@ -12,6 +12,7 @@ "online": true, "cache": true, "showKeysPanel": true, + "editor": "dword", "port": 8000, "ip": null } diff --git a/lib/client/edit.js b/lib/client/edit.js index 550e5bce..865e1baa 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -15,6 +15,8 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; Menu, + Editor = 'edward', + Images = DOM.Images, MSG_CHANGED, Element, @@ -38,6 +40,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; exec.series([ CloudCmd.View, + getConfig, function(callback) { loadFiles(element, callback); }, @@ -70,21 +73,24 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; ConfigView.beforeShow = callback; Info.getData(function(error, data) { - var isDir = Info.isDir, - name = Info.name, - path = Info.path; + var path = Info.path; if (error) { alert(error); } else { + edward.once('change', function() { + var isDir = Info.isDir, + name = Info.name; + + if (isDir) + edward.setMode('json'); + else + edward.setModeForPath(name); + + CloudCmd.View.show(Element, ConfigView); + }); + edward.setValueFirst(path, data); - - if (isDir) - edward.setMode('json'); - else - edward.setModeForPath(name); - - CloudCmd.View.show(Element, ConfigView); } }); @@ -154,8 +160,19 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; return this; }; + function getConfig(callback) { + DOM.Files.get('config', function(error, config) { + if (error) + alert(error); + else if (config.editor) + Editor = config.editor; + + callback(); + }); + } + function loadFiles(element, callback) { - var url = '/edward/edward.js'; + var url = '/' + Editor + '/' + Editor + '.js'; Util.time(Name + ' load'); @@ -166,6 +183,8 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; Loading = false; + edward = window[Editor]; + edward(element, options, function() { Util.timeEnd(Name + ' load'); exec(callback); diff --git a/lib/cloudcmd.js b/lib/cloudcmd.js index d0cfe23c..bb367547 100644 --- a/lib/cloudcmd.js +++ b/lib/cloudcmd.js @@ -19,8 +19,9 @@ restafary = require('restafary'), webconsole = require('console-io'), edward = require('edward'), + dword = require('dword'), - emptyFunc = function(req, res, next) { + emptyFunc = function(req, res, next) { next(); }; @@ -61,6 +62,10 @@ edward.listen(socket, { size: size }); + + dword.listen(socket, { + size: size + }); }; function cloudcmd() { @@ -105,7 +110,14 @@ diff : isDiff, zip : isZip }), - + + dword({ + minify : isMinify, + online : isOnline, + diff : isDiff, + zip : isZip + }), + mollify({ dir : DIR_ROOT, is : isMinify diff --git a/package.json b/package.json index 963300dc..4fcd0cb8 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "ashify": "~1.0.0", "console-io": "~2.2.0", "copymitter": "~1.5.0", + "dword": "~1.1.2", "edward": "~1.3.0", "execon": "~1.1.0", "express": "~4.12.0",