utils.js
2.01 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
// 编译
function compileRun(l){
var l = Ladda.create(el);
l.start();
var code = (typeof GBCodePlayBack.htmleditor !=='undefined' && GBCodePlayBack.htmleditor.getValue())
|| (typeof GBCodePlayBack.htmlplayereditor !=='undefined' && GBCodePlayBack.htmlplayereditor.getValue());
var langid = $('#htmlbutton').data("languageid");
var input = $('#input').val() || '';
var compileData = {
code: code,
langid: langid,
input: input
}
$.ajax({
type: "post",
url: gxb_api + "/submit/submitCode/api",
data: JSON.stringify(compileData),
dataType: "json",
contentType: "application/json",
success: function(data) {
compileResult(data)
l.stop();
$('.compile-loading').hide();
$('.compile-reslut').show();
GBCodePlayBack.compileResultData = data;
},
error: function(){
l.stop();
alert('错误');
}
});
}
function compileMode(el, userId, languageId) {
var l = Ladda.create(el);
l.start();
// 获取标准输入值
var runtimeArgus = $('#runtimeArgus').val() || '';
var mainPath = Dir.mainPath;
var _fileList = Dir.getTreeData();
var compileData = {
"userId": userId,
"langId": languageId,
"mainPath": mainPath,
"mainArgus": "",
"runtimeArgus": runtimeArgus,
"rand": "123456",
"fileList": _fileList || []
}
console.log(compileData);
$.ajax({
type: "POST",
url: gxb_api + "/gxb-web/programmingMulti/codeRun/api",
data: JSON.stringify(compileData),
dataType: "json",
contentType: "application/json",
success: function(data) {
console.log(data);
l.remove();
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
l.remove();
alert('错误');
console.log(XMLHttpRequest);
},
});
}
function