This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
75 lines (66 loc) · 4.64 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
document.addEventListener("DOMContentLoaded", function () {
fetch('mods.json')
.then(response => response.json())
.then(data => {
const modContainer = document.getElementById('modContainer');
const searchInput = document.getElementById('searchInput');
// Remove existing cards
modContainer.innerHTML = '';
// Add cards from the JSON data
data.mods.forEach(mod => {
const card = document.createElement('div');
card.className = 'col-md-11 col-lg-12 col-xl-11';
card.innerHTML = `
<div class="card">
<div class="card-body p-4">
<h4 class="card-title" style="padding-top: 0px;margin-left: 3px;padding-bottom: 0px;margin-bottom: 2px;margin-top: 0px;padding-left: 112px;">${mod['display-name']}</h4>
<p style="padding-left: 108px;margin-top: 3px;margin-bottom: -25px;margin-left: 5px;">Author : </p>
<a target="_blank" href="${mod['author-link']}" style="padding-left: 113px;padding-right: 0px;padding-top: 0px;padding-bottom: 0px;margin-top: -23px;margin-bottom: -15px;margin-left: 65px;">
<i class="far fa-user" style="font-size: 16px;"></i> ${mod.author}
</a>
<p class="card-text" style="margin-top: 3px;padding-left: 113px;margin-bottom: -35px;padding-bottom: 0px;padding-top: 6px;">${mod.description}</p>
<img style="padding-top: 0px;padding-bottom: 0px;margin-bottom: -48px;margin-top: -89px;" src="${mod.icon}" width="100">
<div class="mt-3">
<a href="${mod['repo-link']}" class="btn btn-primary" target="_blank">View Files</a>
<a href="${mod['download-link']}" class="btn btn-success" target="_blank">Download</a>
</div>
</div>
</div>`;
modContainer.appendChild(card);
});
// Add event listener for search input
searchInput.addEventListener('input', () => {
const searchValue = searchInput.value.toLowerCase();
// Filter mods based on search input
const filteredMods = data.mods.filter(mod =>
mod['display-name'].toLowerCase().includes(searchValue) ||
mod.description.toLowerCase().includes(searchValue) ||
mod['author-link'].toLowerCase().includes(searchValue)
);
// Update mod cards based on filtered mods
modContainer.innerHTML = '';
filteredMods.forEach(mod => {
const card = document.createElement('div');
card.className = 'col-md-11 col-lg-12 col-xl-11';
card.innerHTML = `
<div class="card">
<div class="card-body p-4">
<h4 class="card-title" style="padding-top: 0px;margin-left: 3px;padding-bottom: 0px;margin-bottom: 2px;margin-top: 0px;padding-left: 112px;">${mod['display-name']}</h4>
<p style="padding-left: 108px;margin-top: 3px;margin-bottom: -25px;margin-left: 5px;">Author : </p>
<a href="${mod['author-link']}" style="padding-left: 113px;padding-right: 0px;padding-top: 0px;padding-bottom: 0px;margin-top: -23px;margin-bottom: -15px;margin-left: 65px;">
<i class="far fa-user" style="font-size: 16px;"></i> ${mod.author}
</a>
<p class="card-text" style="margin-top: 3px;padding-left: 113px;margin-bottom: -35px;padding-bottom: 0px;padding-top: 6px;">${mod.description}</p>
<img style="padding-top: 0px;padding-bottom: 0px;margin-bottom: -48px;margin-top: -89px;" src="${mod.icon}" width="100">
<div class="mt-3">
<a href="${mod['repo-link']}" class="btn btn-primary" target="_blank">View Files</a>
<a href="${mod['download-link']}" class="btn btn-success" target="_blank">Download</a>
</div>
</div>
</div>`;
modContainer.appendChild(card);
});
});
})
.catch(error => console.error('Error fetching mods.json:', error));
});