-
Notifications
You must be signed in to change notification settings - Fork 0
/
clans.html
280 lines (265 loc) · 14.3 KB
/
clans.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Clans</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" type="image/png" href="assets/kubu.png"/>
<!-- Custom built theme - This already includes Bootstrap 4 -->
<script src="js/utils.js"></script>
<script src="js/classes.js"></script>
<link rel="stylesheet" href="css/toggle-bootstrap.min.css">
<link rel="stylesheet" href="css/toggle-bootstrap-dark.min.css">
<link rel="stylesheet" href="css/toggle-bootstrap-print.min.css">
<link rel="stylesheet" href="https://maxst.icons8.com/vue-static/landings/line-awesome/line-awesome/1.3.0/css/line-awesome.min.css">
<link rel="stylesheet" href="css/style.css">
<style>
html, body {
height: 100%;
}
#clan-container {
padding-top:2rem !important;
}
#clan-name-container {
background-image: url(https://dummyimage.com/560x300/aaa/ffffff.jpg&text=No+Background);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border-radius: 15px;
backdrop-filter: blur(5px);
box-shadow: 0px 0px 50px 0px rgb(128 128 128 / 82%);
color: rgb(255, 255, 255);
text-shadow: 3px 3px 20px #000000,
-2px 1px 30px #4f4f4f;
}
#clan-bg {
border-radius: 10px;
opacity: 0.9;
}
.jumbotron {
padding:0.5rem !important;
background-color: #24292e !important;
box-shadow: 0px 0px 50px 0px #24292e;
}
</style>
</head>
<body class="bootstrap-dark">
<nav class="navbar navbar-expand-lg border-bottom navbar-themed" id="main-nav-bar">
<button class="navbar-toggler navbar-toggler-right" 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>
<a class="navbar-brand" href="index.html">JSNFM</a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav mr-auto mt-2 mt-md-0">
<li class="nav-item">
<a class="nav-link" href="index.html"><i class="las la-house-damage mr-1"></i>Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="top20.html"><i class="las la-chart-bar mr-1"></i>Top 20</a>
</li>
<li class="nav-item">
<a class="nav-link" href="editor.html"><i class="las la-cube mr-1"></i>Editor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="cars.html"><i class="las la-car mr-1"></i>Cars</a>
</li>
<li class="nav-item">
<a class="nav-link" href="stages.html"><i class="las la-map mr-1"></i>Stages</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="clans.html"><i class="las la-users mr-1"></i>Clans</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0 mr-3">
<div class="input-group">
<input type="text" class="form-control" placeholder="Clan name" id="clannamesearch">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="clanmembersearch-btn" onclick="search()"><i class="las la-search"></i></button>
</div>
</div>
</form>
<ul class="form-inline navbar-nav my-2 my-lg-0">
<li class="nav-item mx-2">
<a class="nav-link" href="javascript:document.getElementsByTagName('body')[0].setAttribute('class', 'bootstrap-dark');"><i class="las la-moon"></i></a>
</li>
<li class="nav-item mx-2">
<a class="nav-link" href="javascript:document.getElementsByTagName('body')[0].setAttribute('class', 'bootstrap');"><i class="las la-sun"></i></a>
</li>
</ul>
</div>
</nav>
<!-- clan -->
<div class="jumbotron jumbotron-fluid text-center" id="clan-container">
<div class="container" id="clan-name-container">
<h5 class="display-3"><img src="https://dummyimage.com/350x30/aaa/ffffff.png&text=No+Logo" alt="Clan Background" id="clan-bg"></h1>
<h1 class="display-4" id="clanname">No Name</h1>
<p class="lead pb-2"><i class="las la-user-friends mr-1"></i><span id="membercount" class="mr-3">0</span><i class="las la-car mr-1"></i><span id="carcount" class="mr-3">0</span><i class="las la-map mr-1"></i><span id="stagecount" class="mr-3">0</span></p>
</div>
</div>
<div class="jumbotron jumbotron-fluid text-center">
<div class="container-fluid">
<h1 class="display-4"><i class="las la-user-friends"></i></h1>
<p class="lead">
<div class="row justify-content-center" id="clanmembers-container">
<!-- members -->
</div>
</p>
</div>
</div>
<div class="jumbotron jumbotron-fluid text-center">
<div class="container-fluid">
<h1 class="display-4"><i class="las la-map"></i></h1>
<p class="lead">
<div class="row justify-content-center" id="clanstages-container">
<!-- stages -->
</div>
</p>
</div>
</div>
<div class="jumbotron jumbotron-fluid text-center">
<div class="container-fluid">
<h1 class="display-4"><i class="las la-car"></i></h1>
<p class="lead">
<div class="row justify-content-center" id="clancars-container">
<!-- cars -->
</div>
</p>
</div>
</div>
<!-- templates -->
<div class="col-lg-2 mt-2" id="clanmembertemplate">
<div class="card">
<h5 class="card-header">
<span id="membername">undefined</span><span class="badge badge-secondary ml-2" id="memberrank">0</span>
</h5>
<img src="https://dummyimage.com/120x30/aaa/ffffff.png&text=No+Logo" class="card-img-top" alt="..." id="memberlogo">
<div class="card-body" id="memberdescription">undefined</div>
</div>
</div>
<div class="col-lg-4 mt-2" id="clancartemplate">
<div class="card">
<h5 class="card-header">
<span id="name">undefined</span><span class="badge ml-2" id="publishtype">undefined</span>
</h5>
<canvas id="canvas" style="margin:auto;" width="350" height="250"></canvas>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<i class="las la-vector-square mr-2 text-secondary"></i><span id="polycount">0</span> polygons <i class="las la-code-branch ml-2 mr-2 text-secondary"></i><span id="vertcount">0</span> vertices<i class="las la-cube ml-2 mr-2 text-secondary"></i><span id="sizex">0</span> x <span id="sizey">0</span> x <span id="sizez">0</span>
</li>
<li class="list-group-item">
<i style="color: #000000;" id="color1-tint" class="las la-tint mr-2"></i><span id="color1-hex" class="mr-2">#000000</span><span id="color1-rgb" class="mr-2">c(0,0,0)</span><i style="color: #000000;" id="color2-tint" class="las la-tint mr-2"></i><span id="color2-hex" class="mr-2">#000000</span><span id="color2-rgb" class="mr-2">c(0,0,0)</span>
</li>
<li class="list-group-item">
<i class="las la-user-edit mr-2 text-secondary"></i><span id="publisher" class="mr-2">undefined</span><i class="las la-download mr-2 text-secondary"></i><span id="addedcount">0</span><i class="las la-user-friends ml-2 mr-2 text-secondary"></i><span id="addedbylist">-</span>
</li>
<button class="btn btn-primary" id="downloadbtn">
<i class="las la-download"></i>
</button>
</ul>
</div>
</div>
<div class="col-md-4 mt-2" id="clanstagetemplate">
<div class="card">
<h5 class="card-header">
<span id="stagename">undefined</span>
</h5>
</div>
</div>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/edit.js"></script>
<script src="js/fiddle3dV2.js"></script>
<script>
let cars = [];
function search(apiUrl = 'https://localhost:7041/api/') {
fetch(apiUrl+'clans/get/'+document.getElementById('clannamesearch').value).then(response => response.json()).then(data => {
console.log(data);
document.getElementById('clanname').innerHTML = data.name;
document.getElementById('membercount').innerHTML = data.members.length;
document.getElementById('carcount').innerHTML = data.cars.length;
document.getElementById('stagecount').innerHTML = data.stages.length;
document.getElementById('clan-bg').src = data.logo;
document.getElementById('clan-name-container').style.backgroundImage = `url(${data.background})`;
document.getElementById('clanmembers-container').innerText = '';
document.getElementById('clancars-container').innerText = '';
document.getElementById('clanstages-container').innerText = '';
let stagetemplate = document.getElementById('clanstagetemplate').cloneNode(true);
data.members.forEach(member => {
createMemberElem(member);
});
data.stages.forEach(stagename => {
createStageElem(stagename);
});
data.cars.forEach(carname => {
fetch(apiUrl+'cars/get/'+(carname.replaceAll(' ','_'))).then(responsecar => responsecar.json()).then(cardata => {
createCarElem(cardata);
});
});
});
}
function createMemberElem(member) {
let membertemplate = document.getElementById('clanmembertemplate').cloneNode(true);
membertemplate.removeAttribute('id');
[
['#membername',member.name],
['#memberrank',member.rank],
['#memberdescription',member.description]
].forEach(prop => membertemplate.querySelector(prop[0]).innerHTML = prop[1]);
membertemplate.querySelector('#memberlogo').src = `http://multiplayer.needformadness.com/profiles/${member.name}/avatar.png`;
membertemplate.querySelector('#memberlogo').setAttribute('onerror',`this.onerror=null; this.src = "https://dummyimage.com/200x200/aaa/ffffff.png&text=No+Avatar"`);
document.getElementById('clanmembers-container').appendChild(membertemplate);
}
function createStageElem(stage) {
console.log(stage);
let stagetemplate = document.getElementById('clanstagetemplate').cloneNode(true);
stagetemplate.removeAttribute('id');
stagetemplate.querySelector('#stagename').innerText = stage;
document.getElementById('clanstages-container').appendChild(stagetemplate);
}
function createCarElem(car) {
let container = document.getElementById('clancars-container');
let elem = document.getElementById('clancartemplate').cloneNode(true);
let carobject = new Car(car.code,car.name);
let carsize = NUtils.getModelSize(carobject.polys, carobject.scaleX, carobject.scaleY, carobject.scaleZ).actualSize;
cars.push(carobject);
elem.removeAttribute('id');
[
['#name',car.name.replaceAll(' ',' ')],
['#publishtype',['Private','Public','Super Public'][car.publishType]],
['#polycount',carobject.polys.length],
['#vertcount',carobject.polys.map(poly => poly.vertices.length).sum()],
['#sizex',NUtils.roundNum(carsize[0],2)],
['#sizey',NUtils.roundNum(carsize[1],2)],
['#sizez',NUtils.roundNum(carsize[2],2)],
['#color1-hex',NUtils.rgbToHex(carobject.color1)],
['#color2-hex',NUtils.rgbToHex(carobject.color2)],
['#color1-rgb',`c(${carobject.color1.join(',')})`],
['#color2-rgb',`c(${carobject.color2.join(',')})`],
['#publisher',car.publisher.replaceAll(' ',' ')],
['#addedcount',car.addedBy.length],
['#addedbylist',car.addedBy.map(profileName => profileName.replaceAll(' ',' ')).join(', ')],
].forEach(prop => elem.querySelector(prop[0]).innerHTML = prop[1]);
if(car.clanProperty) {
elem.querySelector('.card-header').innerHTML += '<span class="badge badge-warning">Clan Car</span>';
}
elem.querySelector('#color1-tint').style.color = `rgb(${carobject.color1.join(',')})`;
elem.querySelector('#color2-tint').style.color = `rgb(${carobject.color2.join(',')})`;
elem.querySelector('#publishtype').classList.add(['badge-secondary','badge-primary','badge-success'][car.publishType]);
elem.querySelector('#downloadbtn').addEventListener('click',() => {
NUtils.saveFile(car.name+'.rad',car.code);
},false);
container.appendChild(elem);
renderIsometric(carobject.polys,elem.querySelector('#canvas'));
}
</script>
</body>
</html>