add some semicolons ;(
This commit is contained in:
parent
3d6ce5fdf5
commit
30445fd2f8
7 changed files with 109 additions and 112 deletions
|
|
@ -51,7 +51,7 @@ function initDoc(file, path, doc) {
|
||||||
session.setUseWrapMode(true);
|
session.setUseWrapMode(true);
|
||||||
session.setWrapLimitRange(80, 80);
|
session.setWrapLimitRange(80, 80);
|
||||||
}
|
}
|
||||||
var mode = modelist.getModeFromPath(path)
|
var mode = modelist.getModeFromPath(path);
|
||||||
session.modeName = mode.name;
|
session.modeName = mode.name;
|
||||||
session.setMode(mode.mode);
|
session.setMode(mode.mode);
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ function initDoc(file, path, doc) {
|
||||||
function makeHuge(txt) {
|
function makeHuge(txt) {
|
||||||
for (var i = 0; i < 5; i++)
|
for (var i = 0; i < 5; i++)
|
||||||
txt += txt;
|
txt += txt;
|
||||||
return txt
|
return txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
var docs = {
|
var docs = {
|
||||||
|
|
@ -110,7 +110,7 @@ var docs = {
|
||||||
"docs/xquery.xq": "XQuery",
|
"docs/xquery.xq": "XQuery",
|
||||||
"docs/yaml.yaml": "YAML",
|
"docs/yaml.yaml": "YAML",
|
||||||
"docs/c9search.c9search_results": "C9 Search Results"
|
"docs/c9search.c9search_results": "C9 Search Results"
|
||||||
}
|
};
|
||||||
|
|
||||||
var ownSource = {
|
var ownSource = {
|
||||||
/* filled from require*/
|
/* filled from require*/
|
||||||
|
|
@ -127,12 +127,12 @@ if (window.require && window.require.s) try {
|
||||||
path = path.split("!").pop();
|
path = path.split("!").pop();
|
||||||
else
|
else
|
||||||
path = path + ".js";
|
path = path + ".js";
|
||||||
ownSource[path] = ""
|
ownSource[path] = "";
|
||||||
}
|
}
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
|
|
||||||
function prepareDocList(docs) {
|
function prepareDocList(docs) {
|
||||||
var list = []
|
var list = [];
|
||||||
for (var path in docs) {
|
for (var path in docs) {
|
||||||
var doc = docs[path];
|
var doc = docs[path];
|
||||||
if (typeof doc != "object")
|
if (typeof doc != "object")
|
||||||
|
|
@ -141,11 +141,11 @@ function prepareDocList(docs) {
|
||||||
doc.path = path;
|
doc.path = path;
|
||||||
doc.desc = doc.name.replace(/^(ace|docs|demo|build)\//, "");
|
doc.desc = doc.name.replace(/^(ace|docs|demo|build)\//, "");
|
||||||
if (doc.desc.length > 18)
|
if (doc.desc.length > 18)
|
||||||
doc.desc = doc.desc.slice(0, 7) + ".." + doc.desc.slice(-9)
|
doc.desc = doc.desc.slice(0, 7) + ".." + doc.desc.slice(-9);
|
||||||
|
|
||||||
fileCache[doc.name] = doc;
|
fileCache[doc.name] = doc;
|
||||||
list.push(doc);
|
list.push(doc);
|
||||||
};
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +156,7 @@ function loadDoc(name, callback) {
|
||||||
return callback(null);
|
return callback(null);
|
||||||
|
|
||||||
if (doc.session)
|
if (doc.session)
|
||||||
return callback(doc.session)
|
return callback(doc.session);
|
||||||
|
|
||||||
// TODO: show load screen while waiting
|
// TODO: show load screen while waiting
|
||||||
var path = doc.path;
|
var path = doc.path;
|
||||||
|
|
@ -168,7 +168,7 @@ function loadDoc(name, callback) {
|
||||||
|
|
||||||
net.get(path, function(x) {
|
net.get(path, function(x) {
|
||||||
initDoc(x, path, doc);
|
initDoc(x, path, doc);
|
||||||
callback(doc.session)
|
callback(doc.session);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,8 +178,7 @@ module.exports = {
|
||||||
ownSource: prepareDocList(ownSource),
|
ownSource: prepareDocList(ownSource),
|
||||||
hugeDocs: prepareDocList(hugeDocs),
|
hugeDocs: prepareDocList(hugeDocs),
|
||||||
initDoc: initDoc,
|
initDoc: initDoc,
|
||||||
loadDoc: loadDoc,
|
loadDoc: loadDoc
|
||||||
|
|
||||||
};
|
};
|
||||||
module.exports.all = {
|
module.exports.all = {
|
||||||
"Mode Examples": module.exports.docs,
|
"Mode Examples": module.exports.docs,
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ splitter:hover {\
|
||||||
width:3px;\
|
width:3px;\
|
||||||
border-color: #B5B4E0;\
|
border-color: #B5B4E0;\
|
||||||
}\
|
}\
|
||||||
", "splitEditor")
|
", "splitEditor");
|
||||||
|
|
||||||
exports.edit = function(el) {
|
exports.edit = function(el) {
|
||||||
if (typeof(el) == "string")
|
if (typeof(el) == "string")
|
||||||
|
|
@ -40,12 +40,12 @@ exports.edit = function(el) {
|
||||||
|
|
||||||
var SplitRoot = function(el, theme, position, getSize) {
|
var SplitRoot = function(el, theme, position, getSize) {
|
||||||
el.style.position = position || "relative";
|
el.style.position = position || "relative";
|
||||||
this.container = el
|
this.container = el;
|
||||||
this.getSize = getSize || this.getSize
|
this.getSize = getSize || this.getSize;
|
||||||
this.resize = this.$resize.bind(this)
|
this.resize = this.$resize.bind(this);
|
||||||
|
|
||||||
event.addListener(el.ownerDocument.defaultView, "resize", this.resize);
|
event.addListener(el.ownerDocument.defaultView, "resize", this.resize);
|
||||||
this.editor = this.createEditor()
|
this.editor = this.createEditor();
|
||||||
};
|
};
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
|
|
@ -71,12 +71,12 @@ var SplitRoot = function(el, theme, position, getSize) {
|
||||||
x: size.left,
|
x: size.left,
|
||||||
y: size.top,
|
y: size.top,
|
||||||
w: size.width,
|
w: size.width,
|
||||||
h: size.height,
|
h: size.height
|
||||||
}
|
};
|
||||||
this.item.resize(this.rect)
|
this.item.resize(this.rect);
|
||||||
};
|
};
|
||||||
this.getSize = function(el) {
|
this.getSize = function(el) {
|
||||||
return el.getBoundingClientRect()
|
return el.getBoundingClientRect();
|
||||||
};
|
};
|
||||||
this.destroy = function() {
|
this.destroy = function() {
|
||||||
var win = this.container.ownerDocument.defaultView;
|
var win = this.container.ownerDocument.defaultView;
|
||||||
|
|
@ -186,7 +186,7 @@ exports.singleLineEditor = function(el) {
|
||||||
editor.$mouseHandler.$focusWaitTimout = 0;
|
editor.$mouseHandler.$focusWaitTimout = 0;
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ function getModeFromPath(path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mode;
|
return mode;
|
||||||
};
|
}
|
||||||
|
|
||||||
var Mode = function(name, desc, extensions) {
|
var Mode = function(name, desc, extensions) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
@ -76,7 +76,7 @@ var modesByName = {
|
||||||
|
|
||||||
for (var name in modesByName) {
|
for (var name in modesByName) {
|
||||||
var mode = modesByName[name];
|
var mode = modesByName[name];
|
||||||
mode = new Mode(name, mode[0], mode[1])
|
mode = new Mode(name, mode[0], mode[1]);
|
||||||
modesByName[name] = mode;
|
modesByName[name] = mode;
|
||||||
modes.push(mode);
|
modes.push(mode);
|
||||||
}
|
}
|
||||||
|
|
@ -85,7 +85,7 @@ module.exports = {
|
||||||
getModeFromPath: getModeFromPath,
|
getModeFromPath: getModeFromPath,
|
||||||
modes: modes,
|
modes: modes,
|
||||||
modesByName: modesByName
|
modesByName: modesByName
|
||||||
}
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ var StatusBar = function(editor, parentNode) {
|
||||||
this.updateStatus = function(editor) {
|
this.updateStatus = function(editor) {
|
||||||
var status = [];
|
var status = [];
|
||||||
function add(str, separator) {
|
function add(str, separator) {
|
||||||
str && status.push(str, separator || "|")
|
str && status.push(str, separator || "|");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editor.$vimModeHandler)
|
if (editor.$vimModeHandler)
|
||||||
|
|
@ -35,14 +35,14 @@ var StatusBar = function(editor, parentNode) {
|
||||||
var c = editor.selection.lead;
|
var c = editor.selection.lead;
|
||||||
add(c.row + ":" + c.column, " ");
|
add(c.row + ":" + c.column, " ");
|
||||||
if (!editor.selection.isEmpty()) {
|
if (!editor.selection.isEmpty()) {
|
||||||
var r = editor.getSelectionRange()
|
var r = editor.getSelectionRange();
|
||||||
add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")");
|
add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")");
|
||||||
}
|
}
|
||||||
status.pop();
|
status.pop();
|
||||||
this.element.textContent = status.join("");
|
this.element.textContent = status.join("");
|
||||||
}
|
};
|
||||||
}).call(StatusBar.prototype)
|
}).call(StatusBar.prototype);
|
||||||
|
|
||||||
exports.StatusBar = StatusBar;
|
exports.StatusBar = StatusBar;
|
||||||
|
|
||||||
})
|
});
|
||||||
|
|
@ -82,7 +82,7 @@ var TokenTooltip = function(editor) {
|
||||||
type: "",
|
type: "",
|
||||||
value: "",
|
value: "",
|
||||||
state: session.bgTokenizer.getState(0)
|
state: session.bgTokenizer.getState(0)
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
if (!token) {
|
if (!token) {
|
||||||
session.removeMarker(this.marker);
|
session.removeMarker(this.marker);
|
||||||
|
|
@ -112,9 +112,9 @@ var TokenTooltip = function(editor) {
|
||||||
|
|
||||||
this.updateTooltipPosition(this.x, this.y);
|
this.updateTooltipPosition(this.x, this.y);
|
||||||
|
|
||||||
this.token = token
|
this.token = token;
|
||||||
session.removeMarker(this.marker);
|
session.removeMarker(this.marker);
|
||||||
this.range = new Range(docPos.row, token.start, docPos.row, token.start + token.value.length)
|
this.range = new Range(docPos.row, token.start, docPos.row, token.start + token.value.length);
|
||||||
this.marker = session.addMarker(this.range, "ace_bracket", "text");
|
this.marker = session.addMarker(this.range, "ace_bracket", "text");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ var TokenTooltip = function(editor) {
|
||||||
|
|
||||||
this.onMouseOut = function(e) {
|
this.onMouseOut = function(e) {
|
||||||
var t = e && e.relatedTarget;
|
var t = e && e.relatedTarget;
|
||||||
var ct = e && e.currentTarget
|
var ct = e && e.currentTarget;
|
||||||
while(t && (t = t.parentNode)) {
|
while(t && (t = t.parentNode)) {
|
||||||
if (t == ct)
|
if (t == ct)
|
||||||
return;
|
return;
|
||||||
|
|
@ -146,7 +146,7 @@ var TokenTooltip = function(editor) {
|
||||||
var st = tooltipNode.style;
|
var st = tooltipNode.style;
|
||||||
if (x + 10 + this.tooltipWidth > this.maxWidth)
|
if (x + 10 + this.tooltipWidth > this.maxWidth)
|
||||||
x = innerWidth - this.tooltipWidth - 10;
|
x = innerWidth - this.tooltipWidth - 10;
|
||||||
if (y > innerHeight * 0.75 || y + 20 + this.tooltipHeight > this.maxHeight)
|
if (y > innerHeight * 0.75 || y + 20 + this.tooltipHeight > this.maxHeight);
|
||||||
y = y - this.tooltipHeight - 30;
|
y = y - this.tooltipHeight - 30;
|
||||||
|
|
||||||
st.left = x + 10 + "px";
|
st.left = x + 10 + "px";
|
||||||
|
|
@ -155,29 +155,29 @@ var TokenTooltip = function(editor) {
|
||||||
|
|
||||||
this.$init = function() {
|
this.$init = function() {
|
||||||
tooltipNode = document.documentElement.appendChild(dom.createElement("div"));
|
tooltipNode = document.documentElement.appendChild(dom.createElement("div"));
|
||||||
var st = tooltipNode.style
|
var st = tooltipNode.style;
|
||||||
st.position = "fixed"
|
st.position = "fixed";
|
||||||
st.display = "none"
|
st.display = "none";
|
||||||
st.background = "lightyellow"
|
st.background = "lightyellow";
|
||||||
st.borderRadius = ""
|
st.borderRadius = "";
|
||||||
st.border = "1px solid gray"
|
st.border = "1px solid gray";
|
||||||
st.padding = "1px"
|
st.padding = "1px";
|
||||||
st.zIndex = 1000;
|
st.zIndex = 1000;
|
||||||
st.fontFamily = "monospace";
|
st.fontFamily = "monospace";
|
||||||
st.whiteSpace = "pre-line";
|
st.whiteSpace = "pre-line";
|
||||||
return tooltipNode
|
return tooltipNode;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.destroy = function() {
|
this.destroy = function() {
|
||||||
this.onMouseOut();
|
this.onMouseOut();
|
||||||
event.removeListener(this.editor.renderer.scroller, "mousemove", this.onMouseMove);
|
event.removeListener(this.editor.renderer.scroller, "mousemove", this.onMouseMove);
|
||||||
event.removeListener(this.editor.renderer.content, "mouseout", this.onMouseOut);
|
event.removeListener(this.editor.renderer.content, "mouseout", this.onMouseOut);
|
||||||
delete this.editor.tokenTooltip;
|
delete this.editor.tokenTooltip;
|
||||||
}
|
};
|
||||||
|
|
||||||
}).call(TokenTooltip.prototype)
|
}).call(TokenTooltip.prototype);
|
||||||
|
|
||||||
exports.TokenTooltip = TokenTooltip
|
exports.TokenTooltip = TokenTooltip;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,32 +47,32 @@ exports.createSplitEditor = function(el) {
|
||||||
var e0 = document.createElement("div");
|
var e0 = document.createElement("div");
|
||||||
var s = document.createElement("splitter");
|
var s = document.createElement("splitter");
|
||||||
var e1 = document.createElement("div");
|
var e1 = document.createElement("div");
|
||||||
el.appendChild(e0)
|
el.appendChild(e0);
|
||||||
el.appendChild(e1)
|
el.appendChild(e1);
|
||||||
el.appendChild(s)
|
el.appendChild(s);
|
||||||
e0.style.position = e1.style.position = s.style.position = "absolute";
|
e0.style.position = e1.style.position = s.style.position = "absolute";
|
||||||
el.style.position = "relative"
|
el.style.position = "relative";
|
||||||
var split = {$container: el};
|
var split = {$container: el};
|
||||||
|
|
||||||
split.editor0 = split[0] = new Editor(new Renderer(e0, require("ace/theme/textmate")));
|
split.editor0 = split[0] = new Editor(new Renderer(e0, require("ace/theme/textmate")));
|
||||||
split.editor1 = split[1] = new Editor(new Renderer(e1, require("ace/theme/textmate")));
|
split.editor1 = split[1] = new Editor(new Renderer(e1, require("ace/theme/textmate")));
|
||||||
split.splitter = s
|
split.splitter = s;
|
||||||
|
|
||||||
MultiSelect(split.editor0);
|
MultiSelect(split.editor0);
|
||||||
MultiSelect(split.editor1);
|
MultiSelect(split.editor1);
|
||||||
|
|
||||||
s.ratio = 0.5
|
s.ratio = 0.5;
|
||||||
|
|
||||||
split.resize = function resize(){
|
split.resize = function resize(){
|
||||||
var height = el.parentNode.clientHeight - el.offsetTop;
|
var height = el.parentNode.clientHeight - el.offsetTop;
|
||||||
var total = el.clientWidth;
|
var total = el.clientWidth;
|
||||||
var w1 = total * s.ratio
|
var w1 = total * s.ratio;
|
||||||
var w2 = total * (1- s.ratio)
|
var w2 = total * (1- s.ratio);
|
||||||
s.style.left = w1 - 1 + "px";
|
s.style.left = w1 - 1 + "px";
|
||||||
s.style.height = el.style.height = height + "px";
|
s.style.height = el.style.height = height + "px";
|
||||||
|
|
||||||
var st0 = split[0].container.style
|
var st0 = split[0].container.style;
|
||||||
var st1 = split[1].container.style
|
var st1 = split[1].container.style;
|
||||||
st0.width = w1 + "px";
|
st0.width = w1 + "px";
|
||||||
st1.width = w2 + "px";
|
st1.width = w2 + "px";
|
||||||
st0.left = 0 + "px";
|
st0.left = 0 + "px";
|
||||||
|
|
@ -83,10 +83,10 @@ exports.createSplitEditor = function(el) {
|
||||||
|
|
||||||
split[0].resize();
|
split[0].resize();
|
||||||
split[1].resize();
|
split[1].resize();
|
||||||
}
|
};
|
||||||
|
|
||||||
split.onMouseDown = function(e) {
|
split.onMouseDown = function(e) {
|
||||||
var rect = el.getBoundingClientRect()
|
var rect = el.getBoundingClientRect();
|
||||||
var x = e.clientX;
|
var x = e.clientX;
|
||||||
var y = e.clientY;
|
var y = e.clientY;
|
||||||
|
|
||||||
|
|
@ -118,17 +118,17 @@ exports.createSplitEditor = function(el) {
|
||||||
|
|
||||||
event.addListener(s, "mousedown", split.onMouseDown);
|
event.addListener(s, "mousedown", split.onMouseDown);
|
||||||
event.addListener(window, "resize", split.resize);
|
event.addListener(window, "resize", split.resize);
|
||||||
split.resize()
|
split.resize();
|
||||||
return split;
|
return split;
|
||||||
}
|
};
|
||||||
|
|
||||||
/***************************/
|
/***************************/
|
||||||
exports.stripLeadingComments = function(str) {
|
exports.stripLeadingComments = function(str) {
|
||||||
if(str.slice(0,2)=='/*'){
|
if(str.slice(0,2)=='/*') {
|
||||||
var j = str.indexOf('*/')+2
|
var j = str.indexOf('*/')+2;
|
||||||
str = str.substr(j)
|
str = str.substr(j);
|
||||||
}
|
}
|
||||||
return str.trim() + "\n"
|
return str.trim() + "\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
/***************************/
|
/***************************/
|
||||||
|
|
@ -148,7 +148,7 @@ exports.saveOption = function(el, val) {
|
||||||
|
|
||||||
localStorage && localStorage.setItem(el.id, el.value);
|
localStorage && localStorage.setItem(el.id, el.value);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.bindCheckbox = function(id, callback, noInit) {
|
exports.bindCheckbox = function(id, callback, noInit) {
|
||||||
if (typeof id == "string")
|
if (typeof id == "string")
|
||||||
|
|
@ -167,7 +167,7 @@ exports.bindCheckbox = function(id, callback, noInit) {
|
||||||
};
|
};
|
||||||
el.onclick = onCheck;
|
el.onclick = onCheck;
|
||||||
noInit || onCheck();
|
noInit || onCheck();
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.bindDropdown = function(id, callback, noInit) {
|
exports.bindDropdown = function(id, callback, noInit) {
|
||||||
if (typeof id == "string")
|
if (typeof id == "string")
|
||||||
|
|
@ -209,7 +209,7 @@ function elt(tag, attributes, content) {
|
||||||
|
|
||||||
for (var i in attributes)
|
for (var i in attributes)
|
||||||
el.setAttribute(i, attributes[i]);
|
el.setAttribute(i, attributes[i]);
|
||||||
return el
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function optgroup(values) {
|
function optgroup(values) {
|
||||||
|
|
|
||||||
|
|
@ -22,54 +22,52 @@ var editor1 = window.editor1 = splitEditor.editor0;
|
||||||
var editor2 = window.editor2 = splitEditor.editor1;
|
var editor2 = window.editor2 = splitEditor.editor1;
|
||||||
new TokenTooltip(editor2);
|
new TokenTooltip(editor2);
|
||||||
|
|
||||||
timeout = null
|
var timeout = null;
|
||||||
schedule = function() {
|
schedule = function() {
|
||||||
if(timeout != null) {
|
if(timeout != null) {
|
||||||
clearTimeout(timeout)
|
clearTimeout(timeout);
|
||||||
}
|
}
|
||||||
timeout = setTimeout(run, 800)
|
timeout = setTimeout(run, 800);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
setAutorunEnabled = function(val) {
|
setAutorunEnabled = function(val) {
|
||||||
if (val)
|
if (val)
|
||||||
editor1.on('change', schedule)
|
editor1.on('change', schedule);
|
||||||
else
|
else
|
||||||
editor1.removeEventListener('change', schedule)
|
editor1.removeEventListener('change', schedule);
|
||||||
}
|
}
|
||||||
|
|
||||||
util.bindCheckbox("autorunEl", setAutorunEnabled)
|
util.bindCheckbox("autorunEl", setAutorunEnabled);
|
||||||
|
|
||||||
|
|
||||||
docEl = document.getElementById("doc")
|
docEl = document.getElementById("doc");
|
||||||
util.fillDropdown(docEl, doclist.docs)
|
util.fillDropdown(docEl, doclist.docs);
|
||||||
util.bindDropdown("doc", function(value) {
|
util.bindDropdown("doc", function(value) {
|
||||||
doclist.loadDoc(value, function(session) {
|
doclist.loadDoc(value, function(session) {
|
||||||
if (session) {
|
if (session) {
|
||||||
editor2.setSession(session)
|
editor2.setSession(session);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
modeEl = document.getElementById("modeEl");
|
modeEl = document.getElementById("modeEl");
|
||||||
util.fillDropdown(modeEl, modelist.modes)
|
util.fillDropdown(modeEl, modelist.modes);
|
||||||
var modeSessions = {}
|
var modeSessions = {};
|
||||||
util.bindDropdown(modeEl, function(value) {
|
util.bindDropdown(modeEl, function(value) {
|
||||||
if (modeSessions[value])
|
if (modeSessions[value])
|
||||||
editor1.setSession(modeSessions[value])
|
editor1.setSession(modeSessions[value]);
|
||||||
var hp = "./lib/ace/mode/" + value + "_highlight_rules.js"
|
var hp = "./lib/ace/mode/" + value + "_highlight_rules.js";
|
||||||
net.get(hp, function(text) {
|
net.get(hp, function(text) {
|
||||||
text = util.stripLeadingComments(text)
|
text = util.stripLeadingComments(text);
|
||||||
var desc = value
|
|
||||||
modePath = "ace/mode/" + value
|
|
||||||
|
|
||||||
var session = new EditSession(text)
|
var session = new EditSession(text);
|
||||||
session.setUndoManager(new UndoManager())
|
session.setUndoManager(new UndoManager());
|
||||||
modeSessions[value] = session;
|
modeSessions[value] = session;
|
||||||
session.setMode("ace/mode/javascript")
|
session.setMode("ace/mode/javascript");
|
||||||
|
|
||||||
editor1.setSession(modeSessions[value])
|
editor1.setSession(modeSessions[value]);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
util.fillDropdown("themeEl", {
|
util.fillDropdown("themeEl", {
|
||||||
|
|
@ -79,60 +77,60 @@ util.fillDropdown("themeEl", {
|
||||||
dark: [ "clouds_midnight", "cobalt", "idle_fingers", "kr_theme", "merbivore", "merbivore_soft",
|
dark: [ "clouds_midnight", "cobalt", "idle_fingers", "kr_theme", "merbivore", "merbivore_soft",
|
||||||
"mono_industrial", "monokai", "pastel_on_dark", "solarized_dark", "tomorrow_night",
|
"mono_industrial", "monokai", "pastel_on_dark", "solarized_dark", "tomorrow_night",
|
||||||
"tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties", "twilight", "vibrant_ink"]
|
"tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties", "twilight", "vibrant_ink"]
|
||||||
})
|
});
|
||||||
|
|
||||||
util.bindDropdown("themeEl", function(value) {
|
util.bindDropdown("themeEl", function(value) {
|
||||||
if (!value)
|
if (!value)
|
||||||
return;
|
return;
|
||||||
editor1.setTheme("ace/theme/" + value);
|
editor1.setTheme("ace/theme/" + value);
|
||||||
editor2.setTheme("ace/theme/" + value);
|
editor2.setTheme("ace/theme/" + value);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
function getDeps(src, path) {
|
function getDeps(src, path) {
|
||||||
var deps = []
|
var deps = [];
|
||||||
src.replace(/require\((['"])(.*?)\1/g, function(a,b,c){
|
src.replace(/require\((['"])(.*?)\1/g, function(a,b,c){
|
||||||
if (c[0] == ".") {
|
if (c[0] == ".") {
|
||||||
var base = path.split("/")
|
var base = path.split("/");
|
||||||
c.split("/").forEach(function(part) {
|
c.split("/").forEach(function(part) {
|
||||||
if (part == ".") {
|
if (part == ".") {
|
||||||
base.pop()
|
base.pop();
|
||||||
} else if (part == "..") {
|
} else if (part == "..") {
|
||||||
base.pop();
|
base.pop();
|
||||||
base.pop()
|
base.pop();
|
||||||
} else {
|
} else {
|
||||||
base.push(part)
|
base.push(part);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
c = base.join("/")
|
c = base.join("/");
|
||||||
}
|
}
|
||||||
deps.push('"' + c + '"')
|
deps.push('"' + c + '"');
|
||||||
})
|
});
|
||||||
|
|
||||||
return deps
|
return deps;
|
||||||
}
|
}
|
||||||
function run() {
|
function run() {
|
||||||
var src = editor1.getValue();
|
var src = editor1.getValue();
|
||||||
var path = "ace/mode/new";
|
var path = "ace/mode/new";
|
||||||
var deps = getDeps(src, path)
|
var deps = getDeps(src, path);
|
||||||
src = src.replace("define(", 'define("' + path +'", ["require","exports","module",' + deps +'],');
|
src = src.replace("define(", 'define("' + path +'", ["require","exports","module",' + deps +'],');
|
||||||
src += ';require(["ace/mode/new"], continueRun, function(e){console.log(e);require.undef("ace/mode/new")})'
|
src += ';require(["ace/mode/new"], continueRun, function(e){console.log(e);require.undef("ace/mode/new")})';
|
||||||
try {
|
try {
|
||||||
eval(src)
|
eval(src);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e)
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var continueRun = function(rules) {
|
var continueRun = function(rules) {
|
||||||
rules = rules[Object.keys(rules)[0]]
|
rules = rules[Object.keys(rules)[0]];
|
||||||
var Tokenizer = DebugTokenizer
|
var Tokenizer = DebugTokenizer;
|
||||||
|
|
||||||
var tk = new Tokenizer(new rules().getRules())
|
var tk = new Tokenizer(new rules().getRules());
|
||||||
editor2.session.bgTokenizer.setTokenizer(tk)
|
editor2.session.bgTokenizer.setTokenizer(tk);
|
||||||
editor2.renderer.updateText()
|
editor2.renderer.updateText();
|
||||||
}
|
};
|
||||||
|
|
||||||
editor1.commands.bindKey("ctrl-Return", run)
|
editor1.commands.bindKey("ctrl-Return", run);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue