Skip to content

Commit 1f87d8c

Browse files
committed
Added mods search bar
1 parent 0e9b7a8 commit 1f87d8c

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

img/gui/oreui/search.png

182 Bytes
Loading

mods/index.html

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
@media (max-width: 768px) {
147147
.modsContainer {
148148
flex-direction: column;
149+
position: relative;
149150
}
150151
.modsSidebar {
151152
width: 100%;
@@ -154,7 +155,16 @@
154155
}
155156
.modsBody {
156157
width: 100%;
158+
position: relative;
157159
}
160+
#searchInput {
161+
position: static !important;
162+
width: calc(100% - 30px);
163+
margin-left: 15px;
164+
margin-right: 15px;
165+
margin-top: 15px;
166+
margin-bottom: 15px;
167+
}
158168
}
159169
@media (min-width: 768px) {
160170
.modsSidebar {
@@ -254,7 +264,30 @@
254264
</div>
255265
</div>
256266

257-
<div style="width: 100%; height: 6.5em; background: linear-gradient(rgba(104, 40, 40, 0.4), rgba(203, 119, 119, 0.1)), url(/img/bg/chiseled_quartz_block_top.png); background-size: 32px; image-rendering: pixelated;"></div>
267+
<div style="width: 100%; height: 6.5em; background: linear-gradient(rgba(104, 40, 40, 0.4), rgba(203, 119, 119, 0.1)), url(/img/bg/chiseled_quartz_block_top.png); background-size: 32px; image-rendering: pixelated;">
268+
269+
<div style="position: relative;" id="desktopSearchContainer">
270+
<input type="text" id="searchInput" placeholder="Search mods..." style="
271+
position: absolute;
272+
right: 15px;
273+
top: calc(4em - 4px);
274+
background-color: rgba(0, 0, 0, 0.8);
275+
border: 2px solid black;
276+
outline: 2px solid white;
277+
color: rgba(255, 255, 255, 0.7);
278+
font-family: 'Minecraft Regular';
279+
font-size: 13pt;
280+
padding-left: 35px;
281+
padding-bottom: 4px;
282+
background-image: url('/img/gui/oreui/search.png');
283+
image-rendering: pixelated;
284+
background-repeat: no-repeat;
285+
background-position: 7px center;
286+
background-size: 20px 20px;
287+
">
288+
</div>
289+
290+
</div>
258291

259292
<div class="modsContainer">
260293

@@ -315,9 +348,12 @@
315348
<img src="/img/gui/oreui/other.png">Other
316349
</label>
317350
<br>
351+
<div style="position: relative;" id="mobileSearchContainer">
352+
</div>
318353
</div>
319354

320355
<div class="modsBody">
356+
321357
<div class="modItem" data-version="1.9.19" data-type="entity" onclick="window.location.href='https://github.com/Cracko298/mc3ds-creaking';">
322358
<div class="modContent">
323359
<div class="modHeader">The Creaking</div>
@@ -1268,6 +1304,46 @@
12681304
});
12691305

12701306
</script>
1307+
<script>
1308+
document.getElementById('searchInput').addEventListener('input', function () {
1309+
searchMods(this.value);
1310+
});
1311+
function searchMods(query) {
1312+
const mods = document.querySelectorAll('.modItem');
1313+
const lowerQuery = query.toLowerCase();
1314+
1315+
mods.forEach(mod => {
1316+
const title = mod.querySelector('.modHeader').textContent.toLowerCase();
1317+
if (title.includes(lowerQuery)) {
1318+
mod.style.display = 'block';
1319+
} else {
1320+
mod.style.display = 'none';
1321+
}
1322+
});
1323+
}
1324+
1325+
</script>
1326+
<script>
1327+
function moveSearchInput() {
1328+
const input = document.getElementById('searchInput');
1329+
const desktopContainer = document.getElementById('desktopSearchContainer');
1330+
const mobileContainer = document.getElementById('mobileSearchContainer');
1331+
1332+
if (window.innerWidth <= 768) {
1333+
if (mobileContainer && !mobileContainer.contains(input)) {
1334+
mobileContainer.appendChild(input);
1335+
}
1336+
} else {
1337+
if (desktopContainer && !desktopContainer.contains(input)) {
1338+
desktopContainer.appendChild(input);
1339+
}
1340+
}
1341+
}
1342+
1343+
window.addEventListener('DOMContentLoaded', moveSearchInput);
1344+
window.addEventListener('resize', moveSearchInput);
1345+
1346+
</script>
12711347

12721348

12731349

0 commit comments

Comments
 (0)