-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew.html
269 lines (245 loc) · 11.3 KB
/
new.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
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<title>明日方舟作业帮</title>
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询(media queries)功能 -->
<!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 -->
<!--[if lt IE 9]>
<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->
<link href="actors.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid" style="min-height:calc(100% - 90px)">
<div class="panel panel-info" style="margin-top:20px">
<div class="panel-heading">
<h3 class="panel-title">基本信息</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">标题</span>
<input type="text" id="m-info-title" class="form-control" aria-describedby="basic-addon1">
</div>
</div>
<div class="col-md-3">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">关卡</span>
<input type="text" id="m-info-level" class="form-control" aria-describedby="basic-addon1">
<span class="input-group-btn">
<button id="m-info-tuxi" class="btn btn-default" type="button" data-toggle="button"
aria-pressed="false" autocomplete="off">突袭</button>
</span>
</div>
</div>
<div class="col-md-3">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">作者</span>
<input type="text" id="m-info-author" class="form-control" aria-describedby="basic-addon1">
</div>
</div>
</div>
<div class="row" style="margin-top:15px">
<div class="col-md-3">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">aid</span>
<input type="text" id="m-info-aid" class="form-control" aria-describedby="basic-addon1">
</div>
</div>
<div class="col-md-3">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">cid</span>
<input type="text" id="m-info-cid" class="form-control" aria-describedby="basic-addon1">
</div>
</div>
<div class="col-md-3">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">page</span>
<input type="text" id="m-info-page" class="form-control" aria-describedby="basic-addon1">
</div>
</div>
</div>
</div>
</div>
<div class="input-group">
<input type="text" id="m-info-input" class="form-control" placeholder="粘贴干员OCR数据到此处">
<span class="input-group-btn">
<button class="btn btn-primary" type="button" onclick="parseActorsInfo()">开始分析</button>
</span>
</div><!-- /input-group -->
<div class="panel panel-info" id="m-actors-panel-parent" style="margin-top:20px">
<div class="panel-heading">
<h3 class="panel-title">干员列表
<span style="font-size: 13px"> | 已选:<span id="m-actors-count">0</span></span>
<span id="m-actors-panel-folder">展开</span>
</h3>
</div>
</div>
<button type="button" id="m-btn-submit" class="btn btn-primary" style="width:100%;margin-bottom:20px"
onclick="submit()">提交作业</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/leancloud-storage@3.15.0/dist/av-min.js"></script>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery,所以必须放在前边) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script src="actors.js"></script>
<script src="levels.js"></script>
<script>
initPanel(0);
// parse video info
(function() {
let hash = location.hash;
if (hash === "") return;
let raw = decodeURI(hash.substr(1));
let info;
try {
info = JSON.parse(raw);
} catch (err) {
console.log("parse data failed");
return;
}
$("#m-info-title").val(info.title);
$("#m-info-level").val(info.level);
if (info.tuxi) $("#m-info-tuxi").click();
$("#m-info-author").val(info.author);
$("#m-info-aid").val(info.aid);
$("#m-info-cid").val(info.cid);
$("#m-info-page").val(info.page);
// check duplicate
let query = new AV.Query("Homework");
query.equalTo('aid', info.aid + "_" + info.page);
query.find().then(function (works) {
if (works.length > 0) {
alert("似乎已经有相同的作业了!");
}
}, function (e) {
alert("查询重复作业失败,错误码:" + e.code);
});
})();
$(".m-actors-row").toggleClass("m-display-none");
$("#m-actors-panel-folder").click(() => {
$(".m-actors-row").toggleClass("m-display-none");
let text = $("#m-actors-panel-folder").text();
$("#m-actors-panel-folder").text(text === "收起" ? "展开" : "收起");
});
function parseActorsInfo() {
let input = $("#m-info-input");
let values = input.val().trim().split(/\s+/);
for (let i = 0; i < values.length; i++) {
let name = _correct(values[i]);
let tag;
try {
tag = $(`#m-pol-${name}`); // 可能提取出来有特殊字符导致报错
} catch (err) {
tag = { length: 0 };
}
if (tag.length === 0 || tag.css("display") === "none") continue;
tag.click();
}
}
function submit() {
if (!AV.User.current()) {
alert("你没有权限!");
return;
}
let aid = $("#m-info-aid").val().trim();
let page = $("#m-info-page").val().trim();
if (aid === "") {
alert("数据不完整!");
return;
}
$("#m-btn-submit").toggleClass("m-btn-loading");
// let query = new AV.Query("Homework");
// query.equalTo('aid', aid + "_" + page);
// query.find().then(function (works) {
// if (works.length > 0) {
// alert("似乎已经有相同的作业了!");
// $("#m-btn-submit").toggleClass("m-btn-loading");
// } else {
// _doSaveObj();
// }
// }, function (e) {
// if (e.code === 101) {
// _doSaveObj();
// } else {
// console.log(e.code);
// alert("查询失败,请联系管理员");
// $("#m-btn-submit").toggleClass("m-btn-loading");
// }
// });
_doSaveObj();
}
function _doSaveObj() {
let level = $("#m-info-level").val().trim() + ($("#m-info-tuxi").attr("aria-pressed") === "true" ? "突袭" : "");
if (!_validateLevel(level)) {
alert("关卡名不正确,请检查拼写或联系管理员");
$("#m-btn-submit").toggleClass("m-btn-loading");
return;
}
let work = new AV.Object("Homework");
work.set('title', $("#m-info-title").val().trim());
work.set('author', $("#m-info-author").val().trim());
work.set('level', level);
work.set('aid', $("#m-info-aid").val().trim() + "_" + $("#m-info-page").val().trim());
work.set('cid', $("#m-info-cid").val().trim());
work.set('actors', getCurrentSelectedActors().include);
work.save().then(function (work1) {
alert("保存成功!");
$("#m-btn-submit").toggleClass("m-btn-loading");
}, function (e) {
alert("保存失败,错误码:" + e.code);
$("#m-btn-submit").toggleClass("m-btn-loading");
});
}
function _validateLevel(level) {
for (let ch in levels) {
if (levels[ch].includes(level)) {
return true;
}
}
return false;
}
function _correct(name) {
if (_specialNamesMap[name]) return _specialNamesMap[name];
name = name.replace(/[,。!?,\\.!\\?\\|\w+]/g, "")
.replace(/^白面.$/, "白面鸮")
.replace(/^米格.$/, "米格鲁")
.replace(/^蛇.箱$/, "蛇屠箱")
.replace(/^.兰莎$/, "玫兰莎");
return _correctMap[name] || name;
}
const _specialNamesMap = {
"12F": "12F",
"Lancet": "Lancet-2",
"Lancet-2": "Lancet-2",
"Castle": "Castle-3",
"Castle-3": "Castle-3",
}
const _correctMap = {
"喜维尔": "嘉维尔",
"未药": "末药",
"林默": "赫默",
"网米短": "阿米娅",
"网米娅": "阿米娅",
"阿米短": "阿米娅",
"克活丝": "克洛丝",
"白营": "白雪",
"幕斯": "慕斯",
"伊美利特": "伊芙利特",
"阿清": "阿消",
"塘丸": "缠丸",
"塞雪娅": "塞雷娅",
"幽灵然": "幽灵鲨",
}
</script>
</body>
</html>