-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
36 lines (32 loc) · 1.1 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var Elm = require("./Pipeliner.elm");
var app = Elm.fullscreen(Elm.Pipeliner, { currentCode: ["", []] });
window.define = window.define || ace.define;
var editor = ace.edit("editor");
editor.session.on('changeMode', function(e, session){
if ("ace/mode/javascript" === session.getMode().$id) {
if (!!session.$worker) {
session.$worker.send("changeOptions", [{
"undef": true
}]);
}
}
});
editor.setTheme("ace/theme/monokai")
editor.getSession().setMode("ace/mode/javascript");
document.getElementById("commit").addEventListener("click", function () {
var currentCode = editor.getValue();
if (currentCode.trim()) {
var annotations = editor.getSession().getAnnotations();
annotations = annotations.filter(function (annotation) {
return annotation.type === "error" || annotation.type === "warning";
}).map(function(annotation) {
annotation.errorType = annotation.type;
delete annotation.type;
return annotation;
});
app.ports.currentCode.send([currentCode, annotations]);
}
}, false);
$(document).ready(function(){
$('.menu .item').tab();
});