add some semicolons ;(

This commit is contained in:
Harutyun Amirjanyan 2012-10-04 03:15:55 -04:00
commit 30445fd2f8
7 changed files with 109 additions and 112 deletions

View file

@ -51,7 +51,7 @@ function initDoc(file, path, doc) {
session.setUseWrapMode(true);
session.setWrapLimitRange(80, 80);
}
var mode = modelist.getModeFromPath(path)
var mode = modelist.getModeFromPath(path);
session.modeName = mode.name;
session.setMode(mode.mode);
}
@ -60,7 +60,7 @@ function initDoc(file, path, doc) {
function makeHuge(txt) {
for (var i = 0; i < 5; i++)
txt += txt;
return txt
return txt;
}
var docs = {
@ -110,7 +110,7 @@ var docs = {
"docs/xquery.xq": "XQuery",
"docs/yaml.yaml": "YAML",
"docs/c9search.c9search_results": "C9 Search Results"
}
};
var ownSource = {
/* filled from require*/
@ -127,12 +127,12 @@ if (window.require && window.require.s) try {
path = path.split("!").pop();
else
path = path + ".js";
ownSource[path] = ""
ownSource[path] = "";
}
} catch(e) {}
function prepareDocList(docs) {
var list = []
var list = [];
for (var path in docs) {
var doc = docs[path];
if (typeof doc != "object")
@ -141,11 +141,11 @@ function prepareDocList(docs) {
doc.path = path;
doc.desc = doc.name.replace(/^(ace|docs|demo|build)\//, "");
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;
list.push(doc);
};
}
return list;
}
@ -156,7 +156,7 @@ function loadDoc(name, callback) {
return callback(null);
if (doc.session)
return callback(doc.session)
return callback(doc.session);
// TODO: show load screen while waiting
var path = doc.path;
@ -168,7 +168,7 @@ function loadDoc(name, callback) {
net.get(path, function(x) {
initDoc(x, path, doc);
callback(doc.session)
callback(doc.session);
});
}
@ -178,8 +178,7 @@ module.exports = {
ownSource: prepareDocList(ownSource),
hugeDocs: prepareDocList(hugeDocs),
initDoc: initDoc,
loadDoc: loadDoc,
loadDoc: loadDoc
};
module.exports.all = {
"Mode Examples": module.exports.docs,

View file

@ -22,7 +22,7 @@ splitter:hover {\
width:3px;\
border-color: #B5B4E0;\
}\
", "splitEditor")
", "splitEditor");
exports.edit = function(el) {
if (typeof(el) == "string")
@ -40,12 +40,12 @@ exports.edit = function(el) {
var SplitRoot = function(el, theme, position, getSize) {
el.style.position = position || "relative";
this.container = el
this.getSize = getSize || this.getSize
this.resize = this.$resize.bind(this)
this.container = el;
this.getSize = getSize || this.getSize;
this.resize = this.$resize.bind(this);
event.addListener(el.ownerDocument.defaultView, "resize", this.resize);
this.editor = this.createEditor()
this.editor = this.createEditor();
};
(function(){
@ -71,12 +71,12 @@ var SplitRoot = function(el, theme, position, getSize) {
x: size.left,
y: size.top,
w: size.width,
h: size.height,
}
this.item.resize(this.rect)
h: size.height
};
this.item.resize(this.rect);
};
this.getSize = function(el) {
return el.getBoundingClientRect()
return el.getBoundingClientRect();
};
this.destroy = function() {
var win = this.container.ownerDocument.defaultView;
@ -186,7 +186,7 @@ exports.singleLineEditor = function(el) {
editor.$mouseHandler.$focusWaitTimout = 0;
return editor;
}
};

View file

@ -12,7 +12,7 @@ function getModeFromPath(path) {
}
}
return mode;
};
}
var Mode = function(name, desc, extensions) {
this.name = name;
@ -76,7 +76,7 @@ var modesByName = {
for (var name in modesByName) {
var mode = modesByName[name];
mode = new Mode(name, mode[0], mode[1])
mode = new Mode(name, mode[0], mode[1]);
modesByName[name] = mode;
modes.push(mode);
}
@ -85,7 +85,7 @@ module.exports = {
getModeFromPath: getModeFromPath,
modes: modes,
modesByName: modesByName
}
};
});

View file

@ -24,7 +24,7 @@ var StatusBar = function(editor, parentNode) {
this.updateStatus = function(editor) {
var status = [];
function add(str, separator) {
str && status.push(str, separator || "|")
str && status.push(str, separator || "|");
}
if (editor.$vimModeHandler)
@ -35,14 +35,14 @@ var StatusBar = function(editor, parentNode) {
var c = editor.selection.lead;
add(c.row + ":" + c.column, " ");
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) + ")");
}
status.pop();
this.element.textContent = status.join("");
}
}).call(StatusBar.prototype)
};
}).call(StatusBar.prototype);
exports.StatusBar = StatusBar;
})
});

View file

@ -82,7 +82,7 @@ var TokenTooltip = function(editor) {
type: "",
value: "",
state: session.bgTokenizer.getState(0)
}
};
}
if (!token) {
session.removeMarker(this.marker);
@ -112,9 +112,9 @@ var TokenTooltip = function(editor) {
this.updateTooltipPosition(this.x, this.y);
this.token = token
this.token = token;
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");
};
@ -131,7 +131,7 @@ var TokenTooltip = function(editor) {
this.onMouseOut = function(e) {
var t = e && e.relatedTarget;
var ct = e && e.currentTarget
var ct = e && e.currentTarget;
while(t && (t = t.parentNode)) {
if (t == ct)
return;
@ -146,7 +146,7 @@ var TokenTooltip = function(editor) {
var st = tooltipNode.style;
if (x + 10 + this.tooltipWidth > this.maxWidth)
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;
st.left = x + 10 + "px";
@ -155,29 +155,29 @@ var TokenTooltip = function(editor) {
this.$init = function() {
tooltipNode = document.documentElement.appendChild(dom.createElement("div"));
var st = tooltipNode.style
st.position = "fixed"
st.display = "none"
st.background = "lightyellow"
st.borderRadius = ""
st.border = "1px solid gray"
st.padding = "1px"
var st = tooltipNode.style;
st.position = "fixed";
st.display = "none";
st.background = "lightyellow";
st.borderRadius = "";
st.border = "1px solid gray";
st.padding = "1px";
st.zIndex = 1000;
st.fontFamily = "monospace";
st.whiteSpace = "pre-line";
return tooltipNode
}
return tooltipNode;
};
this.destroy = function() {
this.onMouseOut();
event.removeListener(this.editor.renderer.scroller, "mousemove", this.onMouseMove);
event.removeListener(this.editor.renderer.content, "mouseout", this.onMouseOut);
delete this.editor.tokenTooltip;
}
};
}).call(TokenTooltip.prototype)
}).call(TokenTooltip.prototype);
exports.TokenTooltip = TokenTooltip
exports.TokenTooltip = TokenTooltip;
});

View file

@ -47,32 +47,32 @@ exports.createSplitEditor = function(el) {
var e0 = document.createElement("div");
var s = document.createElement("splitter");
var e1 = document.createElement("div");
el.appendChild(e0)
el.appendChild(e1)
el.appendChild(s)
el.appendChild(e0);
el.appendChild(e1);
el.appendChild(s);
e0.style.position = e1.style.position = s.style.position = "absolute";
el.style.position = "relative"
el.style.position = "relative";
var split = {$container: el};
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.splitter = s
split.splitter = s;
MultiSelect(split.editor0);
MultiSelect(split.editor1);
s.ratio = 0.5
s.ratio = 0.5;
split.resize = function resize(){
var height = el.parentNode.clientHeight - el.offsetTop;
var total = el.clientWidth;
var w1 = total * s.ratio
var w2 = total * (1- s.ratio)
var w1 = total * s.ratio;
var w2 = total * (1- s.ratio);
s.style.left = w1 - 1 + "px";
s.style.height = el.style.height = height + "px";
var st0 = split[0].container.style
var st1 = split[1].container.style
var st0 = split[0].container.style;
var st1 = split[1].container.style;
st0.width = w1 + "px";
st1.width = w2 + "px";
st0.left = 0 + "px";
@ -83,10 +83,10 @@ exports.createSplitEditor = function(el) {
split[0].resize();
split[1].resize();
}
};
split.onMouseDown = function(e) {
var rect = el.getBoundingClientRect()
var rect = el.getBoundingClientRect();
var x = e.clientX;
var y = e.clientY;
@ -118,17 +118,17 @@ exports.createSplitEditor = function(el) {
event.addListener(s, "mousedown", split.onMouseDown);
event.addListener(window, "resize", split.resize);
split.resize()
split.resize();
return split;
}
};
/***************************/
exports.stripLeadingComments = function(str) {
if(str.slice(0,2)=='/*'){
var j = str.indexOf('*/')+2
str = str.substr(j)
if(str.slice(0,2)=='/*') {
var j = str.indexOf('*/')+2;
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);
}
}
};
exports.bindCheckbox = function(id, callback, noInit) {
if (typeof id == "string")
@ -167,7 +167,7 @@ exports.bindCheckbox = function(id, callback, noInit) {
};
el.onclick = onCheck;
noInit || onCheck();
}
};
exports.bindDropdown = function(id, callback, noInit) {
if (typeof id == "string")
@ -209,7 +209,7 @@ function elt(tag, attributes, content) {
for (var i in attributes)
el.setAttribute(i, attributes[i]);
return el
return el;
}
function optgroup(values) {

View file

@ -22,54 +22,52 @@ var editor1 = window.editor1 = splitEditor.editor0;
var editor2 = window.editor2 = splitEditor.editor1;
new TokenTooltip(editor2);
timeout = null
var timeout = null;
schedule = function() {
if(timeout != null) {
clearTimeout(timeout)
clearTimeout(timeout);
}
timeout = setTimeout(run, 800)
}
timeout = setTimeout(run, 800);
};
setAutorunEnabled = function(val) {
if (val)
editor1.on('change', schedule)
editor1.on('change', schedule);
else
editor1.removeEventListener('change', schedule)
editor1.removeEventListener('change', schedule);
}
util.bindCheckbox("autorunEl", setAutorunEnabled)
util.bindCheckbox("autorunEl", setAutorunEnabled);
docEl = document.getElementById("doc")
util.fillDropdown(docEl, doclist.docs)
docEl = document.getElementById("doc");
util.fillDropdown(docEl, doclist.docs);
util.bindDropdown("doc", function(value) {
doclist.loadDoc(value, function(session) {
if (session) {
editor2.setSession(session)
editor2.setSession(session);
}
})
});
modeEl = document.getElementById("modeEl");
util.fillDropdown(modeEl, modelist.modes)
var modeSessions = {}
util.fillDropdown(modeEl, modelist.modes);
var modeSessions = {};
util.bindDropdown(modeEl, function(value) {
if (modeSessions[value])
editor1.setSession(modeSessions[value])
var hp = "./lib/ace/mode/" + value + "_highlight_rules.js"
editor1.setSession(modeSessions[value]);
var hp = "./lib/ace/mode/" + value + "_highlight_rules.js";
net.get(hp, function(text) {
text = util.stripLeadingComments(text)
var desc = value
modePath = "ace/mode/" + value
text = util.stripLeadingComments(text);
var session = new EditSession(text)
session.setUndoManager(new UndoManager())
var session = new EditSession(text);
session.setUndoManager(new UndoManager());
modeSessions[value] = session;
session.setMode("ace/mode/javascript")
session.setMode("ace/mode/javascript");
editor1.setSession(modeSessions[value])
})
editor1.setSession(modeSessions[value]);
});
});
util.fillDropdown("themeEl", {
@ -79,60 +77,60 @@ util.fillDropdown("themeEl", {
dark: [ "clouds_midnight", "cobalt", "idle_fingers", "kr_theme", "merbivore", "merbivore_soft",
"mono_industrial", "monokai", "pastel_on_dark", "solarized_dark", "tomorrow_night",
"tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties", "twilight", "vibrant_ink"]
})
});
util.bindDropdown("themeEl", function(value) {
if (!value)
return;
editor1.setTheme("ace/theme/" + value);
editor2.setTheme("ace/theme/" + value);
})
});
function getDeps(src, path) {
var deps = []
var deps = [];
src.replace(/require\((['"])(.*?)\1/g, function(a,b,c){
if (c[0] == ".") {
var base = path.split("/")
var base = path.split("/");
c.split("/").forEach(function(part) {
if (part == ".") {
base.pop()
base.pop();
} else if (part == "..") {
base.pop();
base.pop()
base.pop();
} 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() {
var src = editor1.getValue();
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 += ';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 {
eval(src)
eval(src);
} catch(e) {
console.log(e)
console.log(e);
}
}
var continueRun = function(rules) {
rules = rules[Object.keys(rules)[0]]
var Tokenizer = DebugTokenizer
rules = rules[Object.keys(rules)[0]];
var Tokenizer = DebugTokenizer;
var tk = new Tokenizer(new rules().getRules())
editor2.session.bgTokenizer.setTokenizer(tk)
editor2.renderer.updateText()
}
var tk = new Tokenizer(new rules().getRules());
editor2.session.bgTokenizer.setTokenizer(tk);
editor2.renderer.updateText();
};
editor1.commands.bindKey("ctrl-Return", run)
editor1.commands.bindKey("ctrl-Return", run);
});