-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsonp.php
296 lines (220 loc) · 7.41 KB
/
jsonp.php
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<script>
// var server = "http://localhost/AT/jsonp_test1.php? x=";
var server = "http://atburst.atwebpages.com/at/rosetta/jsonp_test1.php? x=";
// ************
// *** Compile
// ************
function compile_mc() {
document.getElementById("_compiler").value = "";
tab_mcode();
createScriptTag_mcode();
}
function compile_bc() {
document.getElementById("_compiler").value = "";
tab_bcode();
createScriptTag_bcode();
}
function step1() {
tab_steps();
createScriptTag_step1();
}
function step2() {
tab_steps();
createScriptTag_step2();
}
function step3() {
tab_steps();
createScriptTag_step3();
}
function step4() {
tab_steps();
createScriptTag_step4();
}
function step5() {
tab_steps();
createScriptTag_step5();
}
function step6() {
tab_steps();
createScriptTag_step6();
}
// *************
// *** Evaluate
// *************
function evaluate_bc() {
tab_evaluate();
createScriptTag_evaluate();
/***
document.getElementById("_compiler").value =
document.getElementById("bcode").value;
***/
}
// *********
// *** tabs
// *********
function tab_assembly() {
}
function tab_mcode() {
$('#tabs_left a[href="#mcode_"]').tab('show');
$('#tabs_right a[href="#_compiler_"]').tab('show');
// ll btns
document.getElementById("compmc").classList.add("hide");
document.getElementById("compbc").classList.remove("hide");
}
function tab_bcode() {
$('#tabs_left a[href="#bcode_"]').tab('show');
$('#tabs_right a[href="#_compiler_"]').tab('show');
// ll btns
document.getElementById("compmc").classList.add("hide");
document.getElementById("compbc").classList.add("hide");
document.getElementById("evaluate").classList.remove("hide");
}
function tab_steps() {
$('#tabs_right a[href="#_bcode_"]').tab('show');
}
function tab_evaluate() {
$('#tabs_right a[href="#_compiler_"]').tab('show');
}
// ****************
// *** ScriptTags
// ****************
function createScriptTag_mcode() {
var s = document.createElement("script");
var data = document.getElementById("assembly").value;
data = data.replace(/#/g, "~");
data = data.replace(/\+/g, "§");
var obj = { "request":"mcode", "input": data };
// s.src = "http://localhost/AT/jsonp_test1.php? x=" + JSON.stringify(obj);
s.src = server + JSON.stringify(obj);
//alert(s.src);
document.body.appendChild(s);
}
function createScriptTag_bcode() {
var s = document.createElement("script");
var data = document.getElementById("mcode").value;
data = data.replace(/#/g, "~");
data = data.replace(/\+/g, "§");
var obj = { "request":"bcode", "input": data };
// s.src = "http://localhost/AT/jsonp_test1.php? x=" + JSON.stringify(obj);
s.src = server + JSON.stringify(obj);
document.body.appendChild(s);
}
function createScriptTag_evaluate() {
var s = document.createElement("script");
var data = document.getElementById("bcode").value;
data = data.replace(/#/g, "~");
data = data.replace(/\+/g, "§");
var obj = { "request":"evaluate", "input": data };
s.src = server + JSON.stringify(obj);
document.body.appendChild(s);
}
function createScriptTag_step6() {
var s = document.createElement("script");
var data = document.getElementById("_compiler").value;
data = data.replace(/#/g, "~");
data = data.replace(/\+/g, "§");
var obj = { "request":"step6", "input": data };
// s.src = "http://localhost/AT/jsonp_test1.php? x=" + JSON.stringify(obj);
s.src = server + JSON.stringify(obj);
document.body.appendChild(s);
}
function createScriptTag_step5() {
var s = document.createElement("script");
var data = document.getElementById("_compiler").value;
data = data.replace(/#/g, "~");
data = data.replace(/\+/g, "§");
//alert(data);
var obj = { "request":"step5", "input": data };
// s.src = "http://localhost/AT/jsonp_test1.php? x=" + JSON.stringify(obj);
s.src = server + JSON.stringify(obj);
document.body.appendChild(s);
}
function createScriptTag_step4() {
var s = document.createElement("script");
var data = document.getElementById("_compiler").value;
data = data.replace(/#/g, "~");
data = data.replace(/\+/g, "§");
var obj = { "request":"step4", "input": data };
// s.src = "http://localhost/AT/jsonp_test1.php? x=" + JSON.stringify(obj);
s.src = server + JSON.stringify(obj);
document.body.appendChild(s);
}
function createScriptTag_step3() {
var s = document.createElement("script");
var data = document.getElementById("_compiler").value;
data = data.replace(/#/g, "~");
data = data.replace(/\+/g, "§");
var obj = { "request":"step3", "input": data };
// s.src = "http://localhost/AT/jsonp_test1.php? x=" + JSON.stringify(obj);
s.src = server + JSON.stringify(obj);
document.body.appendChild(s);
}
function createScriptTag_step2() {
var s = document.createElement("script");
var data = document.getElementById("_compiler").value;
data = data.replace(/#/g, "~");
data = data.replace(/\+/g, "§");
var obj = { "request":"step2", "input": data };
// s.src = "http://localhost/AT/jsonp_test1.php? x=" + JSON.stringify(obj);
s.src = server + JSON.stringify(obj);
document.body.appendChild(s);
}
function createScriptTag_step1() {
var s = document.createElement("script");
var data = document.getElementById("_compiler").value;
data = data.replace(/#/g, "~");
data = data.replace(/\+/g, "§");
var obj = { "request":"step1", "input": data };
// s.src = "http://localhost/AT/jsonp_test1.php? x=" + JSON.stringify(obj);
s.src = server + JSON.stringify(obj);
document.body.appendChild(s); //
}
// **************
// *** callbacks
// **************
function callback_mc(myObj) {
var s = myObj.output;
// s = s.replace(/~/g, "#");
// s = s.replace(/\§/g, "+");
//alert("callback mc");
document.getElementById("mcode").value = s;
}
function callback_bc(myObj) {
var s = myObj.output;
s = s.replace(/~/g, "#");
s = s.replace(/\§/g, "+");
document.getElementById("bcode").value = s;
}
function callback_evaluate(myObj) {
var s = myObj.output;
s = s.replace(/~/g, "#");
s = s.replace(/\§/g, "+");
document.getElementById("bcode").value = s;
document.getElementById("_compiler").value =
document.getElementById("bcode").value;
}
function callback_step6(myObj) {
var s = myObj.output;
document.getElementById("_bcode").value = s;
}
function callback_step5(myObj) {
var s = myObj.output;
document.getElementById("_bcode").value = s;
}
function callback_step4(myObj) {
var s = myObj.output;
document.getElementById("_bcode").value = s;
}
function callback_step3(myObj) {
var s = myObj.output;
document.getElementById("_bcode").value = s;
}
function callback_step2(myObj) {
var s = myObj.output;
document.getElementById("_bcode").value = s;
}
function callback_step1(myObj) {
var s = myObj.output;
document.getElementById("_bcode").value = s;
}
</script>