feature(edit) add suport of .jshintrc

This commit is contained in:
coderaiser 2014-04-04 06:21:35 -04:00
parent 5543727ae0
commit c79e785ae4

View file

@ -21,7 +21,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
Dialog = DOM.Dialog,
Key = CloudCmd.Key,
Images = DOM.Images,
Element;
Element, JSHintConfig;
function init() {
Loading = true;
@ -33,7 +33,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
}
this.show = function(value) {
var mode, htmlMode, isHTML,
var mode, htmlMode, jsMode, isHTML, isJS, modesByName,
isStr = Util.isString(value),
name = Info.name,
isDir = Info.isDir,
@ -56,13 +56,18 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
initAce();
}
modesByName = Modelist.modesByName;
if (isDir)
mode = Modelist.modesByName.json.mode;
mode = modesByName.json.mode;
else
mode = Modelist.getModeForPath(name).mode;
htmlMode = Modelist.modesByName.html.mode;
htmlMode = modesByName.html.mode;
jsMode = modesByName.javascript.mode;
isHTML = mode === htmlMode;
isJS = mode === jsMode;
Session.setMode(mode);
@ -97,6 +102,9 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
Value = data;
Ace.setValue(data);
CloudCmd.View.show(Element, focus);
if (isJS && Session.getUseWorker())
setJsHintConfig();
});
}
};
@ -273,6 +281,28 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
});
}
function setJsHintConfig(callback) {
var JSHINT_PATH = '/.jshintrc',
func = function() {
var worker = Session.$worker;
if (worker)
worker.send('changeOptions', [JSHintConfig]);
Util.exec(callback);
};
Util.ifExec(JSHintConfig, func, function() {
DOM.ajax({
url : JSHINT_PATH,
success : function(data) {
JSHintConfig = Util.parseJSON(data);
func();
}
});
});
}
function load(callback) {
var files = [