-
Notifications
You must be signed in to change notification settings - Fork 16
/
jar.html
173 lines (171 loc) · 7.33 KB
/
jar.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>BN-jar包在线编译</title>
<link rel="icon" href="https://tools.blocklynukkit.com/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="./mdui/css/mdui.min.css">
<script src="mdui/js/mdui.min.js"></script>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-indigo ">
<script type="text/javascript">
var $$ = mdui.JQ;
var f = null;
var changed = false;
var path = "";
function openwin(url){
window.open(url,'_blank');
}
function clicksefile(){
document.getElementById("sefile").click();
}
function isChinese(val){
var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
if(reg.test(val)){return true; }
else{return false;}
}
function numstart(val){
for(let i=0;i<9;i++){
if(val.startsWith(i+"")){
return true;
}
}
return false;
}
function changefile(){
f = document.getElementById("sefile").files[0];
if(f==undefined||f==null){
f=null;
return;
}
if(isChinese(f.name)){
mdui.alert("您选择的文件名含有中文!这会导致编译系统错误,请改文件名后重新选择!","选择失败");
f=null;document.getElementById("sefile").files=[];
}else if(numstart(f.name)){
mdui.alert("您选择的文件名以数字开头!这会导致编译系统错误,请改文件名后重新选择!","选择失败");
f=null;document.getElementById("sefile").files=[];
}else if(f.name.indexOf("-")!=-1){
mdui.alert("您选择的文件名含有非法字符!这会导致编译系统错误,请改文件名后重新选择!","选择失败");
f=null;document.getElementById("sefile").files=[];
}else if(f.size>=1024*1024){
mdui.alert('您选择的文件大小'+(f.size/1024).toFixed(2)+"KB,文件大小限制1024KB以内!", '选择失败');
f=null;document.getElementById("sefile").files=[];
}else{
document.getElementById("uploadbtn").innerHTML=f.name+" "+(f.size/1024).toFixed(2)+"KB";
changed=true;
}
}
function downloadfilejar(){
var $eleForm = $("<form method='get'></form>");
$eleForm.attr("action",path);
$(document.body).append($eleForm);
$eleForm.submit();
}
function compile(){
let author = document.getElementById("authorname").value;
let ver = document.getElementById("version").value;
if(author=="" || author == null || ver == "" || ver == null || author == undefined || ver == undefined){
mdui.alert("作者名或版本号未填写!","提交失败");
return;
}
if(!changed){
mdui.alert("未选择文件!","提交失败");
return;
}
$$(document.getElementById("progress")).removeClass("mdui-hidden");
var reader = new FileReader();
reader.onload = function()
{
var str = this.result
if(str!=undefined&&str.length>=10){
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', 'https://service-ph7gsebv-1259395953.bj.apigw.tencentcs.com/release/BlocklyNukkitCloud', true);
httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
httpRequest.send(f.name.substring(0,f.name.indexOf("."))+".js"+"&&&"+str);
httpRequest.onreadystatechange = function () {
let getjs = "https://blocklynukkitxml-1259395953.cos.ap-beijing.myqcloud.com/"+f.name.substring(0,f.name.indexOf("."))+".js";
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
var back = httpRequest.responseText;
console.log(back);
if(back!=null){
console.log(getjs);
var httpRequest2 = new XMLHttpRequest();
httpRequest2.open('POST', 'https://service-owoxe67f-1259395953.bj.apigw.tencentcs.com/release/onlineCompile', true);
httpRequest2.setRequestHeader("Content-type","application/x-www-form-urlencoded");
httpRequest2.send(author+"&&&"+ver+"&&&"+f.name.substring(0,f.name.indexOf(".")));
httpRequest2.onreadystatechange = function () {
let url = httpRequest2.responseText;
console.log(url);
$$(document.getElementById("progress")).addClass("mdui-hidden");
$$(document.getElementById("downurlbox")).removeClass("mdui-hidden");
document.getElementById("downurl").innerHTML="编译完成,jar包下载链接 <a>"+url+"</a>";
path = url;
}
}
}
}
}
}
reader.readAsText(f);
}
</script>
<div class="mdui-appbar">
<div class="mdui-toolbar mdui-color-theme">
<a href="javascript:;" class="mdui-btn mdui-btn-icon"><i class="mdui-icon material-icons">cloud_queue</i></a>
<a href="javascript:openwin('https://tools.blocklynukkit.com');" class="mdui-typo-headline">BlocklyNukkit</a>
<a href="javascript:;" class="mdui-typo-title">jar在线编译器</a>
<div class="mdui-toolbar-spacer"></div>
<a href="javascript:;" class="mdui-btn mdui-btn-icon"><i class="mdui-icon material-icons">more_vert</i></a>
</div>
</div>
<div class="mdui-container-fluid">
<div class="mdui-row">
<div class="mdui-col-xs-10 mdui-col-offset-xs-1">
<div class=" mdui-center mdui-typo">
<br><br>
<div class="mdui-typo-display-2-opacity mdui-text-center">BlocklyNukkit JAR编译器</div>
<div class="mdui-typo-headline-opacity mdui-text-center">在线使用 一键打包<br><br></div>
</div>
</div>
</div>
<div class="mdui-row">
<div class="mdui-col-xs-8 mdui-col-offset-xs-2">
<div class="mdui-panel mdui-panel-popout" mdui-panel>
<div class="mdui-panel-item">
<div class="mdui-panel-item-header"><i class="mdui-icon material-icons"></i> 源文件</div>
<div class="mdui-panel-item-body">
<p>文件限制格式: .js / .py / .lua / .php / .bnp</p>
<p>文件限制编码: utf-8</p>
<p>文件限制大小: 1024KB</p>
<button class="mdui-btn mdui-color-theme-accent mdui-ripple" onclick="clicksefile()" id="uploadbtn">选择上传文件</button>
<input type="file" style="visibility: hidden;" accept=".js,.py,.lua,.php,.bnp" id="sefile" onchange="changefile()"></input>
</div>
</div>
<div class="mdui-panel-item">
<div class="mdui-panel-item-header"><i class="mdui-icon material-icons"></i> 编译设置</div>
<div class="mdui-panel-item-body">
<div class="mdui-textfield">
<i class="mdui-icon material-icons"></i>
<input class="mdui-textfield-input" type="text" id="authorname" placeholder="作者名"/>
</div>
<div class="mdui-textfield">
<i class="mdui-icon material-icons"></i>
<input class="mdui-textfield-input" type="text" id="version" placeholder="版本号"/>
</div>
<button class="mdui-btn mdui-color-theme-accent mdui-ripple" onclick="compile()" id="submitbtn">提交编译</button>
<br><br>
<div class="mdui-progress mdui-hidden" id="progress">
<div class="mdui-progress-indeterminate"></div>
</div>
<div class="mdui-chip mdui-hidden" id="downurlbox" onclick="downloadfilejar()">
<span class="mdui-chip-title" id="downurl"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>