-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLOL.html
143 lines (122 loc) · 4.9 KB
/
LOL.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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>《英雄聯盟》官方網站</title>
<style>
header {
width: 100%;
height: 100vh;
background-image: url(https://exp.gg/wp-content/uploads/2018/10/20170902125347259.jpg);
background-position: bottom;
background-size: 100%;
}
.card p {
height: 200px;
overflow: auto;
}
.card:hover img {
transform: scale(1.2);
transition: 0.5s;
}
.card:hover {
overflow: hidden;
transform: scale(1.1);
transition: 0.5s;
}
</style>
</head>
<body>
<header></header>
<div class="row m-3"></div>
<!-- card template -->
<template id="card">
<div class="col-12 col-sm-6 col-md-3">
<div class="card my-3 bg-dark text-light">
<img src="..." class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title mt-3">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
content.</p>
<button type="button" class="btn btn-outline-warning" data-bs-toggle="modal" data-bs-target="#exampleModal">
詳細資訊
</button>
</div>
</div>
</div>
</template>
<!-- Button trigger modal -->
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content bg-dark text-light">
<div class="modal-body mt-4">
<img src="" alt="" class="w-100">
<h5 class="modal-title my-3" id="exampleModalLabel">Modal title</h5>
<p></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<!-- <button type="button" class="btn btn-primary">Save changes</button> -->
</div>
</div>
</div>
</div>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT"
crossorigin="anonymous"></script>
<script>
let url = "https://ddragon.leagueoflegends.com/cdn/10.22.1/data/zh_TW/champion.json";
window.onload = function () {
fetch(url)
.then(response => response.text())
.then(result => {
result = JSON.parse(result).data;
character_array = Object.values(result);
let row = $g(".row")
character_array.forEach(function (character) {
let tempCard = $g("template#card")
let cloneCard = tempCard.content.cloneNode(true);
let img = cloneCard.querySelector("img");
let h5 = cloneCard.querySelector("h5");
let p = cloneCard.querySelector("p");
let keyname = character.id;
img.setAttribute("src", `https://ddragon.leagueoflegends.com/cdn/img/champion/splash/${keyname}_0.jpg`);
h5.innerText = `${character.name} ${character.id}`;
p.innerText = `${character.blurb}`;
cloneCard.querySelector(".btn").addEventListener("click", function () {
// this.setAttribute("data-toggle", "modal");
// this.setAttribute("data-target", "#exampleModal");
let modal = $g("#exampleModal");
console.log(modal)
let h5M = modal.querySelector("h5");
h5M.innerText = `${character.name}`
let imgM = modal.querySelector("img");
imgM.setAttribute("src", `https://ddragon.leagueoflegends.com/cdn/img/champion/splash/${character.id}_0.jpg`)
let Mbody = modal.querySelector(".modal-body>p");
Mbody.innerHTML = `<p>HP: ${character["stats"].hp}</p>
<p>Move Speed: ${character["stats"].movespeed}</p>
<p>Armord: ${character["stats"].armor}
<p>Attack Range: ${character["stats"].attackrange}`;
});
row.appendChild(cloneCard);
});
console.log(character_array[0])
})
}
function $g(element) {
let found = document.querySelectorAll(element);
return found.length == 1 ? found[0] : found;
}
</script>
</body>
</html>