-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
206 lines (177 loc) · 6.17 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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Flesh and Blood 非公式 日本語カード訳</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
}
#searchBox {
margin-top: 10px;
width: 50%;
max-width: 600px;
height: 30px;
font-size: 16px;
padding: 10px;
border: none;
border-radius: 5px;
}
#results {
display: flex;
flex-direction: column;
align-items: center;
padding: 0 10px;
}
.card {
display: flex;
align-items: center;
background-color: white;
margin: 10px;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
max-width: 800px;
width: 100%;
}
.card img {
height: 190.5px;
width: 136.5px;
margin-right: 20px;
}
.card img:hover {
height: 381px;
width: 273px;
}
.card .text {
display: flex;
flex-direction: column;
align-items: flex-start;
width: 100%;
padding-right: 20px;
}
.card p {
margin: 0;
padding: 10px;
text-align: left;
white-space: pre-wrap;
}
.card .name {
font-size: 1.2em;
}
.card .functional,
.card .japanese {
font-size: 0.9em;
width: 100%;
}
.card .functional {}
.card .japanese {
font-size: 0.8em;
color: #383838;
background-color: #e8e8e8;
}
.card .report {
align-self: flex-end;
margin-top: 10px;
font-size: 0.8em;
}
.card .report a {}
.card .report a:hover {
text-decoration: underline;
}
@media only screen and (max-width: 600px) {
#searchBox,
#results {
width: 90%;
max-width: none;
}
}
.page_title {
font-size: large;
}
.page_description {
font-size: small;
color: darkslategrey;
text-align: center;
padding-top: 10px;
}
</style>
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MRHTTTLNL3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-MRHTTTLNL3');
</script>
<body>
<div style="text-align:center">
<div class="page_title"><strong>Flesh and Blood</strong> 非公式 日本語カード検索</div>
<input id="searchBox" type="text" placeholder="検索..." onkeyup="search()">
</div>
<div id="results">
<div class="page_description">
<p>Flesh and Bloodのカード名で検索できます。</p>
日本語テキストは基本的に自動翻訳されたものなので、正確じゃなかったり、テキストのスタイルが一定でない場合があります。
問題を見つけたら「誤訳を報告する」リンクから報告していただけるとありがたいです。
</div>
</div>
<script>
let cards;
// Fetch cards.json file
fetch('cards.json')
.then(response => response.json())
.then(data => cards = data)
.catch((error) => console.error('Error:', error));
// Function to get the preferred ID for the card image
function getPreferredId(ids) {
const preferences = ['WTR', 'ARC', 'CRU', 'MON', 'ELE', 'EVR', '1HP', 'UPR', 'DYN', 'OUT', 'DTD'];
for (let i = 0; i < preferences.length; i++) {
for (let j = 0; j < ids.length; j++) {
if (ids[j].includes(preferences[i])) {
return ids[j];
}
}
}
return ids[0]; // return the first id if no preference is found
}
// Function to format card text
function formatCardText(text) {
return text.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
}
// Search function
function search() {
let input = document.getElementById('searchBox').value;
input = input.toLowerCase();
let output = document.getElementById('results');
output.innerHTML = '';
let count = 0;
if (input == "") {
return;
}
for (let i = 0; i < cards.length; i++) {
if (count >= 10)
break;
if (cards[i].name.toLowerCase().includes(input)) {
count++;
let preferredId = getPreferredId(cards[i].ids);
let formattedFunctionalText = formatCardText(cards[i].functional_text);
let formattedJapaneseText = formatCardText(cards[i].japanese_text);
output.innerHTML += `
<div class="card">
<img src="https://json.fabrec.gg/cardmeta/cardfaces/${preferredId}.jpg" alt="${cards[i].name}" onerror="this.onerror=null; this.src='ph.png'">
<div class="text">
<p class="name">${cards[i].name}</p>
<p class="functional">${formattedFunctionalText}</p>
<p class="japanese"><strong>[自動翻訳]</strong> ${formattedJapaneseText}</p>
<div class="report"><a href="https://docs.google.com/forms/d/e/1FAIpQLSctIkGGVT10bxwqdYWGgHfwG42J6oTRda6dp1OvQCA2AmIbCA/viewform?usp=pp_url&entry.1010258363=${cards[i].name}">誤訳を報告する</a></div>
</div>
</div>`;
}
}
}
</script>
</body>
</html>