-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.html
89 lines (75 loc) · 2.68 KB
/
code.html
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<html>
<head>
<script src="jquery/jquery-1.12.3.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="bootstrap-3.3.6/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="bootstrap-3.3.6/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script src="ace/ace.js"></script>
<script src="ace/ext-language_tools.js"></script>
<script src="javascript/draw.js"></script>
<style>
.row {
margin-right: 0px;
margin-left: 0px;
}
#editor {
height: 800px;
width: 100%;
}
footer {
position: fixed;
bottom: 10px;
right: 10px;
width: 300px;
height: 50px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<h2>Hour of code</h2>
</div>
<div class="col-md-3" style="margin-top:20px">
<button class="pull-right btn btn-default btn-sm" onclick="evaluateScript();"><i class="glyphicon glyphicon-play"></i> Run</button>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div id="editor">//WRITE YOUR CODE</div>
</div>
<div class="col-md-6">
<canvas id="canvas" width=800 height=800 style='width:800px;height:800px;border:1px solid #000000;'></canvas>
</div>
</div>
<br>
<footer>
<img src="img/infobip.png" alt="[image]" height="40" width="280">
</footer>
<script src="ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.getSession().setUseWorker(false);
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
</script>
<script type="text/javascript">
function evaluateScript(){
try {
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
var scriptText = editor.getSession().getValue();
eval(scriptText);
} catch (error){
alert("Error! " + error.message);
}
}
</script>
</body>
</html>