-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (26 loc) · 862 Bytes
/
app.js
File metadata and controls
32 lines (26 loc) · 862 Bytes
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
var html = ace.edit("html");
ace.require("ace/ext/language_tools");
html.setTheme("ace/theme/monokai");
html.session.setMode("ace/mode/html");
html.setValue(`<h1 onclick='giveAlert()'> Hello </h1>`);
var css = ace.edit("css");
css.setTheme("ace/theme/monokai");
css.session.setMode("ace/mode/css");
css.setValue(`h1 {
color: red;
}`);
var js = ace.edit("js");
js.setTheme("ace/theme/monokai");
js.session.setMode("ace/mode/javascript");
var output = document.getElementById("output").contentWindow.document;
function compile() {
var outputCode = "";
document.body.onkeyup = function() {
output.open();
outputCode = html.getValue();
outputCode += "<style>" + css.getValue() + "</style>";
outputCode += "<script>" + js.getValue() + "</script>";
output.writeln( outputCode);
output.close();
};
}