finalise code

This commit is contained in:
sq 2024-09-22 19:47:09 +08:00 committed by GitHub
parent b959a6b047
commit 657fb6bb3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 23 deletions

View File

@ -11,32 +11,30 @@ for (let elementName in elements) {
}
}
runAfterLoad(function() {
let modDescriptions = {};
let modDescriptions = {};
let fetchPromises = enabledMods.map(mod => {
return fetch(mod)
.then(response => response.text())
.then(data => {
console.log(`Loaded mod: ${mod}`);
modDescriptions[mod] = data;
})
.catch(error => console.error('Error fetching the mod file: ', error));
});
let fetchPromises = enabledMods.map(mod => {
return fetch(mod)
.then(response => response.text())
.then(data => {
console.log(`Loaded mod: ${mod}`);
modDescriptions[mod] = data;
})
.catch(error => console.error('Error fetching the mod file: ', error));
});
Promise.all(fetchPromises).then(() => {
Object.keys(elements).forEach(function(elementName) {
let element = elements[elementName];
for (let mod of enabledMods) {
if (element.desc && typeof element.desc === 'string' && element.desc.trim() !== '') {
if (!element.desc.includes("This Element is from")) {
element.desc += `\nThis Element is from ${mod}`;
}
} else {
element.desc = `This Element is from ${mod}`;
Promise.all(fetchPromises).then(() => {
Object.keys(elements).forEach(function(elementName) {
let element = elements[elementName];
for (let mod of enabledMods) {
if (element.desc && typeof element.desc === 'string' && element.desc.trim() !== '') {
if (!element.desc.includes("This Element is from")) {
element.desc += `\nThis Element is from ${mod}`;
}
} else {
element.desc = `This Element is from ${mod}`;
}
});
}
});
});