-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·168 lines (136 loc) · 3.97 KB
/
index.html
File metadata and controls
executable file
·168 lines (136 loc) · 3.97 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<html>
<head>
<script src="./ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
<script>
$(function() {
// create first editor
var editor = ace.edit("editor");
editor.setTheme("ace/theme/xcode");
editor.session.setMode("ace/mode/python");
var recv = 0;
function refresh(recv) {
$('#msg').append( recv + '</br>');
}
var conn = new SockJS('http://localhost:8081/weio');
conn.onopen = function() {
// alert('OTVORIO BA');
console.log('otvorio');
};
conn.onmessage = function(e) {
console.log('Received: ' + e.data);
editor.setValue(e.data);
//refresh(e.data);
}
conn.onclose = function() {
//alert('ZATVORIO BA');
console.log('zatvorio');
};
var play = new SockJS('http://localhost:8081/play');
play.onopen = function() {
console.log('otvorio play');
//
};
play.onmessage = function(e) {
console.log('Received: ' + e.data);
refresh(e.data);
}
play.onclose = function() {
//alert('ZATVORIO BA');
console.log('zatvorio');
};
$("#large-button").click( function(){
play.send(getCodeFromEditor());
$('#msg').empty();
}
);
function getCodeFromEditor() {
qstr = editor.getValue();
//return encodeURIComponent(qstr);
return qstr;
};
});
</script>
<title>Editor</title>
<style type="text/css" media="screen">
.ace_editor {
position: relative !important;
border: 1px solid lightgray;
margin: auto;
height: 500px;
width: 100%;
}
.scrollmargin {
height: 40px;
text-align: left;
}
.large-button {
color: lightgray;
cursor: pointer;
font: 18px arial;
padding: 4px;
text-align: left;
border: medium solid transparent;
display: inline-block;
border: thin solid lightgray;
border-radius: 4px 4px 4px 4px;
}
.large-button:hover {
box-shadow: 0 0 12px 0 lightgray;
}
</style>
</head>
<body>
<div class="scrollmargin">
<span id="large-button" class="large-button">
Run
</span>
</div>
<pre id="editor">print("hello")
</pre>
<div id="result"></div>
<script>
//
// // create first editor
// var editor = ace.edit("editor");
// editor.setTheme("ace/theme/xcode");
// editor.session.setMode("ace/mode/python");
//
// // AJAX CONNECTION
//
// function xmlhttpPost(strURL) {
//
// var xmlHttpReq = false;
// var self = this;
// // Mozilla/Safari
// if (window.XMLHttpRequest) {
// self.xmlHttpReq = new XMLHttpRequest();
// }
// // IE
// else if (window.ActiveXObject) {
// self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
// }
// self.xmlHttpReq.open('POST', strURL, true);
// self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// self.xmlHttpReq.onreadystatechange = function() {
// if (self.xmlHttpReq.readyState == 4) {
// updatepage(self.xmlHttpReq.responseText);
// }
// }
// self.xmlHttpReq.send(getCodeFromEditor());
// }
// function getCodeFromEditor() {
// qstr = editor.getValue();
// return "script_file=" + encodeURIComponent(qstr);
// }
//
// function updatepage(str){
// document.getElementById("result").innerHTML = str;
// }
</script>
<h3>Weio talks :</h3>
<div id="msg"></div>
</body>
</html>