-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
374 lines (361 loc) · 10.2 KB
/
app.js
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
document.addEventListener("DOMContentLoaded", function() {
const itemSelect = document.getElementById("item-select");
const quantityInput = document.getElementById("quantity");
// Material spans
const materialSpans = [
document.getElementById("material1"),
document.getElementById("material2"),
document.getElementById("material3"),
document.getElementById("material4"),
document.getElementById("material5"),
document.getElementById("material6"),
document.getElementById("material7"),
document.getElementById("material8"),
document.getElementById("material9"),
document.getElementById("material10"),
document.getElementById("material11"),
document.getElementById("material12"),
document.getElementById("material13"),
document.getElementById("material14"),
document.getElementById("material15"),
document.getElementById("material16"),
document.getElementById("material17"),
document.getElementById("material18"),
document.getElementById("material19"),
document.getElementById("material20"),
document.getElementById("material21"),
document.getElementById("material22"),
document.getElementById("material23"),
document.getElementById("material24"),
document.getElementById("material25"),
document.getElementById("material26"),
document.getElementById("material27"),
document.getElementById("material28"),
document.getElementById("material29"),
document.getElementById("material30"),
document.getElementById("material31"),
document.getElementById("material32"),
document.getElementById("material33"),
document.getElementById("material34"),
document.getElementById("material35")
];
// Database of items
const items = [
{
name: "lockpick",
material1: 3,
material2: 2,
material3: 2
},
{
name: "pikhouweel",
material4: 2,
material3: 5,
},
{
name: "Reparatieset",
material1: 10,
material5: 10,
material3: 10
},
{
name: "Houten Bak",
material4: 10,
material6: 3
},
{
name: "Handboeien",
material1: 4,
material3: 4,
material34: 4
},
{
name: "Elektronische kit",
material7: 3,
material8: 3,
material2: 2,
material9: 5
},
{
name: "Geavanceerd Lockpick",
material1: 4,
material2: 6,
material10: 2,
material3: 2
},
{
name: "Radio Scanner",
material9: 1,
material2: 6,
material8: 6,
material11: 1
},
{
name: "Gieter",
material2: 30,
material12: 15
},
{
name: "Plastic Bootje",
material2: 20,
material12: 15
},
{
name: "Glazen Kerstbal",
material13: 15,
},
{
name: "Metaaldetector",
material14: 1,
material2: 15,
material9: 10,
material7: 15,
material15: 15
},
{
name: "Grijze USB",
material14: 1,
material2: 3,
material9: 1
},
{
name: "Gereedschapsset",
material16: 2,
material2: 5,
material5: 3
},
{
name: "Slakken Fossiel",
material17: 5,
},
{
name: "Leeg zakje",
material18: 1,
},
{
name: "Versteende Slak",
material17: 5,
},
{
name: "Trilobiet Fossiel",
material17: 5,
},
{
name: "Tas",
material19: 15,
material20: 5
},
{
name: "Vpn",
material15: 5,
material14: 1,
material21: 2
},
{
name: "GPS Verwijderaar",
material2: 10,
material9: 10,
material7: 15,
material15: 5,
material22: 2
},
{
name: "Kogelwerend Vest",
material20: 5,
material19: 10
},
{
name: "MijnLaser",
material23: 1,
material24: 1,
material2: 10,
material9: 15
},
{
name: "Zware Boor",
material2: 10,
material24: 1,
material8: 15,
material23: 1
},
{
name: "Hacking Device",
material22: 1,
material1: 10,
material14: 1,
material9: 10,
material15: 5,
},
{
name: "Pijpbom",
material2: 5,
material25: 2,
material26: 1,
material3: 10,
material27: 2
},
{
name: "Mal voor Clip",
material2: 20,
material28: 1
},
{
name: "Mal voor Trigger",
material2: 20,
material28: 1
},
{
name: "Mal voor Loop",
material2: 20,
material28: 1
},
{
name: "9mm Ammo Box",
material29: 5,
material35: 2,
material30: 5
},
{
name: "Mal voor Extended Clip",
material2: 20,
material28: 1
},
{
name: "Mal voor Silencer",
material2: 20,
material28: 1
},
{
name: "SNS Pistool",
material31: 1,
material32: 1,
material33: 1,
material34: 5,
material1: 10
},
{
name: "Mal voor CombatPistool loop",
material2: 20,
material28: 1
},
];
// Function to update item details
function updateItemDetails(item) {
materialSpans.forEach((span, index) => {
const material = item[`material${index + 1}`];
span.textContent = material ? `${material} x ${getMaterialName(index + 1)}` : '';
});
}
// Function to get the material name
function getMaterialName(index) {
switch (index) {
case 1:
return "Metaalschroot";
case 2:
return "Plastic";
case 3:
return "Ijzer";
case 4:
return "Houten plank";
case 5:
return "Staal";
case 6:
return "Doosje Spijkers";
case 7:
return "Koperdraad";
case 8:
return "Kabels";
case 9:
return "Elektronische schroot";
case 10:
return "Lockpick";
case 11:
return "Radio";
case 12:
return "Leeg Flesje";
case 13:
return "Lege fles glas";
case 14:
return "Printplaat";
case 15:
return "Koper";
case 16:
return "Geavanceerde Lockpick";
case 17:
return "Stukje fossiel";
case 18:
return "Plastic Pulp";
case 19:
return "Stof";
case 20:
return "Rubber";
case 21:
return "USB";
case 22:
return "Antenne";
case 23:
return "Mijnboor";
case 24:
return "Elektronische kit";
case 25:
return "Aluminium Poeder";
case 26:
return "Pijpbom Huls";
case 27:
return "Ijzer Poeder";
case 28:
return "Houten bak Zand";
case 29:
return "9mm Hulzen";
case 30:
return "Buskruit";
case 31:
return "SNS Trigger";
case 32:
return "SNS Loop";
case 33:
return "SNS Clip";
case 34:
return "Aluminium";
case 35:
return "Karton";
default:
return "";
}
}
// Function to calculate and display materials
function calculateMaterials() {
const itemName = itemSelect.value.toLowerCase();
const quantity = parseInt(quantityInput.value) || 1; // Ensure quantity is at least 1
// Find the item in the database
const item = items.find(i => i.name.toLowerCase() === itemName);
if (!item) {
alert("Item not found in database.");
return;
}
updateItemDetails(item);
// Calculate the total materials based on the quantity
materialSpans.forEach((span, index) => {
const material = item[`material${index + 1}`];
const totalMaterial = material ? material * quantity : 0;
span.textContent = totalMaterial ? `${totalMaterial} x ${getMaterialName(index + 1)}` : '';
});
}
// Populate the dropdown menu with the items in the database
items.forEach(item => {
const option = document.createElement("option");
option.value = item.name.toLowerCase();
option.textContent = item.name;
itemSelect.appendChild(option);
});
// Event listener for the dropdown change
itemSelect.addEventListener("change", () => {
calculateMaterials(); // Call the function to update materials when item changes
});
// Event listener for quantity change
quantityInput.addEventListener("input", () => {
calculateMaterials(); // Call the function to calculate materials when quantity changes
});
// Initialize materials display
calculateMaterials();
});