forked from freakitties/freakitties.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jeans.html
736 lines (688 loc) · 31.2 KB
/
jeans.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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
<html>
<head>
<title>Axie Gene Explorer</title>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-116189657-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-116189657-1');
</script>
<!--web3 v0.20.6-->
<script src="/js/web3.min.js" integrity="sha384-rXHfd7f1o1jpr3t+dYI17CkzUY3Wswo1OGbiXPGSbg4s2E42+jkRgllwt7ss2Vlq"></script>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" crossorigin="anonymous"></script> -->
<!-- jquery 3.3.1-->
<script src="/js/jquery.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/js/bootstrap.min.js" integrity="sha384-7aThvCh9TypR7fIc2HV4O/nFMVCBwyIUKL8XCtKE+8xgCgl/PQGuFsvShjr74PBp" crossorigin="anonymous"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.18/js/jquery.dataTables.min.js" integrity="sha384-r3v0/sXe5ocDydKBFcxP390rex2dEm9qN3Yv68S6uNX/F3b/RtMdGMUADZ8tabkz" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js" integrity="sha384-zOjU8Lmrn7aY/0op2Zr4DRXhg0el3XJ4SEMVakZ7bni+KP5F9geHOJ0cWYSvj0HN" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js" integrity="sha384-EzXZHFRG/n4Omd1nQTNbrErjupvcy1TetvtLCAR9wX6U7/CnXYYe8Ea6l6n1KtM5" crossorigin="anonymous"></script>
<script src="traitmapping.js"></script>
<script src="/axie/js/api.js"></script>
<script src="js/utils.js"></script>
<script src="js/geneTable.js"></script>
<script src="js/axieChainUtils.js"></script>
<script src="js/constants.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.0/css/bootstrap.min.css" integrity="sha384-PDle/QlgIONtM1aqA2Qemk5gPOE7wFq8+Em+G/hmo5Iq0CCmYZLv3fVRDJ4MMwEA" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" integrity="sha384-1UXhfqyOyO+W+XsGhiIFwwD3hsaHRz2XDGMle3b8bXPH5+cMsXVShDoHA3AH/y/p" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css" integrity="sha384-4zgE69bwrfaNYUZPA2TaKwT/mjqMcBEvQmjHf1qkjg3c2JSWfEGflXXz6xXBLGGN" crossorigin="anonymous">
<link rel="stylesheet" href="/css/jquery-ui.css" integrity="sha384-7UG1JWOW1s2Zo3gDfHmL9dAVD/QS57qS+pRAq3icsyDwzlkPRQlk4PDD0bySIiQq">
<script src="/js/jquery-ui.min.js" integrity="sha384-PtTRqvDhycIBU6x1wwIqnbDo8adeWIWP3AHmnrvccafo35E7oIvW7HPXn2YimvWu"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<style>
body {background-color: #efefef;}
.selected {
position: relative;
width: auto;
/*font-size: 14px;*/
background-color: rgb(255, 255, 255);
padding: 4px 8px 4px 4px;
border-radius: 18px;
border-width: 1.5px;
border-style: solid;
border-color: rgb(230, 230, 230);
border-image: initial;
color: black;
display: inline-block;
}
.selected-box {
display: inline-block;
margin-right: 5px ;
}
[data-toggle="collapse"] .fa:before {
content: "\f139";
}
[data-toggle="collapse"].collapsed .fa:before {
content: "\f13a";
}
.pointer {
cursor: pointer;
}
.fa-eye-slash {
color: grey;
}
.circle-horn-sm, .circle-eyes-sm, .circle-mouth-sm, .circle-ears-sm, .circle-back-sm, .circle-tail-sm {
width: 18px !important;
height: 18px !important;
}
.ib {
display: inline-block;
}
</style>
<link rel="stylesheet" href="css/axie.css">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<script>
var axies = {};
var checkedAddresses = [];
function getRegionFromGroup(group) {
let regionBin = group.slice(8,13);
if (regionBin in regionGeneMap) {
return regionGeneMap[regionBin];
}
return "Unknown Region";
}
function getClassFromGroup(group) {
let bin = group.slice(0, 4);
if (!(bin in classGeneMap)) {
return "Unknown Class";
}
return classGeneMap[bin];
}
function getPatternsFromGroup(group) {
//patterns could be 6 bits. use 4 for now
return {d: group.slice(2, 8), r1: group.slice(8, 14), r2: group.slice(14, 20)};
}
function getColor(bin, cls) {
let color;
if (bin == "0000") {
color = "ffffff";
} else if (bin == "0001") {
color = "7a6767";
} else {
color = geneColorMap[cls][bin];
}
return color;
}
function getColorsFromGroup(group, cls) {
return {d: getColor(group.slice(20, 24), cls), r1: getColor(group.slice(24, 28), cls), r2: getColor(group.slice(28, 32), cls)};
}
//hack. key: part name + " " + part type
var partsClassMap = {};
function getPartName(cls, part, region, binary) {
let trait;
if (binary in binarytraits[cls][part]) {
if (region in binarytraits[cls][part][binary]) {
trait = binarytraits[cls][part][binary][region];
} else if ("global" in binarytraits[cls][part][binary]) {
trait = binarytraits[cls][part][binary]["global"]; //don't use mystic name. breeding doesn't pass mystic.
} else {
trait = "UNKNOWN Regional " + cls + " " + part;
}
} else {
trait = "UNKNOWN " + cls + " " + part;
}
//return part + "-" + trait.toLowerCase().replace(/\s/g, "-");
partsClassMap[trait + " " + part] = cls;
return trait;
}
function getPartsFromGroup(part, group, region) {
let mystic = group.slice(0, 2) == "11";
let dClass = classGeneMap[group.slice(2, 6)];
let dBin = group.slice(6, 12);
let dName = getPartName(dClass, part, region, dBin);
let r1Class = classGeneMap[group.slice(12, 16)];
let r1Bin = group.slice(16, 22);
let r1Name = getPartName(r1Class, part, region, r1Bin);
let r2Class = classGeneMap[group.slice(22, 26)];
let r2Bin = group.slice(26, 32);
let r2Name = getPartName(r2Class, part, region, r2Bin);
return {d: getPartFromName(part, dName), r1: getPartFromName(part, r1Name), r2: getPartFromName(part, r2Name), mystic: mystic};
}
function getTraits(genes) {
var groups = [genes.slice(0, 32), genes.slice(32, 64), genes.slice(64, 96), genes.slice(96, 128), genes.slice(128, 160), genes.slice(160, 192), genes.slice(192, 224), genes.slice(224, 256)];
let cls = getClassFromGroup(groups[0]);
let region = getRegionFromGroup(groups[0]);
let pattern = getPatternsFromGroup(groups[1]);
let color = getColorsFromGroup(groups[1], groups[0].slice(0, 4));
let eyes = getPartsFromGroup("eyes", groups[2], region);
let mouth = getPartsFromGroup("mouth", groups[3], region);
let ears = getPartsFromGroup("ears", groups[4], region);
let horn = getPartsFromGroup("horn", groups[5], region);
let back = getPartsFromGroup("back", groups[6], region);
let tail = getPartsFromGroup("tail", groups[7], region);
return {cls: cls, region: region, pattern: pattern, color: color, eyes: eyes, mouth: mouth, ears: ears, horn: horn, back: back, tail: tail};
}
function getPartFromName(traitType, partName) {
let traitId = traitType.toLowerCase() + "-" + partName.toLowerCase().replace(/\s/g, "-").replace(/[\?']/g, "");
return bodyPartsMap[traitId];
}
async function getAxies(offset, address) {
var numSkipped = 0;
let data = await getAxiesByAddress(address, 0);
let percentage = (offset + AXIE_QUERY_SIZE)/data.total * 100;
$("#loading").text("Loading..." + Math.round(percentage) + "%");
for (let i in data.results) {
if (data.results[i].stage < 3) {
numSkipped++;
continue;
}
axies[data.results[i].id] = {"id": data.results[i].id, "genes": genesToBin(new BigNumber(data.results[i].genes)), "class": data.results[i].class, "sireId": data.results[i].sireId, "matronId": data.results[i].matronId, "stats": data.results[i].stats, "name": data.results[i].name, "breedCount": data.results[i].breedCount, "stage": data.results[i].stage, "owner": data.results[i].owner}; //update 3 places
//"exp": data.results[i].exp,
//"expForBreeding": expForBreeding[data.results[i].breedCount],
let axie = axies[data.results[i].id];
axie.traits = getTraits(axie.genes);
addRow(axies[data.results[i].id]);
}
let totalAxies = data.total;
if (totalAxies > AXIE_QUERY_SIZE) {
for (let i = AXIE_QUERY_SIZE; i < totalAxies; i+=AXIE_QUERY_SIZE) {
let data = await getAxiesByAddress(address, i);
let percentage = (Object.keys(axies).length + AXIE_QUERY_SIZE)/data.total * 100;
$("#loading").text("Loading..." + Math.round(percentage) + "%");
for (let i in data.results) {
if (data.results[i].stage < 3) {
numSkipped++;
continue;
}
axies[data.results[i].id] = {"id": data.results[i].id, "genes": genesToBin(new BigNumber(data.results[i].genes)), "class": data.results[i].class, "sireId": data.results[i].sireId, "matronId": data.results[i].matronId, "stats": data.results[i].stats, "name": data.results[i].name, "breedCount": data.results[i].breedCount, "stage": data.results[i].stage, "owner": data.results[i].owner}; //update 3 places
//"exp": data.results[i].exp,
//"expForBreeding": expForBreeding[data.results[i].breedCount],
let axie = axies[data.results[i].id];
axie.traits = getTraits(axie.genes);
addRow(axies[data.results[i].id]);
}
if (Object.keys(axies).length + numSkipped >= totalAxies) { //fudge incase over for some reason
$("#loading").text("Done.")
$("#loading").fadeOut(3500);
}
}
} else {
$("#loading").text("Done.")
$("#loading").fadeOut(3500);
}
}
async function getAxie(id) {
let data = await getAxieDetails(id);
if (data.stage < 3) {
return;
}
axies[data.id] = {"id": data.id, "genes": genesToBin(new BigNumber(data.genes)), "class": data.class, "sireId": data.sireId, "matronId": data.matronId, "stats": data.stats, "name": data.name, "breedCount": data.breedCount, "stage": data.stage, "owner": data.owner}; //update 3 places
//"exp": data.exp,
//"expForBreeding": expForBreeding[data.breedCount],
let axie = axies[data.id];
axie.traits = getTraits(axie.genes);
addRow(axies[data.id]);
}
var calcWorker;
var intID;
function init() {
clearInterval(intID);
$.ajax({
url: "../header.html",
cache: false,
dataType: "html",
success: function(data) {
$("#headerDiv").html(data);
initTable();
let cb = null;
if (typeof web3 == 'undefined') {
$("#account").text("Web3 enabled browser not detected. Use the search box.");
$("#loading").text("")
$("#loading").fadeOut(1);
} else {
if (typeof web3.eth.accounts[0] == "undefined") {
$("#account").text("Can't detect your account. Unlock your wallet or try reloading the page and waiting a few seconds.");
$("#loading").text("")
$("#loading").fadeOut(1);
} else {
if (window.location.hash.substr(1) == "noAuto") {
$("#loading").text("");
getBodyParts(cb);
} else {
let profile = getProfileByEthAddress(web3.eth.accounts[0]).then((profile) => {
let address = profile.data.publicProfileWithEthereumAddress.addresses.ronin;
$("#account").text("Your Account: " + address);
cb = () => {
getAxies(0, address);
}
getBodyParts(cb);
});
}
}
}
calcWorker = new Worker('js/partBreederWorker.js');
calcWorker.onmessage = receiveCalc;
}
});
}
function initBodyParts(parts) {
bodyParts = parts;
for (let i in parts) {
bodyPartsMap[parts[i].partId] = parts[i];
bodyParts[i].value = bodyParts[i].partId;
bodyParts[i].label = bodyParts[i].name;
}
$("#searchParts").autocomplete({
source: bodyParts,
select: partSelected,
}).autocomplete("instance")._renderItem = renderSearch;
$("#searchForm").show();
}
var bodyPartsMap = {};
var bodyParts;
function getBodyParts(callback) {
$.getJSON("https://axieinfinity.com/api/v2/body-parts", (parts) => {
initBodyParts(parts);
}).always(() => {
$("#search").prop("disabled", false);
if (callback) {
callback();
}
}).fail(() => {
console.log("Failed to get body parts from the API");
//API is unreliable. fall back to hard-coded local copy.
$.getJSON("/axie/js/body-parts.json", (parts) => {
console.log("Using static body part data");
initBodyParts(parts);
}).fail(() => {
$("#searchParts").prop("disabled", true);
$("#searchParts").prop("placeholder", "Error connecting to Axie API");
});
});
}
var allProbs;
var traitMapping = binarytraits;
var BigNumber;
window.addEventListener('load', async () => {
// Modern dapp browsers...
if (window.ethereum) {
window.web3 = new Web3(ethereum);
BigNumber = web3.BigNumber;
try {
// Request account access if needed
await ethereum.enable();
console.log("modern dapp browser");
} catch (error) {
// User denied account access...
console.log("User denied ethereum account access.")
}
}
// Legacy dapp browsers...
else if (window.web3) {
window.web3 = new Web3(web3.currentProvider);
BigNumber = web3.BigNumber;
// Acccounts always exposed
console.log("legacy dapp browser");
}
// Non-dapp browsers...
else {
console.log('Non-Ethereum browser detected.');
//since we are using our own web3.min.js
let w3 = new Web3();
BigNumber = w3.BigNumber;
}
//defer init until accounts are loaded
intID = setInterval(init, 250);
$("#searchForm").submit(calc);
$("#calcPartsButton").click(calc);
$("#clearIgnoreAxieButton").click(clearIgnore);
$("#ignoreForm").submit(clearIgnore);
});
function clearIgnore(e) {
if (e) {
e.preventDefault();
}
ignoreList.clear();
$("#ignoreUL").empty();
renderTraitProbs(selectedParts, allProbs);
}
var ignoreList = new Set();
function ignoreAxie(axieId) {
if (axieId && axieId in axies) {
if (!ignoreList.has(axieId)) {
ignoreList.add(axieId);
let ignoreItemId = "ignoreItem" + axieId;
$("#ignoreUL").append($("<li/>", {"class": "list-group-item pointer", "text": axieId, "id": ignoreItemId}));
$("#" + ignoreItemId).append('<img src="' + axies[axieId].image + '" height="25" class="ml-5">')
$("#" + ignoreItemId).click(function () {
ignoreList.delete(axieId);
$("#" + ignoreItemId).remove();
renderTraitProbs(selectedParts, allProbs);
});
renderTraitProbs(selectedParts, allProbs);
}
}
}
function receiveCalc(e) {
$("#loading").text("Done.");
$("#loading").fadeOut(1000, () => {
$("#loading").text("");
$("#loading").fadeIn(0);
});
allProbs = e.data.allProbs;
renderTraitProbs(selectedParts, allProbs);
}
function calc(e) {
if (e) {
e.preventDefault();
}
$("#result").empty();
$("#loading").text("Calculating...");
$("#loading").append('<div class="spinner-border spinner-border-sm"></div>');
$("#loading").show();
calcWorker.postMessage({selectedParts: selectedParts, axies: axies, ignoreList: ignoreList, traitMapping: traitMapping});
}
var numToDisplay = 10;
function renderTraitProbs(traits, allProbs) {
let names = [];
for (let t in traits) {
names.push(traits[t].name);
}
let out = '<div class="card mb-3 col-12">';
out += '<div class="card-header row">Probability for breeding traits: ' + weakEscape(names.join(", ")) + (ignoreList.size > 0 ? " (" + ignoreList.size + " axies ignored)" : "") + '</div>';
if (allProbs.length == 0) {
out += "<div>No axies found or none meet the criteria.</div></div>";
$("#result").empty();
$("#result").append(out);
return;
}
//let numToDisplay = parseInt($("#numToDisplay").val());
//const numToDisplay = 10;
let images = [];
let count = 0;
for (let i=0; i < allProbs.length && count < numToDisplay ; i++) {
let pair = allProbs[i].pair.split("_");
let axieId1 = parseInt(pair[0]);
let axieId2 = parseInt(pair[1]);
if (ignoreList.has(axieId1) || ignoreList.has(axieId2)) continue;
count++;
out += '<div class="row border-bottom">';
let prob = (allProbs[i].probability * 100).toFixed(3);
out += '<div class="col-3 d-flex justify-content-center flex-column"><a target="blank" href="/axie/calc.html?sireId=' + axieId1 + '&matronId=' + axieId2 + '">' + prob + "%</a></div>";
let id1 = "axie" + axieId1 + "_" + i;
let id2 = "axie" + axieId2 + "_" + i;
images.push({tagId: id1, axieId: pair[0]})
images.push({tagId: id2, axieId: pair[1]})
out += '<div class="col-4 text-center d-flex justify-content-center flex-column"><div class="row justify-content-center"><i id="' + id1 + '_ign" class="fas fa-eye-slash pointer" title="Ignore"></i><a target="_blank" href="https://marketplace.axieinfinity.com/axie/' + axieId1 + '?r=freak"><img id="' + id1 + '" height="80" data-toggle="tooltip" data-placement="top"><br>#' + axieId1 + '</a></div><div id="' + id1 + '_data"></div></div>';
out += '<div class="col-4 text-center d-flex justify-content-center flex-column"><div class="row justify-content-center"><i id="' + id2 + '_ign" class="fas fa-eye-slash pointer" title="Ignore"></i><a target="_blank" href="https://marketplace.axieinfinity.com/axie/' + axieId2 + '?r=freak"><img id="' + id2 + '" height="80" data-toggle="tooltip" data-placement="top"><br>#' + axieId2 + '</a></div><div id="' + id2 + '_data"></div></div>';
out += '</div>';
}
out += "</div>"
$("#result").empty();
$("#result").append(out);
for (let id in images) {
setImageAndStats(images[id].tagId, images[id].axieId);
$("#" + images[id].tagId + "_ign").click(function() {
ignoreAxie(parseInt(images[id].axieId));
});
}
$('[data-toggle="tooltip"]').tooltip();
}
function genImageStatsHTML(tag, axie) {
var img = $("#" + tag);
img.attr('src', axie.image);
var dataTag = $("#" + tag + "_data");
//dataTag.text("Exp: " + (axie.exp ? axie.exp : 0) + " + " + axie.truePending);
//dataTag.append($("<br>"));
let breeds = $("<div/>", {class: "row justify-content-center", text: "Breeds: " + axie.breedCount}); // + " ("});
/*
if (axie.stage < 4 || axie.exp + axie.truePending < axie.expForBreeding) {
breeds.append($("<div/>", {class: "text-danger", text: axie.expForBreeding}));
} else {
breeds.append($("<div/>", {class: "text-success", text: axie.expForBreeding}));
}
breeds.append(")");
*/
dataTag.append(breeds);
}
function setImageAndStats(tag, axieID) {
let axie = axies[axieID.toString()];
if (axie.hasOwnProperty("image")) {
genImageStatsHTML(tag, axie);
} else {
getExtendedAxieData(axie, (axie) => {
genImageStatsHTML(tag, axie);
});
}
}
var selectedParts = {};
function partSelected(event, ui) {
$("#searchParts").val("");
event.preventDefault();
if (selectedParts.hasOwnProperty(ui.item.partId)) {
return true;
}
let id = ui.item.partId + "-selected";
selectedParts[ui.item.partId] = bodyPartsMap[ui.item.partId];
$("#calcPartsButton").show();
$("<div/>", {"class": "selected", "id": ui.item.partId + "-parent"})
.append($('<div/>', {"class": "selected-box", "text": ui.item.name}))
.prepend($("<div> ").prop('class', 'align-middle mr-1 ib circle-' + ui.item.type + ' circle-' + ui.item.type + '-sm btn-' + ui.item.class))
.append($("<span/>", {"id": id, "text": "x", "class": "pointer text-secondary"}))
.prependTo( "#searchResult" );
$("#" + id).click(function() {
let spanId = $(this).prop('id');
let partId = spanId.substr(0, spanId.indexOf("-selected"));
$("#" + partId + "-parent").remove();
delete selectedParts[partId];
});
return true;
}
function renderSearch(ul, item ) {
for (let i in selectedParts) {
if (selectedParts[i].type == item.type) {
return $( "<li>" )
}
}
return $( "<li>" )
.append(
$("<div/>", {"text": item.name})
.prepend($("<div> ").prop('class', 'align-middle mr-1 ib circle-' + item.type + ' circle-' + item.type + '-sm btn-' + item.class))
)
.appendTo( ul );
};
function addSinglesAxie(ids) {
for (let i in ids) {
getAxie(ids[i]);
}
}
function search() {
$("#loading").text("");
$("#loading").show();
let text = $("#search").val().trim();
if (axieTable) {
axieTable.clear();
axieTable.draw();
}
if (text.includes(",")) {
let splits = text.split(/\s*,\s*/);
let addresses = [];
let ids = [];
for (let i in splits) {
if (splits[i] == "") continue;
//if (splits[i].startsWith("0x")) {
if (splits[i].startsWith("ronin:")) {
addresses.push(splits[i].replace("ronin:", "0x"));
}
else if (!$.isNumeric(splits[i])) {
continue;
} else {
ids.push(splits[i]);
}
}
axies = {};
addSinglesAxie(ids);
for (let a in addresses) {
getAxies(0, addresses[a]);
}
} else if (text.startsWith("ronin:")) {
getAxies(0, text.replace("ronin:", "0x"));
} else if ($.isNumeric(text)) {
getAxie(text);
} else {
//TODO: do this more elegantly
alert("invalid search criteria");
}
}
$(document).keyup(function(event) {
if ($("#search").is(":focus") && event.key == "Enter") {
search();
}
});
function toggleBinary() {
if ($('#binaryToggle').is(":checked")) {
$(".binary").css("display", "none");
} else {
$(".binary").css("display", "block");
}
}
</script>
<!-- header -->
<div id="headerDiv"></div><br/>
<div id="mainDiv" class="container ml-5">
<div class="row">
<div class="text-left col-6" id="account"></div><br/>
<input class="text-right col-5 form-control" id="search" size="55" placeholder="ID, ronin address or comma separated list of IDs and/or addresses" disabled/>
<button type="submit" class="btn btn-dark" onclick="search();" id="searchButton0">Search</button>
</div>
<div class="row">
<div id="loading" class="col-8">Loading...</div><div id="spacer"> </div>
</div>
<div id="copyDiv"></div>
<br/>
<div class="pl-3" id="partBreeding">
<p>
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseSearch" aria-expanded="true" aria-controls="collapseSearch">
<i class="fa"></i> Part Breeding
</button>
</p>
<div class="">
<div class="collapse" id="collapseSearch" data-parent="#partBreeding">
<div class="row">
<div class="col-8">
<form class="col-12" action="" id="searchForm">
<div class="row">
<div class="form-inline col-10">
<input type="text" class="form-control col-6" id="searchParts" name="searchParts" placeholder="Search for parts">
<input type="submit" value="Search" class="btn btn-primary" id="searchButton"></input>
</div>
</div>
<div>
<br>
<div id="searchResult" class="mb-3"></div>
<button id="calcPartsButton" class="btn btn-primary">Find pairs</button>
</div>
</form>
<div id="result" class=""></div>
<br>
</div>
<div class="col-4">
<div id="ignores" class="col-12 row">
<div class="col-9">
<div class="card">
<div class="card-header">Ignore List</div>
<ul class="list-group list-group-flush" id="ignoreUL">
</ul>
</div>
</div>
<div class="">
<button class="btn btn-primary ml-1" id="clearIgnoreAxieButton">Clear</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div><br>
<table class="table display nowrap" id="axieTable">
<thead>
<tr>
<th rowspan="2">ID</th>
<th colspan="6">Group 0 (Class, Region, Tag, Skin)</th>
<th colspan="6">Group 1 (Pattern and Color)</th>
<th colspan="7">Group 2 (Eyes)</th>
<th colspan="7">Group 3 (Mouth)</th>
<th colspan="7">Group 4 (Ears)</th>
<th colspan="7">Group 5 (Horn)</th>
<th colspan="7">Group 6 (Back)</th>
<th colspan="7">Group 7 (Tail)</th>
<th colspan="14">Additional Info</th> <!-- adjust for new column -->
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th><!-- adjust for new column -->
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</html>