-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchampion-detail.html
More file actions
560 lines (462 loc) · 24.2 KB
/
champion-detail.html
File metadata and controls
560 lines (462 loc) · 24.2 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>League of Legends </title>
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/styles.css" rel="stylesheet">
<!-- Import font -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noticia+Text:ital,wght@0,400;0,700;1,400;1,700&display=swap"
rel="stylesheet">
<!-- Import Swiper -->
<link rel="stylesheet" href="assets/css/swiper-bundle.min.css" />
<script src="assets/js/swiper-bundle.min.js"></script>
<script src="assets/js/jquery-3.6.0.min.js"></script>
</head>
<body>
<style>
.owl-carousel .item {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
}
.owl-carousel .item img {
max-width: 100%;
height: auto;
}
</style>
<!-- NAVBAR -->
<nav id="legends-nav" class="legends-nav navbar navbar-expand-lg bg-body-tertiary bg-legends">
<div class="container">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03"
aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="mobile-search search">
<div class="search-icon"><img src="assets/images/search.png" /></div>
<input type="search" class="form-control btn btn-primary text-uppercase rounded-pill mx-2" />
</div>
<a class="navbar-brand" href="index.html">
<img src="assets/images/logo.svg" alt="logo" />
</a>
<div class="collapse navbar-collapse justify-content-between row" id="navbarTogglerDemo03">
<ul class="navbar-nav col-12 col-md-5">
<li class="nav-item active d-flex">
<a class="nav-link " aria-current="page" href="game.html">Game</a>
</li>
<li class="nav-item d-flex">
<a class="nav-link" href="champion.html">Champion</a><span class="badge badge-pill badge-success">New</span>
</li>
<li class="nav-item d-flex">
<a class="nav-link" href="tft.html">Tactics</a><span class="badge badge-pill badge-success" style="margin: 0 0em 2em 7em;">New</span>
</li>
<li class="nav-item hide-desktop-flex" style="display:none;">
<a class="nav-link" href="news.html">News</a>
</li>
</ul>
<div class="logo col-2 text-center">
<a href="index.html"> <img src="assets/images/logo.svg" alt="logo"></a>
</div>
<div class="col-5 login d-flex justify-content-between align-items-center">
<li class="nav-item d-flex">
<a class="nav-link" href="news.html">News</a>
</li>
<div class="search d-flex align-items-center ">
<div class="search-icon"><img src="assets/images/search.png" /></div>
<input id="inputField" type="search"
class="form-control btn btn-primary text-uppercase rounded-pill mx-2" />
</div>
<button type="button" class="btn btn-primary text-uppercase">Đăng nhập</button>
</div>
</div>
</div>
</nav>
<!-- NAVBAR -->
<!-- Champion-detail -->
<!-- Champion-detail-ID -->
<section id="champion-background" class="normal-section">
<div class="container">
<div class="row position-absolute bottom-50 champion-name-banner-mb ">
<h2 id="champion-name-banner" class="col-12 primary-color py-4 "></h2>
</div>
<div class="row position-absolute bottom-0 translate-middle-x start-50 w-100 align-items-end">
<div class="col-12 col-md-12 text-center branding">
<!-- <img src="assets/images/champion-147.png" alt="hero-image" class="hero-image"> -->
</div>
</div>
</div>
</section>
<!-- Champion section -->
<section class="section-hero champion-detail-description ">
<div id="champion-overplay" class="overplay">
</div>
<div class="container champion-content p-4">
<div class="row my-4">
<div class="col-2">
<img id="champion-icon" class="rounded-circle" src="" alt="Champion Icon">
</div>
<div class="col-10 mx-0 row align-content-center">
<h3 id="champion-title" class="col-12"></h3>
<h2 id="champion-name" class="col-12 primary-color mt-2"></h2>
</div>
</div>
<div class="row">
<div class="col-12 col-sm-7">
<p id="champion-description" class="primary-color"></p>
</div>
<div class="col-1 vl"></div>
<div class="col-12 col-sm-4 mt-4 mt-sm-0">
<div class="row">
<div class="col-4">
<img src="assets/images/role-mage.png" alt="role">
</div>
<div class="col-8">
<h3 class="primary-color">Role</h3>
<h2 id="champion-tags" class="primary-color"></h2>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="skill-section">
<div class="container px-4">
<div class="row bottom-50 champion-name-banner-mb ">
<h2 class="col-12 primary-color py-4 ">Skill</h2>
</div>
<div class="row">
</div>
</div>
</section>
<section class="skin-section">
<div id="skin-overplay" class="overplay"></div>
<div class="container px-4">
<div class="row bottom-50 champion-name-banner-mb ">
<h2 class="col-12 primary-color py-4 ">Skin</h2>
</div>
<div class="row ">
<div class="swiper-container ">
<div class="swiper-wrapper">
<!-- Slides will be dynamically added here -->
</div>
<!-- Add Pagination -->
<div class="swiper-pagination mt-4"></div>
<!-- Add Navigation -->
<div class="swiper-button-next"></div>
<div class="swiper-button-prev "></div>
</div>
</div>
</div>
</section>
<!-- Equipment section -->
<section class="equipment-section">
<div class="container champion-content p-4">
<div class="row bottom-50 champion-name-banner-mb ">
<h2 class="col-12 primary-color py-4 ">Equipment</h2>
</div>
<div class="row">
<div id="equipment-list" class="row"> </div>
</div>
</div>
</section>
<!-- footer -->
<footer>
<div class="container">
<div class="row">
<div class="col-12 col">
<div class="footer-logo d-flex justify-content-center">
<img src="assets/images/riot.png" alt="logo" height="100px">
<img src="assets/images/vng.png" alt="logo" height="100px">
</div>
</div>
<div class="col-12 col-sm-7 m-auto text-center mt-5">
<p>2009-2022 by Riot Games Corporation. LEAGUE OF LEGENDS and related logos are trademarks, service
marks
and/or registered trademarks of Riot Games Corporation.</p>
</div>
</div>
</div>
</footer>
<!-- footer -->
<script>
// Ensure script runs after DOM has fully loaded
document.addEventListener('DOMContentLoaded', () => {
// Function to extract champion name from URL
function getNameFromUrl() {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get('n');
}
// Function to remove special characters and spaces from a string
function formatName(championName) {
return championName.replace(/[^a-zA-Z0-9]/g, '');
}
// Asynchronous function to fetch champion data by name
async function fetchChampionByName(championName) {
try {
// Fetch the champion data
const response = await fetch(`/assets/data/en_US/champion/${championName}.json`);
const data = await response.json();
const champions = Object.values(data.data); // Convert the champions object to an array
const champion = champions.find(champ => formatName(champ.name) === championName);
if (champion) {
const formattedName = formatName(champion.name);
// Access the DOM elements and set their content
document.getElementById('champion-name-banner').textContent = champion.name;
document.getElementById('champion-name').textContent = champion.name;
document.getElementById('champion-title').textContent = champion.title;
document.getElementById('champion-icon').src =
`/assets/data/en_US/champion/tiles/${formattedName}_0.jpg`;
document.getElementById('champion-description').textContent = champion.blurb;
document.getElementById('champion-tags').textContent = champion.tags.join(', ');
// Set background image of the champion-background section
const championBackground = document.getElementById('champion-background');
championBackground.style.background =
`url(/assets/data/en_US/champion/centered/${formattedName}_0.jpg`;
championBackground.style.backgroundSize = 'cover';
const championOverplay = document.getElementById('champion-overplay');
championOverplay.style.background =
`url(/assets/data/en_US/champion/splash/${formattedName}_1.jpg`;
// Display skills and passive
displaySkills(champion.passive, champion.spells);
// Display skins
// Initialize Swiper
const swiper = new Swiper('.swiper-container', {
loop: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
slidesPerView: 1,
breakpoints: {
600: {
slidesPerView: 3
},
// 1000: {
// slidesPerView: 5
// }
},
autoplay: {
delay: 2000,
},
on: {
init: function () {
updateSectionBackground();
},
slideChangeTransitionEnd: function () {
updateSectionBackground();
}
}
});
// Populate the Swiper with skins
displaySkins(champion.skins, champion.name);
// Display equipment
// Display equipment if blocks exist
displayEquipment(championName);
} else {
console.error('Champion not found');
}
} catch (error) {
console.error('Error fetching champion data:', error);
}
// Function to display skills in the HTML
function displaySkills(passive, spells) {
const skillSection = document.querySelector('.skill-section .container');
const skillRow = document.createElement('div');
skillRow.className = 'row';
// Create a div for each skill (Passive, Q, W, E, R)
const skillNames = ['Passive', 'Q', 'W', 'E', 'R'];
skillNames.forEach((skillName, index) => {
const skillDiv = document.createElement('div');
skillDiv.className = 'row skill py-4 align-items-center';
if (skillName === 'Passive') {
// Display passive details
// description left
const passiveDiv = document.createElement('div');
passiveDiv.className = 'col-3 col-sm-2 skill ';
const passiveImage = document.createElement('img');
passiveImage.src = `/assets/data/en_US/passive/${passive.image.full}`;
passiveImage.alt = passive.name;
passiveDiv.appendChild(passiveImage);
skillDiv.appendChild(passiveDiv);
// description right
const passiveDivDecription = document.createElement('div');
passiveDivDecription.className = 'col-9 col-sm-10 skill';
const skillHeader = document.createElement('h3');
skillHeader.innerHTML = skillName + ': <span class="text-white">' +
passive.name + '</span>';
const passiveDescription = document.createElement('p');
passiveDescription.textContent = passive.description;
passiveDivDecription.appendChild(skillHeader);
passiveDivDecription.appendChild(passiveDescription);
skillDiv.appendChild(passiveDivDecription);
skillRow.appendChild(skillDiv);
} else {
const skill = spells[index -
1]; // spells array starts from 0 index but we skip the passive
// Create the container for the skill details
const skillDiv = document.createElement('div');
skillDiv.className = 'row skill py-4 align-items-center';
// Create the left column for the image
const skillImageDiv = document.createElement('div');
skillImageDiv.className = 'col-3 col-sm-2 skill';
const skillImage = document.createElement('img');
skillImage.src = `/assets/data/en_US/spell/${skill.image.full}`;
skillImage.alt = skill.name;
skillImageDiv.appendChild(skillImage);
skillDiv.appendChild(skillImageDiv);
// Create the right column for the description and other details
const skillDetailsDiv = document.createElement('div');
skillDetailsDiv.className = 'col-9 col-sm-10 skill';
const skillHeader = document.createElement('h3');
skillHeader.innerHTML = skillName + ': <span class="text-white">' +
skill.name + '</span>';
const skillDescription = document.createElement('p');
skillDescription.textContent = skill.description;
const skillCooldown = document.createElement('p');
skillCooldown.textContent = `Cooldown: ${skill.cooldownBurn}`;
const skillCost = document.createElement('p');
skillCost.textContent = `Cost: ${skill.costBurn}`;
const skillTooltip = document.createElement('p');
skillTooltip.innerHTML = skill.tooltip;
// Append all details to the right column
skillDetailsDiv.appendChild(skillHeader);
skillDetailsDiv.appendChild(skillDescription);
skillDetailsDiv.appendChild(skillCooldown);
skillDetailsDiv.appendChild(skillCost);
skillDetailsDiv.appendChild(skillTooltip);
// Append the right column to the container
skillDiv.appendChild(skillDetailsDiv);
skillRow.appendChild(skillDiv);
}
});
skillSection.appendChild(skillRow);
}
}
// Update the background image of .section-map based on the active slide
function updateSectionBackground() {
var activeSkinImage = document.querySelector('.skin-slide.swiper-slide-active img');
var imageSrc = activeSkinImage ? activeSkinImage.src : null;
if (imageSrc) {
var sectionMap = document.getElementById('skin-overplay');
sectionMap.style.backgroundImage = 'url(' + imageSrc + ')';
} else {
console.error('imageSrc attribute not found on the active slide');
}
}
// Function to display skins in the Swiper
function displaySkins(skins, championName) {
const formattedName = formatName(championName);
// console.log(formattedName);
const swiperWrapper = document.querySelector('.swiper-wrapper');
skins.forEach(skin => {
const slide = document.createElement('div');
slide.className = 'swiper-slide skin-slide';
const skinImage = document.createElement('img');
skinImage.src =
`/assets/data/en_US/champion/splash/${formattedName}_${skin.num}.jpg`;
skinImage.alt = skin.name;
const skinName = document.createElement('h3');
skinName.textContent = skin.name;
slide.appendChild(skinImage);
slide.appendChild(skinName);
swiperWrapper.appendChild(slide);
});
}
// Function to fetch the champion data
async function fetchChampionFullByName(championName) {
console.log(1);
try {
const response = await fetch(`/assets/data/en_US/championFull.json`);
const data = await response.json();
const champion = data.data[championName];
if (champion) {
return champion;
} else {
console.error('Champion not found:', championName);
return null;
}
} catch (error) {
console.error('Error fetching champion data:', error);
return null;
}
}
// Function to display equipment
async function displayEquipment(championName) {
const equipmentList = document.getElementById('equipment-list');
equipmentList.innerHTML = ''; // Clear previous content
const champion = await fetchChampionFullByName(championName); // lấy dữ liệu full
console.log(championName);
console.log(champion);
if (!champion || !champion.recommended || champion.recommended.length === 0) {
console.error('Recommended equipment not found for champion:', champion ? champion
.name : 'Unknown');
return;
}
const recommended = champion.recommended.find(rec => rec.mode === 'CLASSIC' || rec.mode ===
'ARAM'); // Modify as needed
if (recommended) {
recommended.blocks.forEach(block => {
if (block.type !== 'consumables') {
const colBlock = document.createElement('div');
colBlock.className = 'col-3 col-sm-2';
const blockDiv = document.createElement('div');
blockDiv.className = 'equipment-block col-2 my-4';
const blockTitle = document.createElement('h3');
blockTitle.textContent = block.type.charAt(0).toUpperCase() + block.type
.slice(1);
blockTitle.className = 'mb-4';
blockDiv.appendChild(blockTitle);
block.items.forEach(item => {
const itemDiv = document.createElement('div');
itemDiv.className = 'item';
const itemImage = document.createElement('img');
itemImage.src = `/assets/data/en_US/item/${item.id}.png`;
itemImage.alt = `Item ${item.id}`;
itemDiv.appendChild(itemImage);
const itemCount = document.createElement('p');
itemCount.textContent = `x${item.count}`;
itemDiv.appendChild(itemCount);
blockDiv.appendChild(itemDiv);
colBlock.appendChild(blockDiv);
});
equipmentList.appendChild(colBlock);
}
});
} else {
console.error('Recommended equipment not found for champion:', champion.name);
}
}
// Extract the champion name from the URL and call fetchChampionByName function
const championName = getNameFromUrl();
console.log(championName);
if (championName) {
fetchChampionByName(championName);
} else {
console.error('No champion name found in URL');
}
});
</script>
<script>
$('#inputField').keypress(function (event) {
if (event.which === 13) { // Enter key pressed
var inputVal = $('#inputField').val();
window.location.href = `/search.html?s=${inputVal}`;
}
});
</script>
<script src="assets/js/main.js"></script>
<script src="assets/js/swiper.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> -->
<!-- Bootstrap JS and dependencies (Popper.js and jQuery) -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>