@@ -331,8 +285,8 @@ async function updateItemPage() {
// Update the total translation count
updateTotalTranslation(modsData, otherData);
+ populateIconContainer(selectedItem, modsData, otherData);
- applyIconStyles(modIcon);
} else {
document.title = "Йой, халепа";
@@ -411,3 +365,100 @@ function updateTotalTranslation(mods, other) {
if (modsData && otherData) {
updateTotalTranslation(modsData, otherData);
}
+
+// Function to get status classes based on certain conditions
+function getStatusClasses(selectedItem, modsData, otherData) {
+ try {
+ // Initialize an array to store status classes
+ const statusClasses = [];
+
+ // Add status classes based on item properties or conditions
+ if (selectedItem.verified === true) {
+ statusClasses.push('verified');
+ } else if (selectedItem.semiverified === true) {
+ statusClasses.push('semiverified');
+ }
+ if (selectedItem.completed === false) {
+ statusClasses.push('completed');
+ }
+ // Add more conditions as needed
+
+ // Check if the mod exists in modsData
+ const modExistsInModsData = modsData.some(modData => modData.id === selectedItem.id);
+ // Check if the mod exists in otherData
+ const modExistsInOtherData = otherData.some(otherMod => otherMod.id === selectedItem.id);
+
+ if (modExistsInModsData) {
+ statusClasses.push('minecraft');
+ } else if (modExistsInOtherData) {
+ statusClasses.push('other');
+ }
+
+
+ // Return the array of status classes
+ return statusClasses;
+ } catch (error) {
+ console.error("Error getting status classes:", error);
+ return []; // Return an empty array in case of error
+ }
+}
+
+
+// Function to fetch icon data from icons.json
+async function getIconData() {
+ try {
+ const iconsResponse = await fetch('icons.json');
+ return await iconsResponse.json();
+ } catch (error) {
+ console.error("Error fetching icon data:", error);
+ return null;
+ }
+}
+
+function addIcons(iconsData, statusClasses) {
+ try {
+ // Check if iconsData is an object
+ if (typeof iconsData === 'object' && iconsData !== null) {
+ // Generate HTML for each icon
+ const iconHTML = statusClasses.map(statusClass => {
+ const icon = iconsData[statusClass];
+ // Check if the icon object exists
+ if (icon) {
+ // Use an element to display the SVG icon
+ return ``;
+ } else {
+ console.error(`Error: Icon for status class '${statusClass}' not found`);
+ return ''; // Return an empty string for missing icons
+ }
+ }).join('');
+
+ // Append the generated HTML to IconContainer
+ $('#IconContainer').html(iconHTML);
+ } else {
+ console.error("Error: iconsData is not an object");
+ }
+ } catch (error) {
+ console.error("Error adding icons:", error);
+ }
+}
+
+// Function to populate IconContainer with SVG icons from icons.json
+async function populateIconContainer(selectedItem, modsData, otherData) {
+ try {
+ // Fetch icons data
+ const iconsData = await getIconData();
+
+ // Determine status classes for the item
+ const statusClasses = getStatusClasses(selectedItem, modsData, otherData);
+
+ // Add icons to the IconContainer
+ addIcons(iconsData, statusClasses);
+ } catch (error) {
+ console.error("Error populating icon container:", error);
+ }
+}
+
+
+
+
+
diff --git a/js/showcards.js b/js/showcards.js
index 1488719..34ffd7d 100644
--- a/js/showcards.js
+++ b/js/showcards.js
@@ -8,17 +8,19 @@ let modsData;
let otherData;
let filteredData;
-// Function to create a card for each mod
function createModCard(mod) {
const card = document.createElement('div');
card.classList.add('card');
- // Determine the status class based on priority
- let statusClass = getStatusClass(mod);
+ // Call getStatusClasses with modsData and otherData
+ let statusClasses = getStatusClasses(mod, modsData, otherData);
- // Only add the status class if it's not empty
- if (statusClass) {
- card.classList.add(statusClass); // Add the status class to the card
+
+ // Only add the status classes if they are not empty
+ if (statusClasses.length > 0) {
+ statusClasses.forEach(statusClass => {
+ card.classList.add(statusClass); // Add each status class to the card
+ });
}
card.id = `${mod.id}`;
@@ -28,7 +30,8 @@ function createModCard(mod) {
${mod.title}
-
від ${truncateText(mod.author, 35)}
+
від ${truncateText(mod.author, 35)}
+
`;
@@ -41,17 +44,17 @@ function createModCard(mod) {
shortDescription.innerText = mod.description.length > 100 ? mod.description.substring(0, 100) + '...' : mod.description;
descriptionContainer.appendChild(shortDescription);
-// Add icons based on status
-if (statusClass) {
- const iconContainer = document.createElement('div');
- iconContainer.classList.add('IconContainer');
+ // Add icons based on status classes
+ if (statusClasses.length > 0) {
+ const iconContainer = document.createElement('div');
+ iconContainer.classList.add('IconContainer');
- // Use Promise to get icon data
- addIcon(iconContainer, statusClass);
+ // Use Promise to get icon data
+ addIcons(iconContainer, statusClasses);
- // Append the IconContainer to descriptionContainer
- descriptionContainer.appendChild(iconContainer);
-}
+ // Append the IconContainer to descriptionContainer
+ descriptionContainer.appendChild(iconContainer);
+ }
// Add a click event listener to redirect to the item page when clicking on cardimage or textContainer
const clickableElements = card.querySelectorAll('.cardimage, .modtitle');
@@ -76,50 +79,72 @@ if (statusClass) {
-// Function to get the status class based on mod properties
-function getStatusClass(mod) {
+
+// Function to get the status classes based on mod properties and type
+function getStatusClasses(mod, modsData, otherData) {
+ const statusClasses = [];
+
if (mod.completed === false) {
- return 'completed';
+ statusClasses.push('completed');
} else if (mod.semiverified === true) {
- return 'semiverified';
+ statusClasses.push('semiverified');
} else if (mod.verified === true) {
- return 'verified';
+ statusClasses.push('verified');
}
- // Return an empty string if none of the conditions match
- return '';
+
+ // Check if the mod exists in modsData
+ const modExistsInModsData = modsData.some(modData => modData.id === mod.id);
+ // Check if the mod exists in otherData
+ const modExistsInOtherData = otherData.some(otherMod => otherMod.id === mod.id);
+
+ if (modExistsInModsData) {
+ statusClasses.push('minecraft');
+ } else if (modExistsInOtherData) {
+ statusClasses.push('other');
+ }
+
+ // Return an array of status classes
+ return statusClasses;
}
// Function to get icon data from Icons.json
-function getIconData(statusClass) {
+function getIconData(statusClasses) {
// Replace this with the actual path to your Icons.json file
const iconsJsonPath = 'icons.json';
// Return a Promise for fetching and processing the icon data
return fetch(iconsJsonPath)
.then(response => response.json())
- .then(iconData => iconData[statusClass] || {})
+ .then(iconData => {
+ const icons = [];
+ statusClasses.forEach(statusClass => {
+ const icon = iconData[statusClass];
+ if (icon && icon.icon) {
+ icons.push(icon);
+ }
+ });
+ return icons;
+ })
.catch(error => {
console.error('Error fetching icon data:', error);
- return {};
+ return [];
});
}
-// Function to add icons based on status
-function addIcon(element, type) {
- const iconContainer = document.createElement('div');
-
+// Function to add icons based on files and status
+function addIcons(element, statusClasses) {
// Use Promise to get icon data
- getIconData(type).then(iconData => {
- if (iconData.icon) {
+ getIconData(statusClasses).then(icons => {
+ icons.forEach(iconData => {
+ const iconContainer = document.createElement('div');
iconContainer.title = iconData.title || '';
- iconContainer.style.backgroundImage = `url('${iconData.icon}')`;
- iconContainer.classList.add(`statusicon`, `${type}Icon`);
+ iconContainer.style.backgroundImage = `url("${iconData.icon}")`;
+ iconContainer.classList.add('ItemIcons', `${iconData.class}Icon`);
element.appendChild(iconContainer);
- }
+ });
});
}
-
function truncateText(text, maxLength) {
if (text.length > maxLength) {
return text.substring(0, maxLength) + '...';
diff --git a/mods.json b/mods.json
index 61c837e..3559159 100644
--- a/mods.json
+++ b/mods.json
@@ -81,7 +81,7 @@
},
{
"title": "delightful",
- "description": "Налаштовуваний аддон Farmer's Delight з функціями сумісності та захоплюючими новими продуктами.",
+ "description": "Налаштовуване доповнення до Farmer's Delight з новими видами їжі, спорядження та продуктів.",
"image": "https://cdn.modrinth.com/data/JtSnhtNJ/707d7697b315dd6dfc84648c893bf3e057bb3e34.png",
"verified": true,
"author": "СУМ",
@@ -90,11 +90,20 @@
"https://www.curseforge.com/minecraft/mc-mods/delightful",
"https://modrinth.com/mod/delightful"
],
- "id": "000005"
+ "id": "000005",
+ "gameversion": "1.19+",
+ "categories": [
+ "Спорядження",
+ "Їжа",
+ "Зберігання",
+ "Корисні функції",
+ "Генерація створення"
+ ],
+ "engine": "Forge, NeoForge"
},
{
"title": "End's Delight",
- "description": "End's Delight - це аддон-мод для Farmer's Delight, заснований на додаванні кулінарного контенту з предметів Енду!",
+ "description": "End's Delight - це аддон-мод для Farmer's Delight, заснований на додаванні нового кулінарного контенту з предметів Енду!",
"image": "https://cdn.modrinth.com/data/yHN0njMr/8b215554e49c51cb5bb5ded435263d2078e0829e.png",
"verified": true,
"author": "СУМ",
@@ -103,11 +112,17 @@
"https://www.curseforge.com/minecraft/mc-mods/ends-delight",
"https://modrinth.com/mod/ends-delight"
],
- "id": "000006"
+ "id": "000006",
+ "gameversion": "1.16.5+",
+ "categories": [
+ "Їжа",
+ "Генерація створення"
+ ],
+ "engine": "Fabric, Forge"
},
{
"title": "Framed Compacting Drawers",
- "description": "Це аддон-мод до Storage Drawers, який додає безмежно велику кількість нових ящиків до гри.",
+ "description": "Це доповнення до Storage Drawers, який додає нові шухляди, контролери та інші блоки з основного моду.\r\nВсі шухляди можна оздобити з кожної сторони будь-яким блоком в грі(підтримуються навіть блоки з інших модів).",
"image": "https://media.forgecdn.net/avatars/264/387/637226486288344415.png",
"verified": false,
"author": "СУМ",
@@ -115,7 +130,14 @@
"link": [
"https://www.curseforge.com/minecraft/mc-mods/framed-compacting-drawers"
],
- "id": "000007"
+ "id": "000007",
+ "gameversion": "1.12.2+",
+ "categories": [
+ "Декорації",
+ "Зберігання",
+ "Корисні функції"
+ ],
+ "engine": "Forge"
},
{
"title": "Frozen Delight",