This repository has been archived by the owner on Nov 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1247 lines (1133 loc) · 56.3 KB
/
index.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
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!--
AzurViewer
[ A web explorer for Azur Lane. Look at detailed ship stats, descriptions and more. ]
Developed by Chen Zheng (@HotFireyDeath)
http://czheng.me
-->
<html>
<head>
<title>AzurViewer</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#72a6db">
<link rel="manifest" href="manifest.json">
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<!-- FONT AWESOME -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"
integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<!-- GOOGLE FONTS -->
<link href="https://fonts.googleapis.com/css?family=Dosis" rel="stylesheet">
<!-- JQUERY -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<!-- MATERIALIZE -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<!-- LOCALFORAGE -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.7.2/localforage.min.js"></script>
<style>
body {
font-family: "Dosis", serif;
}
/*
Below is a solution to fit an image to the page responsively.
The solution can be found at:
https://stackoverflow.com/a/14696457
*/
* {
margin: 0;
padding: 0;
}
.imgbox {
display: grid;
height: 100%;
}
.center-fit {
max-width: 100%;
max-height: 100vh;
margin: auto;
}
a {
cursor: pointer;
}
/*
Below is a solution to fit 5 columns in a grid in Materialize.
The solution can be found at:
https://stackoverflow.com/a/43084048
*/
.s5ths,
.m5ths,
.l5ths,
.xl5ths {
margin-left: auto;
left: auto;
right: auto;
}
.row .col.s5ths {
width: 20%;
}
@media only screen and (min-width: 601px) {
.row .col.m5ths {
width: 20%;
}
}
@media only screen and (min-width: 993px) {
.row .col.l5ths {
width: 20%;
}
}
@media only screen and (min-width: 1201px) {
.row .col.xl5ths {
width: 20%;
}
}
#search::placeholder {
font-family: "Dosis", serif;
color: grey;
}
</style>
</head>
<body>
<!-- omnisearch -->
<br>
<nav id="omnisearch" class="container z-depth-0" style="background-color: white; display: none;">
<div class="nav-wrapper white lighten-3" style="border-radius: 50px;">
<form>
<div class="input-field">
<input id="search" type="search" placeholder="Type 'help' for navigation options">
<label class="label-icon" for="search"><i class="fas fa-search" style="color: black;"></i></label>
<i class="material-icons fas fa-times" onclick="$('#search').val('');"></i>
</div>
</form>
</div>
</nav>
<!-- search results list -->
<div class="container">
<ul class="collection" id="search_results" style="display: none;"></ul>
</div>
<!-- loading element -->
<div id="loading_pleaseWait" style="display: none;">
<div class="container">
<div class="card horizontal">
<div class="card-image">
<img id="loading_pleaseWait_char" src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/f/fb/SaratogaChibi.png">
</div>
<div class="card-stacked">
<div class="card-content" style="text-align: center;" id="loading_pleaseWait_phrase">
<span id="loading_pleaseWait_percentage" style="font-size: 10px;"></span>
<span class="card-title">Loading...</span>
</div>
</div>
</div>
</div>
</div>
<!-- main page element -->
<div id="mainMenuDisplay" class="container" style="display: none;">
<br>
</div>
<!-- ship display element -->
<div id="ship_displayCase" style="display: none;">
<div class="container">
<p id="ship_displayCase_rawData"></p> <!-- rawData div will only be filled for development purpose. -->
<br>
<button class="waves-effect waves-teal btn-flat"
onclick="document.title='AzurViewer';$('#ship_displayCase').hide();$('#mainMenuDisplay').show();"><i
class="fas fa-angle-left"></i> Back
</button>
<!-- ship name -->
<h4 id="ship_displayCase_name" style="text-align: center;" onclick="checkClick();"></h4>
<!-- ship skin display -->
<div class="imgbox"><img onclick="displaySkinModal();" class="center-fit" id="ship_displayCase_skinpicture"
src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/0/06/Akagi.png"></div>
<!-- ship basic info -->
<ul class="collection z-depth-1">
<li id="ship_displayCase_nationality" class="collection-item"></li>
<li id="ship_displayCase_rarity" class="collection-item"></li>
<li id="ship_displayCase_constructionTime" class="collection-item"></li>
<li id="ship_displayCase_class" class="collection-item"></li>
<li id="ship_displayCase_hullType" class="collection-item"></li>
<li id="ship_displayCase_id" class="collection-item"></li>
<li id="ship_displayCase_clickMiscInfo" class="collection-item"
style="background-color: whitesmoke; cursor: pointer;" onclick="$('#miscInfoModal').modal('open');">
<small>Click for misc. info</small>
</li>
</ul>
<!-- ship stats -->
<div class="card">
<div class="card-tabs">
<ul class="tabs tabs-fixed-width" id="ship_displayCase_tabs">
<li class="tab"><a onclick="changeStats('Kai');">Lv. 100 Retrofit</a></li>
<li class="tab"><a id='100tabs' onclick="changeStats('Max');" class="active">Lv. 100</a></li>
<li class="tab"><a onclick="changeStats('Kai120');">Lv. 120 Retrofit</a></li>
<li class="tab"><a onclick="changeStats('120');">Lv. 120</a></li>
<li class="tab"><a onclick="changeStats('Initial');">Base</a></li>
</ul>
</div>
<div class="card-content">
<ul class="collection">
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/8/8b/Duration.png/25px-Duration.png"
class="circle">
<span class="title">Health</span>
<p id="ship_displayCase_health"></p>
</li>
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/0/06/Armor.png/25px-Armor.png"
class="circle">
<span class="title">Armor Type</span>
<p id="ship_displayCase_armorType"></p>
</li>
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/e/e3/Refill.png/25px-Refill.png"
class="circle">
<span class="title">Reload</span>
<p id="ship_displayCase_reload"></p>
</li>
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/d/d5/Firepower.png/25px-Firepower.png"
class="circle">
<span class="title">Firepower</span>
<p id="ship_displayCase_fire"></p>
</li>
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/4/40/Torpedo.png/25px-Torpedo.png"
class="circle">
<span class="title">Torpedo</span>
<p id="ship_displayCase_torp"></p>
</li>
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/d/d2/Evasion.png/25px-Evasion.png"
class="circle">
<span class="title">Evasion</span>
<p id="ship_displayCase_evade"></p>
</li>
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/0/0f/AntiAir.png/25px-AntiAir.png"
class="circle">
<span class="title">Anti-Air</span>
<p id="ship_displayCase_aa"></p>
</li>
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/6/6a/Aviation.png/25px-Aviation.png"
class="circle">
<span class="title">Air Power</span>
<p id="ship_displayCase_air"></p>
</li>
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/9/90/Consumption.png/25px-Consumption.png"
class="circle">
<span class="title">Oil consumption</span>
<p id="ship_displayCase_consumption"></p>
</li>
<li class="collection-item avatar">
<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/1/16/ASW.png/25px-ASW.png" class="circle">
<span class="title">Anti-submarine warfare</span>
<p id="ship_displayCase_asw"></p>
</li>
</ul>
<ul class='collection'>
<li class='collection-item' id='ship_displayCase_speed'></li>
<li class='collection-item' id='ship_displayCase_reinforce'></li>
<li class='collection-item' id='ship_displayCase_scrapIncome'></li>
</ul>
</div>
</div>
<!--
<div class="row">
<div class="col s6">
<div class="card">
<div class="card-content">
<h6>Limit Break Ranks</h6>
</div>
</div>
</div>
<div class="col s6">
<div class="card">
<div class="card-content">
<h6>Abilities</h6>
</div>
</div>
</div>
</div>
-->
<!-- equipment, collection and voice lines collapsible -->
<ul class="collapsible">
<li>
<div class="collapsible-header"><i class="fas fa-wrench"></i> Equipment</div>
<div class="collapsible-body" id="ship_displayCase_equipmentPanel"></div>
</li>
<li>
<div class="collapsible-header"><i class="fas fa-cogs"></i> Construction</div>
<div class="collapsible-body">
<div class="row" style="text-align: center;">
<div class="col m5ths s6" id="ship_displayCase_lightCraftable"></div>
<div class="col m5ths s6" id="ship_displayCase_heavyCraftable"></div>
<div class="col m5ths s6" id="ship_displayCase_aviationCraftable"></div>
<div class="col m5ths s6" id="ship_displayCase_limitedCraftable"></div>
<div class="col m5ths s6" id="ship_displayCase_exchangeCraftable"></div>
</div>
<ul class="collection" id="ship_displayCase_dropLocations"></ul>
</div>
</li>
<li>
<div class="collapsible-header"><i class="far fa-comment"></i> Voice Lines</div>
<div class="collapsible-body"><i>Coming soon...</i> <!-- WIP --></div>
</li>
</ul>
<!-- retrofit component -->
<div id="ship_displayCase_retrofit" style="display: none;">
<button class="waves-effect waves-light btn-large white"
onclick="window.open('https://azurlane.koumakan.jp/' + document.title.replace(/ /g, '_') + '#Retrofit', '_blank');"
style="color: black; width: 100%;">Click for Retrofit data
</button>
<br><br>
</div>
</div>
</div>
<!-- modals -->
<div id="skinModal" class="modal">
<div class="modal-content">
<h4>Select a skin: </h4>
<ul class="collection" id="skinModal_list"></ul>
</div>
</div>
<div id="miscInfoModal" class="modal">
<div class="modal-content">
<h4>Misc. Info</h4>
<ul class="collection">
<li id="miscInfoModal_artist" class="collection-item"></li>
<li id="miscInfoModal_voiceActress" class="collection-item"></li>
</ul>
<button class="waves-effect waves-blue btn-flat"
onclick="window.open('https://azurlane.koumakan.jp/' + document.title.replace(/ /g, '_'), '_blank');">
Open in Wiki
</button>
</div>
</div>
<!-- !modals -->
<script>
// Click on name about 20 times and you will get the entire data blob (dev only).
var devClicks = 0;
function checkClick() {
if (devClicks === 20) {
$("#ship_displayCase_rawData").text(JSON.stringify(ship_db[document.title]));
devClicks = 0;
}
else {
devClicks++;
}
}
/**
* Gets the key corresponding to the value in object.
* Original solution found here: https://stackoverflow.com/a/28191966
*/
function getKeyByValue(object, value) {
return Object.keys(object).find(key => object[key] === value);
}
// Set random loading character and 'slogan'.
var loadingRandoms = {
"https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/8/86/LaffeyChibi.png": "Commander... wait here (yawn)...",
"https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/f/fb/SaratogaChibi.png": "Commander, please wait a moment~",
"https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/0/08/AyanamiChibi.png": "Please wait a second, commander...",
"https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/8/84/BelfastChibi.png": "Pardon me, Commander, but you will have to wait a second. In the meantime, would you like some tea?",
"https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/7/70/AkashiChibi.png": "Commander, wait here while I examine the site meow...",
"https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/e/e7/UnicornChibi.png": "Big brother... Unicorn will stay with you while you wait...",
"https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/2/2c/Ning_HaiChibi.png": "I wonder if the fleet's expenses can be covered by this site...",
"https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/f/f5/AjaxChibi.png": "My precious little piggy, let me step on your face~"
};
// This is a slightly modified version of the solution found here: https://stackoverflow.com/a/15106541
var randomKey = function (loadingRandoms) {
var keys = Object.keys(loadingRandoms);
return keys[keys.length * Math.random() << 0];
};
randomKey = randomKey(loadingRandoms);
$("#loading_pleaseWait_char").attr("src", randomKey);
var phrase = $("#loading_pleaseWait_phrase");
phrase.html(phrase.html() + loadingRandoms[randomKey]);
// An object containing ALL ship data. This is a large variable.
var ship_db = {};
// An object containing ALL resource data. This is a fairly large variable.
var resource_db = {};
var searchTextCache = '';
/**
* Gets the index of the nth occurance of a substring in a string.
* This solution was deprived from StackOverflow, original answer found here:
* https://stackoverflow.com/a/14482123
* */
function nthIndex(str, pat, n) {
var L = str.length, i = -1;
while (n-- && i++ < L) {
i = str.indexOf(pat, i);
if (i < 0) break;
}
return i;
}
function showMainMenu() {
// If the client is a mobile browser, display list instead of rows as render is broken.
if (/Mobi|Android/i.test(navigator.userAgent)) {
var ul = $('<ul class="collection"></ul>');
var shipNames = Object.keys(ship_db);
shipNames.forEach(function (item) {
var liAvatar = $('<li class="collection-item avatar" onclick="renderShipDisplayCase(\'' + item + '\');"></li>');
liAvatar.html(
'<img src="https://images.weserv.nl/?url=' + resource_db[item.replace(/ /g, "_") + 'Icon.png'] + '" class="circle" alt="profile">' +
'<span class="title">' + item + '</span>'
);
ul.append(liAvatar);
});
$('#mainMenuDisplay').append(ul);
}
else {
// create a row.
var row = $('<div class="row"></div>');
var shipNames = Object.keys(ship_db);
shipNames.forEach(function (item) {
var col = $('<div class="col s4"></div>');
col.html(
'<div class="card horizontal" style="cursor: pointer;" onclick="renderShipDisplayCase(\'' + item + '\');">' +
'<div class="card-image"><img src="https://images.weserv.nl/?url=' + resource_db[item.replace(/ /g, "_") + 'Icon.png'] + '"></div>' +
'<div class="card-stacked"><div class="card-content"><h6>' + item + '</h6></div></div></div>'
);
row.append(col);
if (row.children().length === 3) {
$('#mainMenuDisplay').append(row);
row = $('<div class="row"></div>');
}
});
}
$('#mainMenuDisplay').show();
}
/**
* Displays the skins for the current ship in a modal.
*/
function displaySkinModal() {
// Remove previous results (visual).
var node = document.getElementById('skinModal_list');
while (node.firstChild) {
node.removeChild(node.firstChild);
}
// Search and list all skins.
var shipName = document.title.replace(/ /g, "_");
for (var fileName in resource_db) {
if (fileName.indexOf(shipName) !== -1) {
var extension = fileName.split('.').pop(); // gets the file extension.
if (extension === 'png') {
var filter = false; // If picture matches filter, we can add to skin list.
var skinName = fileName.replace('.png', ' ');
skinName = skinName.replace(document.title.replace(/ /g, "_"), '');
if (skinName.trim().length > 0) {
var sufKey = getKeyByValue(ship_db[document.title]['detailedItems'], skinName.trim());
if (sufKey && (sufKey.indexOf('Suffix') !== -1)) {
skinName = ship_db[document.title]['detailedItems'][sufKey.replace('Suffix', 'Name')];
filter = true;
}
else {
if ((skinName.indexOf('Kai') !== -1) && (skinName.replace('Kai', '').replace(document.title.replace(/ /g, "_"), '').trim().length === 0)) {
skinName = "Retrofit";
filter = true;
}
}
}
else {
skinName = fileName.replace('.png', ' ');
if (skinName.trim() === document.title.replace(/ /g, "_")) {
skinName = "Default";
filter = true;
}
}
if (filter) {
var parent = document.getElementById('skinModal_list');
var child = document.createElement('LI');
child.className = 'collection-item';
child.innerHTML = '<a onclick="forceSkin(\'' + fileName + '\');" style="color: black; text-decoration: none; cursor: pointer;">' + skinName + '</a>';
parent.appendChild(child);
}
}
}
}
// Display modal after all the work is done.
var sm = $('#skinModal');
sm.modal('open');
}
/**
* Force loads a skin into the viewer given a file key.
*/
function forceSkin(fileKey) {
var sp = $("#ship_displayCase_skinpicture");
sp.hide();
sp.ready(function () {
$("#ship_displayCase_skinpicture").show();
});
sp.attr("src", "https://images.weserv.nl/?url=" + resource_db[fileKey]);
// Since this method is only used for skin loading, close skin modal once processing.
$('#skinModal').modal('close');
}
/**
* Renders the ship display case with the given ship.
*/
function renderShipDisplayCase(shipName) {
document.title = shipName;
changeStats('Max');
var shipChunk = ship_db[shipName];
var nationality = shipChunk["detailedItems"]["Nationality"];//detailedItems is more accurate to read from
var nationalityColorTypes = {
"Sakura Empire": "pink",
"Eagle Union": "dodgerblue",
"Royal Navy": "#6EC8F5",
"Ironblood": "lightcoral",
"Eastern Radiance": "hotpink",
"North Union": "lightgray",
"Iris Libre": "gold",
"Vichya Dominion": "italianred",
"Bilibili": "#495FFF",
"Universal": "#845bc1"
};
var nationalityAbbrev = {
"Sakura Empire": "IJN",
"Eagle Union": "USS",
"Royal Navy": "HMS",
"Ironblood": "KMS",
"Eastern Radiance": "ROC",
"North Union": "SN",
"Iris Libre": "FFNF",
"Vichya Dominion": "MNF",
"Bilibili": "",
"Universal": "UNIV"
};
// General display and name.
$("#search").val("");
$("#ship_displayCase").show();
$("#ship_displayCase_name").html("<small style='color: " + nationalityColorTypes[nationality] + "; font-weight: bold;'>[" + nationalityAbbrev[nationality] + "]</small> " + shipName + " <small><small><small>(CN: " + shipChunk["detailedItems"]["CNName"] + "; JP: " + shipChunk["detailedItems"]["JPName"] + ")</small></small></small>");
// Skin image
var sp = $("#ship_displayCase_skinpicture");
sp.hide();
sp.ready(function () {
$("#ship_displayCase_skinpicture").show();
});
sp.attr("src", "https://images.weserv.nl/?url=" + resource_db[shipName.replace(/ /g, "_") + ".png"]);
// Ship general attributes and misc info.
var rarity = shipChunk["detailedItems"]["Rarity"];
var constructionTime = shipChunk["detailedItems"]["ConstructTime"];
var clas = shipChunk["detailedItems"]["Class"];
var hullType = shipChunk["detailedItems"]["Type"];
var id = shipChunk["detailedItems"]["ID"];
var rarityColorTypes = {
"Normal": "lightgray",
"Rare": "lightblue",
"Elite": "#B19CD9",
"Super Rare": "#FFE974"
};
var n = $("#ship_displayCase_nationality");
n.css("background-color", nationalityColorTypes[nationality]);
n.html("<small>Nationality</small> " + nationality);
var r = $("#ship_displayCase_rarity");
if (rarity === "Ultra Rare") {
// Ultra Rare gradient (very close to wiki gradient).
r.css({
'background-image': 'linear-gradient(to right, #FFB2B2, #F5D4BC, #FFF4A5, #C9FD94, #AEDDFF, #CAAEFF)',
'background-color': ''
});
}
else {
r.css({
"background-color": rarityColorTypes[rarity],
'background-image': ''
});
}
r.html("<small>Rarity</small> " + rarity);
$("#ship_displayCase_constructionTime").html("<small>Construction Time</small> " + constructionTime);
$("#ship_displayCase_class").html("<small>Class</small> " + clas);
$("#ship_displayCase_hullType").html("<small>Hull Type</small> " + hullType);
$("#ship_displayCase_id").html("<small>ID</small> " + id);
// Ship misc info modal.
$('#miscInfoModal_artist').html("<small>Artist</small> <a target='_blank' href='" + shipChunk['detailedItems']['ArtistLink'].replace('[', '').replace(']', '').replace(shipChunk['detailedItems']['Artist'], '') +
"'>" + shipChunk['detailedItems']['Artist'] + "</a>");
if (('VA' in shipChunk['detailedItems'])) {
var VAchunk = shipChunk['detailedItems']['VA']; // have to process this before putting into HTML.
VAchunk = VAchunk.replace('[', '').replace(']', '').replace('https://en.wikipedia.org/wiki/', '');
VAchunk = VAchunk.substring(0, VAchunk.indexOf(' '));
VAchunk = decodeURIComponent(VAchunk);
var VAlink = 'https://en.wikipedia.org/wiki/' + encodeURIComponent(VAchunk);
$('#miscInfoModal_voiceActress').html("<small>Voice Actress</small> <a target='_blank' href='" + VAlink + "'>" + VAchunk.replace('_', ' ') + "</a>");
}
// Ship reinforcement and scrap income
var fphtml = '<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/d/d5/Firepower.png/25px-Firepower.png">';
var torphtml = '<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/4/40/Torpedo.png/25px-Torpedo.png">';
var aviahtml = '<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/6/6a/Aviation.png/25px-Aviation.png">';
var reloadhtml = '<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/e/e3/Refill.png/25px-Refill.png">';
var coinhtml = '<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/c/c4/Coinicon.png/25px-Coinicon.png">';
var oilhtml = '<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/f/f2/Oilicon.png/25px-Oilicon.png">';
var medalhtml = '<img src="https://images.weserv.nl/?url=https://azurlane.koumakan.jp/w/images/thumb/3/33/Medalicon.png/20px-Medalicon.png">';
if (('ScrapIncome' in shipChunk['detailedItems'])) {
var sr = shipChunk['detailedItems']['ScrapIncome'];
if (sr.replace('{{coin}}', '').replace('{{oil}}', '').replace('{{Medal}}', '').trim().length < 1) {
$('#ship_displayCase_scrapIncome').html("<small>Scrap Income</small> Unavailable");
}
else {
var scrapValues = shipChunk['detailedItems']['ScrapIncome']
.replace('{{coin}}', '')
.replace('{{oil}}', '')
.replace('{{Medal}}', '')
.split(' ');
$('#ship_displayCase_scrapIncome').html('<small>Scrap Income</small> ' + scrapValues[0] + ' ' + coinhtml + ', ' + scrapValues[1] + ' ' + oilhtml + ', ' + scrapValues[2] + ' ' + medalhtml);
}
}
else {
$('#ship_displayCase_scrapIncome').html("<small>Scrap Income</small> Unavailable");
}
if (('ReinforcementValue' in shipChunk['detailedItems'])) {
var rr = shipChunk['detailedItems']['ReinforcementValue'];
if (rr.replace('{{Firepower}}', '').replace('{{Torpedo}}', '').replace('{{Aviation}}', '').replace('{{RoF}}', '').trim().length < 2) {
$('#ship_displayCase_reinforce').html("<small>Reinforcement Value</small> Unavailable");
}
else {
var reinforcementValues = [];
reinforcementValues[0] = rr.substring(0, rr.indexOf('{{Firepower}}')).trim();
rr = rr.substring(rr.indexOf('{{Firepower}}') + 13);
reinforcementValues[1] = rr.substring(0, rr.indexOf('{{Torpedo}}')).trim();
rr = rr.substring(rr.indexOf('{{Torpedo}}') + 11);
reinforcementValues[2] = rr.substring(0, rr.indexOf('{{Aviation}}')).trim();
rr = rr.substring(rr.indexOf('{{Aviation}}') + 12);
reinforcementValues[3] = rr.substring(0, rr.indexOf('{{RoF}}')).trim();
$('#ship_displayCase_reinforce').html('<small>Reinforcement Value</small> ' + reinforcementValues[0] + ' ' + fphtml + ', ' + reinforcementValues[1] + ' ' + torphtml + ', ' + reinforcementValues[2] + ' ' + aviahtml + ', ' + reinforcementValues[3] + ' ' + reloadhtml);
}
}
else {
$('#ship_displayCase_reinforce').html("<small>Reinforcement Value</small> Unavailable");
}
// Ship equipment.
var ep = $('#ship_displayCase_equipmentPanel');
ep.empty();
ep.html("<div class=\"row\"><div class=\"col s4\"><b>Slot</b></div><div class=\"col s4\"><b>Efficiency</b></div><div class=\"col s4\"><b>Equippable</b></div></div>");
var ableToRender = [];
for (var i = 1; i <= 5; i++) {
if (('Eq' + i + 'EffInit' in shipChunk['detailedItems']) && ('Eq' + i + 'EffInitMax' in shipChunk['detailedItems'])) {
// Both EffInit and EffMax keys exist, check if they are full and add to render array if full.
if ((shipChunk['detailedItems']['Eq' + i + 'EffInit'].length > 0) && (shipChunk['detailedItems']['Eq' + i + 'EffInitMax'].length > 0)) {
ableToRender.push('Eq' + i);
}
}
}
ableToRender.forEach(function (item, index) {
var row = $('<div></div>');
row.addClass('row');
// Create the three col items.
var slotNum = $('<div></div>');
slotNum.addClass('col s4');
slotNum.html(index);
var efficiencyVal = $('<div></div>');
efficiencyVal.addClass('col s4');
efficiencyVal.html(shipChunk['detailedItems'][item + 'EffInit'] + '/' + shipChunk['detailedItems'][item + 'EffInitMax']);
if ((item + 'EffInitKai' in shipChunk['detailedItems']) && (shipChunk['detailedItems'][item + 'EffInitKai'].length > 0)) {
efficiencyVal.html(efficiencyVal.html() + '/' + shipChunk['detailedItems'][item + 'EffInitKai']);
}
var equipType = $('<div></div>');
equipType.addClass('col s4');
equipType.html(shipChunk['detailedItems'][item + 'Type']);
// Append the three to row, and then append row to panel. Redo for possible of 5 times per ship.
row.append(slotNum, efficiencyVal, equipType);
ep.append(row);
});
// Ship construction
var constructTypes = ["Light", "Heavy", "Aviation", "Limited", "Exchange"];
constructTypes.forEach(function (item, index) {
var test = false;
if (('D' + item in shipChunk['detailedItems'])) {
if (shipChunk['detailedItems']['D' + item] === '1') {
test = true;
}
}
var target = $('#ship_displayCase_' + item.toLowerCase() + 'Craftable');
var note = "";
var attr = "";
if (('D' + item + 'Note' in shipChunk['detailedItems'])) {
note += shipChunk['detailedItems']['D' + item + 'Note'];
}
if (note.length > 0) {
attr += 'class="tooltipped" data-position="top" data-tooltip="' + note + '"';
}
if (test) {
target.empty();
target.append('<b ' + attr + '>' + item + '</b>' + '<br><i class="fas fa-check"></i>');
}
else {
target.empty();
target.append('<b ' + attr + '>' + item + '</b>' + '<br><i class="fas fa-times"></i>');
}
});
var locs = Object.keys(shipChunk['detailedItems']);
var rlocs = [];
locs.forEach(function (item) {
if (item.charAt(0) === 'D') rlocs.push(item);
});
locs = [];
rlocs.forEach(function (item) {
if (!isNaN(item.charAt(1))) {
// D[somenumber] so should be a map entry.
locs.push(item);
}
});
var chapters = {};
locs.forEach(function (item) {
var chopD = item.replace('D', '');
var split = chopD.split('-');
if (!(split[0] in chapters)) {
chapters[split[0]] = [];
}
chapters[split[0]].push(split[1]);
});
var chapterArray = Object.keys(chapters);
var col = $('#ship_displayCase_dropLocations');
col.empty();
chapterArray.forEach(function (item, index) {
var li = $('<li></li>');
li.addClass('collection-item');
li.html('Chapter ' + item + ': ');
chapters[item].forEach(function (map, index) {
// Go through each chapter and see if there is a note for the map. Add as tooltip.
var elementMeta = '';
if (('D' + item + '-' + map in shipChunk['detailedItems']) && (shipChunk['detailedItems']['D' + item + '-' + map] !== '1')) {
elementMeta += ' class="tooltipped" data-position="top" data-tooltip="' + shipChunk['detailedItems']['D' + item + '-' + map] + '">';
}
var span = $('<span' + elementMeta + '</span>');
map = map.replace('note', '');
if ((index + 1) === chapters[item].length) {
span.html(map);
}
else {
span.html(map + ', ');
}
li.html(li.html() + span.prop('outerHTML'));
});
col.append(li);
});
// Ship retrofit (button hide).
if (shipChunk['detailedItems']['Remodel'] === '1') {
$("#ship_displayCase_retrofit").show();
}
else {
$("#ship_displayCase_retrofit").hide();
}
// Dynamically add tooltip call for Materialize.
$('.tooltipped').tooltip();
// Force user to go to the top of page.
window.scrollTo(0, 0);
// Tabs fix (the tab selector is broken)
var tabParent = $('#ship_displayCase_tabs');
tabParent.tabs('select', '100tabs');
tabParent.tabs('updateTabIndicator');
}
/**
* Changes the stats shown in the 'display case' for the ship.
* type is a proper identifier such as 'Initial' or 'Kai120'.
*/
function changeStats(type) {
var needChunk = ship_db[document.title]['detailedItems'];
// Display the speed value dependent only on kai or normal.
var speed = needChunk['Speed'];
if (type.indexOf('Kai') !== -1) {
// retrofitted ship speed if existant.
if (type === 'Kai120') {
if ('SpeedKai120' in needChunk) {
speed = needChunk['SpeedKai120'];
}
else if ('SpeedKai' in needChunk) {
speed = needChunk['SpeedKai'];
}
}
else {
if ('SpeedKai' in needChunk) {
speed = needChunk['SpeedKai'];
}
}
}
$('#ship_displayCase_speed').html('<small>Speed</small> ' + speed);
var gradeSuffix = 'Grade' + type;
if ((type === 'Initial') || (type === 'Max') || (type === '120')) gradeSuffix = 'Grade';
$('#ship_displayCase_armorType').text(needChunk['Armor']); // armor should be constant on all ships...
var statItems = ['Torp', 'Fire', 'AA', 'Reload', 'Consumption', 'Air', 'Health', 'Evade', 'ASW'];
statItems.forEach(function (item) {
var gradeFilter = '(' + needChunk[item + gradeSuffix] + ')';
// key exceptions (key item prefix is different than the others)
if (item === 'Torp') {
gradeFilter = '(' + needChunk[item + 'edo' + gradeSuffix] + ')';
}
else if (item === 'Air') {
gradeFilter = '(' + needChunk['Aviation' + gradeSuffix] + ')';
}
else if (item === 'Evade') {
gradeFilter = '(' + needChunk['Evasion' + gradeSuffix] + ')';
}
// exception cases
if (
(item === 'Reload') ||
(item === 'ASW') ||
(item === 'Consumption')
) {
gradeFilter = '';
}
if (gradeFilter.length < 3) {
gradeFilter = '';
}
$('#ship_displayCase_' + item.toLowerCase()).text(needChunk[item + type] + ' ' + gradeFilter);
});
}
/**
* Parses the list of ships given the wikimedia HTML parse data for https://azurlane.koumakan.jp/List_of_Ships.
* This is hard-coded, and therefore is subject to breaking. Will attempt to update as often as possible.
* Developed by @HotFireyDeath (Chen Zheng)
* https://czheng.me
*/
function parseListOfShips(data) {
var ships = {};
// Parse ship's 'top layer' data using List of Ships Azur Wiki result.
for (var i = 0; i < data.length; i++) {
if ((i + 1) < data.length) { // Check for out of bounds.
if (
data[i].includes("td data-sort-value=") &&
data[i + 1].includes("a href=\"") &&
(isNaN(data[i + 1].substring(data[i + 1].indexOf(">") + 1)) || (parseInt(data[i + 1].substring(data[i + 1].indexOf(">") + 1)) < 3000))
) {
var shipName = (data[i + 1].substring(9, nthIndex(data[i + 1], "\"", 2))).replace(/_/g, " ").replace('%C3%B6', 'ö');
ships[shipName] = {
pageLink: "/" + shipName.replace(/ /g, "_"), // Ship Wikimedia page
id: data[i + 1].substring(data[i + 1].indexOf(">") + 1), // Ship ID
category: data[i + 11].substring(data[i + 11].indexOf(">") + 1),
rarity: data[i + 8].substring(data[i + 8].indexOf(">") + 1),
affiliation: data[i + 15].substring(data[i + 15].indexOf(">") + 1),
firepower_rating: data[i + 18].substring(data[i + 18].indexOf(">") + 1),
health_rating: data[i + 20].substring(data[i + 20].indexOf(">") + 1),
anti_air_rating: data[i + 22].substring(data[i + 22].indexOf(">") + 1),
evasion_rating: data[i + 24].substring(data[i + 24].indexOf(">") + 1),
air_power_rating: data[i + 26].substring(data[i + 26].indexOf(">") + 1),
torpedo_rating: data[i + 28].substring(data[i + 28].indexOf(">") + 1)
}
}
}
}
localStorage.setItem('fullDataAmount', "0");
localStorage.setItem('dataFetched', "0");
// Deep search for each ship, grab available stats.
var shipNames = Object.keys(ships);
shipNames.forEach(function (name) {
//var name = "Universal Bullin";
var shipNameTag = ships[name]["pageLink"].substring(1).replace('%C3%B6', 'ö');
localStorage.setItem('fullDataAmount', (parseInt(localStorage.getItem('fullDataAmount')) + 1) + "");
$.ajax({
url: "https://azurlane.koumakan.jp/w/api.php",
method: "GET",
dataType: "jsonp",
data: {
action: "parse",
page: shipNameTag,
prop: "wikitext",
format: "json"
},
success: function (data) {
localStorage.setItem('dataFetched', (parseInt(localStorage.getItem('dataFetched')) + 1) + "");
var raw = data["parse"]["wikitext"]["*"];
raw = raw.split("|");
// Reverse search ships by matching ID.
var currentShipID = raw[1].split("=")[1].trim();
var currentShipAffiliation = raw[5].split("=")[1].trim();
// This is a quick workaround for the app in order to fix loading issue with the new characters.
// Essentially hard-coded solution to new wiki data format (order of data is swapped).
if (["Normal", "Rare", "Elite", "Super Rare", "Ultra Rare"].indexOf(currentShipAffiliation) !== -1) {
currentShipAffiliation = raw[6].split("=")[1].trim();
}
for (var s in ships) {
if ((ships[s]["id"] === currentShipID) && (ships[s]["affiliation"] === currentShipAffiliation)) {
ships[s]["detailedItems"] = {};
raw.forEach(function (item) {
var twig = item.split("=");
if (twig.length === 2) {
// Remove format whitespacing.
twig[0] = twig[0].trim();
twig[1] = twig[1].trim();
ships[s]["detailedItems"][twig[0]] = twig[1];
}
});
}
}
}
});
// Separate ajax calls for images.
localStorage.setItem('fullDataAmount', (parseInt(localStorage.getItem('fullDataAmount')) + 1) + "");
$.ajax({
url: "https://azurlane.koumakan.jp/w/api.php",
method: "GET",
dataType: "jsonp",
data: {
action: "query",
list: "allimages",
ailimit: 300,
aifrom: shipNameTag,
aiprop: "url",
format: "json"
},
success: function (data2) {
localStorage.setItem('dataFetched', (parseInt(localStorage.getItem('dataFetched')) + 1) + "");
var allImages = data2["query"]["allimages"];
allImages.forEach(function (item) {
resource_db[item["name"]] = item["url"];
});
}
});
});
// Essentially, waits until the ajaxes (above) are done, and then saves the data.
var interval = window.setInterval(function () {
$("#loading_pleaseWait_percentage").text(Math.round((parseInt(localStorage.getItem('dataFetched')) / parseFloat(localStorage.getItem('fullDataAmount'))) * 100) + "% done");
if (localStorage.getItem('dataFetched') === localStorage.getItem('fullDataAmount')) {
localStorage.removeItem('dataFetched');
localStorage.removeItem('fullDataAmount');
// All data received, now parse and render.
document.title = "AzurViewer";
$("#loading_pleaseWait").hide();
$("#omnisearch").show();
ship_db = ships;
// Attempt to cache data locally (reduces load times after initial loading)
localforage.setItem('az_ship', JSON.stringify(ship_db), function (error) {
if (error !== null) {
alert("Error while attempting to cache ship data.");
}
});
localforage.setItem('az_resource', JSON.stringify(resource_db), function (error) {
if (error !== null) {
alert("Error while attempting to cache resource data.");
}
});
showMainMenu();
clearInterval(interval);
}
else if ((document.readyState === "complete") && (localStorage.getItem('dataFetched') !== localStorage.getItem('fullDataAmount'))) {