forked from Aceship/AN-EN-Tags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
akhr.html
484 lines (472 loc) · 26 KB
/
akhr.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
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<!DOCTYPE html>
<html lang="zh-Hans" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>明日方舟公开招募计算器</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery-3.4.0.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/multilingual.js"></script>
<link rel="stylesheet" href="css/multilingual.css">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-138420636-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-138420636-1');
</script>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="navbar-brand cn" href="/">明日方舟工具箱</a>
<a class="navbar-brand en" href="/">Arknights Toolbox</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="展开">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-between" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link cn" href="akhr.html">公开招募计算器</a>
<a class="nav-link en" href="akhr.html?lang=en">Recuitment Recommender</a>
</li>
<li class="nav-item">
<a class="nav-link cn" href="aklevel.html">升级计算</a>
<a class="nav-link en" href="aklevel.html?lang=en">Levelup Calculator</a>
</li>
<li class="nav-item">
<a class="nav-link cn" href="akevolve.html">精英材料计算</a>
<a class="nav-link en" href="akevolve.html?lang=en">Evolve Calculator</a>
</li>
<li class="nav-item">
<a class="nav-link cn" href="akhrchars.html">干员表</a>
<a class="nav-link en" href="akhrchars.html?lang=en">Operators Table</a>
</li>
<li class="nav-item">
<a class="nav-link disabled cn" href="#">施工中…</a>
<a class="nav-link disabled en" href="#">WIP</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="switchLang" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Language
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="?lang=cn">中文</a>
<a class="dropdown-item" href="?lang=en">English</a>
</div>
</li>
</ul>
</div>
</nav>
<div class="container" style="margin:auto;max-width:1400px;">
<div class="row mt-3">
<div class="col-12 col-lg-4 px-2">
<div class="alert alert-dark px-2 py-1" role="alert">
<table class="table table-sm m-0">
<tbody id="box-options">
<tr>
<td>
<button type="button" class="btn btn-sm btn-danger my-1" id="btn-clear">
<span class="cn">清空</span>
<span class="en">Clear</span>
</button>
<span class="d-none d-sm-inline">
<button type="button" class="btn btn-sm btn-primary btn-showopt my-1 btn-name" opt-id="showName">
<span class="cn">名称</span>
<span class="en">Name</span>
</button>
<button type="button" class="btn btn-sm btn-secondary btn-showopt my-1 btn-image" opt-id="showImage">
<span class="cn">图片</span>
<span class="en">Image</span>
</button>
<button type="button" class="btn btn-sm btn-secondary btn-showopt my-1 btn-imgsize btn-imgsizedefault" sizeval="27">
<span class="cn">小</span>
<span class="en">Small</span>
</button>
<button type="button" class="btn btn-sm btn-secondary btn-showopt my-1 btn-imgsize" sizeval="45">
<span class="cn">中</span>
<span class="en">Middle</span>
</button>
<button type="button" class="btn btn-sm btn-secondary btn-showopt my-1 btn-imgsize" sizeval="80">
<span class="cn">大</span>
<span class="en">Large</span>
</button>
<button type="button" class="btn btn-sm btn-secondary btn-showopt my-1 btn-imgsize" sizeval="128">
<span class="cn">特大</span>
<span class="en">Ex-large</span>
</button>
</span>
</td>
</tr>
<tr>
<td>
<button type="button" class="btn btn-sm btn-primary btn-opt my-1" opt-id="all" id="opt-all">ALL</button>
<button type="button" class="btn btn-sm btn-primary btn-opt my-1" opt-id="6">6★</button>
<button type="button" class="btn btn-sm btn-primary btn-opt my-1" opt-id="5">5★</button>
<button type="button" class="btn btn-sm btn-primary btn-opt my-1" opt-id="4">4★</button>
<button type="button" class="btn btn-sm btn-primary btn-opt my-1" opt-id="3">3★</button>
<button type="button" class="btn btn-sm btn-primary btn-opt my-1" opt-id="2">2★</button>
<button type="button" class="btn btn-sm btn-primary btn-opt my-1" opt-id="1">1★</button>
</td>
</tr>
</tbody>
</table>
<table class="table table-sm m-0"><tbody id="box-tags"></tbody></table>
</div>
</div>
<div class="col-12 col-lg-8 px-0">
<table class="table table-striped table-hover" id="table-recommend">
<thead class="thead-dark">
<tr>
<th scope="col" class="d-none d-sm-table-cell">#</th>
<th scope="col" style="width:16.67%">Tags</th>
<th scope="col">
<span class="cn">可能出现</span>
<span class="en">Possible Operators</span>
</th>
<th scope="col" class="d-none d-sm-table-cell">$~</th>
</tr>
</thead>
<tbody id="tbody-recommend"></tbody>
</table>
</div>
</div>
<hr />
<div class="row col-12 tutorial">
<div class="col-12 text-left cn">
<p>使用说明:</p>
<p>1. 勾选需要查询的Tag,最多6个;</p>
<p>2. 勾选需要查询的星级,默认全部;</p>
<p>3. 现在点击标签即可开始计算,可点击“清空”重新开始;</p>
<p>4. 可以点击推荐表格中的干员或标签进行精准查询,再点击任意干员或标签返回。</p>
</div>
<div class="col-12 text-left en">
<p>How To Use:</p>
<p>1. Click on tags, up to 6 tags</p>
<p>2. Check the star you want to filter</p>
<p>3. Click on calculate (currently automatically calculated on pressing tags)</p>
<p>4. You can click on the clerk or label in the recommendation form to make an accurate query, then click on any clerk or label to return.</p>
</div>
</div>
<div class="col-12 alert alert-success mt-1 cn" role="alert">
19/05/04 升级消耗计算器上线,可在导航栏切换使用。<br />
19/05/09 精英材料计算器上线,可在导航栏切换使用。
</div>
</div>
<hr />
<div class="row col-12 page-footer">
<div class="col-12 text-center cn">
<p>最近更新:2019/05/06,<a href="https://bbs.nga.cn/read.php?tid=16971344">联系作者</a></p>
<p>
数据来源:
<a href="http://wiki.joyme.com/arknights/%E5%B9%B2%E5%91%98%E6%95%B0%E6%8D%AE%E8%A1%A8">明日方舟Wiki</a>
</p>
<p>Powered by 一只灰猫。</p>
</div>
<div class="col-12 text-center en">
<p>Last update: 05/06/2019, <a href="https://github.com/graueneko/graueneko.github.io/issues">Contact</a></p>
<p>
Data source:
<a href="http://wiki.joyme.com/arknights/%E5%B9%B2%E5%91%98%E6%95%B0%E6%8D%AE%E8%A1%A8">Arknights Wiki (CN)</a>
</p>
<p>Powered by GraueNeko, Aceship</p>
</div>
</div>
<script>
$(function () {
let lang = getLang();
showCurrentLang();
document.title = {
"cn": "明日方舟公开招募计算器",
"en": "Arknights Recruitment Recommender"
}[lang];
let tags = [
{
"cn": "资质", "cntags": ["新手", "资深干员", "高级资深干员"],
"en": "Qualification", "entags": ["Newbie", "Senior", "Advanced Senior"]
},
{
"cn": "位置", "cntags": ["远程位", "近战位"],
"en": "Position", "entags": ["Ranged", "Melee"]
},
{
"cn": "性别", "cntags": ["男性干员", "女性干员"],
"en": "Gender", "entags": ["Male", "Female"]
},
{
"cn": "种类", "cntags": ["先锋干员", "狙击干员", "医疗干员", "术师干员", "近卫干员", "重装干员", "辅助干员", "特种干员"],
"en": "Class", "entags": ["Vanguard", "Sniper", "Medic", "Caster", "Guard", "Defender", "Support", "Specialist"]
},
{
"cn": "词缀", "cntags": ["治疗", "支援", "输出", "群攻", "减速", "生存", "防护", "削弱", "位移", "控场", "爆发", "召唤", "快速复活", "费用回复"],
"en": "Affix", "entags": ["Healing", "Support", "DPS", "Splash", "Slow", "Survival", "Protection", "Debuffer", "Displacement", "Crowd Control", "Burst", "Summoner", "Quick Resurrection", "Cost Recovery"]
}
];
$.each(tags, (_, v) => {
let row = '<tr><td><button class="btn btn-sm btn-info my-1" disabled>' + v[lang] + '</button></td><td>';
let tags_btn = []
for (let i = 0; i < v['cntags'].length; i++) {
tags_btn.push('<button type="button" class="btn btn-sm btn-secondary btn-tag my-1" ' +
(lang === 'cn' ? '' : ('data-toggle="tooltip" data-placement="top" title="' + v[lang + 'tags'][i] + '"'))
+ '>' + v['cntags'][i] + "</button>");
}
row += tags_btn.join("\r\n") + "</td></tr>";
$("#box-tags").append(row);
});
if (lang !== 'cn') $('[data-toggle="tooltip"]').tooltip();
let showImage = false;
let showName = true;
let imageSize = 27;
$(document).on("click", ".btn-name", function () {
$(this).toggleClass("btn-primary btn-secondary");
showName = !showName;
calc();
});
$(document).on("click", ".btn-image", function () {
$(this).toggleClass("btn-primary btn-secondary");
$(".btn-imgsize").removeClass("btn-primary btn-secondary").addClass("btn-secondary");
if ($(this).hasClass("btn-primary")) $(".btn-imgsize[sizeval=" + imageSize + "]").toggleClass("btn-primary btn-secondary");
showImage = $(".btn-image").hasClass("btn-primary");
calc();
});
$(document).on("click", ".btn-imgsize", function () {
if ($(this).hasClass("btn-primary")) {
$(".btn-image").removeClass("btn-primary btn-secondary").addClass("btn-secondary");
$(".btn-imgsize").removeClass("btn-primary btn-secondary").addClass("btn-secondary");
} else {
imageSize = parseInt($(this).attr("sizeval"));
$(".btn-image").removeClass("btn-primary btn-secondary").addClass("btn-primary");
$(".btn-imgsize").removeClass("btn-primary btn-secondary").addClass("btn-secondary");
$(this).toggleClass("btn-primary btn-secondary");
}
showImage = $(".btn-image").hasClass("btn-primary");
calc();
});
let tags_aval = {};
let all_chars = {};
let avg_char_tag = 0;
$.getJSON("akhr.json", function (data) {
let tag_count = 0;
let char_tag_sum = 0;
// console.log(data);
$.each(data, function (_, char) {
if (char.hidden) return;
char.tags.push(char.type + "干员");
char.tags.push(char.sex + "性干员");
let name = lang === 'cn' ? char.name : char["name-" + lang];
$.each(char.tags, function (_, tag) {
if (tag in tags_aval) {
tags_aval[tag].push({ "name": name, "img": char["name-en"], "level": char.level, "type": char.type });
} else {
tags_aval[tag] = [{ "name": name, "img": char["name-en"], "level": char.level, "type": char.type }];
tag_count++;
}
char_tag_sum++;
});
all_chars[name] = { 'level': char.level, 'tags': char.tags };
});
avg_char_tag = char_tag_sum / tag_count;
});
function calc() {
let len = checkedTags.length;
let count = Math.pow(2, checkedTags.length);
let combs = [];
for (let i = 0; i < count; i++) {
let ts = [], tsTL = [];
for (let j = 0, mask = 1; j < len; j++) {
if ((i & mask) !== 0) {
ts.push(checkedTags[j]);
tsTL.push(checkedTagsTL[j]);
// console.log(checkedTags[j]);
}
mask = mask * 2;
}
combs.push({ "tags": ts, "tagsTL": tsTL, "score": 0.0, "possible": [] });
}
// console.log(combs);
let optStars = [];
$(".btn-opt").each(function (_, __) {
if ($(this).attr("opt-id") === "all" || $(this).hasClass("btn-secondary")) return;
optStars.push($(this).attr("opt-id"));
});
//console.log(optStars);
$("#tbody-recommend").html("");
$.each(combs, function (_, comb) {
let tags = comb.tags;
if (tags.length === 0 || tags.length > 3) return;
let chars = [...tags_aval[tags[0]]];
for (let i = 1; i < tags.length; i++) {
let reduced_chars = [];
$.each(chars, function (_, char) {
// console.log(tags_aval[tags[i]]);
// console.log(char);
$.each(tags_aval[tags[i]], function (_, tgch) {
if (char.name === tgch.name) {
reduced_chars.push(char);
return false;
}
});
});
chars = reduced_chars;
}
if (chars.length === 0) return;
if (!tags.includes("高级资深干员")) {
// console.log(tags.join(",") + " 不含(高级)资深干员");
let reduce6 = [];
$.each(chars, function (_, char) {
if (char.level !== 6) {
reduce6.push(char);
}
});
chars = reduce6;
}
let filtered_chars = [];
$.each(chars, function (_, char) {
//console.log(char.level);
if (optStars.includes(char.level.toString())) {
filtered_chars.push(char);
}
});
chars = filtered_chars;
comb.possible = chars;
if (chars.length === 0) return;
let s = 0;
$.each(chars, (_, char) => {
s += char.level;
});
s = s / chars.length;
comb.score = s + 0.1 / tags.length + 0.9 / chars.length;
});
combs.sort(function (a, b) {
return a.score > b.score ? -1 : (a.score < b.score ? 1 :
(a.tags.length > b.tags.length ? 1 : (a.tags.length < b.tags.length ? -1 : 0)));
});
let no = 1;
$.each(combs, function (_, comb) {
if (comb.possible.length === 0) return;
let chars = comb.possible;
let tags = comb.tags;
let tagsTL = comb.tagsTL;
let chars_html = [];
let colors = { 1: "dark", 2: "light", 3: "success", 4: "info", 5: "warning", 6: "danger" };
comb.possible.sort(function (a, b) {
return a.level > b.level ? -1 : (a.level < b.level ? 1 : 0);
});
$.each(chars, function (_, char) {
let padding = showName && imageSize < 60 ? "padding-right: 4px" : "padding-right: 1px";
let style = showImage ? "style=\"border-radius: 5px;padding: 1px 1px;" + padding + ";\" " : "";
let buttonstyle = imageSize > 25 ? "background-color: #AAA;border-radius: 4px;" : "background-color: transparent;border-radius: 4px;";
chars_html.push("<button type=\"button\" class=\"btn btn-sm btn-" + colors[char.level] + " btn-char my-1 d-none d-sm-inline\" " + style + "title=\"" + char.name + "\">");
if (showImage) chars_html.push("<img style=\"" + buttonstyle + "\"height=\"" + imageSize + "\" width=\"" + imageSize + "\" src=\"img/chara/" + char.img + ".png\"> ");
if (imageSize > 60) chars_html.push("<div>");
if (showName) chars_html.push(char.name);
if (imageSize > 60) chars_html.push("</div>");
chars_html.push("</button>\n");
chars_html.push("<button type=\"button\" class=\"btn btn-sm btn-" + colors[char.level] + " btn-char my-1 d-inline d-sm-none\" " + "title=\"" + char.name + "\">" + char.name + "</button>\n");
});
let tags_html = [];
for (let i = 0; i < tags.length; i++) {
if (lang === 'cn') {
tags_html.push('<button type="button" class="btn btn-sm btn-secondary btn-char my-1">' +
tags[i] + "</button>\n");
} else {
tags_html.push('<button type="button" class="btn btn-sm btn-secondary btn-char my-1' +
' btn-char my-1" data-toggle="tooltip" data-placement="top" title="' + tagsTL[i] + '">' +
tags[i] + "</button>\n");
}
}
$("#tbody-recommend").append(
"<tr class=\"tr-recommd\">" +
"<td class=\"py-2 d-none d-sm-table-cell\">" + no++ + "</td>" +
"<td class=\"py-1\">" + tags_html.join("") + "</td><td class=\"py-1\">" + chars_html.join("") +
"</td>" +
"<td class=\"py-2 d-none d-sm-table-cell\">" + Math.floor(comb.score * 100) / 100 + "</td>" +
"</tr>");
});
if (lang !== 'cn') $('[data-toggle="tooltip"]').tooltip();
}
let hasHidden = false;
$(document).on("click", ".btn-char", function () {
if (!hasHidden) {
let char_name = $(this).attr("title");
$(".tr-recommd:not(:contains('" + char_name + "'))").hide();
let char = all_chars[char_name];
let colors = { 1: "dark", 2: "light", 3: "success", 4: "info", 5: "warning", 6: "danger" };
let tags_html = [];
$.each(char.tags, function (_, tag) {
tags_html.push("<button type=\"button\" class=\"btn btn-sm btn-secondary btn-char my-1\">" +
tag + "</button>\n")
});
$("#tbody-recommend").append(
"<tr class=\"tr-chartag\">" +
"<td class=\"py-2 d-none d-sm-table-cell\">#</td>" +
"<td class=\"py-1\"><button type=\"button\" class=\"btn btn-sm btn-" + colors[char.level] +
" btn-char my-1\">" + char_name + "</button>\n" +
"</td><td class=\"py-1\">" + tags_html.join("") +
"</td><td class=\"py-2 d-none d-sm-table-cell\">#</td></tr>");
} else {
$(".tr-recommd").show();
$(".tr-chartag").remove();
}
hasHidden = !hasHidden;
});
let checkedTags = [];
let checkedTagsTL = [];
$(document).on("click", ".btn-tag", function () {
let checked = $(this).hasClass("btn-primary");
let tag = $(this).text();
let tagTL = $(this).attr("data-original-title");
if (checked) {
checkedTags = checkedTags.filter(function (v, _, __) {
return v !== tag;
});
checkedTagsTL = checkedTagsTL.filter(function (v, _, __) {
return v !== tagTL;
});
} else {
if (checkedTags.length >= 6) {
alert({ "cn": "无法选择更多标签:最多6个。", "en": "No more tags: max 6." }[lang]);
return;
} else {
checkedTags.push(tag);
checkedTagsTL.push(tagTL);
}
}
$(this).toggleClass("btn-primary btn-secondary");
calc();
});
$(document).on("click", ".btn-opt", function () {
$(this).toggleClass("btn-primary btn-secondary");
let checked = $(this).hasClass("btn-primary");
if ($(this).attr("id") === "opt-all") {
$(".btn-opt").removeClass("btn-primary btn-secondary").addClass(
checked ? "btn-primary" : "btn-secondary"
);
} else {
if ($("#opt-all").hasClass("btn-primary")) {
$("#opt-all").toggleClass("btn-primary btn-secondary");
} else {
let checkedCount = 0;
$(".btn-opt").each(function (_, __) {
if ($(this).attr("id") === "opt-all") return;
if ($(this).hasClass("btn-primary")) checkedCount++;
});
if (checkedCount === 6) $("#opt-all").toggleClass("btn-primary btn-secondary");
}
}
calc();
});
$(document).on('click', '#btn-clear', function () {
$('.btn-tag').removeClass('btn-primary').addClass('btn-secondary');
$("#tbody-recommend").html("");
checkedTags = [];
});
});
</script>
</body>
</html>