-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharticles.html
414 lines (355 loc) · 17.2 KB
/
articles.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
<!doctype html>
<html lang="en">
<head>
<title>Articles - Starshop</title>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<!-- CSS -->
<link rel="stylesheet" href="css/bootstrap-dark.css">
<link href="css/custom.css" rel="stylesheet">
<!-- source: https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-dark.min.css -->
<!-- icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<link rel="icon" href="assets/icons/cart.png">
<!-- javascript -->
<script src="js/handlebars.min-v4.7.8.js"></script>
<script src="js/vanilla.js"></script>
<script src="js/search.js"></script>
<script src="js/filter.js"></script>
<script src="js/sort.js"></script>
<script src="js/admin.js"></script>
<script src="js/index.js"></script>
<script src="js/pagination.js"></script>
<script>
function init() {
const amountOnPage = 12
$on($('#search'), 'click', setSearch)
$on($('#createnew'), 'click', create)
$on($('#increment'), 'click', increment)
$on($('#decrement'), 'click', decrement)
render({}, '[type="text/x-handlebars-navbar"]')
render({}, '[type="text/x-handlebars-footer"]')
render(colors, '[type="text/x-handlebars-filter"]', setFilterHighlight)
const params = new URLSearchParams(window.location.search)
const pageParam = params.get("page")
const pageNumbers = getPageNumbers(pageParam, amountOnPage)
const queryDataFull = getQueryData(
params.get("search"),
params.get("filter"),
params.get("sort"),
params.get("filterValue"),
params.get("filterOperation"),
params.get("sortDirection")
)
// sets the number besides cart icon to display current amount of products inside of cart on reload
var CART = sessionStorage.getItem("cart")
if (!(CART === null)) {
var parsedCart = JSON.parse(CART)
document.getElementById("cartcounter").innerHTML = parsedCart.length
}
var queryData;
if (!(queryDataFull === null)) {
queryData = queryDataFull.slice(pageNumbers[0], pageNumbers[1])
} else {
queryData = null
}
// Search form code
const searchForm = document.getElementById("searchForm")
startSearchForm(searchForm)
render({ "page": pageNumbers[2] }, '[type="text/x-handlebars-page"]')
// render the stars, if they are in the local storage
if (queryData !== null) {
render(queryData, '[type="text/x-handlebars-cards"]', setInCart)
render(queryData, '[type="text/x-handlebars-modals"]')
}
else {
fetch('data/hygfull.json')
.then(response => response.json())
.then(data => {
localStorage.setItem("data", JSON.stringify(data))
location.reload()
})
.catch(error => console.error('Error fetching JSON file:', error))
}
// render pagination
var max
if (queryDataFull != null) {
max = Math.ceil(queryDataFull.length / 12)
}
else {
const data = JSON.parse(localStorage.getItem("data"));
max = Math.ceil(data.length / 12)
}
render({ "max": max }, '[type="text/x-handlebars-max"]', ()=>paginationCheck(pageParam, max))
}
</script>
</head>
<body onload="init()">
<script id="template" type="text/x-handlebars-navbar">
{{> navbar }}
</script>
<div id="nav"></div>
<section id="" class="bg-black">
<div class="container-l py-4">
<div class="text-center">
<h2 class="display-3">Star Collection</h2>
<p class="lead text-muted">choose the perfect star</p>
</div>
</section>
<section id="pricing" class="container-background-repeat border-bottom bg-black">
<nav class="navbar sticky-top bg-black border-bottom border-dark">
<div class="container-fluid justify-content-end px-5">
<div class="btn-group mx-2 mt-2">
<a class="btn btn-secondary btn border-dark " type="submit" href="warenkorb.html">
<i class="bi-cart-fill px-2 bi"></i>
<div id="cartcounter" class="badge bg-dark text-white rounded-pill">0
</div>
</a>
</div>
<div class="btn-group mx-2 mt-2" role="group">
<a onclick="toggleFilter()" class="btn border btn-dark text-muted" id="filterButton"><i class="bi bi-funnel"></i></a>
<a onclick="toggleSort()" class="btn border btn-dark text-muted" id="sortButton"><i class="bi bi-filter-right"></i></a>
<a href="#nav" class="btn btn-dark border text-muted"><i class="bi bi-arrow-bar-up"></i></a>
</div>
<a id="createBtn" href="#" class="btn btn-primary mt-2 mx-2 d-none" data-bs-toggle="modal"
data-bs-target="#createModal"><i class="bi bi-plus-square"></i></a>
<form class="d-flex needs-validation mt-2" id="searchForm" novalidate>
<div class="input-group ms-2" required>
<input id="query" class="form-control" type="text" placeholder="Search" aria-label="Search"
oninput="updateRecommendation()" required>
<button class=" btn btn-dark text-muted border border-secondary" type="button" onclick="removeSearch()">
<i class="bi bi-trash"></i>
</button>
</div>
<button class="btn btn-outline-white btn-secondary d-none " type="submit" id="search"><i
class="bi bi-search"></i></button>
</form>
</div>
<div class="container justify-content-center">
<div class="row" id="searchResults"></div>
</div>
<div class="container border border-dark mt-3 d-none justify-content-center" id="filter">
<script id="template" type="text/x-handlebars-filter">
{{#each this}}
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="{{key}}{{color}}eq">
<a class="btn btn-outline-dark border-0" onclick="setFilter('{{key}}', '{{color}}', 'eq')">
<img src="assets/icons/starIcons/{{color}}.png" class="card-img-top cart-image-articles">
<p class="lead text-muted">{{title}}</p>
</a>
</div>
</div>
{{/each}}
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="Price100000sm">
<a class="btn btn-outline-dark border-0" onclick="setFilter('Price', '100000', 'sm')">
<img src="assets/icons/sale.png" class="card-img-top cart-image-articles">
<p class="lead text-muted">Sale</p>
</a>
</div>
</div>
</script>
<div class="row justify-content-center my-2"></div>
</div>
<div class="container border border-dark mt-2 d-none justify-content-center" id="sort">
<div class="row justify-content-center my-2">
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="Priceasc">
<a class="btn btn-outline-dark border-0" onclick="setSort('Price', 'asc')">
<img src="assets/icons/aufsteigend.png" class="cart-image-articles">
<p class="lead text-muted">Price</p>
</a>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="Pricedsc">
<a class="btn btn-outline-dark border-0" onclick="setSort('Price', 'dsc')">
<img src="assets/icons/absteigend.png" class="cart-image-articles">
<p class="lead text-muted">Price</p>
</a>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="ProperNameasc">
<a class="btn btn-outline-dark border-0" onclick="setSort('ProperName', 'asc')">
<img src="assets/icons/ascending.png" class="cart-image-articles">
<p class="lead text-muted">Name</p>
</a>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="ProperNamedsc">
<a class="btn btn-outline-dark border-0" onclick="setSort('ProperName', 'dsc')">
<img src="assets/icons/descending.png" class="cart-image-articles">
<p class="lead text-muted">Name</p>
</a>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="Distanceasc">
<a class="btn btn-outline-dark border-0" onclick="setSort('Distance', 'asc')">
<img src="assets/icons/asc.png" class="cart-image-articles">
<p class="lead text-muted">Distance</p>
</a>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="Distancedsc">
<a class="btn btn-outline-dark border-0" onclick="setSort('Distance', 'dsc')">
<img src="assets/icons/desc.png" class="cart-image-articles">
<p class="lead text-muted">Distance</p>
</a>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="Magasc">
<a class="btn btn-outline-dark border-0" onclick="setSort('Mag', 'asc')">
<img src="assets/icons/ascc.png" class="cart-image-articles">
<p class="lead text-muted">Magnitude</p>
</a>
</div>
</div>
<div class="col-4 col-sm-4 col-md-3 col-xl-2">
<div class="card bg-black border border-black" id="Magdsc">
<a class="btn btn-outline-dark border-0" onclick="setSort('Mag', 'dsc')">
<img src="assets/icons/descc.png" class="cart-image-articles">
<p class="lead text-muted">Magnitude</p>
</a>
</div>
</div>
</div>
</div>
</nav>
<script id="template" type="text/x-handlebars-cards">
{{> card }}
</script>
<div class="row mx-sm-5 align-items-center justify-content-center g-2 my-4"></div>
</div>
</section>
<div class="container mt-2">
<div class="row justify-content-center align-items-center">
<div class="col text-center">
<div class="btn-group">
<button class="btn md-3" id="startPage" onclick="goToStartPage()">
<u id="startPageValue">1</u>
</button>
<button class="btn md-3" id="decrement">
<i class="bi bi-arrow-left"></i>
</button>
<script id="template" type="text/x-handlebars-page">
{{page}}
</script>
<div id="centralpage" class="btn "></div>
<button class="btn btn md-3" id="increment">
<i class="bi bi-arrow-right"></i>
</button>
<script id="template" type="text/x-handlebars-max">
<button class="btn md-3" id="endPage"onclick="goToEndPage({{max}})">
<u id="endPageValue">{{max}}</u>
</button>
</script>
<div></div>
</div>
</div>
</div>
</div>
<script id="template" type="text/x-handlebars-modals">
{{> modal }}
</script>
<div></div>
<div class="modal fade" id="createModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="text-center">
<h2>Create new Item</h2>
<p class="lead">Fill out the form</p>
</div>
<form id="createForm" class="needs-validation" onsubmit="return false;" novalidate action="#">
<div class="row justify-content-center align-items-center g-2">
<div class="col">
<label for="number" class="form-label">StarID:</label>
<input type="number" class="form-control" id="StarID" placeholder="e.g. 65795" required>
<div class="invalid-feedback">Please enter a valid StarID</div>
<label for="number" class="form-label">Hip:</label>
<input type="number" class="form-control" id="Hip" placeholder="e.g. 91262" required>
<div class="invalid-feedback">Please enter a valid Hip</div>
<label for="number" class="form-label">HD:</label>
<input type="number" class="form-control" id="HD" placeholder="e.g. 172167" required>
<div class="invalid-feedback">Please enter a valid HD</div>
<label for="name" class="form-label">Name:</label>
<input type="name" class="form-control" id="ProperName" placeholder="e.g. Vega" required>
<div class="invalid-feedback">Please enter a name</div>
<label for="number" class="form-label">RA:</label>
<input type="number" step="any" class="form-control" id="RA" placeholder="e.g. 18.61560722" required>
<div class="invalid-feedback">Please enter a valid RA</div>
<label for="number" class="form-label">Dec:</label>
<input type="number" step="any" class="form-control" id="Dec" placeholder="e.g. 38.78299311" required>
<div class="invalid-feedback">Please enter a valid Dec</div>
<label for="number" class="form-label">Distance:</label>
<input type="number" step="any" class="form-control" id="Distance" placeholder="e.g. 7.76" required>
<div class="invalid-feedback">Please enter a valid Distance</div>
<label for="number" class="form-label">Mag:</label>
<input type="number" step="any" class="form-control" id="Mag" placeholder="e.g. 0.03" required>
<div class="invalid-feedback">Please enter a valid Mag</div>
</div>
<div class="col mb-auto">
<label for="number" class="form-label">AbsMag:</label>
<input type="number" step="any" class="form-control" id="AbsMag" placeholder="e.g. 0.58" required>
<div class="invalid-feedback">Please enter a valid AbsMag</div>
<label for="text" class="form-label">Spectrum:</label>
<input type="text" class="form-control" id="Spectrum" placeholder="e.g. B2.5V" required>
<div class="invalid-feedback">Please enter a Spectrum</div>
<label for="number" class="form-label">ColorIndex:</label>
<input type="number" step="any" class="form-control" id="ColorIndex" placeholder="e.g. -0.134" required>
<div class="invalid-feedback">Please enter a valid ColorIndex</div>
<div class="form-floating mb-4 mt-4">
<textarea class="form-control" id="GeneralInformation" style="height: 140px;" required></textarea>
<label for="GeneralInformation">Information:</label>
<div class="invalid-feedback">Please enter General Information</div>
</div>
<label for="number" class="form-label">Price:</label>
<input type="number" class="form-control" id="Price" placeholder="e.g. 83506" required>
<div class="invalid-feedback">Please enter a valid Price</div>
<label class="form-label">Color:</label>
<select id="Color" class="form-select" required>
<option value="yellowWhiteStar" selected>yellowWhiteStar</option>
<option value="yellowStar">yellowStar</option>
<option value="whiteStar">whiteStar</option>
<option value="orangeStar">orangeStar</option>
<option value="orangeRedStar">orangeRedStar</option>
<option value="blueStar">blueStar</option>
<option value="blueWhiteStar">blueWhiteStar</option>
</select>
</div>
</div>
<div class="mt-2 text-center">
<button type="submit" id="createnew" class="btn btn-secondary">save changes</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
setSortHighlight()
setSearchPlaceholdert()
// checks for admin param and shows the Button for Creating new elements if admin param equals "true"
const params = new URLSearchParams(window.location.search)
const admin = params.get("admin")
if (admin === "true") { document.getElementById('createBtn').classList.remove('d-none'); }
else { document.getElementById('createBtn').classList.add('d-none'); }
</script>
<script id="template" type="text/x-handlebars-footer">
{{> footer }}
</script>
<div></div>
<!-- Bootstrap JavaScript Libraries -->
<script src="js/bootstrap.js"></script>
</body>
</html>