diff --git a/website/index.php b/website/index.php index 8bf23b54..1910ee24 100644 --- a/website/index.php +++ b/website/index.php @@ -8,6 +8,9 @@ $db = new DataBase(); if (isset($_SESSION['steamid'])) { $steamid = $_SESSION['steamid']; + + // Fetch Steam user information + require_once 'steamauth/userInfo.php'; $weapons = UtilsClass::getWeaponsFromArray(); $skins = UtilsClass::skinsFromJson(); @@ -135,16 +138,20 @@ if (isset($_SESSION['steamid'])) {
-
-
- Knives - Knives - -
-
- -
-
+ $knife): ?> + +
+
+ <?php echo $knife['paint_name']; ?> + + +
+
+ +
+
+ + @@ -449,7 +456,7 @@ if (isset($_SESSION['steamid'])) { skinGrid.appendChild(skinsContainer); } - function toggleKnifeSkins() { + function toggleKnifeSkins(knifeType) { const weaponItem = event.target.closest('.weapon-item'); const skinGrid = weaponItem.parentNode.querySelector('.weapon-skins-grid'); @@ -467,14 +474,14 @@ if (isset($_SESSION['steamid'])) { item.classList.remove('expanded'); }); - // Expand knife skin grid - populateKnifeSkins(skinGrid); + // Expand this knife type's skin grid + populateKnifeTypeSkins(knifeType, skinGrid); skinGrid.classList.add('expanded'); weaponItem.classList.add('expanded'); } } - function populateKnifeSkins(skinGrid) { + function populateKnifeTypeSkins(knifeType, skinGrid) { // Create skins container const skinsContainer = document.createElement('div'); skinsContainer.className = 'skins-container'; @@ -482,22 +489,44 @@ if (isset($_SESSION['steamid'])) { // Clear previous content skinGrid.innerHTML = ''; - // Populate knife skins in 3-column grid - Object.entries(knivesData).forEach(([knifeId, knife]) => { - if (knifeId != 0) { // Skip default knife + // Check if this knife type has skins in the skins data + if (skinsData[knifeType]) { + // This knife type has multiple skins + Object.entries(skinsData[knifeType]).forEach(([paintId, skin]) => { const skinOption = document.createElement('div'); skinOption.className = 'skin-option'; - skinOption.onclick = () => equipKnife(knifeId); + // Check if this skin is currently equipped + if (selectedSkinsData[knifeType] && selectedSkinsData[knifeType].weapon_paint_id == paintId) { + skinOption.classList.add('active'); + } + + skinOption.onclick = () => equipSkin(knifeType, paintId); + + skinOption.innerHTML = ` + ${skin.paint_name} +
${skin.paint_name.replace(/.*\| /, '')}
+ `; + + skinsContainer.appendChild(skinOption); + }); + } else { + // This knife type has only one variant (the knife itself) + const knife = knivesData[knifeType]; + if (knife) { + const skinOption = document.createElement('div'); + skinOption.className = 'skin-option'; + + skinOption.onclick = () => equipKnife(knifeType); skinOption.innerHTML = ` ${knife.paint_name} -
${knife.paint_name}
+
Default
`; skinsContainer.appendChild(skinOption); } - }); + } skinGrid.appendChild(skinsContainer); } diff --git a/website/style.css b/website/style.css index 97bf1474..8876d934 100644 --- a/website/style.css +++ b/website/style.css @@ -130,6 +130,8 @@ body { display: flex; flex-direction: column; position: relative; + max-height: 100vh; + overflow: hidden; } .sidebar-header { @@ -172,6 +174,8 @@ body { .sidebar-nav { flex: 1; padding: 1rem 0; + overflow-y: auto; + overflow-x: hidden; } .nav-item { @@ -721,7 +725,7 @@ body { } .weapon-list.expanded { - max-height: 500px; + max-height: 300px; padding: 0.5rem 0; overflow-y: auto; overflow-x: hidden; @@ -792,7 +796,7 @@ body { } .weapon-skins-grid.expanded { - max-height: 400px; + max-height: 250px; padding: 1rem; overflow-y: auto; overflow-x: hidden;